feat(cli): support building WASM via podman
Previously, `tree-sitter build-wasm` had the ability to build WASM
by using docker to pull in an image with a complete emscripten toolchain.
This commit adds the ability to use podman to do the same thing.
Using podman requires two notable changes:
1. Using the fully-qualified image name. Docker defaults to prepending
`docker.io` to the image name, but podman does not.
2. Podman will mount the `/src/` volume as belonging to root unless
`--userns=keep-id` is passed. I think podman's different
volume-ownership is related to podman's daemonless execution and
`--uidmap` functionality, but I'm not 100% sure.
To test, I ran
```sh
script/fetch-fixtures
script/generate-fixtures
script/generate-fixtures-wasm # <- the important one!
```
which worked as well as the docker version.
This commit is contained in:
parent
78c297e6ed
commit
d35efd4608
5 changed files with 119 additions and 49 deletions
|
|
@ -64,21 +64,32 @@ while [[ $# > 0 ]]; do
|
|||
shift
|
||||
done
|
||||
|
||||
emcc=
|
||||
emcc=""
|
||||
docker=""
|
||||
if which emcc > /dev/null && [[ "$force_docker" == "0" ]]; then
|
||||
emcc=emcc
|
||||
elif which docker > /dev/null; then
|
||||
emcc="docker run \
|
||||
# detect which one to use
|
||||
docker=docker
|
||||
elif which podman > /dev/null; then
|
||||
docker=podman
|
||||
fi
|
||||
|
||||
if [ -z "$emcc" ] && [ -n "$docker" ]; then
|
||||
export PODMAN_USERNS=keep-id
|
||||
emcc="$docker run \
|
||||
--rm \
|
||||
-v $(pwd):/src:Z \
|
||||
-u $(id -u) \
|
||||
emscripten/emsdk:$emscripen_version \
|
||||
emcc"
|
||||
else
|
||||
fi
|
||||
|
||||
if [ -z "$emcc" ]; then
|
||||
if [[ "$force_docker" == "1" ]]; then
|
||||
echo 'You must have `docker` on your PATH to run this script with --docker'
|
||||
echo 'You must have `docker` or `podman` on your PATH to run this script with --docker'
|
||||
else
|
||||
echo 'You must have either `docker` or `emcc` on your PATH to run this script'
|
||||
echo 'You must have either `docker`, `podman`, or `emcc` on your PATH to run this script'
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue