blob: 619f4d7ba1be865dc7f56a233405aa5078b8bf12 [file] [log] [blame]
Alexandre Lision43b9aeb2014-07-15 14:21:19 -04001# Sources and objects
Tristan Matthewsccf51e32013-07-18 14:40:51 -04002
Alexandre Lision43b9aeb2014-07-15 14:21:19 -04003export ANDROID_HOME=$(ANDROID_SDK)
Tristan Matthews5bb1b5d2013-07-18 14:32:58 -04004
Ciro Santilli7ff57fb2016-02-20 22:23:17 +01005TOP=$(shell pwd)/ring-android
6SRC=$(TOP)/app/src/main
Alexandre Lisionec1f3ee2014-08-04 19:12:42 -04007
Adrien Béraudb00ed3f2015-06-07 15:36:06 -04008JAVA_SOURCES=$(shell find $(SRC)/java/cx/ring/ -type f -name "*.java")
Alexandre Lision43b9aeb2014-07-15 14:21:19 -04009
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040010ifneq ($(V),)
Adrien Béraudb00ed3f2015-06-07 15:36:06 -040011GRADLE_OPTS += -d
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040012VERBOSE =
13GEN =
14else
15VERBOSE = @
16GEN = @echo "Generating" $@;
17endif
18
19ifeq ($(RELEASE),1)
Adrien Béraudb00ed3f2015-06-07 15:36:06 -040020GRADLE_TARGET = assembleRelease
Adrien Béraud04d822c2015-04-02 17:44:36 -040021RING_APK=$(SRC)/bin/Ring-release-unsigned.apk
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040022NDK_DEBUG=0
23else
Adrien Béraudb00ed3f2015-06-07 15:36:06 -040024GRADLE_TARGET = assembleDebug
Adrien Béraud04d822c2015-04-02 17:44:36 -040025RING_APK=$(SRC)/bin/Ring-debug.apk
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040026NDK_DEBUG=1
27endif
28
Alexandre Lision7d5df5d2014-10-27 13:10:01 -040029define build_apk
30 @echo
Adrien Béraud04d822c2015-04-02 17:44:36 -040031 @echo "=== Building $(RING_APK) for $(ARCH) ==="
Alexandre Lision7d5df5d2014-10-27 13:10:01 -040032 @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éraudb00ed3f2015-06-07 15:36:06 -040037 # many times the gradlew script is not executable by default
Ciro Santilli7ff57fb2016-02-20 22:23:17 +010038 $(VERBOSE)cd $(TOP) && chmod +x ./gradlew && ./gradlew $(GRADLE_OPTS) $(GRADLE_TARGET) -Parchs=$(ARCH)
Alexandre Lision7d5df5d2014-10-27 13:10:01 -040039endef
40
Adrien Béraud86759bb2016-09-28 13:54:54 -040041$(RING_APK): $(JAVA_SOURCES)
Ciro Santilli7ff57fb2016-02-20 22:23:17 +010042 @echo
43 @echo "=== Building $@ for ${ARCH} ==="
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040044 @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éraudb00ed3f2015-06-07 15:36:06 -040048 # many times the gradlew script is not executable by default
Ciro Santilli7ff57fb2016-02-20 22:23:17 +010049 $(VERBOSE)cd $(TOP) && chmod +x ./gradlew && ./gradlew $(GRADLE_OPTS) $(GRADLE_TARGET) -Parchs=$(ARCH)
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040050
Alexandre Lision7d5df5d2014-10-27 13:10:01 -040051apk:
52 $(call build_apk)
53
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040054apkclean:
Adrien Béraud04d822c2015-04-02 17:44:36 -040055 rm -f $(RING_APK)
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040056
57lightclean:
Adrien Béraud86759bb2016-09-28 13:54:54 -040058 cd $(SRC) && rm -rf libs/$(ARCH) obj bin $(RING_APK)
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040059
60clean: lightclean
Romain Bertozzi197c8c82016-04-04 14:18:11 -040061 rm -rf $(SRC)/gen java-libs/*/gen java-libs/*/bin
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040062
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040063distclean: clean jniclean
64
Adrien Béraud04d822c2015-04-02 17:44:36 -040065install: $(RING_APK)
Adrien Béraud87d878d2015-06-03 15:09:19 -040066 @echo "=== Installing Ring on device ==="
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040067 adb wait-for-device
Adrien Béraud04d822c2015-04-02 17:44:36 -040068 adb install -r $(RING_APK)
Tristan Matthews5bb1b5d2013-07-18 14:32:58 -040069
Tristan Matthewsfdd94e52013-07-19 16:44:44 -040070uninstall:
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040071 adb wait-for-device
Adrien Béraud04d822c2015-04-02 17:44:36 -040072 adb uninstall cx.ring
Tristan Matthewsfdd94e52013-07-19 16:44:44 -040073
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040074run:
Adrien Béraud87d878d2015-06-03 15:09:19 -040075 @echo "=== Running Ring on device ==="
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040076 adb wait-for-device
Adrien Béraud04d822c2015-04-02 17:44:36 -040077 adb shell am start -n cx.ring/cx.ring.client.HomeActivity
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040078
79build-and-run: install run
80
81apkclean-run: apkclean build-and-run
82 adb logcat -c
83
84distclean-run: distclean build-and-run
85 adb logcat -c
86
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040087.PHONY: lightclean clean jniclean distclean distclean-run apkclean apkclean-run install run build-and-run