feat: ci: Deploy to Gitlab Pages 🚀

This commit is contained in:
Thibault Lemaire
2024-09-20 15:43:47 +02:00
parent 38dda1fb92
commit 4591a17a1b
9 changed files with 92 additions and 41 deletions

27
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,27 @@
pages:
rules:
# Run on all tags (but only on tags)
- if: "$CI_COMMIT_TAG"
when: always
image: $CI_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/emscripten-build-env
cache:
paths:
- Linux/build.emscripten
script:
- meson setup --reconfigure --cross-file wasm/wasm32-emscripten.meson-cross-build-definition.txt -Dbuildtype=release -Db_sanitize=none -Dmovies=false Linux/build.emscripten .
- cd Linux/build.emscripten
- export EM_CACHE=$(pwd)/cache
# The docker image has no /tmp dir
# https://github.com/llvm/llvm-project/blob/b530eeea5e7697d58af2adac66c8b86c79e649bb/llvm/lib/Support/Unix/Path.inc#L1427
- export TMP=$(pwd)
- meson compile
- mkdir ../../public
- cp -r *.wasm* *.js *.html *.data ../../public
publish: public
artifacts:
paths:
- public

View File

@ -132,12 +132,10 @@ You need to have emscripten installed and enable your installed emsdk tools in y
source emsdk_env.sh source emsdk_env.sh
``` ```
Then copy the necessary Homeworld demo assets (HomeworldDL.big, DL_demo.vce, DL_Music.wxd and ideally the Update.big from the Homeworld 1.05 Update) to the wasm/demo_assets/ folder.
Now you can setup meson for cross-compiling to wasm32 using emscripten: Now you can setup meson for cross-compiling to wasm32 using emscripten:
```sh ```sh
meson setup --cross-file ../wasm32-emscripten.meson-cross-build-definition.txt -Db_sanitize=none -Dmovies=false build.emscripten .. meson setup --cross-file ../wasm/wasm32-emscripten.meson-cross-build-definition.txt -Db_sanitize=none -Dmovies=false build.emscripten ..
``` ```
Now switch to the created build.emscripten folder and compile: Now switch to the created build.emscripten folder and compile:
@ -152,4 +150,10 @@ To automatically open the compiled wasm32 binaries in the browser using the prov
emrun . emrun .
``` ```
### Building the Docker image used in the CI
```sh
docker load < $(nix build --no-link --print-out-paths .#ci-docker-image)
```

View File

@ -64,6 +64,32 @@
${nixGL.packages.x86_64-linux.default}/bin/nixGL ${self.packages.x86_64-linux.default}/bin/homeworld ${nixGL.packages.x86_64-linux.default}/bin/nixGL ${self.packages.x86_64-linux.default}/bin/homeworld
''; '';
ci-docker-image = with nixpkgs.legacyPackages.x86_64-linux;
dockerTools.buildLayeredImage {
name = "registry.gitlab.com/gardens-of-kadesh/gardens-of-kadesh/emscripten-build-env";
tag = "latest";
contents = [
busybox
meson
pkg-config
ninja
emscripten
gcc
yacc
flex
# Root certificates for HTTPS, so emscripten can download SDL2
dockerTools.caCertificates
];
config = {
Env = [
"PKG_CONFIG_PATH=${SDL2.dev}/lib/pkgconfig"
];
Cmd = [ "/bin/sh" ];
};
};
apps.x86_64-linux.default = { apps.x86_64-linux.default = {
type = "app"; type = "app";
program = "${self.packages.x86_64-linux.default}/bin/homeworld"; program = "${self.packages.x86_64-linux.default}/bin/homeworld";

View File

@ -1,21 +1,20 @@
# Tenhauser Gate # Gardens of Kadesh
📣 **Play in your browser!** Try our experimental wasm port here: [Gardens of Kadesh] [📣 **Play the demo in your browser!**][wasm-demo] (Will download ~70MiB of data. You need a good internet connection.)
Source port of Homeworld 1 to modern systems (Linux, Windows, macOS). Source port of Homeworld 1 to modern systems (Linux, Windows, macOS, and web browsers).
[Homeworld] is a 3D space real-time strategy game released in 1999. [Homeworld] is a 3D space real-time strategy game released in 1999.
It's source code was [released in 2003] by [Relic Entertainment], allowing a small but dedicated community of fans to port it to [SDL], enabling native versions for Linux, MacOS, and more recently, web browsers. It's source code was [released in 2003] by [Relic Entertainment], allowing a small but dedicated community of fans to port it to [SDL], enabling native versions for Linux, MacOS, and more recently, web browsers.
💬 Join our [matrix space] 💬 Join our [matrix space]
[wasm-demo]: https://gardens-of-kadesh.gitlab.io/gardens-of-kadesh/
[matrix space]: https://matrix.to/#/#homeworld-sdl:matrix.org [matrix space]: https://matrix.to/#/#homeworld-sdl:matrix.org
[Homeworld SDL]: https://github.com/HomeworldSDL/HomeworldSDL
[SDL]: https://en.wikipedia.org/wiki/Simple_DirectMedia_Layer [SDL]: https://en.wikipedia.org/wiki/Simple_DirectMedia_Layer
[Homeworld]: https://en.wikipedia.org/wiki/Homeworld [Homeworld]: https://en.wikipedia.org/wiki/Homeworld
[released in 2003]: http://www.insidemacgames.com/news/story.php?ArticleID=8516 [released in 2003]: http://www.insidemacgames.com/news/story.php?ArticleID=8516
[Relic Entertainment]: https://www.relic.com/ [Relic Entertainment]: https://www.relic.com/
[Gardens of Kadesh]: https://gardensofkadesh.github.io/
## Requirements ## Requirements
@ -80,27 +79,15 @@ Open the game installation folder (usually `~/.wine/drive_c/Sierra/Homeworld`).
##### Steam ##### Steam
After installing the game, you should find the [required assets](#asset-checklist) in `~/.local/share/Steam/steamapps/common/Homeworld/Homeworld1Classic/Data`. Put them to `$ASSETS_FOLDER`. After installing [the game][store_page], you should find the [required assets](#asset-checklist) in `~/.local/share/Steam/steamapps/common/Homeworld/Homeworld1Classic/Data`. Put them to `$ASSETS_FOLDER`.
[store_page]: https://store.steampowered.com/app/244160/Homeworld_Remastered_Collection/
## Compiling from source ## Compiling from source
### Linux ### Linux
If you have [Nix] installed, just run: Please refer to [`Linux/BUILD.md`](Linux/BUILD.md)
```sh
HW_Data=$ASSETS_FOLDER nix run --impure 'git+https://gitlab.com/homeworldsdl/TenhauserGate.git?dir=Linux#i-am-not-on-nixos'
```
Or if you are on NixOS:
```sh
HW_Data=$ASSETS_FOLDER nix run 'git+https://gitlab.com/homeworldsdl/TenhauserGate.git?dir=Linux'
```
Nix will download everything it needs, build the HomeworldSDL source code, then run the resulting binary.
If you don't have Nix installed, please refer to [`Linux/BUILD.md`](Linux/BUILD.md)
#### Game is slow/crashes #### Game is slow/crashes
@ -123,8 +110,6 @@ Please refer to [`Mac/BUILD.md`](Mac/BUILD.md).
To setup either the data from the original or remaster. Please place the data assets into 'Library/Application Support/Homeworld' or, if you are using Raider Retreat, place them in the same destination folder except to use 'Raider Retreat' instead of 'Homeworld'. To setup either the data from the original or remaster. Please place the data assets into 'Library/Application Support/Homeworld' or, if you are using Raider Retreat, place them in the same destination folder except to use 'Raider Retreat' instead of 'Homeworld'.
[Nix]: https://nixos.org/nix/
## Running the game for the first time ## Running the game for the first time
The first time you run the game, you will have to point it to [the directory containing the required assets](#setting-up-the-assets-folder). For example, if you have [compiled the game from source](#compiling-from-source): The first time you run the game, you will have to point it to [the directory containing the required assets](#setting-up-the-assets-folder). For example, if you have [compiled the game from source](#compiling-from-source):
@ -160,7 +145,7 @@ Once the game has launched, you need to:
If you want to know more about this project (and see some screenshots!), please head over to the [wiki]. If you want to know more about this project (and see some screenshots!), please head over to the [wiki].
[wiki]: https://gitlab.com/ThibaultLemaire/HomeworldSDL/wikis/home [wiki]: https://gitlab.com/gardens-of-kadesh/gardens-of-kadesh/wikis/home
[releases]: https://gitlab.com/ThibaultLemaire/HomeworldSDL/-/releases [releases]: https://gitlab.com/gardens-of-kadesh/gardens-of-kadesh/-/releases
[the official 1.05 patch]: https://www.homeworldaccess.net/infusions/downloads/downloads.php?file_id=35 [the official 1.05 patch]: https://www.homeworldaccess.net/infusions/downloads/downloads.php?file_id=35

View File

@ -9,11 +9,15 @@ endif
dep_sdl = dependency('sdl2') dep_sdl = dependency('sdl2')
base_deps = [ base_deps = [ ]
dependency('gl'),
dep_sdl, if host_machine.system() != 'emscripten'
meson.get_compiler('c').find_library('m', required: false), base_deps += [
] dependency('gl'),
dep_sdl,
meson.get_compiler('c').find_library('m', required: false),
]
endif
c_base_args = [ c_base_args = [
'-DHAVE_CONFIG_H', '-DHAVE_CONFIG_H',
@ -113,7 +117,7 @@ elif host_machine.system() == 'darwin'
elif host_machine.system() == 'windows' elif host_machine.system() == 'windows'
c_base_args += ['-D_LINUX_FIX_ME', '-D_GNU_SOURCE', '-D_WIN32', '-DWIN32', '-DWINDOWS'] c_base_args += ['-D_LINUX_FIX_ME', '-D_GNU_SOURCE', '-D_WIN32', '-DWIN32', '-DWINDOWS']
elif host_machine.system() == 'emscripten' elif host_machine.system() == 'emscripten'
base_deps += [dependency('x11')] base_deps += [subproject('demo-assets').get_variable('demo_assets_dep')]
c_base_args += ['-D_LINUX_FIX_ME', '-D_GNU_SOURCE'] c_base_args += ['-D_LINUX_FIX_ME', '-D_GNU_SOURCE']
endif endif
@ -155,15 +159,12 @@ if host_machine.system() == 'emscripten'
'-s', 'ALLOW_MEMORY_GROWTH=1', '-s', 'ALLOW_MEMORY_GROWTH=1',
'--use-preload-plugins', '--use-preload-plugins',
'--preload-file', '../../wasm/demo_assets@/', '--preload-file', '../../subprojects/demo-assets-1.05/assets@/',
'-o', 'homeworld.html', '-o', 'homeworld.html',
] ]
add_project_arguments(emscripten_compile_args, language: ['c', 'cpp'])
dep_sdl = [] add_project_link_arguments(emscripten_link_args, language: ['c', 'cpp'])
add_global_arguments(emscripten_compile_args, language: ['c', 'cpp'])
add_global_link_arguments(emscripten_link_args, language: ['c', 'cpp'])
endif endif

View File

@ -29,7 +29,7 @@ src_sdl += files('fqcodec.c',
lib_sdl = static_library('hw_sdl', lib_sdl = static_library('hw_sdl',
src_sdl, src_sdl,
c_args: c_args, c_args: c_args,
dependencies: [dep_sdl], dependencies: base_deps,
include_directories: ['../Game', '../Ships', '../ThirdParty/CRC', '../ThirdParty/stb']) include_directories: ['../Game', '../Ships', '../ThirdParty/CRC', '../ThirdParty/stb'])
inc_src_sdl = include_directories('.') inc_src_sdl = include_directories('.')

3
subprojects/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
*
!.gitignore
!*.wrap

View File

@ -0,0 +1,5 @@
[wrap-file]
directory = demo-assets-1.05
source_url = https://gitlab.com/gardens-of-kadesh/demo-assets/-/archive/1.05/demo-assets-1.05.tar.gz
source_filename = demo-assets-1.05.tar.gz
source_hash = aa4df87ab95688970d91eb37b6a7ce8b69c5bf6f7ee963f75c098a4c1fb1f03d