Skip to content

Commit

Permalink
Add makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-rifkin committed May 19, 2024
1 parent 877359b commit ad9baa7
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
6 changes: 4 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ too much ultimately but consistency within a codebase is important.

## Local development

To build the project make a `build/` folder and run `cmake ..`, along with any cmake configurations
you desire. Then run `make -j`, `ninja test`, or `msbuild assert.sln`.
The easiest way to develop locally is to run `make build` which will handle cmake invocation and
build in `build/`. Alternatively you can manually run `cmake ..`, along with any cmake
configurations you desire in a build folder. Then run `make -j`, `ninja`, or
`msbuild libassert.sln`.

Some useful configurations:
- `-DCMAKE_BUILD_TYPE=Debug|Release|RelWithDebInfo`: Build in debug / release / etc.
Expand Down
41 changes: 41 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
default: help

# The general philosophy and functionality of this makefile is shamelessly stolen from compiler explorer

help: # with thanks to Ben Rady
@grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'

.PHONY: build
build: debug ## build in debug mode

.PHONY: debug
debug: ## build in debug mode
cmake -S . -B build -GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=On -DLIBASSERT_BUILD_TESTING=On
cmake --build build

.PHONY: release
release: ## build in release mode (with debug info)
cmake -S . -B build -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_EXPORT_COMPILE_COMMANDS=On -DLIBASSERT_BUILD_TESTING=On
cmake --build build

.PHONY: debug-msvc
debug-msvc: ## build in debug mode
cmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=On -DLIBASSERT_BUILD_TESTING=On
cmake --build build --config Debug

.PHONY: release-msvc
release-msvc: ## build in release mode (with debug info)
cmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=On -DLIBASSERT_BUILD_TESTING=On
cmake --build build --config RelWithDebInfo

.PHONY: clean
clean: ## clean
rm -rf build

.PHONY: test
test: debug ## test
cd build && ninja test

.PHONY: test-release
test-release: release ## test-release
cd build && ninja test

0 comments on commit ad9baa7

Please sign in to comment.