forked from astagi/magpi-android
-
Notifications
You must be signed in to change notification settings - Fork 16
/
YMCA.mk
160 lines (149 loc) · 6.26 KB
/
YMCA.mk
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
#______________________________________________________________________________________
# _ _ _____ ___ ___
# | v | | | | _| | _ |
# |_| |_|_|_| |___| |_|_|
#______________________________________________________________________________________
# version 1.0
# YMCA (You Make Cool Apps)
# Description: Makefile for building Android apps using Ant
# Author: Andrea Stagi (@4ndreaSt4gi)
# Source: https://github.com/4ndreaSt4gi/YMCA
# License: MIT
#
# Copyright (C) 2012 Andrea Stagi <stagi.andrea@gmail.com>.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#______________________________________________________________________________________
#
# Here is a complete list of configuration parameters:
#
# ANDROID_SDK The path where the Android SDK is placed on your system.
#
# TARGET The Android target. For a complete list, type Makefile targets.
#
# DEVICE The device where you want to run your app on. Set to ALL for uploading
# your app on all devices attached.
#
# ACTIVITY The main activity you want to run.
#
# This makefile also defines the following goals for use on the command line
# when you run make:
#
# all This is the default goal if no one is specified. It builds the apk.
#
# clean Deletes files created during the build.
#
# upload Uploads the last debug apk on an attached Android DEVICE.
# Set DEVICE to a specified target, ALL for every device attached.
#
# upload-release Uploads the last signed apk on an attached Android DEVICE.
# Set DEVICE to a specified target, ALL for every device attached.
#
# sign Generate a signed package.
#
# restartadb Restarts adb. Sometimes needed.
#
# devices Shows the list of all available DEVICEs.
#
# targets Shows the list of all available targets.
#
# log Shows the log of a specified DEVICE. Set DEVICE to a specified target.
#______________________________________________________________________________________
ifeq ($(DEVICE) , ALL)
ALL_DEVS=$(shell $(ANDROID_SDK)/platform-tools/adb devices | grep '[A-Z0-9][A-Z0-9][A-Z0-9]*' | tr '\t[a-z]' ' ' | tr '\n' ' ')
else
ifdef DEVICE
DEVICE_CMD= -s $(DEVICE)
endif
endif
all:
ifdef TARGET
@echo "\nUpdating the project..."
@$(ANDROID_SDK)/tools/android update project --path ./ --target $(TARGET)
else
ifeq ($(wildcard build.xml),)
$(error "\nERROR! Use make TARGET=N. For a complete list, type 'Makefile targets'.")
endif
endif
@echo "\nBuilding debug apk..."
@ant debug
upload:
ifeq ($(DEVICE) , ALL)
@echo "\nUploading on all the devices attached..."
$(foreach dev, $(ALL_DEVS),$(ANDROID_SDK)/platform-tools/adb -s $(dev) install -r ./bin/*debug.apk;)
@echo "\nLaunching the main activity on all the devices attached..."
$(foreach dev, $(ALL_DEVS),$(ANDROID_SDK)/platform-tools/adb -s $(dev) shell am start -n $(ACTIVITY);)
else
@echo "\nUploading on device..."
@$(ANDROID_SDK)/platform-tools/adb $(DEVICE_CMD) install -r ./bin/*debug.apk
@echo "\nLaunching the main activity..."
@$(ANDROID_SDK)/platform-tools/adb $(DEVICE_CMD) shell am start -n $(ACTIVITY)
endif
upload-release:
ifeq ($(DEVICE) , ALL)
@echo "\nUploading on all the devices attached..."
$(foreach dev, $(ALL_DEVS),$(ANDROID_SDK)/platform-tools/adb -s $(dev) install -r ./bin/*release.apk;)
@echo "\nLaunching the main activity on all the devices attached..."
$(foreach dev, $(ALL_DEVS),$(ANDROID_SDK)/platform-tools/adb -s $(dev) shell am start -n $(ACTIVITY);)
else
@echo "\nUploading on device..."
@$(ANDROID_SDK)/platform-tools/adb $(DEVICE_CMD) install -r ./bin/*release.apk
@echo "\nLaunching the main activity..."
@$(ANDROID_SDK)/platform-tools/adb $(DEVICE_CMD) shell am start -n $(ACTIVITY)
endif
clean:
@echo "\nCleaning the project..."
ant clean
sign:
@echo "\nGenerating a signed apk..."
ifneq ($(wildcard ant.properties),)
@cat ant.properties > .ant.propertiestmp
ifneq ($(wildcard build.properties),)
@cat build.properties > .build.propertiestmp
endif
@echo "" >> ant.properties
@echo "" >> build.properties
@echo "key.store=$(KEY_STORE)" >> ant.properties
@echo "key.alias=$(KEY_ALIAS)" >> ant.properties
@echo "key.store=$(KEY_STORE)" >> build.properties
@echo "key.alias=$(KEY_ALIAS)" >> build.properties
ifdef KEY_STORE_PASSWORD
ifdef KEY_ALIAS_PASSWORD
@echo "key.alias.password=$(KEY_ALIAS_PASSWORD)" >> ant.properties
@echo "key.store.password=$(KEY_STORE_PASSWORD)" >> ant.properties
@echo "key.alias.password=$(KEY_ALIAS_PASSWORD)" >> build.properties
@echo "key.store.password=$(KEY_STORE_PASSWORD)" >> build.properties
endif
endif
ant release
endif
@cat .ant.propertiestmp > ant.properties
@cat .build.propertiestmp > build.properties
@rm .ant.propertiestmp
@rm .build.propertiestmp
restartadb:
@echo "\nRestarting adb..."
sudo $(ANDROID_SDK)/platform-tools/adb kill-server
sudo $(ANDROID_SDK)/platform-tools/adb start-server
devices:
@$(ANDROID_SDK)/platform-tools/adb devices
targets:
@$(ANDROID_SDK)/tools/android list
log:
@$(ANDROID_SDK)/platform-tools/adb $(DEVICE_CMD) logcat