Skip to content

Commit 4c195b6

Browse files
committed
Use llvm clang tools on macOS and explicitly install it on Linux
1 parent 7b02b99 commit 4c195b6

File tree

4 files changed

+19
-21
lines changed

4 files changed

+19
-21
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- uses: actions/checkout@v4
1212

1313
- name: Install dependencies
14-
run: sudo apt-get install check
14+
run: sudo apt-get install check clang-19
1515

1616
- name: make
1717
run: make
@@ -44,10 +44,10 @@ jobs:
4444
- uses: actions/checkout@v4
4545

4646
- name: Install clang-tidy
47-
run: sudo apt-get install -y clang-tidy
47+
run: sudo apt-get install -y clang-tidy-19
4848

4949
- name: clang-tidy version
50-
run: clang-tidy --version
50+
run: clang-tidy-19 --version
5151

5252
- name: Tidy
5353
run: bin/tidy

Brewfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
brew "check"
2-
brew "clang-format"
3-
brew "llvm" # for clang and clang-tidy
2+
brew "llvm@19" # for clang, clang-format and clang-tidy

Makefile

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,44 +22,43 @@ ruby_extension = ext/erbx/$(lib_name)
2222

2323
os := $(shell uname -s)
2424

25-
flags = -g -Wall -fPIC
25+
flags = -std=c17 -g -Wall -fPIC
2626

2727
ifeq ($(os),Linux)
2828
test_cflags = $(flags) -I/usr/include/check
2929
test_ldflags = -L/usr/lib/x86_64-linux-gnu -lcheck -lm -lsubunit
30-
llvm_path = TODO
31-
cc = clang
30+
cc = clang-19
3231
clang_format = clang-format-19
33-
clang_tidy = clang-tidy
32+
clang_tidy = clang-tidy-19
3433
endif
3534

3635
ifeq ($(os),Darwin)
3736
brew_prefix := $(shell brew --prefix check)
3837
test_cflags = $(flags) -I$(brew_prefix)/include
3938
test_ldflags = -L$(brew_prefix)/lib -lcheck -lm
40-
llvm_path = /opt/homebrew/opt/llvm
39+
llvm_path = $(shell brew --prefix llvm@19)
4140
cc = $(llvm_path)/bin/clang
42-
clang_format = clang-format
41+
clang_format = $(llvm_path)/bin/clang-format
4342
clang_tidy = $(llvm_path)/bin/clang-tidy
4443
endif
4544

4645
all: $(exec) $(lib_name) test
4746

4847
$(exec): $(objects)
49-
gcc $(objects) $(flags) -o $(exec)
48+
$(cc) $(objects) $(flags) -o $(exec)
5049

5150
$(lib_name): $(objects)
52-
gcc -shared $(objects) $(flags) -o $(lib_name)
51+
$(cc) -shared $(objects) $(flags) -o $(lib_name)
5352
# cp $(lib_name) $(ruby_extension)
5453

5554
%.o: %.c include/%.h
56-
gcc -c $(flags) $< -o $@
55+
$(cc) -c $(flags) $< -o $@
5756

5857
test/%.o: test/%.c
59-
gcc -c $(test_cflags) $< -o $@
58+
$(cc) -c $(test_cflags) $< -o $@
6059

6160
test: $(test_objects) $(non_main_objects)
62-
gcc $(test_objects) $(non_main_objects) $(test_cflags) $(test_ldflags) -o $(test_exec)
61+
$(cc) $(test_objects) $(non_main_objects) $(test_cflags) $(test_ldflags) -o $(test_exec)
6362

6463
clean:
6564
rm -f $(exec) $(test_exec) $(lib_name) $(ruby_extension)

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ This project builds the ERBX program and its associated unit tests using a Makef
88

99
### Requirements
1010

11-
- **GCC**
1211
- **Check**: The project uses the [Check](https://libcheck.github.io/check/) library for unit testing.
13-
- **Clang Format**: The project uses [Clang Format](https://clang.llvm.org/docs/ClangFormat.html) for formatting.
14-
- **Clang Tidy**: The project uses [Clang Format](https://clang.llvm.org/docs/ClangFormat.html) for formatting.
12+
- **Clang 19**: For compiling the project.
13+
- **Clang Format 19**: The project uses [Clang Format](https://clang.llvm.org/docs/ClangFormat.html) for formatting.
14+
- **Clang Tidy 19**: The project uses [Clang Format](https://clang.llvm.org/docs/ClangFormat.html) for formatting.
1515

1616
For Linux:
1717
```bash
18-
sudo apt-get install check clang-format-19 clang-tidy
18+
sudo apt-get install check clang-19 clang-tidy-19 clang-format-19
1919
```
2020

2121
For macOS (using Homebrew):
2222
```bash
23-
brew install check clang-format llvm
23+
brew install check llvm@19
2424
# or
2525
brew bundle
2626
```

0 commit comments

Comments
 (0)