-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
99 lines (83 loc) · 2.49 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
CARGO = cargo
CLANG_FORMAT = clang-format
CMAKE = cmake
DEBCHANGE = debchange
DEBUILD = debuild
GIT = git
NINJA = ninja
QMAKE = qmake
BUILD_DIR = target/build
BUILD_TYPE = Debug
DESTDIR =
PREFIX = /usr/local
CARGO_BUILD_FLAGS =
CMAKE_FLAGS =
DEB_VERSION = 0.1~$(shell date +"%Y%m%d").git$(shell git rev-parse --short HEAD)
QT_VERSION_MAJOR = $(word 1,$(subst ., ,$(shell $(QMAKE) -query QT_VERSION)))
ifeq ($(BUILD_TYPE),Release)
override CARGO_BUILD_FLAGS += --release
endif
ifneq ($(shell command -v $(NINJA) 2>/dev/null),)
CMAKE_FLAGS += -GNinja
endif
ifeq ($(QT_VERSION_MAJOR),6)
CMAKE_FLAGS += -DUSE_QT6=ON
endif
.PHONY: help
help:
@echo 'Make targets:'
@echo ' local - build and install for in-place usage'
@echo ' release - build release binaries'
@echo ' install - install binaries'
@echo ' deb - build debian package'
@echo ' clean - remove build directory'
@echo ' format - run code formatter'
@echo ' tests - run linter and automated tests'
@echo ' build-examples - generate .ui from example .qml files and build them'
@echo
@echo 'Make variables:'
@echo ' BUILD_TYPE=$(BUILD_TYPE)'
@echo ' CARGO_BUILD_FLAGS=$(CARGO_BUILD_FLAGS)'
@echo ' CMAKE_FLAGS=$(CMAKE_FLAGS)'
@echo ' QT_VERSION_MAJOR=$(QT_VERSION_MAJOR)'
.PHONY: local
local:
$(MAKE) build install PREFIX=$(CURDIR)/target/local
.PHONY: release
release:
$(MAKE) build BUILD_TYPE=Release
.PHONY: build
build:
mkdir -p $(BUILD_DIR)
$(CARGO) build $(CARGO_BUILD_FLAGS) --workspace
cd $(BUILD_DIR) && $(CMAKE) -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) \
-DCMAKE_INSTALL_PREFIX=$(PREFIX) $(CMAKE_FLAGS) $(CURDIR)
$(CMAKE) --build $(BUILD_DIR) --config $(BUILD_TYPE)
.PHONY: install
install:
$(CMAKE) --install $(BUILD_DIR)
.PHONY: deb
deb:
$(RM) -R debian
cp -pR contrib/debian debian
$(DEBCHANGE) --create --package qmluic -v "$(DEB_VERSION)" "New snapshot build."
$(DEBUILD) -uc -us --build=binary
.PHONY: clean
clean:
$(CARGO) clean
.PHONY: format
format:
$(CARGO) fmt --all
find examples uiviewer -type f \( -name '*.cpp' -o -name '*.h' \) -print0 \
| xargs -0 $(CLANG_FORMAT) -i
.PHONY: tests
tests:
$(CARGO) clippy
$(CARGO) test $(CARGO_BUILD_FLAGS) --workspace
.PHONY: build-examples
build-examples: BUILD_DIR = target/build-examples
build-examples: export PATH := $(CURDIR)/target/local/bin:$(PATH)
build-examples:
mkdir -p $(BUILD_DIR)
cd $(BUILD_DIR) && $(CMAKE) -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) $(CMAKE_FLAGS) $(CURDIR)/examples
$(CMAKE) --build $(BUILD_DIR) --config $(BUILD_TYPE)