Skip to content

Commit d7e82bd

Browse files
committed
feat: support platform linux/amd64
1 parent 31ddf8a commit d7e82bd

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM debian:12-slim
1+
FROM --platform=linux/amd64 debian:12-slim
22

33
ARG LIBRARY_NAME=tree-sitter-cedarscript
44

Makefile

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.sh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,25 @@ ts build --wasm && \
2828
cp -a test "$TARGET_DIR" && \
2929
ts test || { playground; exit 1 ;}
3030

31-
# MacOS compilation
32-
rm -f "$TARGET_DIR"/lib"$LIBRARY_NAME".* "$GRAMMAR_DIR"/lib"$LIBRARY_NAME".* && \
33-
(cd "$TARGET_DIR" && cc -c -I./src src/parser.c && cc -dynamiclib -o lib"$LIBRARY_NAME".dylib parser.o) && \
34-
mv "$TARGET_DIR"/lib"$LIBRARY_NAME".dylib "$GRAMMAR_DIR"/ \
35-
|| exit
31+
rm -f "$TARGET_DIR"/lib"$LIBRARY_NAME".* "$GRAMMAR_DIR"/lib"$LIBRARY_NAME".*
3632

3733
# Linux and Windows compilation using Docker
38-
BUILDKIT_PROGRESS=plain docker build -t "$LIBRARY_NAME"-builder --build-arg LIBRARY_NAME="$LIBRARY_NAME" . || exit
34+
BUILDKIT_PROGRESS=plain docker buildx build --platform linux/amd64 \
35+
-t "$LIBRARY_NAME"-builder --build-arg LIBRARY_NAME="$LIBRARY_NAME" --load . || exit
3936
container_id=$(docker create "$LIBRARY_NAME"-builder) || exit
4037
# Copy both Linux and Windows libraries from the single container
4138
docker cp "$container_id:/out/lib/lib${LIBRARY_NAME}.so" "$GRAMMAR_DIR/" && \
4239
docker cp "$container_id:/out/lib/lib${LIBRARY_NAME}.dll" "$GRAMMAR_DIR/" && \
4340
docker rm "$container_id" > /dev/null || exit
4441

42+
# MacOS compilation
43+
if test "$(uname)" = Darwin; then
44+
echo "MacOS compilation..."
45+
(cd "$TARGET_DIR" && cc -c -I./src src/parser.c && cc -dynamiclib -o lib"$LIBRARY_NAME".dylib parser.o) && \
46+
mv "$TARGET_DIR"/lib"$LIBRARY_NAME".dylib "$GRAMMAR_DIR"/ \
47+
|| exit
48+
fi
49+
4550
ls -Falk "$GRAMMAR_DIR"/*.{so,dylib,dll}
4651
du -hs "$GRAMMAR_DIR"/*.{so,dylib,dll}
4752

0 commit comments

Comments
 (0)