Commits

Ivan Vučica committed 840060a

Building under Linux. Removed binary files that were shipped accidentally.

  • Participants
  • Parent commits 8176b79

Comments (0)

Files changed (7)

File DummyClass.java

+class DummyClass
+{
+}
-#COMPILER_BIN=
-COMPILER_BIN=$(shell cygpath -u `cygpath -w android-sdk`)/../compiler/bin/
-
-#CC=$(COMPILER_BIN)clang
-#CXX=$(COMPILER_BIN)clang++
-CC=$(COMPILER_BIN)arm-linux-androideabi-gcc
-CXX=$(COMPILER_BIN)arm-linux-androideabi-g++
-CFLAGS=-isystem .
-LDFLAGS=-shared -llog -landroid -lEGL -lGLESv1_CM
-JAVA_BIN=/cygdrive/c/Program Files (x86)/Java/jdk1.7.0_25/bin
-
 KEYSTORE=TheKeyStore.jks
 KEYNAME=TheReleaseKeyName
 STOREPASS=TheStorePassword
 KEYPASS=TheKeyPassword
 DNAME=CN=Hermann Digimon, OU=Software Building Department, O=Big Company ltd., L=Sometown, S=Somewhere, C=HR
 
-#ANDROID_SDK_PATH=Path/To/AndroidSDK/On/F/Drive
-#ANDROID_SDK=/cygdrive/f/$(ANDROID_SDK_PATH)
-#ANDROID_SDK_WIN=F:/$(ANDROID_SDK_PATH)
-ANDROID_SDK=$(shell cygpath -u `cygpath -w android-sdk`)
-ANDROID_SDK_WIN=$(shell cygpath -w android-sdk | sed 's_\\_/_g')
-ANDROID_REV=android-14
-ANDROID_JAR=$(ANDROID_SDK_WIN)/platforms/$(ANDROID_REV)/android.jar
-AAPT=$(ANDROID_SDK)/build-tools/17.0.0/aapt.exe
-AAPT_PACK=$(AAPT) package -v -f -I $(ANDROID_JAR)
-ADB=$(ANDROID_SDK)/platform-tools/adb
-# -s emulator-5556
-DX=$(ANDROID_SDK)/build-tools/17.0.0/dx.bat
-
 APKNAME=TheGrandExperiment
 IDENTIFIER=net.vucica.tv.ouya.sample.game
 
 # sdcard install
 #INSTALLARGS=-r -s
 
+#CFLAGS=-isystem .
+LDFLAGS=-shared -llog -landroid -lEGL -lGLESv1_CM
+
+ANDROID_REV=android-18
+
+##############################
+
+PLATFORM=linux
+ifeq ("$(PLATFORM)","linux")
+COMPILER_BIN=/tmp/my-android-toolchain/bin/
+
+CC=$(COMPILER_BIN)clang
+CXX=$(COMPILER_BIN)clang++
+JAVA_BIN=/usr/bin
+
+ANDROID_SDK=/root/android-sdk-linux
+ANDROID_SDK_WIN=${ANDROID_SDK}
+AAPT=$(ANDROID_SDK)/build-tools/19.0.1/aapt
+ADB=$(ANDROID_SDK)/platform-tools/adb
+# -s emulator-5556
+DX=$(ANDROID_SDK)/build-tools/19.0.1/dx
+
+PROJECT_PATH_WIN=`pwd`
+
+JARSIGNER="$(JAVA_BIN)"/jarsigner
+KEYTOOL="$(JAVA_BIN)"/keytool
+JAVAC="$(JAVA_BIN)"/javac
+endif
+ifeq ("$(PLATFORM)","windows")
+COMPILER_BIN=$(shell cygpath -u `cygpath -w android-sdk`)/../compiler/bin/
+
+CC=$(COMPILER_BIN)arm-linux-androideabi-gcc
+CXX=$(COMPILER_BIN)arm-linux-androideabi-g++
+JAVA_BIN=/cygdrive/c/Program Files (x86)/Java/jdk1.7.0_25/bin
+
+#ANDROID_SDK_PATH=Path/To/AndroidSDK/On/F/Drive
+#ANDROID_SDK=/cygdrive/f/$(ANDROID_SDK_PATH)
+#ANDROID_SDK_WIN=F:/$(ANDROID_SDK_PATH)
+ANDROID_SDK=$(shell cygpath -u `cygpath -w android-sdk`) # android-sdk is a symlink
+ANDROID_SDK_WIN=$(shell cygpath -w android-sdk | sed 's_\\_/_g')
+
 PROJECT_PATH_WIN=$(shell cygpath -w `pwd` | sed 's_\\_/_g')
 
+AAPT=$(ANDROID_SDK)/build-tools/17.0.0/aapt.exe
+ADB=$(ANDROID_SDK)/platform-tools/adb.exe
+# -s emulator-5556
+DX=$(ANDROID_SDK)/build-tools/17.0.0/dx.bat
+
+JARSIGNER="$(JAVA_BIN)"/jarsigner.exe
+KEYTOOL="$(JAVA_BIN)"/keytool.exe
+JAVAC="$(JAVA_BIN)"/javac.exe
+endif
+
+ANDROID_JAR=$(ANDROID_SDK_WIN)/platforms/$(ANDROID_REV)/android.jar
+AAPT_PACK=$(AAPT) package -v -f -I $(ANDROID_JAR)
+
+#####################################
+
+CFLAGS += -I $(COMPILER_BIN)/../include
+
 all: $(APKNAME).apk
 
 install: $(APKNAME).apk
 	$(AAPT_PACK) -M AndroidManifest.xml -S res -A assets -m -J gen -F $(APKNAME).unsigned.apk apk
 
 $(APKNAME).apk: $(APKNAME).unsigned.apk $(KEYSTORE)
-	"$(JAVA_BIN)"/jarsigner.exe -keystore $(KEYSTORE) -storepass $(STOREPASS) -keypass $(KEYPASS) -signedjar $(APKNAME).apk $(APKNAME).unsigned.apk "$(KEYNAME)" -sigalg MD5withRSA -digestalg SHA1
+	$(JARSIGNER) -keystore $(KEYSTORE) -storepass $(STOREPASS) -keypass $(KEYPASS) -signedjar $(APKNAME).apk $(APKNAME).unsigned.apk "$(KEYNAME)" -sigalg MD5withRSA -digestalg SHA1
 
 
 $(KEYSTORE):
-	"$(JAVA_BIN)"/keytool.exe -genkey -v -keystore "$(KEYSTORE)" -alias "$(KEYNAME)" -keyalg RSA -keysize 2048 -validity 10000 -storepass "$(STOREPASS)" -keypass "$(KEYPASS)" -dname "$(DNAME)" -sigalg MD5withRSA
+	$(KEYTOOL) -genkey -v -keystore "$(KEYSTORE)" -alias "$(KEYNAME)" -keyalg RSA -keysize 2048 -validity 10000 -storepass "$(STOREPASS)" -keypass "$(KEYPASS)" -dname "$(DNAME)" -sigalg MD5withRSA
 
 classes.dex: classes/DummyClass.class
 	$(DX) --dex --output=$(PROJECT_PATH_WIN)/classes.dex --verbose $(PROJECT_PATH_WIN)/classes
 
 classes/DummyClass.class: DummyClass.java
 	mkdir -p classes/
-	"$(JAVA_BIN)"/javac.exe -bootclasspath $(ANDROID_JAR) -d classes/ DummyClass.java -source 1.6 -target 1.6
+	$(JAVAC) -bootclasspath $(ANDROID_JAR) -d classes/ DummyClass.java -source 1.6 -target 1.6
 
 clean:
 	-rm *.o
 This is an exercise in building Android native activities with GNU Make.
 And it's the smallest possible project I could come up with.
 
+Windows
+-------
+
 Expectations to build out of the box:
 
 * build with cygwin
 `android_native_app_glue.c/h` are coming from 
 `[android_ndk]/sources/android/native_app_glue`.
 
+There are references to build tools version 17.0.0. There are references
+to particular API revision. `PLATFORM` needs to be set to `windows`.
+There may be other assumptions.
 
+Linux
+-----
+Makefile now actually contains code to build under Linux, as long as:
+
+* JDK is in `/usr/bin/`
+* Android SDK is in `/root/android-sdk-linux`
+* standalone NDK compiler is in `/tmp/my-android-toolchain`
+
+Build tools are presumed to be 19.0.1. `PLATFORM` needs to be set to
+`linux`. There may be other assumptions.

File TheGrandExperiment.c

 
 #include <android/sensor.h>
 #include <android/log.h>
-#include <android_native_app_glue.h>
+#include "android_native_app_glue.h"
 
 #define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "native-activity", __VA_ARGS__))
 #define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "native-activity", __VA_ARGS__))

File android_native_app_glue.o

Binary file removed.

File assets/do_not_remove.txt

Empty file added.

File classes/DummyClass.class

Binary file removed.