Skip to content

Commit da842cb

Browse files
authored
Use llvm clang tools on macOS and explicitly install it on Linux (#27)
* Use `llvm` clang tools on macOS and explicitly install it on Linux * Use Aptfile and simplify GitHub Actions
1 parent 7b02b99 commit da842cb

File tree

7 files changed

+66
-78
lines changed

7 files changed

+66
-78
lines changed

.github/workflows/build.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Build
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
name: Build
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
14+
- name: Install APT dependencies
15+
run: xargs sudo apt-get install -y < Aptfile
16+
17+
- name: make
18+
run: make
19+
20+
- name: run tests
21+
run: ./run_erbx_tests
22+
23+
- name: clang-format version
24+
run: clang-format-19 --version
25+
26+
- name: Lint
27+
run: bin/lint
28+
29+
- name: clang-tidy version
30+
run: clang-tidy-19 --version
31+
32+
- name: Tidy
33+
run: bin/tidy

.github/workflows/ruby.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Ruby Tests
1+
name: Ruby
22

33
on: [push, pull_request]
44

@@ -9,8 +9,8 @@ jobs:
99
steps:
1010
- uses: actions/checkout@v4
1111

12-
- name: Install dependencies
13-
run: sudo apt-get install check
12+
- name: Install APT dependencies
13+
run: xargs sudo apt-get install -y < Aptfile
1414

1515
- name: make
1616
run: make

.github/workflows/test.yml

Lines changed: 0 additions & 53 deletions
This file was deleted.

Aptfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
check
2+
clang-19
3+
clang-format-19
4+
clang-tidy-19

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: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,39 +27,38 @@ flags = -g -Wall -fPIC
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: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,29 @@ Seamless Parsing for HTML, ERB, and more.
66

77
This project builds the ERBX program and its associated unit tests using a Makefile for automation. The Makefile provides several useful commands for compiling, running tests, and cleaning the project.
88

9-
### Requirements
9+
### Building
1010

11-
- **GCC**
12-
- **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.
11+
#### Requirements
12+
13+
- [**Check**](https://libcheck.github.io/check/): For unit testing.
14+
- [**Clang 19**](https://clang.llvm.org): The compiler used to build this project.
15+
- [**Clang Format 19**](https://clang.llvm.org/docs/ClangFormat.html): For formatting the project.
16+
- [**Clang Tidy 19**](https://clang.llvm.org/extra/clang-tidy/): For linting the project.
17+
18+
**For Linux:**
1519

16-
For Linux:
1720
```bash
18-
sudo apt-get install check clang-format-19 clang-tidy
21+
xargs sudo apt-get install < Aptfile
22+
# or
23+
sudo apt-get install check clang-19 clang-tidy-19 clang-format-19
1924
```
2025

21-
For macOS (using Homebrew):
26+
**For macOS (using Homebrew):**
27+
2228
```bash
23-
brew install check clang-format llvm
24-
# or
2529
brew bundle
30+
# or
31+
brew install check llvm@19
2632
```
2733

2834
### Commands

0 commit comments

Comments
 (0)