Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
64 lines (48 loc) · 1.94 KB
/
Copy pathMakefile
File metadata and controls
64 lines (48 loc) · 1.94 KB
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
ANDROID_HOME ?= $(firstword $(wildcard $(HOME)/Android/Sdk /opt/android-sdk $(HOME)/Library/Android/sdk))
ANDROID_NDK_HOME ?= $(lastword $(sort $(wildcard $(ANDROID_HOME)/ndk/*)))
JAVA_HOME ?= $(firstword $(wildcard \
/usr/lib/jvm/java-17-openjdk \
/usr/lib/jvm/java-17-openjdk-amd64 \
/usr/lib/jvm/default-runtime \
$(shell /usr/libexec/java_home -v 17 2>/dev/null) \
))
export JAVA_HOME
AAR_OUT := udpfs-server/libs/udpfsdbridge.aar
DEBUG_APK_DIR := udpfs-server/build/outputs/apk/debug
RELEASE_APK_DIR := udpfs-server/build/outputs/apk/release
.DELETE_ON_ERROR:
.PHONY: all aar apk apk-debug apk-release apk-abi install install-release test check lint clean check-env
all: apk-debug
check-env:
@if [ -z "$(ANDROID_HOME)" ]; then echo "Error: ANDROID_HOME not found. Export it in your environment."; exit 1; fi
@if [ -z "$(ANDROID_NDK_HOME)" ]; then echo "Error: NDK not found under $(ANDROID_HOME)/ndk."; exit 1; fi
@if [ -z "$(JAVA_HOME)" ]; then echo "Error: JDK 17 not found. Export JAVA_HOME."; exit 1; fi
test:
go test -tags nochd ./udpfsdbridge/ -count=1
lint:
./gradlew :udpfs-server:lintRelease
check:
go vet -tags nochd ./udpfsdbridge/
$(MAKE) test
$(MAKE) lint
aar: check-env
@mkdir -p udpfs-server/libs
ANDROID_HOME="$(ANDROID_HOME)" ANDROID_NDK_HOME="$(ANDROID_NDK_HOME)" \
gomobile bind -tags nochd -target=android -androidapi 23 -javapkg=com.udpfs \
-ldflags="-s -w" -o "$(AAR_OUT)" ./udpfsdbridge
apk-debug: aar
./gradlew assembleDebug
apk-release: aar
./gradlew assembleRelease
apk: apk-debug apk-release
apk-abi: aar
./gradlew assembleRelease -PabiSplits=true
@ls -la $(RELEASE_APK_DIR)/udpfs-server-*-release.apk
install: apk-debug
adb install -r "$(DEBUG_APK_DIR)/udpfs-server-debug.apk"
install-release: apk-release
adb install -r "$(RELEASE_APK_DIR)/udpfs-server-release.apk"
clean:
rm -f "$(AAR_OUT)" udpfs-server/libs/udpfsdbridge-sources.jar udpfs-server/libs/*.jar
rm -rf build
./gradlew clean