···66# Just rename this script to the desired build tool, then prepend it to Envision's PATH environment variable. It will
77# run instead of the system build tool.
8899+use std log
1010+911const cmd = path self | path basename
10121113def main --wrapped [...args] {
1212- # Replace working directory with /build in commands
1313- let args = $args | str replace -a (pwd) /build
1414+ let args = $args | where ($it | is-not-empty)
14151515- # TODO: Use latest image from AtomicXR container registry
1616- podman run -v .:/build localhost/xr-multi:latest $cmd ...$args
1616+ # HACK: I don't exactly know why the source path gets appended to the command line
1717+ let last_as_workdir = $cmd == "cmake" and $args.0 == "-B"
1818+ let workdir = if $last_as_workdir {
1919+ $args | last
2020+ } else {
2121+ pwd
2222+ }
2323+ let args = if $last_as_workdir {
2424+ $args | drop 1
2525+ } else {
2626+ $args
2727+ }
2828+2929+ log info $"Working directory: ($workdir)"
3030+ log info $"Running in OCI container via shim: ($cmd) ($args | str join ' ')"
3131+3232+ # TODO: Use image from AtomicXR container registry
3333+ podman run ...[
3434+ --security-opt label=disable
3535+ --security-opt apparmor=unconfined
3636+ -v $"($env.HOME):($env.HOME)"
3737+ --workdir $workdir
3838+ --env=PWD=$workdir
3939+ --rm
4040+ ] localhost/xr-multi:latest $cmd ...$args
1741}