diff --git a/.travis.yml b/.travis.yml index 4fcc55b9..da121bc5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,4 @@ sudo: required -dist: trusty language: cpp @@ -20,17 +19,32 @@ env: matrix: include: - os: linux + dist: trusty + name: "Linux clang" compiler: clang env: PLATFORM=linux - os: linux + dist: trusty + name: "Linux gcc" compiler: gcc env: PLATFORM=linux - os: linux + dist: trusty + name: "Android" compiler: gcc env: PLATFORM=android CMAKE_ARGS="-DAndroid=1 -DCMAKE_TOOLCHAIN_FILE=../Android.cmake -Dtools=$HOME/android-toolchain/" - os: osx compiler: clang + name: "macOS" env: PLATFORM=osx + - os: windows + name: "Windows" + env: PLATFORM=windows + - os: linux + dist: xenial + name: "Emscripten" + compiler: clang + env: PLATFORM=emscripten CMAKE_ARGS="-DEmscripten=1" CMAKE_EXECUTOR=emconfigure script: "./travis.sh" diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d4e111d..65918341 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,7 +64,7 @@ list(APPEND TARGET_LIBS Box2D ) if (Emscripten) - set_target_properties(openclaw PROPERTIES LINK_FLAGS "-s WASM=1 -s BINARYEN_METHOD='native-wasm' -s EXPORTED_FUNCTIONS='[_main]' -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='[\"pcx\",\"png\",\"tga\"]' -s USE_SDL_TTF=2 -s USE_SDL_GFX=2 -s ASYNCIFY=1 -s TOTAL_MEMORY=268435456 --preload-file config.xml --preload-file CLAW.REZ --preload-file ASSETS.ZIP --preload-file SAVES.XML --preload-file console02.tga --preload-file clacon.ttf") + set_target_properties(openclaw PROPERTIES LINK_FLAGS "-s WASM=1 -s BINARYEN_METHOD='native-wasm' -s EXPORTED_FUNCTIONS='[_main]' -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='[\"pcx\",\"png\",\"tga\"]' -s USE_SDL_TTF=2 -s USE_SDL_GFX=2 -s ASYNCIFY=1 -s TOTAL_MEMORY=268435456 --preload-file ../Build_Release/config.xml@config.xml --preload-file ../Build_Release/CLAW.REZ@CLAW.REZ --preload-file ../Build_Release/ASSETS.ZIP@ASSETS.ZIP --preload-file ../Build_Release/SAVES.XML@SAVES.XML --preload-file ../Build_Release/console02.tga@console02.tga --preload-file ../Build_Release/clacon.ttf@clacon.ttf") else (Emscripten) list(APPEND TARGET_LIBS SDL2 diff --git a/OpenClaw/main.cpp b/OpenClaw/main.cpp index b42517c3..30a3fe47 100644 --- a/OpenClaw/main.cpp +++ b/OpenClaw/main.cpp @@ -10,6 +10,8 @@ ClawGameApp testApp; +int main(int argc, char* argv[]); + #ifdef ANDROID extern "C" void SDL_Android_Init(JNIEnv* env, jclass cls); diff --git a/README.md b/README.md index 37396ed1..0a616e2c 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ [![Build Status](https://ci.appveyor.com/api/projects/status/github/pjasicek/OpenClaw?svg=true)](https://ci.appveyor.com/project/pjasicek/captainclaw) -### Linux (debian): +### Linux (debian), macOS, Windows, Android, Emscripten: [![Build Status](https://travis-ci.org/pjasicek/OpenClaw.svg?branch=master)](https://travis-ci.org/pjasicek/OpenClaw) @@ -29,22 +29,38 @@ - Tinyxml library for data-driven approach # Building and running -For all platforms you will need original CLAW.REZ game archive from original game +For all platforms you will need original `CLAW.REZ` game archive in `Build_Release` directory from original game + +Zip all content inside `Build_Release/ASSETS` directory to `ASSETS.ZIP` file. + ### Windows - Project contains VS2017 solution with all libraries and include directories preset - Project also contains CMake files if you want to use other IDEs. + ```shell script + mkdir build + cd build + + cmake -G "Visual Studio 15 2017" .. + msbuild OpenClaw.sln + # Or + cmake -G "NMake Makefiles" .. + nmake + ``` - Box2D is generated by CMake and it hardcodes the file paths. If you want to compile it on your own, you must run CMake on the CMakeLists.txt in the Box2D root directory - Do not try to use different versions of SDL libraries than the ones which are already included in the Build_Release folder ### Linux **Prerequisites for Ubuntu 16.04 (should be almost identical for Fedora/CentOS/*):** - - `sudo apt install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libsdl2-gfx-dev libtinyxml-dev` + ```shell script + sudo apt install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libsdl2-gfx-dev + ``` + You could also install `libtinyxml-dev` but this library will be compiled and linked from `ThirdParty/Tinyxml` directory. + Edit root `CMakeLists.txt` file to change this behaviour. **Compilation:** - `git clone https://github.com/pjasicek/OpenClaw.git` - - `cd OpenClaw/Build_Release` - CLAW.REZ iz required from original game in the OpenClaw/Build_Release folder + - Use `cmake` to build fresh Makefile. There is no need specific arguments. - `make` (it's going to use all threads to compile, edit Makefile in Build_Release folder to whatever number of simultaneous threads you want it on your machine to run) **Remarks:** @@ -62,7 +78,7 @@ For all platforms you will need original CLAW.REZ game archive from original gam **Compilation:** - Install [Emscripten SDK](https://emscripten.org/docs/getting_started/downloads.html) from official website. I'm not sure that compilation will be successful on a Windows platform. If you use Windows then don't show off, enable Windows Subsystem for Linux (WSL), download Linux-like system (for example, Ubuntu) from Windows Store and install Emscripten SDK. It should be something like: - ``` + ```shell script git clone https://github.com/emscripten-core/emsdk.git cd emsdk ./emsdk install latest @@ -72,23 +88,21 @@ For all platforms you will need original CLAW.REZ game archive from original gam # If it doesn't work the project was successfully compiled on 1.39.5 version. ``` - Make sure you have *python* and *cmake* packages. Ubuntu: `sudo apt install python cmake`. - - Zip all content inside `Build_Release/ASSETS` directory to `ASSETS.ZIP` file. - - Create build directory in project root directory as `mkdir build`. - - Copy `ASSETS.ZIP`, `clacon.ttf`, `CLAW.REZ`, `config.xml`, `console02.tga`, `SAVES.XML` files from `Build_Release` directory to `build` directory. - - Open `CMakeLists.txt` in project root directory, set `EMSCRIPTEN_PATH` variable and change `Emscripten` option to `ON`. + - Make sure you have fresh `ASSETS.ZIP` and `CLAW.REZ` files in `Build_Release` directory. - Compile: - ``` + ```shell script + mkdir build cd build - sudo YOUR_SDK_PATH/emsdk/upstream/emscripten/emconfigure cmake .. - sudo make + emconfigure cmake -DEmscripten=1 .. + make ``` **Run:** You will need web server to run compiled project. There are 2 options: - - You can upload `openclaw.html`, `openclaw.js` and `openclaw.data` files from `Build_Release` directory to any web server. + - You can upload `openclaw.html`, `openclaw.js`, `openclaw.wasm` and `openclaw.data` files from `Build_Release` directory to any web server. - Or run Python server: - ``` + ```shell script cd Build_Release python -m SimpleHTTPServer 8080 # Go to http://localhost:8080/openclaw.html diff --git a/travis.sh b/travis.sh index 2c2b4884..2c7efbec 100755 --- a/travis.sh +++ b/travis.sh @@ -11,8 +11,10 @@ coverity() { } prepare_linux() { + sudo apt-get update + sudo apt-get install libsdl2-2.0-0 sudo apt-get install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libsdl2-gfx-dev - sudo apt-get install libtinyxml-dev +# sudo apt-get install libtinyxml-dev sudo apt-get install cmake } @@ -21,12 +23,24 @@ prepare_android() { } prepare_osx() { - brew install sdl2 sdl2_image sdl2_mixer sdl2_ttf sdl2_gfx tinyxml; + brew install sdl2 sdl2_image sdl2_mixer sdl2_ttf sdl2_gfx; +# brew install tinyxml; +} + +prepare_emscripten() { + git clone https://github.com/emscripten-core/emsdk.git + cd emsdk + ./emsdk install latest + ./emsdk activate latest + . ./emsdk_env.sh + cd .. + + emcc -v } build() { case "$PLATFORM" in - linux|android|osx) + linux|android|osx|emscripten) prepare_${PLATFORM} ;; esac @@ -34,8 +48,17 @@ build() { git config user.email "travis@build.bot" && git config user.name "Travis CI" git tag -a -m "Travis build" init - mkdir build; cd build; cmake $CMAKE_ARGS .. - make -j8 + mkdir build; cd build; $CMAKE_EXECUTOR cmake $CMAKE_ARGS .. + + case "$PLATFORM" in + windows) + # TODO: MSBuild.exe command not found. Why??? + "/C/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/MSBuild/15.0/Bin/MSBuild.exe" OpenClaw.sln //p:Configuration=Debug //p:Platform="Win32" + ;; + *) + make -j8 + ;; + esac } case "$TRAVIS_EVENT_TYPE" in