Skip to content

Commit 678b957

Browse files
authored
Merge pull request #16 from jay-tux/clang
Clang support
2 parents 90609b7 + 7cc8281 commit 678b957

14 files changed

+117
-468
lines changed

.github/workflows/c-cpp.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
steps:
1515
- name: update
1616
if: ${{ env.ACT }}
17-
run: sudo apt update && sudo apt install python3 && sudo apt install cmake
17+
run: sudo apt -y update && sudo apt -y install python3 && sudo apt -y install cmake
1818
- name: Install pip3
1919
if: ${{ env.ACT }}
2020
run: curl https://bootstrap.pypa.io/get-pip.py >get-pip.py && python3 get-pip.py

.github/workflows/cpp-clang.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: C/C++ CI (Clang)
2+
3+
on:
4+
push:
5+
branches: [ root ]
6+
pull_request:
7+
branches: [ root ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-22.04
13+
14+
steps:
15+
- name: Update
16+
# if: ${{ env.ACT }}
17+
run: sudo apt -y update && sudo apt -y install python3 clang cmake
18+
- name: Install libc++
19+
run: sudo apt -y install libc++-14-dev libc++abi-14-dev
20+
- name: Install pip3
21+
# if: ${{ env.ACT }}
22+
run: curl https://bootstrap.pypa.io/get-pip.py >get-pip.py && python3 get-pip.py
23+
- name: Install Conan
24+
id: conan
25+
uses: turtlebrowser/get-conan@main
26+
- name: Conan version
27+
run: echo "${{ steps.conan.outputs.version }}"
28+
- uses: actions/checkout@v2
29+
- name: make test (clang)
30+
run: make test-clang
31+
32+
# Note: the steps with `if: ${{ env.ACT }}` are for local setup only.

Makefile

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,28 @@ HTMLDIR=$(abspath ./cov/)
1010
BROWSER=firefox
1111

1212
CC=g++
13+
CONAN_CC=gcc
1314
CXXARGS=-I$(abspath ./inc) -g -c -std=c++20 -MMD -fprofile-arcs -ftest-coverage
1415
LDARGS=-fprofile-arcs -ftest-coverage
1516

1617
all:
1718
@echo "Please choose a target:"
18-
@echo " -> make install: installs the headers under $(INSTALL_DIR)"
19-
@echo " -> make uninstall: uninstalls the headers if they are under $(INSTALL_DIR)"
20-
@echo " -> make docs: generates the documentation using doxygen under $(DOC_DIR)"
21-
@echo " -> make test: builds and runs the tests in $(BUILD_DIR) and $(BIN_DIR) from $(TEST_DIR)"
22-
@echo " -> make clean: cleans up test builds and documentation (from $(BUILD_DIR), $(BIN_DIR), $(DOC_DIR))"
23-
@echo " -> make coverage: builds and runs the tests, then generates a coverage report in $(HTMLDIR) and opens it in $(BROWSER)"
19+
@echo " -> make install: installs the headers under $(INSTALL_DIR)"
20+
@echo " -> make uninstall: uninstalls the headers if they are under $(INSTALL_DIR)"
21+
@echo " -> make docs: generates the documentation using doxygen under $(DOC_DIR)"
22+
@echo " -> make test: builds and runs the tests in $(BUILD_DIR) and $(BIN_DIR) from $(TEST_DIR)"
23+
@echo " -> make test-clang: builds and runs the tests in $(BUILD_DIR) and $(BIN_DIR) from $(TEST_DIR) (using clang++)"
24+
@echo " -> make clean: cleans up test builds and documentation (from $(BUILD_DIR), $(BIN_DIR), $(DOC_DIR))"
25+
@echo " -> make coverage: builds and runs the tests, then generates a coverage report in $(HTMLDIR) and opens it in $(BROWSER)"
2426
@echo ""
2527
@echo "Some targets accept additional arguments in the form of KEY=VALUE pairs:"
2628
@echo " -> CC (for test and coverage): sets the command for the C++ compiler (g++ by default)"
29+
@echo " -> CONAN_CC (for test and coverage): sets the conan compiler name (gcc by default)"
2730
@echo " -> CXXARGS (for test and coverage): current arguments to the compiler - not recommended to change"
2831
@echo " -> EXTRA_CXX (for test and coverage): additional compilation flags/arguments"
2932
@echo " -> LDARGS (for test and coverage): current arguments to the linker - not recommended to change"
3033
@echo " -> EXTRA_LD (for test and coverage): additional linker flags/arguments"
34+
@echo " -> EXTRA_CONAN (for test and coverage): additional arguments for conan"
3135
@echo " -> BUILD_DIR (for test and coverage): build directory"
3236
@echo " -> BIN_DIR (for test and coverage): binary directory"
3337
@echo " -> TEST_DIR (for test and coverage): test sources directory"
@@ -55,14 +59,17 @@ docs:
5559
$(BROWSER) $(DOC_DIR)/html/index.html
5660

5761
test:
58-
make CC="$(CC)" OBJD="$(BUILD_DIR)" BIND="$(BIN_DIR)" SRCD="$(TEST_DIR)" CXXARGS="$(CXXARGS) $(EXTRA_CXX) -I$(INCL_PATH)" LDARGS="$(LDARGS) $(EXTRA_LD)" -C $(TEST_DIR)/..
62+
make CC="$(CC)" CONAN_CC="$(CONAN_CC)" CONARGS="$(EXTRA_CONAN)" OBJD="$(BUILD_DIR)" BIND="$(BIN_DIR)" SRCD="$(TEST_DIR)" CXXARGS="$(CXXARGS) $(EXTRA_CXX) -I$(INCL_PATH)" LDARGS="$(LDARGS) $(EXTRA_LD)" -C $(TEST_DIR)/..
63+
64+
test-clang:
65+
make CC="clang++" CONAN_CC="clang" CONARGS="$(EXTRA_CONAN) -s compiler.libcxx=libc++" OBJD="$(BUILD_DIR)" BIND="$(BIN_DIR)" SRCD="$(TEST_DIR)" CXXARGS="$(CXXARGS) $(EXTRA_CXX) -I$(INCL_PATH) -stdlib=libc++" LDARGS="$(LDARGS) $(EXTRA_LD) -stdlib=libc++" -C $(TEST_DIR)/..
5966

6067
clean:
6168
rm -rf $(DOC_DIR)/*
6269
cd $(TEST_DIR)/.. && make clean OBJD="$(BUILD_DIR)" BIND="$(BIN_DIR)" SRCD="$(TEST_DIR)"
6370

6471
coverage:
65-
make CC="$(CC)" OBJD="$(BUILD_DIR)" BIND="$(BIN_DIR)" SRCD="$(TEST_DIR)" CXXARGS="$(CXXARGS) $(EXTRA_CXX) -I$(INCL_PATH)" LDARGS="$(LDARGS) $(EXTRA_LD)" -C $(TEST_DIR)/..
72+
make CC="$(CC)" CONAN_CC="$(CONAN_CC)" OBJD="$(BUILD_DIR)" BIND="$(BIN_DIR)" SRCD="$(TEST_DIR)" CXXARGS="$(CXXARGS) $(EXTRA_CXX) -I$(INCL_PATH)" LDARGS="$(LDARGS) $(EXTRA_LD)" -C $(TEST_DIR)/..
6673
lcov --directory "$(BUILD_DIR)" --output-file coverage.info -c --exclude '*gmock' --exclude '*doctest*' --exclude '/usr/*'
6774
genhtml coverage.info --output-directory "$(HTMLDIR)"
6875
$(BROWSER) $(HTMLDIR)/index.html

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,12 @@ The build system for fpgen is GNU make. The following targets are available:
3333
`uninstall` | uninstalls the headers
3434
`docs` | generates the documentation using doxygen
3535
`test` | builds and runs the tests
36+
`test-clang` | builds and runs the tests using `clang++`*
3637
`clean` | cleans up test builds and documentation
3738
`coverage` | builds and runs the tests, then generates a coverage report
3839

40+
*: clang requires `-stdlib=libc++` for both compilation and linking.
41+
3942
Some targets provide parameters you can overload:
4043

4144
Parameter name | Usage | Default value | Applicable targets

0 commit comments

Comments
 (0)