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
2
2
3
3
ARG LIBRARY_NAME=tree-sitter-cedarscript
4
4
5
5
# Install necessary dependencies
6
6
RUN 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 \
8
8
&& rm -rf /var/lib/apt/lists/*
9
9
10
10
# Install Node.js and npm
@@ -23,8 +23,13 @@ COPY grammar.js .
23
23
24
24
# Generate and build the parser
25
25
RUN 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
28
33
x86_64-w64-mingw32-gcc -c -I./src src/parser.c && \
29
34
x86_64-w64-mingw32-gcc -shared -o lib/lib$LIBRARY_NAME.dll parser.o && \
30
35
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 ;}
43
43
rm -f " $TARGET_DIR " /lib" $LIBRARY_NAME " .* " $GRAMMAR_DIR " /lib" $LIBRARY_NAME " .*
44
44
45
45
# Linux and Windows compilation using Docker
46
- BUILDKIT_PROGRESS=plain docker buildx build --platform linux/amd64 \
46
+ BUILDKIT_PROGRESS=plain docker buildx build \
47
47
-t " $LIBRARY_NAME " -builder --build-arg LIBRARY_NAME=" $LIBRARY_NAME " --load . || exit
48
48
container_id=$( docker create " $LIBRARY_NAME " -builder) || exit
49
49
# 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 /" && \
51
52
docker cp " $container_id :/out/lib/lib${LIBRARY_NAME} .dll" " $GRAMMAR_DIR /" && \
52
53
docker rm " $container_id " > /dev/null || exit
53
54
Original file line number Diff line number Diff line change @@ -30,7 +30,13 @@ def language() -> Language:
30
30
case x if x .startswith ('darwin' ):
31
31
libext = 'dylib'
32
32
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 } " )
34
40
case x if x .startswith ('win' ):
35
41
libext = 'dll'
36
42
case _ as invalid :
You can’t perform that action at this time.
0 commit comments