diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 2e21a1c..39cfcf7 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -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 diff --git a/.github/workflows/cpp-clang.yml b/.github/workflows/cpp-clang.yml new file mode 100644 index 0000000..fb5473c --- /dev/null +++ b/.github/workflows/cpp-clang.yml @@ -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. diff --git a/Makefile b/Makefile index 0187f06..90a175e 100644 --- a/Makefile +++ b/Makefile @@ -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" @@ -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 diff --git a/README.md b/README.md index fd1e736..5f1d0f5 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docs/doxygen.css b/docs/doxygen.css deleted file mode 100644 index 10a8395..0000000 --- a/docs/doxygen.css +++ /dev/null @@ -1,372 +0,0 @@ -/* From: https://github.com/awalsh128/doxygen-themes/blob/main/themes/primary_dark/doxygen.css */ -:root { - --margin-large: 1rem; - --margin-medium: 0.5rem; - --padding-large: 1rem; - --padding-medium: 0.4rem; - --padding-small: 0.2rem; - --border-radius: 0.4rem; - --header-margin: 0.5rem; -} - -a { - color: var(--bs-info); - text-decoration: none; -} - -body { - background-color: var(--bs-gray-600); -} - -h1 { - background-color: var(--bs-green); - border-radius: var(--border-radius); - font-size: xx-large; - margin-bottom: var(--header-margin); - margin-top: var(--header-margin); - padding: var(--padding-large); -} - -h2 { - background-color: var(--bs-cyan); - border-radius: var(--border-radius); - font-size: x-large; - padding: var(--padding-large); -} - -h3 { - background-color: var(--bs-gray-900); - border-radius: var(--border-radius); - padding: var(--padding-medium); -} - -img { - margin-bottom: var(--margin-large); -} - -p { - padding: 0 var(--padding-medium) 0 var(--padding-medium); -} - -/* Tree View - Hide for now. Doxygen layouts are too unruly. */ -div.ttc { - display: none; -} - -/* Page */ -.header { - background-color: var(--bs-gray-900); - background-image: var(--bs-gradient); - border-style: solid; - border-radius: var(--border-radius); - border-width: 1px; - margin-bottom: var(--margin-large); - margin-top: var(--margin-large); - padding: var(--padding-medium); - text-align: center; -} -.summary { - text-align: center; -} -.summary a { - margin-left: var(--padding-medium); -} -.title { - font-size: x-large; - padding: var(--padding-medium); -} - -.textblock { - background-color: var(--bs-gray-700); - border-style: solid; - border-width: 1px; - border-radius: var(--border-radius); - margin-bottom: var(--margin-medium); - padding: var(--padding-large); -} - -.section { - margin: 0 0 var(--margin-medium) 0; -} -.section dt { - background-color: var(--bs-blue); - border-radius: var(--border-radius) var(--border-radius) 0 0; - padding: var(--padding-medium); -} -.section td { - padding: var(--padding-small); -} -.section dd { - background-color: var(--bs-gray-600); - margin-bottom: 1px; - padding: var(--padding-medium); -} - -.memSeparator { - line-height: 1rem; -} -.separator\: { - line-height: var(--margin-small); -} - -/* Code */ -code { - white-space: pre-wrap; -} -.contents > p > code { - background-color: #000000; - display: inline-block; - padding: 1rem; - width: 100%; -} -.fragment { - background-color: #000000; - border-radius: var(--border-radius); - margin-bottom: var(--margin-medium); - padding: var(--padding-medium); -} -.comment { - color: var(--bs-gray-500); -} -.keyword { - color: var(--bs-pink); -} -.line { - color: var(--bs-cyan); - white-space: pre; -} -span.lineno { - color: var(--bs-teal); - padding-right: 1rem; -} -.preprocessor { - color: var(--bs-blue); -} - -/* Breadcrumbs & Doxygen Header */ -.navpath { - background-color: var(--bs-gray-900); - background-image: var(--bs-gradient); - padding: 0.5rem 0 0.3rem 2rem; - border-radius: 0 0 var(--border-radius) var(--border-radius); -} -.navpath ul { - display: flex; - flex-wrap: wrap; - padding: 0 0; - margin-bottom: 1rem; - list-style: none; -} -.navelem + .navelem { - padding-left: var(--padding-medium); -} -.navelem + .navelem::before { - float: left; - padding-right: var(--padding-medium); - color: #6c757d; - content: var(--bs-breadcrumb-divider, "/"); -} - -/* Class: Types & Public Member Functions */ -.memberdecls { - width: 100%; -} -.memItemLeft { - background-color: var(--bs-gray-800); - padding: var(--padding-medium); - vertical-align: middle; -} -.memItemRight { - background-color: var(--bs-gray-800); - padding: var(--padding-medium); - vertical-align: middle; -} -.mdescLeft { - background-color: var(--bs-gray-700); - padding: var(--padding-medium); - vertical-align: middle; -} -.mdescRight { - background-color: var(--bs-gray-700); - padding: var(--padding-medium); - vertical-align: middle; -} -.inherit_header { - background-color: var(--bs-gray-700); - line-height: 3rem; - padding-left: var(--padding-large); - vertical-align: middle; -} -.memTemplParams { - background-color: var(--bs-gray-700); - padding: var(--padding-medium); - vertical-align: middle; -} -.memTemplItemLeft { - background-color: var(--bs-gray-800); - padding-right: var(--padding-medium); - vertical-align: middle; -} -.memTemplItemRight { - background-color: var(--bs-gray-800); - padding-right: var(--padding-medium); - vertical-align: middle; -} - -/* Class: Member Functions */ -.memtitle { - background-color: var(--bs-orange); - border-bottom-left-radius: 0; - border-bottom-right-radius: 0; - border-style: solid solid none solid; - margin-bottom: 0; -} -.memtitle a { - color: var(--bs-yellow); -} -.memtitle a:hover { - color: var(--bs-red); - font-weight: bolder; -} -.memitem { - background-color: var(--bs-gray-700); - border-radius: 0 0 var(--border-radius) var(--border-radius); - border-style: none solid solid solid; - margin-bottom: 1rem; - padding: var(--padding-medium); -} -/* Class: Member Function - Prototype */ -.memproto { - background-color: var(--bs-gray-800); - border-radius: var(--border-radius); - margin-bottom: var(--margin-medium); - padding: var(--padding-medium); -} -.memproto td { - column-fill: auto; -} -/* Class: Member Function - Signature */ -.paramtype { - color: var(--bs-pink); - vertical-align: middle; -} -.paramname { - color: var(--bs-cyan); - vertical-align: middle; - display: inline-flex; -} -.paramname code { - /* Override code from .fragments. */ - margin: 0; - padding: 0; - line-height: 1.6rem; - vertical-align: baseline; -} -/* Class: Member Function - Components */ -.memdoc dl { - margin-bottom: var(--margin-medium); -} -/* Class: Member Function - Template Parameters */ -.tparams dt { - background-color: var(--bs-green); - border-radius: var(--border-radius) var(--border-radius) 0 0; - padding: var(--padding-medium); -} -.tparams td { - padding: var(--padding-small); -} -.tparams dd { - background-color: var(--bs-gray-600); - margin-bottom: 1px; - padding: var(--padding-small); - padding-left: var(--padding-medium); -} -/* Class: Member Function - Parameters */ -.params dt { - background-color: var(--bs-green); - border-radius: var(--border-radius) var(--border-radius) 0 0; - padding: var(--padding-medium); -} -.params td { - padding: var(--padding-small); -} -.params dd { - background-color: var(--bs-gray-600); - padding: var(--padding-small); - padding-left: var(--padding-medium); -} -table.params tr { - margin-bottom: 1px; -} - -/* Class List */ -.levels { - background-color: var(--bs-green); - padding: var(--padding-large); -} -.levels span { - font-weight: bold; - margin-left: var(--padding-medium); - margin-right: var(--padding-medium); -} -.levels span:hover { - color: var(--bs-cyan); - font-weight: bolder; -} -.directory { - background-color: var(--bs-gray-800); - background-image: var(--bs-gradient); - margin-bottom: var(--margin-large); - margin-top: var(--margin-large); -} -table.directory { - width: 100%; -} -.even { - background-color: var(--bs-gray-700); - background-image: var(--bs-gradient); -} -.entry { - padding: 0.5rem; - vertical-align: middle; -} -.arrow:hover { - color: var(--bs-cyan); - font-weight: bolder; -} -.icona { - background-color: var(--bs-green); - border-radius: 0.5rem; - color: var(--bs-black); - margin: 0.2rem 0.5rem 0.2rem 0.5rem; - padding: 0.2rem 0.5rem 0.2rem 0.5rem; -} - -/* Struct */ -.dynheader { - background-color: var(--bs-blue); - border-radius: var(--border-radius) var(--border-radius) 0 0; - font-weight: bolder; - padding: var(--padding-medium); - text-align: center; -} -.dyncontent { - background-color: var(--bs-gray-700); - background-image: var(--bs-gradient); - border-radius: 0 0 var(--border-radius) var(--border-radius); - margin-bottom: var(--margin-medium); - padding: var(--padding-medium); - text-align: center; -} - -#main-nav { - display: none; -} - -#main-menu-state { - display: none; -} - -.main-menu-btn { - display: none; -} diff --git a/docs/doxygen_footer.html b/docs/doxygen_footer.html deleted file mode 100644 index 25c8f82..0000000 --- a/docs/doxygen_footer.html +++ /dev/null @@ -1,7 +0,0 @@ - - -