File tree Expand file tree Collapse file tree 3 files changed +19
-7
lines changed Expand file tree Collapse file tree 3 files changed +19
-7
lines changed Original file line number Diff line number Diff line change 1- FROM --platform=linux/amd64 debian:12-slim
1+ FROM debian:12-slim
22
33ARG LIBRARY_NAME=tree-sitter-cedarscript
44
55# Install necessary dependencies
66RUN apt-get update && apt-get >/dev/null install -y \
7- build-essential git curl mingw-w64 \
7+ build-essential git curl mingw-w64 gcc-x86-64-linux-gnu \
88 && rm -rf /var/lib/apt/lists/*
99
1010# Install Node.js and npm
@@ -23,8 +23,13 @@ COPY grammar.js .
2323
2424# Generate and build the parser
2525RUN tree-sitter generate -l -b && mkdir lib && \
26- cc -c -I./src src/parser.c && \
27- cc -shared -o lib/lib$LIBRARY_NAME.so parser.o && \
26+ # AMD64 Linux build
27+ x86_64-linux-gnu-gcc -c -I./src src/parser.c -o parser_amd64.o && \
28+ x86_64-linux-gnu-gcc -shared -o lib/lib$LIBRARY_NAME.amd64.so parser_amd64.o && \
29+ # ARM64 Linux build
30+ gcc -c -I./src src/parser.c -o parser_arm64.o && \
31+ gcc -shared -o lib/lib$LIBRARY_NAME.arm64.so parser_arm64.o && \
32+ # Windows build
2833 x86_64-w64-mingw32-gcc -c -I./src src/parser.c && \
2934 x86_64-w64-mingw32-gcc -shared -o lib/lib$LIBRARY_NAME.dll parser.o && \
3035 apt-get >/dev/null purge 2>&1 -y --auto-remove build-essential git curl \
Original file line number Diff line number Diff line change @@ -43,11 +43,12 @@ ts test || { playground; exit 1 ;}
4343rm -f " $TARGET_DIR " /lib" $LIBRARY_NAME " .* " $GRAMMAR_DIR " /lib" $LIBRARY_NAME " .*
4444
4545# Linux and Windows compilation using Docker
46- BUILDKIT_PROGRESS=plain docker buildx build --platform linux/amd64 \
46+ BUILDKIT_PROGRESS=plain docker buildx build \
4747-t " $LIBRARY_NAME " -builder --build-arg LIBRARY_NAME=" $LIBRARY_NAME " --load . || exit
4848container_id=$( docker create " $LIBRARY_NAME " -builder) || exit
4949# Copy both Linux and Windows libraries from the single container
50- docker cp " $container_id :/out/lib/lib${LIBRARY_NAME} .so" " $GRAMMAR_DIR /" && \
50+ docker cp " $container_id :/out/lib/lib${LIBRARY_NAME} .amd64.so" " $GRAMMAR_DIR /" && \
51+ docker cp " $container_id :/out/lib/lib${LIBRARY_NAME} .arm64.so" " $GRAMMAR_DIR /" && \
5152docker cp " $container_id :/out/lib/lib${LIBRARY_NAME} .dll" " $GRAMMAR_DIR /" && \
5253docker rm " $container_id " > /dev/null || exit
5354
Original file line number Diff line number Diff line change @@ -30,7 +30,13 @@ def language() -> Language:
3030 case x if x .startswith ('darwin' ):
3131 libext = 'dylib'
3232 case x if x .startswith ('linux' ):
33- libext = 'so'
33+ arch = platform .machine ().lower ()
34+ if arch == 'x86_64' :
35+ libext = 'amd64.so'
36+ elif arch in ('aarch64' , 'arm64' ):
37+ libext = 'arm64.so'
38+ else :
39+ raise OSError (f"Unsupported Linux architecture: { arch } " )
3440 case x if x .startswith ('win' ):
3541 libext = 'dll'
3642 case _ as invalid :
You can’t perform that action at this time.
0 commit comments