From b022e798795dc5dabd875b11c36a3ecc019f74b3 Mon Sep 17 00:00:00 2001 From: Tri Nguyen Date: Mon, 16 Sep 2024 19:15:53 -0700 Subject: [PATCH] coverage and optimized build seperated --- .github/workflows/build.yml | 12 +++++++++--- Makefile | 18 +++++++++++------- gcovr.cfg | 2 +- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 050e0c3..37e3cac 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -43,13 +43,18 @@ jobs: - uses: actions/checkout@v3 - name: Coverage (Twice) run: (make coverage || make coverage) - - name: Install rsync - run: apt install -y rsync - name: Upload Coverage Report uses: actions/upload-artifact@v3 with: name: Coverage Report path: build/documentation/coverage + - name: Deploy site1 to GitHub Pages + uses: JamesIves/github-pages-deploy-action@v4 + with: + name: Coverage Report + branch: documentation + folder: build/documentation/coverage + folder-path: coverage doxygen: runs-on: ubuntu-latest @@ -65,4 +70,5 @@ jobs: with: name: Doxygen Documentation branch: documentation - folder: build/documentation/doxygen/html \ No newline at end of file + folder: build/documentation/doxygen/html + folder-path: doxygen \ No newline at end of file diff --git a/Makefile b/Makefile index 46288b3..8521cf0 100644 --- a/Makefile +++ b/Makefile @@ -47,7 +47,7 @@ TEST_FILES := $(filter-out $(CATCH_LIB)/%, $(TEST) $(TEST_H)) # Our Object source and test files SRC_OBJS := $(patsubst $(SRC_DIR)/%.cpp, $(BUILD_SRC_DIR)/%.o,$(SRC)) -TEST_OBJS := $(patsubst $(TEST_DIR)/%.cpp, $(BUILD_TEST_DIR)/%.o,$(TEST)) $(filter-out %/main.o, $(SRC_OBJS)) +TEST_OBJS := $(patsubst $(TEST_DIR)/%.cpp, $(BUILD_TEST_DIR)/%.o,$(TEST)) $(filter-out %/main.o, $(patsubst $(SRC_DIR)/%.cpp, $(BUILD_TEST_DIR)/%.o, $(SRC))) # Our pre-processed source and test code PRIVATE_SRC := $(patsubst $(SRC_DIR)/%.cpp, $(BUILD_PRIVATE_SRC_DIR)/%.i,$(SRC)) @@ -58,13 +58,14 @@ SRC_LIBS := -Isrc # Script to automatically include all folders: $(shell find $( TEST_LIBS := $(SRC_LIBS) -I. # We need to include SRC_LIBS here for the test suite to register all src/**/%.hpp files correctly, but in the test folder, we should be placing the full file path # Compiler flags -LIBS := # Nothing for now +LIBS := $(SRC_LIBS) LIBS_TEST := -I$(GTEST_DIR)/$(GTEST)/include -I$(GTEST_DIR)/googlemock/include -pthread DEBUG_FLAGS := -ggdb -fno-omit-frame-pointer COVERAGE_FLAGS := -fprofile-arcs -ftest-coverage CXXFLAGS := $(CXXFLAGS) -Ilibraries -Idocumentation -Wall -Wextra -Wno-missing-field-initializers -pedantic --std=c++11 $(LIBS) CXXFLAGS_TEST := $(CXXFLAGS) $(COVERAGE_FLAGS) $(LIBS_TEST) -LDFLAGS_TEST := -L$(GTEST_BUILD_DIR)/lib -lgtest -lgtest_main -lgmock -lgmock_main -pthread -lgcov +LDFLAGS := # Any dynamic libraries go here +LDFLAGS_TEST := $(LDFLAGS) -L$(GTEST_BUILD_DIR)/lib -lgtest -lgtest_main -lgmock -lgmock_main -pthread -lgcov # Targets COMPILE_SETUP_TARGET := compile_setup @@ -106,15 +107,14 @@ define PRINT_TARGET_HEADER printf "\n" endef -all: CXXFLAGS := $(CXXFLAGS) $(COVERAGE_FLAGS) # The default target (all) all: $(COMPILE_SETUP_TARGET) \ $(COMPILE_TARGET) \ $(GOOGLE_STYLECHECK_TARGET) \ - $(PRIVATE_TARGET) \ $(TEST_TARGET) \ $(COVERAGE_TARGET) \ $(GOOGLE_STYLECHECK_TEST_TARGET) \ + $(PRIVATE_TARGET) \ $(DOXYGEN_TARGET) \ # The build setup target (sets up appropriate directories) @@ -128,7 +128,7 @@ $(COMPILE_SETUP_TARGET): # The compile target $(COMPILE_TARGET): $(COMPILE_SETUP_TARGET) compile_message $(BIN) $(BIN): $(SRC_OBJS) $(BIN_DIR) - $(CXX) $(CXXFLAGS) -o $(BIN) $(SRC_OBJS) + $(CXX) $(CXXFLAGS) -o $(BIN) $(SRC_OBJS) $(LDFLAGS) $(BUILD_SRC_DIR)/%.o: $(SRC_DIR)/%.cpp $(BUILD_DIR) $(BIN_DIR) mkdir -p $(@D) $(CXX) $(CXXFLAGS) -c $< -o $@ $(SRC_LIBS) @@ -140,6 +140,7 @@ $(GOOGLE_STYLECHECK_TARGET): $(SRC) $(SRC_H) $(call PRINT_TARGET_HEADER, $(GOOGLE_STYLECHECK_TARGET)) cpplint $(SRC) $(SRC_H) +$(TEST_SETUP_TARGET): CXXFLAGS := $(CXXFLAGS) $(COVERAGE_FLAGS) $(TEST_SETUP_TARGET): $(COMPILE_SETUP_TARGET) test_setup_message $(BUILD_LIBRARY_TEST_DIR) $(GTEST_DIR) $(BUILD_LIBRARY_TEST_DIR): mkdir -p $(BUILD_LIBRARY_TEST_DIR) @@ -148,13 +149,16 @@ test_setup_message: $(call PRINT_TARGET_HEADER, $(TEST_SETUP_TARGET)) # The test target -$(TEST_TARGET): $(TEST_SETUP_TARGET) $(COMPILE_TARGET) test_message $(TEST_BIN) +$(TEST_TARGET): $(TEST_SETUP_TARGET) test_message $(TEST_BIN) valgrind ./$(TEST_BIN) $(TEST_BIN): $(GTEST_DIR) $(TEST_OBJS) $(BIN_DIR) $(CXX) $(CXXFLAGS_TEST) -o $(TEST_BIN) $(TEST_OBJS) $(LIBS) $(LDFLAGS_TEST) $(BUILD_TEST_DIR)/%.o: $(TEST_DIR)/%.cpp $(GTEST_DIR) $(BUILD_DIR) mkdir -p $(@D) $(CXX) $(TEST_LIBS) $(CXXFLAGS_TEST) -c $< -o $@ +$(BUILD_TEST_DIR)/%.o: $(SRC_DIR)/%.cpp $(GTEST_DIR) $(BUILD_DIR) + mkdir -p $(@D) + $(CXX) $(TEST_LIBS) $(CXXFLAGS_TEST) -c $< -o $@ $(GTEST_DIR): $(BUILD_DIR) wget $(GTEST_URL) tar -xzf $(GTEST_VERSION).tar.gz -C $(BUILD_LIBRARY_TEST_DIR) diff --git a/gcovr.cfg b/gcovr.cfg index 6766289..cacb49e 100644 --- a/gcovr.cfg +++ b/gcovr.cfg @@ -7,7 +7,7 @@ exclude = src/main.cpp # exclude = src/spatial/* # exclude = src/style/* html-details = yes -output = build/documentation/coverage/coverage.html +output = build/documentation/coverage/index.html delete-gcov-files = yes # fail-under-line = 80 # fail-under-branch = 80