~ireas/nitrokey-rs

ref: 60a3c19dff2a0410c7f199c0651dd35aff36eec6 nitrokey-rs/Makefile -rw-r--r-- 2.2 KiB
60a3c19dRobin Krahl Run clippy for all targets 5 months ago
                                                                                
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# Copyright (C) 2022 Robin Krahl <robin.krahl@ireas.org>
# SPDX-License-Identifier: CC0-1.0

# Environment {{{1

# This Makefile supports the following environment variables:
# - TOOLCHAIN: toolchain name to use or msrv to use the MSRV toolchain
# - RELEASE: enables the release profile if set to 1

# Variable definitions {{{1

MSRV := 1.40.0
TOOLCHAINS := stable $(MSRV)
BUILD_FLAGS :=
CARGO_TOOLCHAIN :=
RUSTUP_TOOLCHAIN := stable

ifeq ($(TOOLCHAIN), msrv)
override TOOLCHAIN := $(MSRV)
endif

ifdef TOOLCHAIN
CARGO_TOOLCHAIN := +$(TOOLCHAIN)
RUSTUP_TOOLCHAIN := $(TOOLCHAIN)
endif

CARGO := cargo $(CARGO_TOOLCHAIN)

ifeq ($(RELEASE), 1)
BUILD_FLAGS += --release
endif

# Basic recipes {{{1

.PHONY: all
all: lint build

.PHONY: build
build:
	$(CARGO) build $(BUILD_FLAGS) --all-targets

.PHONY: check
check:
	$(CARGO) check $(BUILD_FLAGS) --all-targets

.PHONY: lint
lint: check
	$(CARGO) fmt -- --check
	$(CARGO) clippy --all-targets -- -D warnings
	reuse lint

.PHONY: fix
fix:
	$(CARGO) fix
	$(CARGO) fmt
	$(CARGO) clippy --fix

.PHONY: clean
clean:
	$(CARGO) clean

.PHONY: clean-nitrokey-sys
clean-nitrokey-sys:
	$(CARGO) clean --package nitrokey-sys

# Test execution {{{1

.PHONY: test
test:
	$(CARGO) test

.PHONY: test-nodev
test-nodev: export NITROKEY_TEST_GROUP=nodev
test-nodev: test

.PHONY: test-librem
test-librem: export NITROKEY_TEST_GROUP=librem
test-librem: test

.PHONY: test-pro
test-pro: export NITROKEY_TEST_GROUP=pro
test-pro: test

.PHONY: test-storage
test-storage: export NITROKEY_TEST_GROUP=storage
test-storage: test

# Toolchain installation {{{1

.PHONY: install-toolchain
install-toolchain:
	rustup install $(RUSTUP_TOOLCHAIN)

.PHONY: install-all-toolchains
install-all-toolchains:
	rustup install $(TOOLCHAINS)

# CI tasks {{{1

.PHONY: ci
ci: ci-msrv ci-stable

.PHONY: ci-lint
ci-lint:
	$(MAKE) lint

.PHONY: ci-build
ci-build: export RELEASE=1
ci-build:
	$(MAKE) build
	$(MAKE) test-nodev
	$(MAKE) clean-nitrokey-sys
	USE_SYSTEM_LIBNITROKEY=1 $(MAKE) build
	USE_SYSTEM_LIBNITROKEY=1 $(MAKE) test-nodev

.PHONY: ci-msrv
ci-msrv: export TOOLCHAIN=msrv
ci-msrv:
	$(MAKE) ci-lint
	$(MAKE) ci-build

.PHONY: ci-stable
ci-stable: export TOOLCHAIN=stable
ci-stable:
	$(MAKE) ci-build