Skip to content

Commit

Permalink
Merge pull request #16 from jay-tux/clang
Browse files Browse the repository at this point in the history
Clang support
  • Loading branch information
jay-tux authored May 29, 2022
2 parents 90609b7 + 7cc8281 commit 678b957
Show file tree
Hide file tree
Showing 14 changed files with 117 additions and 468 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
steps:
- name: update
if: ${{ env.ACT }}
run: sudo apt update && sudo apt install python3 && sudo apt install cmake
run: sudo apt -y update && sudo apt -y install python3 && sudo apt -y install cmake
- name: Install pip3
if: ${{ env.ACT }}
run: curl https://bootstrap.pypa.io/get-pip.py >get-pip.py && python3 get-pip.py
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/cpp-clang.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: C/C++ CI (Clang)

on:
push:
branches: [ root ]
pull_request:
branches: [ root ]

jobs:
build:

runs-on: ubuntu-22.04

steps:
- name: Update
# if: ${{ env.ACT }}
run: sudo apt -y update && sudo apt -y install python3 clang cmake
- name: Install libc++
run: sudo apt -y install libc++-14-dev libc++abi-14-dev
- name: Install pip3
# if: ${{ env.ACT }}
run: curl https://bootstrap.pypa.io/get-pip.py >get-pip.py && python3 get-pip.py
- name: Install Conan
id: conan
uses: turtlebrowser/get-conan@main
- name: Conan version
run: echo "${{ steps.conan.outputs.version }}"
- uses: actions/checkout@v2
- name: make test (clang)
run: make test-clang

# Note: the steps with `if: ${{ env.ACT }}` are for local setup only.
23 changes: 15 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,28 @@ HTMLDIR=$(abspath ./cov/)
BROWSER=firefox

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

all:
@echo "Please choose a target:"
@echo " -> make install: installs the headers under $(INSTALL_DIR)"
@echo " -> make uninstall: uninstalls the headers if they are under $(INSTALL_DIR)"
@echo " -> make docs: generates the documentation using doxygen under $(DOC_DIR)"
@echo " -> make test: builds and runs the tests in $(BUILD_DIR) and $(BIN_DIR) from $(TEST_DIR)"
@echo " -> make clean: cleans up test builds and documentation (from $(BUILD_DIR), $(BIN_DIR), $(DOC_DIR))"
@echo " -> make coverage: builds and runs the tests, then generates a coverage report in $(HTMLDIR) and opens it in $(BROWSER)"
@echo " -> make install: installs the headers under $(INSTALL_DIR)"
@echo " -> make uninstall: uninstalls the headers if they are under $(INSTALL_DIR)"
@echo " -> make docs: generates the documentation using doxygen under $(DOC_DIR)"
@echo " -> make test: builds and runs the tests in $(BUILD_DIR) and $(BIN_DIR) from $(TEST_DIR)"
@echo " -> make test-clang: builds and runs the tests in $(BUILD_DIR) and $(BIN_DIR) from $(TEST_DIR) (using clang++)"
@echo " -> make clean: cleans up test builds and documentation (from $(BUILD_DIR), $(BIN_DIR), $(DOC_DIR))"
@echo " -> make coverage: builds and runs the tests, then generates a coverage report in $(HTMLDIR) and opens it in $(BROWSER)"
@echo ""
@echo "Some targets accept additional arguments in the form of KEY=VALUE pairs:"
@echo " -> CC (for test and coverage): sets the command for the C++ compiler (g++ by default)"
@echo " -> CONAN_CC (for test and coverage): sets the conan compiler name (gcc by default)"
@echo " -> CXXARGS (for test and coverage): current arguments to the compiler - not recommended to change"
@echo " -> EXTRA_CXX (for test and coverage): additional compilation flags/arguments"
@echo " -> LDARGS (for test and coverage): current arguments to the linker - not recommended to change"
@echo " -> EXTRA_LD (for test and coverage): additional linker flags/arguments"
@echo " -> EXTRA_CONAN (for test and coverage): additional arguments for conan"
@echo " -> BUILD_DIR (for test and coverage): build directory"
@echo " -> BIN_DIR (for test and coverage): binary directory"
@echo " -> TEST_DIR (for test and coverage): test sources directory"
Expand Down Expand Up @@ -55,14 +59,17 @@ docs:
$(BROWSER) $(DOC_DIR)/html/index.html

test:
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)/..
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)/..

test-clang:
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)/..

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

coverage:
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)/..
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)/..
lcov --directory "$(BUILD_DIR)" --output-file coverage.info -c --exclude '*gmock' --exclude '*doctest*' --exclude '/usr/*'
genhtml coverage.info --output-directory "$(HTMLDIR)"
$(BROWSER) $(HTMLDIR)/index.html
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ The build system for fpgen is GNU make. The following targets are available:
`uninstall` | uninstalls the headers
`docs` | generates the documentation using doxygen
`test` | builds and runs the tests
`test-clang` | builds and runs the tests using `clang++`*
`clean` | cleans up test builds and documentation
`coverage` | builds and runs the tests, then generates a coverage report

*: clang requires `-stdlib=libc++` for both compilation and linking.

Some targets provide parameters you can overload:

Parameter name | Usage | Default value | Applicable targets
Expand Down
Loading

0 comments on commit 678b957

Please sign in to comment.