Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 1 | # Sources and objects |
Tristan Matthews | ccf51e3 | 2013-07-18 14:40:51 -0400 | [diff] [blame] | 2 | |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 3 | export ANDROID_HOME=$(ANDROID_SDK) |
Tristan Matthews | 5bb1b5d | 2013-07-18 14:32:58 -0400 | [diff] [blame] | 4 | |
Ciro Santilli | 7ff57fb | 2016-02-20 22:23:17 +0100 | [diff] [blame] | 5 | TOP=$(shell pwd)/ring-android |
| 6 | SRC=$(TOP)/app/src/main |
Alexandre Lision | ec1f3ee | 2014-08-04 19:12:42 -0400 | [diff] [blame] | 7 | |
Adrien Béraud | b00ed3f | 2015-06-07 15:36:06 -0400 | [diff] [blame] | 8 | JAVA_SOURCES=$(shell find $(SRC)/java/cx/ring/ -type f -name "*.java") |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 9 | |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 10 | ifneq ($(V),) |
Adrien Béraud | b00ed3f | 2015-06-07 15:36:06 -0400 | [diff] [blame] | 11 | GRADLE_OPTS += -d |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 12 | VERBOSE = |
| 13 | GEN = |
| 14 | else |
| 15 | VERBOSE = @ |
| 16 | GEN = @echo "Generating" $@; |
| 17 | endif |
| 18 | |
| 19 | ifeq ($(RELEASE),1) |
Adrien Béraud | b00ed3f | 2015-06-07 15:36:06 -0400 | [diff] [blame] | 20 | GRADLE_TARGET = assembleRelease |
Adrien Béraud | 04d822c | 2015-04-02 17:44:36 -0400 | [diff] [blame] | 21 | RING_APK=$(SRC)/bin/Ring-release-unsigned.apk |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 22 | NDK_DEBUG=0 |
| 23 | else |
Adrien Béraud | b00ed3f | 2015-06-07 15:36:06 -0400 | [diff] [blame] | 24 | GRADLE_TARGET = assembleDebug |
Adrien Béraud | 04d822c | 2015-04-02 17:44:36 -0400 | [diff] [blame] | 25 | RING_APK=$(SRC)/bin/Ring-debug.apk |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 26 | NDK_DEBUG=1 |
| 27 | endif |
| 28 | |
Alexandre Lision | 7d5df5d | 2014-10-27 13:10:01 -0400 | [diff] [blame] | 29 | define build_apk |
| 30 | @echo |
Adrien Béraud | 04d822c | 2015-04-02 17:44:36 -0400 | [diff] [blame] | 31 | @echo "=== Building $(RING_APK) for $(ARCH) ===" |
Alexandre Lision | 7d5df5d | 2014-10-27 13:10:01 -0400 | [diff] [blame] | 32 | @echo |
| 33 | date +"%Y-%m-%d" > $(SRC)/assets/builddate.txt |
| 34 | echo `id -u -n`@`hostname` > $(SRC)/assets/builder.txt |
| 35 | git rev-parse --short HEAD > $(SRC)/assets/revision.txt |
| 36 | ./gen-env.sh $(SRC) |
Adrien Béraud | b00ed3f | 2015-06-07 15:36:06 -0400 | [diff] [blame] | 37 | # many times the gradlew script is not executable by default |
Ciro Santilli | 7ff57fb | 2016-02-20 22:23:17 +0100 | [diff] [blame] | 38 | $(VERBOSE)cd $(TOP) && chmod +x ./gradlew && ./gradlew $(GRADLE_OPTS) $(GRADLE_TARGET) -Parchs=$(ARCH) |
Alexandre Lision | 7d5df5d | 2014-10-27 13:10:01 -0400 | [diff] [blame] | 39 | endef |
| 40 | |
Adrien Béraud | 86759bb | 2016-09-28 13:54:54 -0400 | [diff] [blame] | 41 | $(RING_APK): $(JAVA_SOURCES) |
Ciro Santilli | 7ff57fb | 2016-02-20 22:23:17 +0100 | [diff] [blame] | 42 | @echo |
| 43 | @echo "=== Building $@ for ${ARCH} ===" |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 44 | @echo |
| 45 | date +"%Y-%m-%d" > $(SRC)/assets/builddate.txt |
| 46 | echo `id -u -n`@`hostname` > $(SRC)/assets/builder.txt |
| 47 | git rev-parse --short HEAD > $(SRC)/assets/revision.txt |
Adrien Béraud | b00ed3f | 2015-06-07 15:36:06 -0400 | [diff] [blame] | 48 | # many times the gradlew script is not executable by default |
Ciro Santilli | 7ff57fb | 2016-02-20 22:23:17 +0100 | [diff] [blame] | 49 | $(VERBOSE)cd $(TOP) && chmod +x ./gradlew && ./gradlew $(GRADLE_OPTS) $(GRADLE_TARGET) -Parchs=$(ARCH) |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 50 | |
Alexandre Lision | 7d5df5d | 2014-10-27 13:10:01 -0400 | [diff] [blame] | 51 | apk: |
| 52 | $(call build_apk) |
| 53 | |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 54 | apkclean: |
Adrien Béraud | 04d822c | 2015-04-02 17:44:36 -0400 | [diff] [blame] | 55 | rm -f $(RING_APK) |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 56 | |
| 57 | lightclean: |
Adrien Béraud | 86759bb | 2016-09-28 13:54:54 -0400 | [diff] [blame] | 58 | cd $(SRC) && rm -rf libs/$(ARCH) obj bin $(RING_APK) |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 59 | |
| 60 | clean: lightclean |
Romain Bertozzi | 197c8c8 | 2016-04-04 14:18:11 -0400 | [diff] [blame] | 61 | rm -rf $(SRC)/gen java-libs/*/gen java-libs/*/bin |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 62 | |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 63 | distclean: clean jniclean |
| 64 | |
Adrien Béraud | 04d822c | 2015-04-02 17:44:36 -0400 | [diff] [blame] | 65 | install: $(RING_APK) |
Adrien Béraud | 87d878d | 2015-06-03 15:09:19 -0400 | [diff] [blame] | 66 | @echo "=== Installing Ring on device ===" |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 67 | adb wait-for-device |
Adrien Béraud | 04d822c | 2015-04-02 17:44:36 -0400 | [diff] [blame] | 68 | adb install -r $(RING_APK) |
Tristan Matthews | 5bb1b5d | 2013-07-18 14:32:58 -0400 | [diff] [blame] | 69 | |
Tristan Matthews | fdd94e5 | 2013-07-19 16:44:44 -0400 | [diff] [blame] | 70 | uninstall: |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 71 | adb wait-for-device |
Adrien Béraud | 04d822c | 2015-04-02 17:44:36 -0400 | [diff] [blame] | 72 | adb uninstall cx.ring |
Tristan Matthews | fdd94e5 | 2013-07-19 16:44:44 -0400 | [diff] [blame] | 73 | |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 74 | run: |
Adrien Béraud | 87d878d | 2015-06-03 15:09:19 -0400 | [diff] [blame] | 75 | @echo "=== Running Ring on device ===" |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 76 | adb wait-for-device |
Adrien Béraud | 04d822c | 2015-04-02 17:44:36 -0400 | [diff] [blame] | 77 | adb shell am start -n cx.ring/cx.ring.client.HomeActivity |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 78 | |
| 79 | build-and-run: install run |
| 80 | |
| 81 | apkclean-run: apkclean build-and-run |
| 82 | adb logcat -c |
| 83 | |
| 84 | distclean-run: distclean build-and-run |
| 85 | adb logcat -c |
| 86 | |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 87 | .PHONY: lightclean clean jniclean distclean distclean-run apkclean apkclean-run install run build-and-run |