Skip to content

Commit

Permalink
Merge pull request #223 from domeengine/release/v1.7.0
Browse files Browse the repository at this point in the history
v1.7.0 Release Branch
  • Loading branch information
avivbeeri authored Dec 7, 2021
2 parents a502a22 + d2578db commit 3eaa209
Show file tree
Hide file tree
Showing 129 changed files with 19,665 additions and 1,775 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2.0.0
- run: sudo xcode-select -switch /Applications/Xcode_12.app/Contents/Developer
- run: sudo xcode-select -switch /Applications/Xcode_12.4.app/Contents/Developer
- name: Cache dependancies
uses: actions/cache@v2
with:
Expand Down
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ libwren.a
libwrend.a
libadd.so
**/.DS_Store
src/util/convert
src/util/embed
src/tools/convert
src/tools/embed
src/modules/*.inc
include/wren.h
include/SDL2/*
lib/SDL2*
lib/SDL/special
Expand All @@ -36,4 +35,4 @@ dome.html
dome.js
dome.wasm

game.egg
*.egg
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "wren"]
path = lib/wren
url = https://github.com/wren-lang/wren.git
[submodule "lib/SDL"]
path = lib/SDL
url = https://github.com/libsdl-org/SDL
Expand Down
2 changes: 2 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ We'd like to thank the following people for their contributions.
* Chayim Refael Friedman [https://github.com/ChayimFriedman2]
* Benjamin Stigsen [https://github.com/benstigsen]
* Alexandru Badiu, aka voidberg [https://github.com/voidberg]
* Aayush Kashyap [https://github.com/TheKing0x9]
* Trevor Martin [https://github.com/trelemar]
66 changes: 36 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ LIBS=lib
OBJS=obj
INCLUDES=include
SOURCE_FILES = $(shell find src -type f)
UTILS = $(SOURCE)/util
TOOLS = $(SOURCE)/tools
MODULES=$(SOURCE)/modules
SCRIPTS=scripts
WREN_LIB ?= $(OBJS)/libwren.o
WREN_PARAMS ?= -DWREN_OPT_RANDOM=0 -DWREN_OPT_META=1


# Build flags
Expand All @@ -19,13 +21,18 @@ MODE ?= release
# ARCH = 64bit or 32bit
UNAME_S = $(shell uname -s)
UNAME_P = $(shell uname -p)
UNAME_M = $(shell uname -m)
ifeq ($(UNAME_S), Darwin)
SYSTEM ?= macosx
ARCH ?= 64bit
FRAMEWORK ?= $(shell which sdl2-config 1>/dev/null && echo "" || echo "framework")
else ifeq ($(UNAME_S), Linux)
SYSTEM ?= linux
ARCH ?= 64bit
ifeq ($(UNAME_M), aarch64)
ARCH ?= arm64
else
ARCH ?= 64bit
endif
else
SYSTEM ?= windows
ifneq (,$(findstring 32,$(UNAME_S)))
Expand All @@ -41,6 +48,7 @@ TAGS = $(ARCH) $(SYSTEM) $(MODE) $(FRAMEWORK) $(SYMBOLS)

ifneq ($(filter debug,$(TAGS)),)
TAGS += symbols
WREN_PARAMS += -DDEBUG=1
endif

OBJS := $(OBJS)/$(ARCH)
Expand Down Expand Up @@ -74,6 +82,9 @@ ifdef DOME_OPT_VERSION
else
DOME_OPTS += -DDOME_VERSION=\"$(shell git describe --tags)\"
endif
ifneq ($(filter windows,$(TAGS)),)
DOME_OPTS += -D__USE_MINGW_ANSI_STDIO=1
endif

SDL_CONFIG ?= $(shell which sdl2-config 1>/dev/null && echo "sdl2-config" || (which "$(LIBS)/sdl2-config" 1>/dev/null && echo "$(LIBS)/sdl2-config" || echo ""))

Expand All @@ -91,14 +102,17 @@ endif


CFLAGS = $(DOME_OPTS) -std=c99 -pedantic $(WARNING_FLAGS) -fvisibility=hidden
ifneq ($(filter macosx,$(TAGS)),)
ifneq ($(filter linux,$(TAGS)),)
CFLAGS += -D_XOPEN_SOURCE=500
else ifneq ($(filter macosx,$(TAGS)),)
CFLAGS += -mmacosx-version-min=10.12
CFLAGS += -D_DARWIN_C_SOURCE
endif

ifneq ($(filter release,$(TAGS)),)
CFLAGS += -O3
CFLAGS += -O2
else ifneq ($(filter debug,$(TAGS)),)
CFLAGS += -O0
CFLAGS += -O0
ifneq ($(filter macosx,$(TAGS)),)
CFLAGS += -fsanitize=address
FFLAGS += -fsanitize=address
Expand Down Expand Up @@ -132,11 +146,6 @@ SDLFLAGS=$(shell $(SDL_CONFIG) --libs)
endif
endif

ifneq ($(filter release,$(TAGS)),)
DEPS += -lwren
else ifneq ($(filter debug,$(TAGS)),)
DEPS += -lwrend
endif
ifneq ($(and $(filter windows,$(TAGS)),$(filter static,$(TAGS))),)
WINDOW_MODE ?= windows
WINDOW_MODE_FLAG = -m$(WINDOW_MODE)
Expand All @@ -147,7 +156,7 @@ FFLAGS += -F/Library/Frameworks -framework SDL2
endif

LDFLAGS = -L$(LIBS) $(WINDOW_MODE_FLAG) $(SDLFLAGS) $(STATIC_FLAG)
ifneq ($(filter linux,$(TAGS)),)
ifneq ($(and $(filter linux,$(TAGS)), $(filter 64bit, $(TAGS))),)
COMPAT_DEP = $(OBJS)/glibc_compat.o
LDFLAGS += -Wl,--wrap=log,--wrap=log2,--wrap=exp,--wrap=pow,--wrap=expf,--wrap=powf,--wrap=logf
endif
Expand All @@ -157,25 +166,26 @@ LDFLAGS += $(DEPS)


# Build Rules
PROJECTS := dome.bin
PROJECTS := dome.bin modules
.PHONY: all clean reset cloc $(PROJECTS)

all: $(PROJECTS)

WREN_LIB ?= $(LIBS)/libwren.a
WREN_PARAMS ?= $(ARCH) WREN_OPT_RANDOM=0 WREN_OPT_META=1
$(LIBS)/wren/lib/libwren.a:
@echo "==== Cloning Wren ===="
git submodule update --init -- $(LIBS)/wren
$(LIBS)/wren: $(LIBS)/wren/lib/libwren.a
$(WREN_LIB): $(LIBS)/wren
@echo "==== Building Wren ===="
./scripts/setup_wren.sh $(WREN_PARAMS)

$(MODULES)/*.inc: $(UTILS)/embed.c $(MODULES)/*.wren
$(TOOLS)/embed: $(TOOLS)/embed-standalone.c $(TOOLS)/embedlib.c
@echo "==== Building standalone embed tool ===="
$(CC) -o $(TOOLS)/embed $(CFLAGS) $(TOOLS)/embed-standalone.c $(WINDOW_MODE_FLAG)

$(MODULES)/*.inc: $(TOOLS)/embed $(MODULES)/*.wren
@echo "==== Building DOME modules ===="
./scripts/generateEmbedModules.sh

modules: $(MODULES)/*.inc

$(OBJS)/libwren.o: $(INCLUDES)/wren.c
@mkdir -p $(OBJS)
@echo "==== Building wren module ===="
$(CC) -c $(INCLUDES)/wren.c -o $(OBJS)/libwren.o $(WREN_PARAMS) $(IFLAGS)

$(OBJS)/glibc_compat.o: $(INCLUDES)/glibc_compat.c
@mkdir -p $(OBJS)
@echo "==== Building glibc_compat module ===="
Expand All @@ -186,12 +196,12 @@ $(OBJS)/vendor.o: $(INCLUDES)/vendor.c
@echo "==== Building vendor module ===="
$(CC) $(CFLAGS) -c $(INCLUDES)/vendor.c -o $(OBJS)/vendor.o $(IFLAGS)

$(OBJS)/main.o: $(SOURCE_FILES) $(INCLUDES) $(WREN_LIB) $(MODULES)/*.inc
$(OBJS)/main.o: $(SOURCE_FILES) $(INCLUDES) $(MODULES)/*.inc
@mkdir -p $(OBJS)
@echo "==== Building core ($(TAGS)) module ===="
$(CC) $(CFLAGS) -c $(SOURCE)/main.c -o $(OBJS)/main.o $(IFLAGS)

$(TARGET_NAME): $(OBJS)/main.o $(OBJS)/vendor.o $(COMPAT_DEP) $(WREN_LIB)
$(TARGET_NAME): $(OBJS)/main.o $(OBJS)/vendor.o $(OBJS)/libwren.o $(COMPAT_DEP) $(WREN_LIB)
@echo "==== Linking DOME ($(TAGS)) ===="
$(CC) $(CFLAGS) $(FFLAGS) -o $(TARGET_NAME) $(OBJS)/*.o $(ICON_OBJECT_FILE) $(LDFLAGS)
./scripts/set-executable-path.sh $(TARGET_NAME)
Expand All @@ -201,7 +211,6 @@ $(OBJS):
mkdir -p $(OBJS)

$(OBJS)/wren.o: $(OBJS)
git submodule update --init -- $(LIBS)/wren
./scripts/setup_wren_web.sh

# EMCC_FLAGS=--profiling -g
Expand All @@ -218,9 +227,6 @@ clean:
rm -rf $(OBJS)/*.o
reset:
git submodule foreach --recursive git clean -xfd
rm -rf $(LIBS)/libwren.a
rm -rf $(LIBS)/libwrend.a
rm -rf $(INCLUDES)/wren.h

cloc:
cloc --by-file --force-lang="java",wren --fullpath --not-match-d "util" -not-match-f ".inc" src
cloc --by-file --force-lang="java",wren --fullpath --not-match-d "font" -not-match-f ".inc" src
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,18 @@ var Game = Main.new()

## Modules

DOME provides the following modules/methods/classes:
DOME provides the following features, as more:

- Graphics
- Canvas
- Rect
- Point
- Circle
- Ellipses
- Lines
- Triangles
- Color
- ImageData
- ImageData (aka Bitmap)
- Draw sprites loaded from files (png)
- Input
- Keyboard
Expand All @@ -100,16 +102,16 @@ DOME provides the following modules/methods/classes:
- Filesystem
- File reading and writing
- Audio (stereo and mono OGG and WAV files only)
- Native Plugins (allowing access to all kinds of functionality!)

## TODO

You can follow my progress on implementing DOME on [my twitter](https://twitter.com/avivbeeri/status/1012448692119457798).

- Graphics
- Triangles
- Potential 3D rendering mode?
- IO
- Asynchronous Operations
- Audio and Graphics also
- Network Access
- UDP
- HTTP client (maybe)
Expand All @@ -119,8 +121,8 @@ You can follow my progress on implementing DOME on [my twitter](https://twitter.

DOME currently depends on a few libraries to achieve it's functions.

- Wren (This is built by `make` automatically)
- SDL2 (version 2.0.12 or newer, please install separately when building DOME from source)
- Wren (included in the project repo already)
- SDL2 (version 2.0.12 or newer. If you install this from source, you'll want to build shared/dynamic libraries.)
- utf8.h
- stb_image
- stb_image_write
Expand All @@ -132,8 +134,9 @@ DOME currently depends on a few libraries to achieve it's functions.
- tinydir
- [ABC_fifo](https://github.com/avivbeeri/abc) (A SPMC threadpool/task dispatching FIFO I wrote for this project)
- mkdirp
- whereami

Apart from SDL2, all other dependancies are baked in or linked statically. DOME aspires to be both minimalist and cross platform, so it depends on as few external components as possible.
Apart from SDL2, all other dependancies are baked in. DOME aspires to be both minimalist and cross platform, so it depends on as few external components as possible.

## Acknowledgements

Expand All @@ -149,6 +152,7 @@ Apart from SDL2, all other dependancies are baked in or linked statically. DOME
- cxong for [tinydir](https://github.com/cxong/tinydir)
- Jon Olick for [jo_gif](https://www.jonolick.com/home/gif-writer)
- Stephen Mathieson for [mkdirp](https://github.com/stephenmathieson/mkdirp.c)
- Gregory Pakosz for [whereami](https://github.com/gpakosz/whereami)


### Example Game Resources
Expand Down
57 changes: 36 additions & 21 deletions docs/guides/distribution.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,67 @@
[< Back](..)

Distributing your games
Distributing your applications
===================

DOME is designed to be cross-platform, and so the same Wren game files and assets should work across Windows, Mac and Linux. On Mac and Linux, the SDL2 shared library will need to be provided.
DOME is designed to be cross-platform, and so the same Wren code and assets should work across Windows, Mac and Linux. There are different approaches to sharing your application with others.

Please note, none of the methods described here will provide adequate protection from reverse engineering or asset extraction, but may be a temporary hurdle against the casual user. They are intended only as measures of convenience.

## Basic Packaging
The easiest way to share a game you've made is to place a DOME binary, your source code and game assets into a single zip file. Do this once for each platform you wish to support, and share those zip files with your users.
The simplest and easiest way to share something you've made is to place a DOME binary, your source code and assets into a single zip file. Do this once for each platform you wish to support, and share those zip files with your users. If you are providing your own DOME binary, rather than a pre-compiled one, you will need to have access to the shared SDL2 library.

## Bundling with `nest`

## NEST - Easy bundling
For convenience, and to reduce the risk of a file going missing, you can create a `.egg` bundle, which packages all of your application code and resources into a single file. This can be done using the `nest` tool built into DOME.

_(Please note: NEST is still in development, and has to be built from source)_
To create a bundle, navigate to your application's root directory, before running the following on the commandline:

```
> dome nest [files | directories]
```

For easy distribution, you can package all of your games resources into a single `.egg` file using a tool called [NEST](https://github.com/domeengine/nest). DOME automatically plays any file named `game.egg` in the current working directory.
This will bundle all the files and directories into a file named `game.egg`. DOME automatically plays any file named `game.egg` in the current working directory. It expects that bundles contain a `main.wren` file in the base directory of the bundle, as the entry point for execution.

If you use a `.egg` file, DOME expects your game to start from a `main.wren` in the base directory as it's entry point.
### Fused Mode

Install NEST, and then navigate to your main game directory, before running the following:
Depending on your needs, you might want to only distribute your application to your users as a single file. This is possible using DOME's "fuse" mode. Once you have a `.egg` file as described in the previous section, you can embed it inside a DOME executable using the "fuse" tool. Run DOME from the commandline like this:

```
> nest -z -o game.egg -- [files | directories]
> dome fuse game.egg [destination file]
```

## Cross-Platform Distribution
_(You can ignore this section if you are using pre-compiled DOME binaries.)_
This creates a standalone executable which requires no other files to run. If you set a destination file, the resulting binary will be placed there. Otherwise, it'll be placed in the current working directory, as a file named `game` (or `game.exe` on Windows). This will only produce a binary for the current platform. You'll need to do this on each platform you want to distribute to.

## Platform-specific Distribution Notes

This section discusses the needs of various platforms when distributing games with DOME.
This section discusses the needs of various platforms when distributing applications with DOME.

### Windows

On Windows, DOME comes compiled with all it's dependancies, so you just need to provide your game files.
On Windows, DOME comes compiled with all its dependancies, so you just need to provide your application files.

### Mac OS X
### Mac OS

On Mac, the SDL2 library needs to be provided. This can either be globally installed, or you can package it as part of an application bundle, using the following layout:
On Mac OS platforms, you can create an application bundle by arranging your code and assets into the following directory/file layout:

`<Game>` is a placeholder and should be replaced by the name of your application. It must be named consistently in the bundle layout, as well as in the Info.plist file.

```
+-- Game.app
+-- <Game>.app
+-- Contents
+-- Info.plist
+-- MacOS
+-- dome
+-- libSDL2.dylib
+-- Game (This is a small runscript)
+-- <Game> (This is a small runscript)
+-- Resources
+-- game.egg
+-- icon.icns
+-- other assets...
```

You only need to provide libSDL2.dylib if you are not using a statically linked version of `dome`. (If you are using an official DOME binary, you don't need to worry.)

The runscript is very simple and looks like this:
```bash
#!/bin/bash
Expand All @@ -62,7 +76,7 @@ Finally, the Info.plist at minimum needs to look like this:
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>Game</string>
<string> <Game> </string>
<key>CFBundleIconFile</key>
<string>icon</string>
<key>NSHighResolutionCapable</key>
Expand All @@ -77,13 +91,14 @@ Doing this results in a self contained and easy to distribute application bundle

### Linux

To run your game on linux, make sure SDL2 is installed, then run the dome executable with a `game.egg` file in the same directory.
Running your application on Linux should be reasonably simple. If you use a version with a statically linked version of SDL2, then you can just run the `dome` executable with a `game.egg` file in the same directory.
If your binary is not statically linked, you'll need to acquire a copy of the SDL2 shared library, and either install it globally, or store a local copy with `dome`.

### Web

DOME has an experimental web engine, which you can use to play your game in a browser.
DOME has an experimental web engine, which you can use to run your application in a browser.
To do this, you need to host the `dome.html` file and your `game.egg` file in the same directory on a server.

You may find that the performance of your game suffers when running in the browser, in which case it may not be suitable for playing in browsers.
You may find that the performance of your application suffers when running in the browser, in which case this may not be a suitable method of distribution.
DOME's web engine does not currently support playing at full screen.

Loading

0 comments on commit 3eaa209

Please sign in to comment.