Skip to content

Commit

Permalink
coverage and optimized build seperated
Browse files Browse the repository at this point in the history
  • Loading branch information
nguy8tri committed Sep 17, 2024
1 parent 3664f72 commit b022e79
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -65,4 +70,5 @@ jobs:
with:
name: Doxygen Documentation
branch: documentation
folder: build/documentation/doxygen/html
folder: build/documentation/doxygen/html
folder-path: doxygen
18 changes: 11 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion gcovr.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b022e79

Please sign in to comment.