forked from rkkr/simple-keyboard
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
59 lines (43 loc) · 2.03 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
mainDir=app/src/main
jniDir=$(mainDir)/jni
.PHONY: help all clean build debug release install ndk style-check cargo-check cargo-format spotlessApply style-apply cbindgen spotlessCheck
help: ## Shows this help.
awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
all: cbindgen release ## Compiles the project from scratch.
cbindgen: ## Generates the c binding header of the afrim_jni library.
echo '#include "jni.h"' > ${jniDir}/init.cc
echo '#include "./afrim_jni/bootstrap.h"' >> ${jniDir}/init.cc
( \
cd ${jniDir} && cbindgen afrim_jni | \
sed 's/^\(\w*\) \(Java\)/JNIEXPORT \1 JNICALL\n\2/' | \
sed 's/JNIEnv/&*/' | \
sed 's/);$$/) {\n\/\/ For more details about the implementation, consult the rust code.\n}/' | \
cat >> init.cc \
)
clang-format -i -style 'file' ${jniDir}/init.cc
spotlessCheck: ## Check the java code style.
./gradlew spotlessCheck
spotlessApply: ## Reformat the java code style.
./gradlew spotlessApply
cargo-format: ## Formats the rust code.
(cd ${jniDir}/afrim_jni && cargo fmt --quiet)
cargo-check: ## Checks the rust code.
(cd ${jniDir}/afrim_jni && cargo check --quiet)
(cd ${jniDir}/afrim_jni && cargo clippy --all-features --quiet -- -D warnings)
(cd ${jniDir}/afrim_jni && cargo fmt --check --quiet)
style-apply: cargo-format spotlessApply # Reformat the project source code.
style-check: cargo-check spotlessCheck # Check the project source code.
clean: ## Clean the project.
(cd ${jniDir}/afrim_jni && cargo clean)
rm -rf build app/build app/.cxx/
./gradlew clean
build: style-check ## Builds the project.
./gradlew build
release: style-check ## Compiles in release mode.
./gradlew assembleRelease
debug: style-check ## Compiles in debug mode.
./gradlew assembleDebug
install: release ## Installs the application in a connected device.
./gradlew installRelease
ndk: ## Build the project in using NDK.
(cd $(mainDir); ndk-build)