build: improve justfile
This commit is contained in:
parent
7de1e84d98
commit
96f8c884b7
21
justfile
21
justfile
@ -1,8 +1,9 @@
|
|||||||
set shell := ['nu', '-c']
|
set shell := ['nu', 'justfile.nu']
|
||||||
|
set export
|
||||||
|
|
||||||
|
|
||||||
profile := 'dev'
|
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`
|
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 | str trim`
|
||||||
artifact-dir := 'addons/boids/lib'
|
artifact-dir := 'addons/boids/lib'
|
||||||
|
|
||||||
[private]
|
[private]
|
||||||
@ -17,15 +18,19 @@ just-cmd *FLAGS="":
|
|||||||
@just -f {{justfile()}} {{FLAGS}}
|
@just -f {{justfile()}} {{FLAGS}}
|
||||||
|
|
||||||
|
|
||||||
build ext $target=(host-target) *FLAGS="": setup-env
|
build $target=(host-target) *FLAGS="": setup-env
|
||||||
cd rust; cross build {{FLAGS}} --profile {{profile}} --target {{target}}
|
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')
|
install $target=(host-target): setup-env
|
||||||
build-windows: (build 'dll' 'x86_64-pc-windows-msvc')
|
mv -f rust/target/{{target}}/{{`$env.profiledir`}}/{{`$env.libprefix`}}boids.{{`$env.ext`}} {{artifact-dir}}/boids.{{`$env.arch`}}.{{`$env.ext`}}
|
||||||
build-linux: (build 'so' 'x86_64-unknown-linux-gnu')
|
|
||||||
|
|
||||||
build-all: (just-cmd '--timestamp' 'profile=release' 'build-linux' 'build-windows' 'build-wasm')
|
build-install target *FLAGS="": (build target FLAGS) (install target)
|
||||||
|
|
||||||
|
wasm: (build-install 'wasm32-unknown-emscripten' '+nightly' '-Zbuild-std')
|
||||||
|
windows: (build-install 'x86_64-pc-windows-msvc')
|
||||||
|
linux: (build-install 'x86_64-unknown-linux-gnu')
|
||||||
|
|
||||||
|
all: (just-cmd '--timestamp' 'profile=release' 'linux' 'windows' 'wasm')
|
||||||
|
|
||||||
|
|
||||||
package:
|
package:
|
||||||
|
22
justfile.nu
Normal file
22
justfile.nu
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
let exts = {
|
||||||
|
wasm32-unknown-emscripten: "wasm"
|
||||||
|
x86_64-pc-windows-msvc: "dll"
|
||||||
|
x86_64-unknown-linux-gnu: "so"
|
||||||
|
}
|
||||||
|
|
||||||
|
def getext [] { $exts | get $env.target }
|
||||||
|
def getlibprefix [] { if ($env.target | str contains "linux") { "lib" } else { "" } }
|
||||||
|
def getarch [] { $env.target | split row - | first }
|
||||||
|
def getprofiledir [] { if ($env.profile == 'dev') { "debug" } else { $env.profile }}
|
||||||
|
|
||||||
|
def main [command: string] {
|
||||||
|
if ('target' in $env) {
|
||||||
|
$env.ext = getext
|
||||||
|
$env.libprefix = getlibprefix
|
||||||
|
$env.arch = getarch
|
||||||
|
}
|
||||||
|
if ('profile' in $env) {
|
||||||
|
$env.profiledir = getprofiledir
|
||||||
|
}
|
||||||
|
nu -c $command
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user