build: use justfile instead of bash scripts

This commit is contained in:
dusk 2024-11-28 21:39:18 +03:00
parent d64091eb59
commit cf87da4c5e
Signed by: dusk
SSH Key Fingerprint: SHA256:Abmvag+juovVufZTxyWY8KcVgrznxvBjQpJesv071Aw
6 changed files with 42 additions and 35 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@
/android/
rust/target
/addons/boids/lib/*
/boids-release.zip

View File

@ -11,8 +11,8 @@ it can handle about 2000 boids in a single flock at 11ms physics process tick on
download it from the [asset library](https://godotengine.org/asset-library/asset/3284).
or clone the repository, and run `rust/package-release.sh` to build the libraries for all supported targets.
(requires [cross](https://github.com/cross-rs/cross))
or clone the repository, and run `just build-all` to build the libraries (in release mode) for all supported targets.
(requires [cross](https://github.com/cross-rs/cross), [just from `master` branch](https://github.com/casey/just) and [nushell](https://github.com/nushell/nushell))
## development

View File

@ -4,15 +4,14 @@ compatibility_minimum = 4.3
reloadable = true
[libraries]
linux.debug.x86_64 = "res://addons/boids/lib/boids.x86.so"
windows.debug.x86_64 = "res://addons/boids/lib/boids.x86.dll"
web.debug.wasm32 = "res://addons/boids/lib/boids.wasm"
linux.release.x86_64 = "res://addons/boids/lib/boids.x86.so"
windows.release.x86_64 = "res://addons/boids/lib/boids.x86.dll"
macos.release = "res://addons/boids/lib/libboids.x86.dylib"
linux.debug.x86_64 = "res://addons/boids/lib/boids.x86_64.so"
linux.release.x86_64 = "res://addons/boids/lib/boids.x86_64.so"
windows.debug.x86_64 = "res://addons/boids/lib/boids.x86_64.dll"
windows.release.x86_64 = "res://addons/boids/lib/boids.x86_64.dll"
macos.release = "res://addons/boids/lib/libboids.x86_64.dylib"
macos.release.arm64 = "res://addons/boids/lib/libboids.arm64.dylib"
web.debug.wasm32 = "res://addons/boids/lib/boids.wasm"
web.release.wasm32 = "res://addons/boids/lib/boids.wasm"
web.debug.wasm32 = "res://addons/boids/lib/boids.wasm32.wasm"
web.release.wasm32 = "res://addons/boids/lib/boids.wasm32.wasm"
[icons]
BoidProperties = "res://addons/boids/resources/boid_properties.svg"

32
justfile Normal file
View File

@ -0,0 +1,32 @@
set shell := ['nu', '-c']
profile := 'dev'
host-target := `rustc -vV | lines | skip 1 | to text | from csv -s : --noheaders | reduce -f {} {|el, acc| $acc | upsert $el.column0 $el.column1 } | get host`
artifact-dir := 'addons/boids/lib'
[private]
default: (just-cmd '-l')
[private]
setup-env:
mkdir -v {{artifact-dir}}
[private]
just-cmd *FLAGS="":
@just -f {{justfile()}} {{FLAGS}}
build ext $target=(host-target) *FLAGS="": setup-env
cd rust; cross build {{FLAGS}} --profile {{profile}} --target {{target}}
mv -f rust/target/{{target}}/{{ if profile == 'dev' { 'debug' } else { profile } }}/{{ if target =~ 'linux' { 'lib' } else { '' } }}boids.{{ext}} {{artifact-dir}}/boids.{{`$env.target | split row - | first`}}.{{ext}}
build-wasm: (build 'wasm' 'wasm32-unknown-emscripten' '+nightly' '-Zbuild-std')
build-windows: (build 'dll' 'x86_64-pc-windows-msvc')
build-linux: (build 'so' 'x86_64-unknown-linux-gnu')
build-all: (just-cmd '--timestamp' 'profile=release' 'build-linux' 'build-windows' 'build-wasm')
package:
run-external 'zip' '-r' 'boids-release.zip' 'addons' 'examples' 'README.md' 'LICENSE.txt'

View File

@ -1,10 +0,0 @@
#!/bin/sh
set -x
cargo build
cd ..
cp -f rust/target/debug/libboids.so addons/boids/lib/boids.x86.so
cp -f rust/target/debug/boids.dll addons/boids/lib/boids.x86.dll

View File

@ -1,15 +0,0 @@
#!/bin/sh
set -x
cross build --release --target x86_64-unknown-linux-gnu
cross build --release --target x86_64-pc-windows-gnu
cross +nightly build -Zbuild-std --release --target wasm32-unknown-emscripten
cd ..
cp -f rust/target/x86_64-unknown-linux-gnu/release/libboids.so addons/boids/lib/boids.x86.so
cp -f rust/target/x86_64-pc-windows-gnu/release/boids.dll addons/boids/lib/boids.x86.dll
cp -f rust/target/wasm32-unknown-emscripten/release/boids.wasm addons/boids/lib/boids.wasm
zip -r ../boids-release.zip addons examples README.md LICENSE.txt