-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
171 lines (141 loc) · 3.73 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
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
ANDROID := $(ANDROID_HOME)/tools/android
ADB := $(ANDROID_HOME)/platform-tools/adb
API := android-19
ANDROIDAPIS := $(API) # Add others as required.
ANDROIDSOURCES := $(addprefix $(ANDROID_HOME)/sources/,$(ANDROIDAPIS))
PACKAGE := com.qrclab.ncouragr
MAINACTIVITY := NcouragrActivity
STARTER := $(PACKAGE)/$(PACKAGE).$(MAINACTIVITY)
MAYBE_RESET_USB := test "$(ANDROID_USB)" && $(ADB) usb && sleep 1 || true
OSASCRIPT := /usr/bin/osascript -e
# Task names extracted from output of './gradlew tasks' and re-ordered
# slightly.
#
GRADLETASKS :=\
help\
tasks\
androidDependencies\
signingReport\
assemble\
assembleDebug\
assembleDebugTest\
assembleRelease\
build\
buildDependents\
buildNeeded\
clean\
init\
wrapper\
dependencies\
dependencyInsight\
projects\
properties\
installDebug\
installDebugTest\
uninstallAll\
uninstallDebug\
uninstallDebugTest\
uninstallRelease\
check\
connectedAndroidTest\
connectedCheck\
deviceCheck\
#
$(GRADLETASKS):
./gradlew $@
.PHONY: $(GRADLETASKS)
define HEY
$(OSASCRIPT) 'display notification"'"$(1)"'"with title "''Hey Human!''"'
endef
debug:
./gradlew app:installDebug
$(MAYBE_RESET_USB)
$(ADB) logcat -c
$(ADB) shell pm path $(PACKAGE)
$(ADB) shell am start -n $(STARTER)
$(call HEY, Android is done.)
$(ADB) logcat
# $(ADB) shell pm dump $(PACKAGE)
.PHONY: debug
mobile:
./gradlew mobile:installDebug
$(MAYBE_RESET_USB)
$(ADB) logcat -c
$(ADB) shell pm path $(PACKAGE)
$(ADB) shell am start -n $(STARTER)
$(call HEY, Android $@ is ready.)
$(ADB) logcat
# $(ADB) shell pm dump $(PACKAGE)
.PHONY: mobile
wearable:
./gradlew wearable:installDebug
$(MAYBE_RESET_USB)
$(ADB) logcat -c
$(ADB) shell pm path $(PACKAGE)
$(ADB) shell am start -n $(STARTER)
$(call HEY, Android $@ is ready.)
$(ADB) logcat
# $(ADB) shell pm dump $(PACKAGE)
.PHONY: wearable
bluetooth: # Debug wearable over bluetooth.
./gradlew wearable:installDebug
$(MAYBE_RESET_USB)
$(ADB) forward tcp:4444 localabstract:/adb-hub
$(ADB) connect localhost:4444
$(ADB) -s localhost:4444 logcat -c
$(ADB) -s localhost:4444 shell pm path $(PACKAGE)
$(ADB) -s localhost:4444 shell am start -n $(STARTER)
$(call HEY, Android $@ is ready.)
$(ADB) -s localhost:4444 logcat
# $(ADB) -s localhost:4444 shell pm dump $(PACKAGE)
.PHONY: bluetooth
INSTRUMENT := $(PACKAGE).test/android.test.InstrumentationTestRunner
DEBUG_TEST_APK := app/build/outputs/apk/app-debug-test-unaligned.apk
test:
./gradlew installDebugTest installDebug
$(MAYBE_RESET_USB)
@echo
@echo Look for: Test results for InstrumentationTestRunner=.....
@echo Look for: 'OK (5 tests)' ... for some value of 5
@echo
$(ADB) logcat -c
$(ADB) shell pm path $(PACKAGE)
$(ADB) shell pm path $(PACKAGE).test
$(ADB) shell pm list instrumentation
$(ADB) shell pm list instrumentation -f
$(ADB) shell am instrument -w -e target $(PACKAGE) $(INSTRUMENT)
$(ADB) shell pm uninstall $(PACKAGE).test
$(ADB) shell pm uninstall $(PACKAGE)
$(ADB) logcat
.PHONY: test
dump: installDebug
$(MAYBE_RESET_USB)
$(ADB) shell pm path $(PACKAGE)
$(ADB) shell pm dump $(PACKAGE)
.PHONY: dump
monitor:
$(ANDROID_HOME)/tools/monitor
.PHONY: monitor
bugreport:
$(MAYBE_RESET_USB)
$(ADB) bugreport > bugreport.txt
gzip bugreport.txt
.PHONY: bugreport
lint lintDebug lintRelease:
./gradlew $@
open app/build/outputs/lint-results.html
.PHONY: lint lintDebug lintRelease
define TAGJAVA
find $(1) -type f -name '*.java' -print |\
xargs etags --append --output=$(2) &&
endef
TAGS tags: . $(LIBRARIES) $(ANDROIDSOURCES)
rm -f TAGS.tmp
$(foreach d,$^,$(call TAGJAVA,$(d),TAGS.tmp)) true
cmp -s ./TAGS TAGS.tmp || rm -f ./TAGS && mv TAGS.tmp ./TAGS
.PHONY: TAGS tags
distclean: clean
rm -f TAGS
.PHONY: distclean
# adb forward tcp:4444 localabstract:/adb-hub
# adb connect localhost:4444