-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
138 lines (120 loc) · 4.95 KB
/
Copy pathMakefile
File metadata and controls
138 lines (120 loc) · 4.95 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
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
126
127
128
129
130
131
132
133
134
135
136
137
138
.PHONY: all debug release universal arm64 amd64 \
install_sdk purge_sdk check_go ndk_version clean help \
--init-conf --setup-conf
ifdef NO_CLIENT
ifdef NO_SERVER
$(error At least one of frpc/frps should be enabled)
endif
endif
SDK_DIR := $(shell grep '^sdk\.dir=.*' local.properties 2>/dev/null | sed 's/sdk\.dir=//g')
ifneq ($(SDK_DIR),)
ANDROID_HOME := $(SDK_DIR)
endif
ifndef ANDROID_HOME
$(error Android SDK not found)
endif
SED_I := sed -i
ifeq ($(shell uname -s),Darwin)
SED_I := sed -i ''
endif
SDK_MANAGER ?= $(ANDROID_HOME)/cmdline-tools/latest/bin/sdkmanager
C_SDK := $(shell grep -o "compileSdkVersion [0-9]*" app/build.gradle | sed "s/compileSdk\ =\ //")
all:
@env TERM=dumb ./gradlew assembleRelease
@mkdir -p app/release
debug:
@env TERM=dumb ./gradlew assembleDebug
release: universal arm64 amd64
universal: --init_conf --setup_conf
@$(MAKE) -- all
@mv -v app/build/outputs/apk/release/app-release-unsigned.apk app/release/
@$(MAKE) -- --init_conf
@if [ ! -s local.properties ]; then rm -f local.properties; fi
arm64: --init_conf --setup_conf
@echo 'frp.disableAmd64=true' | tee -a local.properties
@$(MAKE) -- all
@mv -v app/build/outputs/apk/release/app-release-unsigned.apk app/release/app-release-aarch64-unsigned.apk
@$(MAKE) -- --init_conf
@if [ ! -s local.properties ]; then rm -f local.properties; fi
amd64: --init_conf --setup_conf
@echo 'frp.disableArm64=true' | tee -a local.properties
@$(MAKE) -- all
@mv -v app/build/outputs/apk/release/app-release-unsigned.apk app/release/app-release-x86_64-unsigned.apk
@$(MAKE) -- --init_conf
@if [ ! -s local.properties ]; then rm -f local.properties; fi
install_sdk:
@export TERM=dumb; \
yes 2>/dev/null | $(SDK_MANAGER) --verbose --install "build-tools;$(C_SDK).0.0" "platforms;android-$(C_SDK)"; \
export C_NDK=`$(MAKE) -s -- ndk_version`; \
yes 2>/dev/null | $(SDK_MANAGER) --verbose --install "ndk;$$C_NDK"
purge_sdk:
@echo "WARNING:Removing all Android SDK components (except cmdline-tools)!"; \
echo "This may affect your other Android projects!"; \
echo "Press Control-C in 10 seconds to abort:"; \
for i in 10 9 8 7 6 5 4 3 2 1; do \
echo "$$i..."; \
sleep 1; \
done; \
echo; \
export TERM=dumb; \
yes 2>/dev/null | $(SDK_MANAGER) --verbose --uninstall `$(SDK_MANAGER) --list_installed | awk '{print $$1}' | grep -e '^[a-z]' | grep -v 'cmdline-tools'`
check_go:
@if [ -z $$GO_VERSION ]; then export GO_VERSION=`grep -o '^go\ [0-9]*\.[0-9]*.*' frp/go.mod | sed 's/go\ //g'`; fi; \
if [ `echo $$GO_VERSION | tr '.' '\n' | wc -l` -lt 3 ]; then export GO_VERSION=$$GO_VERSION.0; fi; \
export GO_INSTALLED=`env go version | grep -o 'go[0-9]*\.[0-9]*\.[0-9]*' | sed 's/go//g'`; \
echo Wanted Go $$GO_VERSION; \
echo Actual Go $$GO_INSTALLED; \
test $$GO_VERSION = $$GO_INSTALLED
ndk_version:
@export TERM=dumb; ./gradlew ndkVersion 2>&1 >/dev/null; \
./gradlew ndkVersion --quiet
clean:
@env TERM=dumb ./gradlew clean
help:
@echo "Commands:"; \
echo " Build:"; \
echo " all - Build unsigned apk(without changing configurations)"; \
echo " debug - Build debug apk"; \
echo " release - Build all unsigned release (amd64, arm64, universal)"; \
echo " universal - Build unsigned universal release"; \
echo " arm64 - Build unsigned arm64 release"; \
echo " amd64 - Build unsigned amd64 release"; \
echo ""; \
echo " Tools:"; \
echo " install_sdk - Install required SDK/NDK packages"; \
echo " purge_sdk - Remove all SDK packages except cmdline-tools (Dangerous!)"; \
echo " check_go - Check if Go version is correct"; \
echo " ndk_version - Show project NDK version"; \
echo " clean - Clean up built files"; \
echo " help - Show this help"; \
echo ""; \
echo " Env (optional):"; \
echo " GO_VERSION - Use this go version instead of that specified in go.mod"; \
echo " SDK_MANAGER - Use this sdkmanager instead of that under ANDROID_HOME"; \
echo " NO_CLIENT - Disable frpc (any value)"; \
echo " NO_SERVER - Disable frps (any value)"; \
echo " USE_PREBUILT - Use prebuilt frp binaries (any value)"
# Internal
--init_conf:
@if [ -s local.properties ]; then \
$(SED_I) '/^## This file is automatically generated by Make/d' local.properties; \
$(SED_I) '/frp.disableClient/d' local.properties; \
$(SED_I) '/frp.disableServer/d' local.properties; \
$(SED_I) '/frp.disableArm64/d' local.properties; \
$(SED_I) '/frp.disableAmd64/d' local.properties; \
$(SED_I) '/frp.usePrebuiltExecutables/d' local.properties; \
else \
echo '## This file is automatically generated by Make. DO NOT EDIT THIS' > local.properties; \
fi
--setup_conf:
ifndef USE_PREBUILT
@$(MAKE) check_go
else
@echo frp.usePrebuiltExecutables=true | tee -a local.properties
endif
ifdef NO_CLIENT
@echo frp.disableClient=true | tee -a local.properties
endif
ifdef NO_SERVER
@echo frp.disableServer=true | tee -a local.properties
endif