diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2021-03-31 19:50:23 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2021-03-31 20:04:58 +0300 |
commit | 4be94180be00950319894ccb085ed82c447fa456 (patch) | |
tree | 73d6656e431b7e55410bb61ca140dc89384de719 | |
parent | cmake: use install_pdbs() (diff) | |
download | privilege-check-4be94180be00950319894ccb085ed82c447fa456.tar.gz privilege-check-4be94180be00950319894ccb085ed82c447fa456.zip |
add `make build`, etc.
-rw-r--r-- | .github/workflows/ci.yml | 4 | ||||
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Makefile | 64 | ||||
-rw-r--r-- | README.md | 35 |
4 files changed, 75 insertions, 30 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5823c39..4f4587c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,9 +45,7 @@ jobs: platform: '${{ matrix.platform }}' if: matrix.toolset == 'mingw' - name: Build - run: | - cd cmake - python -m project.ci.cmake --install + run: make install - name: Upload binaries uses: actions/upload-artifact@v2 with: @@ -1 +1,3 @@ +/.build/ + *.aps diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6caa8ad --- /dev/null +++ b/Makefile @@ -0,0 +1,64 @@ +# Various one-liners which I'm too lazy to remember. +# Basically a collection of really small shell scripts. + +MAKEFLAGS += --warn-undefined-variables +unexport MAKEFLAGS +.DEFAULT_GOAL := all +.DELETE_ON_ERROR: +.SUFFIXES: +SHELL := bash +.SHELLFLAGS := -eu -o pipefail -c + +.PHONY: DO +DO: + +escape = $(subst ','\'',$(1)) + +define noexpand +ifeq ($$(origin $(1)),environment) + $(1) := $$(value $(1)) +endif +ifeq ($$(origin $(1)),environment override) + $(1) := $$(value $(1)) +endif +ifeq ($$(origin $(1)),command line) + override $(1) := $$(value $(1)) +endif +endef + +TOOLSET ?= mingw +CONFIGURATION ?= Debug +CMAKE_FLAGS ?= + +this_dir := $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) +src_dir := $(this_dir) +ifdef CI +build_dir := $(this_dir)../build +else +build_dir := $(this_dir).build +endif +cmake_dir := $(build_dir)/cmake +DESTDIR ?= $(build_dir)/install + +$(eval $(call noexpand,TOOLSET)) +$(eval $(call noexpand,CONFIGURATION)) +$(eval $(call noexpand,CMAKE_FLAGS)) +$(eval $(call noexpand,DESTDIR)) + +.PHONY: all +all: build + +.PHONY: clean +clean: + rm -rf -- '$(call escape,$(build_dir))' + +.PHONY: build +build: +ifdef CI + cd cmake && python3 -m project.ci.cmake --install -- $(CMAKE_FLAGS) +else + cd cmake && python3 -m project.cmake.build --toolset '$(call escape,$(TOOLSET))' --configuration '$(call escape,$(CONFIGURATION))' --build '$(call escape,$(cmake_dir))' --install '$(call escape,$(DESTDIR))' -- '$(call escape,$(src_dir))' $(CMAKE_FLAGS) +endif + +.PHONY: install +install: build @@ -15,36 +15,17 @@ Displays a window, showing If it's not "run as Administrator", a button allows to actually re-run the executable as Administrator, utilizing Windows' User Account Control feature. -Building --------- - -Create the build files using CMake and build using your native build tools -(Visual Studio/make/etc.). - -* **Example (Visual Studio).** -In the example below, the project directory is -"C:\workspace\personal\privilege-check" and Visual Studio 2015 is used, -targeting x86-64. - - > cmake -G "Visual Studio 14 2015 Win64" C:\workspace\personal\privilege-check - ... - - > cmake --build . --config release - ... +Development +----------- -* **Example (MinGW-w64).** -Another example, this time using Cygwin + MinGW-w64, targeting x86-64 -(the project directory is "/cygdrive/c/workspace/personal/privilege-check"). +Build using CMake. +The project is Windows-only, so building with either MSVC or MinGW-64 is +required. - > cmake -G "Unix Makefiles" \ - -D CMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ \ - -D CMAKE_RC_COMPILER=x86_64-w64-mingw32-windres \ - -D CMAKE_BUILD_TYPE=Release \ - /cygdrive/c/workspace/personal/privilege-test - ... +There's a Makefile with useful shortcuts to build the project in the .build/ +directory (defaults to building with MinGW-w64): - > cmake --build . -- -j - ... + make build Cross table ----------- |