Skip to content
This repository was archived by the owner on Nov 5, 2024. It is now read-only.

Commit 1973e4e

Browse files
authored
Merge pull request #8 from lib-ruby-parser/add-aarch64-apple-darwin-target
2 parents 152c04c + f9cbdee commit 1973e4e

File tree

8 files changed

+72
-2
lines changed

8 files changed

+72
-2
lines changed

.github/workflows/test.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,33 @@ jobs:
3131
target: x86_64-unknown-linux-gnu
3232
cc: clang-12
3333
ar: llvm-ar-12
34+
zig: false
3435
run: make tests/run
3536

3637
- name: test on mac (clang)
3738
os: macos-latest
3839
target: x86_64-apple-darwin
3940
cc: clang
4041
ar: ar
42+
zig: false
4143
run: |
4244
$CC --version
4345
make tests/run
4446
47+
- name: build for mac m1 (zig)
48+
os: macos-latest
49+
target: aarch64-apple-darwin
50+
cc: zig cc
51+
ar: ar
52+
zig: true
53+
run: |
54+
make libruby_parser_c.a
55+
4556
- name: test on windows (msvc)
4657
os: windows-latest
4758
target: x86_64-pc-windows-msvc
4859
cc: cl.exe
60+
zig: false
4961
run: |
5062
make tests/run
5163
@@ -54,6 +66,7 @@ jobs:
5466
target: x86_64-pc-windows-gnu
5567
cc: gcc
5668
ar: ar
69+
zig: false
5770
run: |
5871
gcc --version
5972
make tests/run
@@ -63,6 +76,7 @@ jobs:
6376
target: x86_64-unknown-linux-gnu
6477
cc: clang-12
6578
ar: llvm-ar-12
79+
zig: false
6680
run: |
6781
sudo apt-get update
6882
sudo apt-get install -y valgrind libtool-bin
@@ -74,6 +88,7 @@ jobs:
7488
target: x86_64-unknown-linux-gnu
7589
cc: clang-12
7690
ar: llvm-ar-12
91+
zig: false
7792
run: ASAN_OPTIONS=detect_leaks=1 CFLAGS="-fsanitize=address" make tests/run
7893

7994
steps:
@@ -104,6 +119,14 @@ jobs:
104119
if: runner.os == 'Windows'
105120
run: rm "C:\\Program Files\\Git\\usr\\bin\\link.exe"
106121

122+
- name: install zig
123+
uses: goto-bus-stop/setup-zig@v2
124+
if: ${{ matrix.build.zig }}
125+
126+
- name: install cargo-zigbuild
127+
run: cargo install cargo-zigbuild
128+
if: ${{ matrix.build.zig }}
129+
107130
- name: codegen
108131
run: make do-codegen
109132

codegen/build.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ endef
44

55
CODEGEN_EXE = codegen/codegen$(EXE)
66
$(CODEGEN_EXE):
7-
$(call download_file, https://github.com/lib-ruby-parser/lib-ruby-parser/releases/download/v4.0.2+ruby-3.1.1/codegen-$(TARGET)$(EXE), $@)
7+
$(call download_file, https://github.com/lib-ruby-parser/lib-ruby-parser/releases/download/v4.0.2+ruby-3.1.1/$(CODEGEN_ASSET_NAME), $@)
88
chmod +x $(CODEGEN_EXE)
99
CLEAN += $(CODEGEN_EXE)
1010

ruby-parser-c/build.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ RUST_SRCS += ruby-parser-c/src/node.rs
33
RUST_SRCS += ruby-parser-c/src/message.rs
44

55
ruby-parser-c/lib_ruby_parser_c.$(A): $(RUST_SRCS)
6-
RUSTFLAGS="$(RUSTFLAGS)" cargo build $(CARGOFLAGS) --manifest-path ruby-parser-c/Cargo.toml
6+
RUSTFLAGS="$(RUSTFLAGS)" $(CARGO_BUILD) $(CARGOFLAGS) --manifest-path ruby-parser-c/Cargo.toml
77
ls -l ruby-parser-c/target/$(TARGET)
88
ls -l ruby-parser-c/target/$(TARGET)/$(RUST_ENV)
99
cp ruby-parser-c/target/$(TARGET)/$(RUST_ENV)/$(STATIC_LIB_FILE) ruby-parser-c/lib_ruby_parser_c.$(A)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
$(info Compiling aarch64-apple-darwin target)
2+
3+
O = o
4+
A = a
5+
EXE =
6+
7+
STATIC_LIB_FILE = libruby_parser_c.$(A)
8+
LIST_DEPS = otool -L
9+
CARGO_BUILD = cargo zigbuild
10+
11+
CFLAGS += -Wall -Wextra -Wpedantic -Weverything -Wdocumentation -g
12+
# but disable -Wpadded, we inherit Rust layouts
13+
CFLAGS += -Wno-padded
14+
# ignore documentation, it has examples of syntax errors on purpose
15+
CFLAGS += -Wno-documentation-unknown-command
16+
# we do mix Rust extern C declarations and C tests
17+
CFLAGS += -Wno-declaration-after-statement
18+
19+
ifeq ($(BUILD_ENV), debug)
20+
CFLAGS += -O0 -DTEST_ENV
21+
else
22+
CFLAGS += -O3
23+
endif
24+
25+
define add_to_lib
26+
$(AR) r $(1) $(2)
27+
endef
28+
29+
define build_c_obj
30+
$(CC) $(1) $(CFLAGS) -c -o $(2)
31+
endef
32+
33+
define build_c_exe
34+
$(CC) $(1) $(CFLAGS) -o $(2)
35+
endef
36+
37+
BENCHMARK_RUNNER_ASSET_NAME = rust-parser-aarch64-apple-darwin
38+
CODEGEN_ASSET_NAME = codegen-x86_64-apple-darwin
39+

scripts/targets/x86_64-apple-darwin.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ EXE =
66

77
STATIC_LIB_FILE = libruby_parser_c.$(A)
88
LIST_DEPS = otool -L
9+
CARGO_BUILD = cargo build
910

1011
CFLAGS += -Wall -Wextra -Wpedantic -Weverything -Wdocumentation -g
1112
# but disable -Wpadded, we inherit Rust layouts
@@ -34,3 +35,4 @@ $(CC) $(1) $(CFLAGS) -o $(2)
3435
endef
3536

3637
BENCHMARK_RUNNER_ASSET_NAME = rust-parser-x86_64-apple-darwin
38+
CODEGEN_ASSET_NAME = codegen-x86_64-apple-darwin

scripts/targets/x86_64-pc-windows-gnu.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ EXE = .exe
66

77
STATIC_LIB_FILE = libruby_parser_c.$(A)
88
LIST_DEPS = ldd
9+
CARGO_BUILD = cargo build
910

1011
CFLAGS += -Wall -Wextra -g
1112
# mingw uses a different allocator from Rust?
@@ -31,3 +32,4 @@ $(CC) $(1) $(CFLAGS) -lws2_32 -luserenv -lbcrypt -o $(2)
3132
endef
3233

3334
BENCHMARK_RUNNER_ASSET_NAME = rust-parser-x86_64-pc-windows-gnu.exe
35+
CODEGEN_ASSET_NAME = codegen-x86_64-pc-windows-msvc.exe

scripts/targets/x86_64-pc-windows-msvc.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ EXE = .exe
66

77
STATIC_LIB_FILE = ruby_parser_c.$(A)
88
LIST_DEPS = dumpbin /dependents
9+
CARGO_BUILD = cargo build
910

1011
# /nologo
1112
CFLAGS += /bigobj /MT /Zi
@@ -29,3 +30,4 @@ $(CC) $(CFLAGS) ws2_32.lib advapi32.lib userenv.lib bcrypt.lib $(1) /link /OUT:$
2930
endef
3031

3132
BENCHMARK_RUNNER_ASSET_NAME = rust-parser-x86_64-pc-windows-msvc.exe
33+
CODEGEN_ASSET_NAME = codegen-x86_64-pc-windows-msvc.exe

scripts/targets/x86_64-unknown-linux-gnu.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ EXE =
66

77
STATIC_LIB_FILE = libruby_parser_c.$(A)
88
LIST_DEPS = ldd
9+
CARGO_BUILD = cargo build
910

1011
CFLAGS += -Wall -Wextra -g -target $(TARGET)
1112

@@ -28,3 +29,4 @@ $(CC) $(1) $(CFLAGS) -lpthread -ldl -lm -o $(2)
2829
endef
2930

3031
BENCHMARK_RUNNER_ASSET_NAME = rust-parser-x86_64-unknown-linux-gnu
32+
CODEGEN_ASSET_NAME = codegen-x86_64-unknown-linux-gnu

0 commit comments

Comments
 (0)