Skip to content

Commit

Permalink
update makefile to make it clear
Browse files Browse the repository at this point in the history
Signed-off-by: wxy407827 <[email protected]>
  • Loading branch information
wxyucs committed Dec 30, 2024
1 parent 127a482 commit fe49291
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 44 deletions.
90 changes: 46 additions & 44 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ CMAKE_INSTALL_PREFIX ?= "/usr/local/"
COMPILE_JOBS ?= 6
DEBUG_BUILD_DIR ?= "./build/"
RELEASE_BUILD_DIR ?= "./build-release/"
VSAG_CMAKE_ARGS = -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DNUM_BUILDING_JOBS=${COMPILE_JOBS} -DENABLE_TESTS=1 -DENABLE_PYBINDS=1 -G ${CMAKE_GENERATOR} -S.

VSAG_CMAKE_ARGS := -DCMAKE_EXPORT_COMPILE_COMMANDS=1
VSAG_CMAKE_ARGS := ${VSAG_CMAKE_ARGS} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DNUM_BUILDING_JOBS=${COMPILE_JOBS}
VSAG_CMAKE_ARGS := ${VSAG_CMAKE_ARGS} -DENABLE_TESTS=1 -DENABLE_PYBINDS=1 -G ${CMAKE_GENERATOR} -S.

UT_FILTER = ""
ifdef CASE
UT_FILTER = $(CASE)
Expand All @@ -22,22 +26,13 @@ help: ## Show the help.
@echo "Targets:"
@fgrep "##" Makefile | fgrep -v fgrep

# ================= development part =================
##
## ================ development ================
.PHONY: debug
debug: ## Build vsag with debug options.
cmake ${VSAG_CMAKE_ARGS} -B${DEBUG_BUILD_DIR} -DCMAKE_BUILD_TYPE=Debug -DENABLE_CCACHE=ON -DENABLE_ASAN=OFF
cmake ${VSAG_CMAKE_ARGS} -B${DEBUG_BUILD_DIR} -DCMAKE_BUILD_TYPE=Debug -DENABLE_ASAN=OFF -DENABLE_CCACHE=ON
cmake --build ${DEBUG_BUILD_DIR} --parallel ${COMPILE_JOBS}

.PHONY: fmt
fmt: ## Format codes.
find include/ -iname "*.h" -o -iname "*.cpp" | xargs clang-format -i
find src/ -iname "*.h" -o -iname "*.cpp" | xargs clang-format -i
find python_bindings/ -iname "*.h" -o -iname "*.cpp" | xargs clang-format -i
find examples/cpp/ -iname "*.h" -o -iname "*.cpp" | xargs clang-format -i
find mockimpl/ -iname "*.h" -o -iname "*.cpp" | xargs clang-format -i
find tests/ -iname "*.h" -o -iname "*.cpp" | xargs clang-format -i
find tools/ -iname "*.h" -o -iname "*.cpp" | xargs clang-format -i

.PHONY: test
test: ## Build and run unit tests.
cmake ${VSAG_CMAKE_ARGS} -B${DEBUG_BUILD_DIR} -DCMAKE_BUILD_TYPE=Debug -DENABLE_CCACHE=ON
Expand All @@ -46,21 +41,11 @@ test: ## Build and run unit tests.
./build/tests/functests -d yes ${UT_FILTER} --allow-running-no-tests ${UT_SHARD}
./build/mockimpl/tests_mockimpl -d yes ${UT_FILTER} --allow-running-no-tests ${UT_SHARD}

.PHONY: test_parallel
test_parallel: debug
@./scripts/test_parallel_bg.sh
./build/mockimpl/tests_mockimpl -d yes ${UT_FILTER} --allow-running-no-tests ${UT_SHARD}

.PHONY: asan
asan: ## Build with AddressSanitizer option.
cmake ${VSAG_CMAKE_ARGS} -B${DEBUG_BUILD_DIR} -DCMAKE_BUILD_TYPE=Debug -DENABLE_ASAN=ON -DENABLE_CCACHE=ON
cmake ${VSAG_CMAKE_ARGS} -B${DEBUG_BUILD_DIR} -DCMAKE_BUILD_TYPE=Debug -DENABLE_ASAN=ON -DENABLE_TSAN=OFF -DENABLE_CCACHE=ON
cmake --build ${DEBUG_BUILD_DIR} --parallel ${COMPILE_JOBS}

.PHONY: test_asan_parallel
test_asan_parallel: asan ## Run unit tests parallel with AddressSanitizer option.
@./scripts/test_parallel_bg.sh
./build/mockimpl/tests_mockimpl -d yes ${UT_FILTER} --allow-running-no-tests ${UT_SHARD}

.PHONY: test_asan
test_asan: asan ## Run unit tests with AddressSanitizer option.
./build/tests/unittests -d yes ${UT_FILTER} --allow-running-no-tests ${UT_SHARD}
Expand All @@ -69,7 +54,7 @@ test_asan: asan ## Run unit tests with AddressSanitizer option.

.PHONY: tsan
tsan: ## Build with ThreadSanitizer option.
cmake ${VSAG_CMAKE_ARGS} -B${DEBUG_BUILD_DIR} -DCMAKE_BUILD_TYPE=Debug -DENABLE_TSAN=ON -DENABLE_CCACHE=ON
cmake ${VSAG_CMAKE_ARGS} -B${DEBUG_BUILD_DIR} -DCMAKE_BUILD_TYPE=Debug -DENABLE_ASAN=OFF -DENABLE_TSAN=ON -DENABLE_CCACHE=ON
cmake --build ${DEBUG_BUILD_DIR} --parallel ${COMPILE_JOBS}

.PHONY: test_tsan
Expand All @@ -78,24 +63,38 @@ test_tsan: tsan ## Run unit tests with ThreadSanitizer option.
./build/tests/functests -d yes ${UT_FILTER} --allow-running-no-tests ${UT_SHARD}
./build/mockimpl/tests_mockimpl -d yes ${UT_FILTER} --allow-running-no-tests ${UT_SHARD}

.PHONY: cov # Build unit tests with code coverage enabled.
cov:
.PHONY: clean
clean: ## Clear build/ directory.
rm -rf ${DEBUG_BUILD_DIR}/*

##
## ================ integration ================
.PHONY: fmt
fmt: ## Format codes.
@./scripts/format-cpp.sh

.PHONY: cov
cov: ## Build unit tests with code coverage enabled.
cmake ${VSAG_CMAKE_ARGS} -B${DEBUG_BUILD_DIR} -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=ON -DENABLE_CCACHE=ON
cmake --build ${DEBUG_BUILD_DIR} --parallel ${COMPILE_JOBS}

.PHONY: test_cov
test_cov: cov ## Build and run unit tests with code coverage enabled.
./build/tests/unittests -d yes ${UT_FILTER} --allow-running-no-tests ${UT_SHARD}
./build/tests/functests -d yes ${UT_FILTER} --allow-running-no-tests ${UT_SHARD}
.PHONY: test_parallel
test_parallel: debug ## Run all tests parallel (used in CI).
@./scripts/test_parallel_bg.sh
./build/mockimpl/tests_mockimpl -d yes ${UT_FILTER} --allow-running-no-tests ${UT_SHARD}
bash scripts/collect_cpp_coverage.sh
genhtml --output-directory coverage/coverage/html coverage/coverage.info --ignore-errors inconsistent,inconsistent

.PHONY: clean
clean: ## Clear build/ directory.
rm -rf ${DEBUG_BUILD_DIR}/*
.PHONY: test_asan_parallel
test_asan_parallel: asan ## Run unit tests parallel with AddressSanitizer option.
@./scripts/test_parallel_bg.sh
./build/mockimpl/tests_mockimpl -d yes ${UT_FILTER} --allow-running-no-tests ${UT_SHARD}

.PHONY: test_tsan_parallel
test_tsan_parallel: tsan ## Run unit tests parallel with ThreadSanitizer option.
@./scripts/test_parallel_bg.sh
./build/mockimpl/tests_mockimpl -d yes ${UT_FILTER} --allow-running-no-tests ${UT_SHARD}

# ================= distribution part =================
##
## ================ distribution ================
.PHONY: release
release: ## Build vsag with release options.
cmake ${VSAG_CMAKE_ARGS} -B${RELEASE_BUILD_DIR} -DCMAKE_BUILD_TYPE=Release
Expand All @@ -111,15 +110,18 @@ libcxx: ## Build vsag using libc++.
cmake ${VSAG_CMAKE_ARGS} -B${RELEASE_BUILD_DIR} -DCMAKE_BUILD_TYPE=Release -DENABLE_LIBCXX=on
cmake --build ${RELEASE_BUILD_DIR} --parallel ${COMPILE_JOBS}

.PHONY: install
install: ## Build and install the release version of vsag.
cmake --install ${RELEASE_BUILD_DIR}/


PARAM1 := "-DNUM_BUILDING_JOBS=${COMPILE_JOBS} -DENABLE_PYBINDS=1 -S. -B${RELEASE_BUILD_DIR} -DCMAKE_BUILD_TYPE=Release"
PARAM2 := "--build ${RELEASE_BUILD_DIR} --parallel ${COMPILE_JOBS}"
PARAM3 := "${RELEASE_BUILD_DIR}"

.PHONY: pyvsag ## Build pyvsag wheel
pyvsag:
.PHONY: pyvsag
pyvsag: ## Build pyvsag wheel.
bash ./scripts/build_pyvsag_multiple_version.sh $(PARAM1) $(PARAM2) $(PARAM3)

.PHONY: clean-release
clean-release: ## Clear build-release/ directory.
rm -rf ${RELEASE_BUILD_DIR}/*

.PHONY: install
install: ## Build and install the release version of vsag.
cmake --install ${RELEASE_BUILD_DIR}/
9 changes: 9 additions & 0 deletions scripts/format-cpp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

find include/ -iname "*.h" -o -iname "*.cpp" | xargs clang-format -i
find src/ -iname "*.h" -o -iname "*.cpp" | xargs clang-format -i
find python_bindings/ -iname "*.h" -o -iname "*.cpp" | xargs clang-format -i
find examples/cpp/ -iname "*.h" -o -iname "*.cpp" | xargs clang-format -i
find mockimpl/ -iname "*.h" -o -iname "*.cpp" | xargs clang-format -i
find tests/ -iname "*.h" -o -iname "*.cpp" | xargs clang-format -i
find tools/ -iname "*.h" -o -iname "*.cpp" | xargs clang-format -i

0 comments on commit fe49291

Please sign in to comment.