-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
60 lines (46 loc) · 1.72 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
.PHONY: debug release zip test check-env clean
# -----------------------------------------------------------------------------
# CONSTANTS
# -----------------------------------------------------------------------------
version = $(shell cat Cargo.toml | grep "^version = \"" | sed -n 's/^.*version = "\(.*\)".*/\1/p' | xargs)
build_dir = build
target_dir = target
factotum_dir = .factotum
compiled_dir = $(build_dir)/compiled
# -----------------------------------------------------------------------------
# BUILDING
# -----------------------------------------------------------------------------
debug:
cargo build --verbose
release:
cargo build --verbose --release
zip: release check-env
ifeq ($(version),$(BUILD_VERSION))
mkdir -p $(compiled_dir)
(cd target/release && zip -r staging.zip factotum-server)
mv target/release/staging.zip $(compiled_dir)/factotum_server_$(version)_$(PLATFORM)_x86_64.zip
else
$(error BUILD_VERSION and Cargo.toml version do not match - cannot release)
endif
# -----------------------------------------------------------------------------
# TESTING
# -----------------------------------------------------------------------------
test:
cargo test --verbose
# -----------------------------------------------------------------------------
# HELPERS
# -----------------------------------------------------------------------------
check-env:
ifndef PLATFORM
$(error PLATFORM is undefined)
endif
ifndef BUILD_VERSION
$(error BUILD_VERSION is undefined)
endif
# -----------------------------------------------------------------------------
# CLEANUP
# -----------------------------------------------------------------------------
clean:
rm -rf $(build_dir)
rm -rf $(target_dir)
rm -rf $(factotum_dir)