summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRay <[email protected]>2017-09-23 18:08:19 +0200
committerRay <[email protected]>2017-09-23 18:08:19 +0200
commit86ebb877fe56579685299b610aab48d40a104d6d (patch)
tree5e458e9d92db721b5dca441a7c3f74fffd76f559
parent00274f070f1297adb468104fc9745a288cf449d1 (diff)
downloadraylib-86ebb877fe56579685299b610aab48d40a104d6d.tar.gz
raylib-86ebb877fe56579685299b610aab48d40a104d6d.zip
Working on project Makefile for Android
-rw-r--r--templates/android_project/Makefile57
-rw-r--r--templates/android_project/build.xml92
-rw-r--r--templates/android_project/project.properties14
3 files changed, 37 insertions, 126 deletions
diff --git a/templates/android_project/Makefile b/templates/android_project/Makefile
index caccc847..5e4f12ec 100644
--- a/templates/android_project/Makefile
+++ b/templates/android_project/Makefile
@@ -25,10 +25,16 @@
PROJECT_NAME = NativeActivity
PROJECT_DIR = ./
+# Generated shared library name
+# NOTE: It should match the name defined in the AndroidManifest.xml
+LIBRARY_NAME = raylib_game
+
+KEYSTORE_USER = raylib
+KEYSTORE_PASS = raylib
+
# define raylib platform to compile for
PLATFORM ?= PLATFORM_ANDROID
-
# Required path variables
# NOTE: JAVA_HOME must be set to JDK
ANDROID_HOME = C:/android-sdk
@@ -56,7 +62,8 @@ LIBS = -lraylib -lopenal -llog -landroid -lEGL -lGLESv2 -lOpenSLES
# Building APK
#-----------------
# typing 'make' will invoke the default target entry called 'all',
-all: native_app_glue \
+all: project_dirs \
+ native_app_glue \
project_code \
gen_keystore \
project_package \
@@ -66,62 +73,72 @@ all: native_app_glue \
apk_signing \
apk_zip_align
+# create required temp directories for APK building
+project_dirs:
+ if not exist temp mkdir temp
+ if not exist temp\obj mkdir temp\obj
+ if not exist temp\src mkdir temp\src
+ if not exist temp\lib mkdir temp\lib
+ if not exist temp\bin mkdir temp\bin
+
# compile native_app_glue static library
-# OUTPUT $(PROJECT_DIR)/jni/libnative_app_glue.a
+# OUTPUT: $(PROJECT_DIR)/jni/libnative_app_glue.a
native_app_glue:
$(CC) -c $(ANDROID_NDK)/sources/android/native_app_glue/android_native_app_glue.c -o jni/native_app_glue.o $(CFLAGS)
$(AR) rcs $(PROJECT_DIR)/jni/libnative_app_glue.a jni/native_app_glue.o
# compile project code as shared libraries
-# OUTPUT $(PROJECT_DIR)/lib/arm64-v8a/libnative-activity.so
+# OUTPUT: $(PROJECT_DIR)/temp/lib/lib$(LIBRARY_NAME).so
project_code:
$(CC) -c jni/basic_game.c -o jni/basic_game.o $(INCLUDES) -I$(ANDROID_NDK)/sources/android/native_app_glue $(CFLAGS) --sysroot=$(ANDROID_TOOLCHAIN)/sysroot -fPIC
- $(CC) -o lib/libnative-activity.so jni/basic_game.o -shared $(INCLUDES) $(LFLAGS) $(LIBS) -lnative_app_glue
+ $(CC) -o temp/lib/lib$(LIBRARY_NAME).so jni/basic_game.o -shared $(INCLUDES) $(LFLAGS) $(LIBS) -lnative_app_glue
# Generate key for APK
-# OUTPUT $(PROJECT_DIR)/ToyKey.keystore
+# OUTPUT: $(PROJECT_DIR)/temp/$(PROJECT_NAME).keystore
gen_keystore:
-# $(JAVA_HOME)/bin/keytool -genkeypair -validity 1000 -dname "CN=raylib,O=Android,C=JPN" -keystore ToyKey.keystore -storepass raylib -keypass raylib -alias $(PROJECT_NAME)Key -keyalg RSA
+ $(JAVA_HOME)/bin/keytool -genkeypair -validity 1000 -dname "CN=raylib,O=Android,C=JPN" -keystore temp/$(PROJECT_NAME).keystore -storepass $(KEYSTORE_USER) -keypass $(KEYSTORE_PASS) -alias $(PROJECT_NAME)Key -keyalg RSA
-# Creating src/com/example/native_activity/R.java
-# OUTPUT $(PROJECT_DIR)/src/com/example/native_activity/R.java
+# Creating src/com/example/$(LIBRARY_NAME)/R.java
+# OUTPUT: $(PROJECT_DIR)/temp/src/com/example/$(LIBRARY_NAME)/R.java
# NOTE: DEPENDS on res/values/strings.xml
project_package:
- $(ANDROID_BUILD_TOOLS)/aapt package -f -m -S res -J src -M AndroidManifest.xml -I $(ANDROID_HOME)/platforms/android-16/android.jar
+ $(ANDROID_BUILD_TOOLS)/aapt package -f -m -S res -J temp/src -M AndroidManifest.xml -I $(ANDROID_HOME)/platforms/android-16/android.jar
-# Creating obj/com/example/native_activity/R.class
-# OUTPUT $(PROJECT_DIR)/obj/com/example/native_activity/R.class
+# Creating obj/com/example/$(LIBRARY_NAME)/R.class
+# OUTPUT: $(PROJECT_DIR)/temp/obj/com/example/$(LIBRARY_NAME)/R.class
project_class:
- $(JAVA_HOME)/bin/javac -source 1.7 -target 1.7 -d obj -classpath $(ANDROID_HOME)/platforms/android-16/android.jar -sourcepath src src/com/raylib/game_sample/R.java
+ $(JAVA_HOME)/bin/javac -source 1.7 -target 1.7 -d temp/obj -classpath $(ANDROID_HOME)/platforms/android-16/android.jar -sourcepath temp/src temp/src/com/raylib/game_sample/R.java
# Creating bin/classes/dex
# OUTPUT $(PROJECT_DIR)/bin/classes.dex
# NOTE: DEPENDS on obj/com/example/native_activity/R.class
project_class_dex:
- $(ANDROID_BUILD_TOOLS)/dx --dex --output=bin/classes.dex obj
+ $(ANDROID_BUILD_TOOLS)/dx --dex --output=temp/bin/classes.dex temp/obj
# Creating bin/$(PROJECT_NAME).unsigned.apk
# NOTE: DEPENDS on bin/classes.dex lib/arm64-v8a/libnative-activity.so
# Use -A resources to define additional directory in which to find raw asset files
project_apk:
- $(ANDROID_BUILD_TOOLS)/aapt package -f -m -M AndroidManifest.xml -S res -A assets -I $(ANDROID_HOME)/platforms/android-16/android.jar -F bin/$(PROJECT_NAME).unsigned.apk -J bin
- $(ANDROID_BUILD_TOOLS)/aapt add $(PROJECT_DIR)/bin/$(PROJECT_NAME).unsigned.apk lib/libnative-activity.so
+ $(ANDROID_BUILD_TOOLS)/aapt package -f -m -M AndroidManifest.xml -S res -A assets -I $(ANDROID_HOME)/platforms/android-16/android.jar -F temp/bin/$(PROJECT_NAME).unsigned.apk -J temp/bin
+ $(ANDROID_BUILD_TOOLS)/aapt add $(PROJECT_DIR)/temp/bin/$(PROJECT_NAME).unsigned.apk temp/lib/lib$(LIBRARY_NAME).so
# Creating bin/$(PROJECT_NAME).signed.apk
apk_signing:
- $(JAVA_HOME)/bin/jarsigner -keystore ToyKey.keystore -storepass raylib -keypass raylib -signedjar $(PROJECT_DIR)/bin/$(PROJECT_NAME).signed.apk bin/$(PROJECT_NAME).unsigned.apk $(PROJECT_NAME)Key
+ $(JAVA_HOME)/bin/jarsigner -keystore temp/$(PROJECT_NAME).keystore -storepass $(KEYSTORE_USER) -keypass $(KEYSTORE_PASS) -signedjar $(PROJECT_DIR)/temp/bin/$(PROJECT_NAME).signed.apk temp/bin/$(PROJECT_NAME).unsigned.apk $(PROJECT_NAME)Key
# Creating bin/$(PROJECT_NAME).apk
apk_zip_align:
- $(ANDROID_BUILD_TOOLS)/zipalign -f 4 bin/$(PROJECT_NAME).signed.apk bin/$(PROJECT_NAME).apk
+ $(ANDROID_BUILD_TOOLS)/zipalign -f 4 temp/bin/$(PROJECT_NAME).signed.apk $(PROJECT_NAME).apk
# Deploy to device
deploy:
- $(ANDROID_HOME)/platform-tools/adb install -r bin/$(PROJECT_NAME).apk
+ $(ANDROID_HOME)/platform-tools/adb install -r $(PROJECT_NAME).apk
$(ANDROID_HOME)/platform-tools/adb logcat -c
$(ANDROID_HOME)/platform-tools/adb logcat *:W
# clean everything
clean:
- del bin\* lib\* obj\* src\* /f/s/q
+ del temp\bin\* temp\lib\* temp\obj\* temp\src\* /f/s/q
+ del temp\*.keystore
+ rmdir temp /s /q
@echo Cleaning done
diff --git a/templates/android_project/build.xml b/templates/android_project/build.xml
deleted file mode 100644
index 6eab44e1..00000000
--- a/templates/android_project/build.xml
+++ /dev/null
@@ -1,92 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project name="nativeGame" default="help">
-
- <!-- The local.properties file is created and updated by the 'android' tool.
- It contains the path to the SDK. It should *NOT* be checked into
- Version Control Systems. -->
- <property file="local.properties" />
-
- <!-- The ant.properties file can be created by you. It is only edited by the
- 'android' tool to add properties to it.
- This is the place to change some Ant specific build properties.
- Here are some properties you may want to change/update:
-
- source.dir
- The name of the source directory. Default is 'src'.
- out.dir
- The name of the output directory. Default is 'bin'.
-
- For other overridable properties, look at the beginning of the rules
- files in the SDK, at tools/ant/build.xml
-
- Properties related to the SDK location or the project target should
- be updated using the 'android' tool with the 'update' action.
-
- This file is an integral part of the build system for your
- application and should be checked into Version Control Systems.
-
- -->
- <property file="ant.properties" />
-
- <!-- if sdk.dir was not set from one of the property file, then
- get it from the ANDROID_HOME env var.
- This must be done before we load project.properties since
- the proguard config can use sdk.dir -->
- <property environment="env" />
- <condition property="sdk.dir" value="${env.ANDROID_HOME}">
- <isset property="env.ANDROID_HOME" />
- </condition>
-
- <!-- The project.properties file is created and updated by the 'android'
- tool, as well as ADT.
-
- This contains project specific properties such as project target, and library
- dependencies. Lower level build properties are stored in ant.properties
- (or in .classpath for Eclipse projects).
-
- This file is an integral part of the build system for your
- application and should be checked into Version Control Systems. -->
- <loadproperties srcFile="project.properties" />
-
- <!-- quick check on sdk.dir -->
- <fail
- message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
- unless="sdk.dir"
- />
-
- <!--
- Import per project custom build rules if present at the root of the project.
- This is the place to put custom intermediary targets such as:
- -pre-build
- -pre-compile
- -post-compile (This is typically used for code obfuscation.
- Compiled code location: ${out.classes.absolute.dir}
- If this is not done in place, override ${out.dex.input.absolute.dir})
- -post-package
- -post-build
- -pre-clean
- -->
- <import file="custom_rules.xml" optional="true" />
-
- <!-- Import the actual build file.
-
- To customize existing targets, there are two options:
- - Customize only one target:
- - copy/paste the target into this file, *before* the
- <import> task.
- - customize it to your needs.
- - Customize the whole content of build.xml
- - copy/paste the content of the rules files (minus the top node)
- into this file, replacing the <import> task.
- - customize to your needs.
-
- ***********************
- ****** IMPORTANT ******
- ***********************
- In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
- in order to avoid having your file be overridden by tools such as "android update project"
- -->
- <!-- version-tag: 1 -->
- <import file="${sdk.dir}/tools/ant/build.xml" />
-
-</project>
diff --git a/templates/android_project/project.properties b/templates/android_project/project.properties
deleted file mode 100644
index 4ab12569..00000000
--- a/templates/android_project/project.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system edit
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-#
-# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
-#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
-
-# Project target.
-target=android-19