diff options
| -rw-r--r-- | .gitignore | 5 | ||||
| -rw-r--r-- | Makefile | 111 | ||||
| -rw-r--r-- | ant.properties | 23 | ||||
| -rw-r--r-- | build.xml | 92 | ||||
| -rw-r--r-- | project.properties | 14 | ||||
| -rw-r--r-- | shell.nix | 6 |
6 files changed, 114 insertions, 137 deletions
@@ -1,5 +1,2 @@ -local.properties -proguard-project.txt -bin/* -gen/* *.keystore +_build diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..66e251f --- /dev/null +++ b/Makefile @@ -0,0 +1,111 @@ +# Configuration + +PACKAGE_NAME = juloo.keyboard2 + +ANDROID_PLATFORM_VERSION = android-29 +JAVA_VERSION = 1.7 + +SRC_DIR = srcs +ASSETS_DIR = assets +RES_DIR = res + +EXTRA_JARS = + +# / + +debug: _build/$(PACKAGE_NAME).debug.apk +release: _build/$(PACKAGE_NAME).apk + +installd: _build/$(PACKAGE_NAME).debug.apk + adb install "$<" + +.PHONY: release debug installd + +$(shell mkdir -p _build) + +ifndef ANDROID_HOME +$(error ANDROID_HOME not set) +endif + +ANDROID_BUILD_TOOLS = $(lastword $(sort $(wildcard $(ANDROID_HOME)/build-tools/*))) +ANDROID_PLATFORM = $(ANDROID_HOME)/platforms/$(ANDROID_PLATFORM_VERSION) + +ifeq ($(shell [ -d "$(ANDROID_PLATFORM)" ] && echo ok),) +$(error Android platform not found. Want $(ANDROID_PLATFORM_VERSION), \ + found $(notdir $(wildcard $(ANDROID_HOME)/platforms/*))) +endif + +JAVAC_FLAGS = -source $(JAVA_VERSION) -target $(JAVA_VERSION) -encoding utf8 + +# Source files + +MANIFEST_FILE = AndroidManifest.xml +JAVA_FILES = $(shell find $(SRC_DIR) -name '*.java') +RES_FILES = $(shell find $(RES_DIR) -type f) +ASSETS_FILES = $(shell find $(ASSETS_DIR) -type f 2>/dev/null) + +# Align + +_build/%.apk: _build/%.signed-apk + $(ANDROID_BUILD_TOOLS)/zipalign -fp 4 "$<" "$@" + +# Debug signing + +DEBUG_KEYSTORE = _build/debug.keystore +DEBUG_PASSWD = debug0 + +$(DEBUG_KEYSTORE): + echo y | keytool -genkeypair -dname "cn=d, ou=e, o=b, c=ug" \ + -alias debug -keypass $(DEBUG_PASSWD) -keystore "$@" \ + -keyalg rsa -storepass $(DEBUG_PASSWD) -validity 10000 + +_build/%.debug.signed-apk: _build/%.debug.unsigned-apk $(DEBUG_KEYSTORE) + jarsigner -keystore $(DEBUG_KEYSTORE) \ + -storepass $(DEBUG_PASSWD) -keypass $(DEBUG_PASSWD) \ + -signedjar "$@" "$<" debug + +# Debug apk + +_build/$(PACKAGE_NAME).debug.unsigned-apk: AAPT_PACKAGE_FLAGS+=--rename-manifest-package $(PACKAGE_NAME).debug + +# Release signing + +# %-keystore.conf should declare KEYSTORE, KEYNAME and OPTS +# it is interpreted as a shell script +# OPTS can be used to pass -storepass or -keypass options to jarsigner +_build/%.signed-apk: _build/%.unsigned-apk %-keystore.conf + eval `cat $(word 2,$^)` && \ + jarsigner -keystore "$$KEYSTORE" $$OPTS -signedjar "$@" "$<" "$$KEYNAME" + +# Package + +_build/%.unsigned-apk: _build/classes.dex $(MANIFEST_FILE) $(ASSETS_FILES) + $(ANDROID_BUILD_TOOLS)/aapt package -f -M $(MANIFEST_FILE) -S $(RES_DIR) \ + -I $(ANDROID_PLATFORM)/android.jar -F "$@" $(AAPT_PACKAGE_FLAGS) + [ -z "$(ASSETS_FILES)" ] || $(ANDROID_BUILD_TOOLS)/aapt add "$@" $(ASSETS_FILES) + cd $(@D) && $(ANDROID_BUILD_TOOLS)/aapt add $(@F) classes.dex + +# R.java + +GEN_DIR = _build/gen +R_FILE = $(GEN_DIR)/$(subst .,/,$(PACKAGE_NAME))/R.java + +$(R_FILE): $(RES_FILES) $(MANIFEST_FILE) + mkdir -p "$(@D)" + $(ANDROID_BUILD_TOOLS)/aapt package -f -m -S $(RES_DIR) -J $(GEN_DIR) \ + -M $(MANIFEST_FILE) -I $(ANDROID_PLATFORM)/android.jar + +# Compile java classes and build classes.dex + +OBJ_DIR = _build/class +# A$B.class files are ignored +# CLASS_FILES = $(JAVA_FILES:$(SRC_DIR)/%.java=$(OBJ_DIR)/%.class) \ +# $(R_FILE:$(GEN_DIR)/%.java=$(OBJ_DIR)/%.class) + +_build/classes.dex: $(JAVA_FILES) $(R_FILE) + mkdir -p $(OBJ_DIR) + javac -d $(OBJ_DIR) $(JAVAC_FLAGS) \ + -classpath $(ANDROID_PLATFORM)/android.jar:$(EXTRA_JARS) \ + -sourcepath $(SRC_DIR):$(GEN_DIR) \ + $^ + $(ANDROID_BUILD_TOOLS)/dx --dex --output="$@" $(OBJ_DIR) $(subst :, ,$(EXTRA_JARS)) diff --git a/ant.properties b/ant.properties deleted file mode 100644 index 190cdd5..0000000 --- a/ant.properties +++ /dev/null @@ -1,23 +0,0 @@ -# This file is used to override default values used by the Ant build system. -# -# This file must be checked into Version Control Systems, as it is -# integral to the build system of your project. - -# This file is only used by the Ant script. - -# You can use this to override default values such as -# 'source.dir' for the location of your java source folder and -# 'out.dir' for the location of your output folder. -source.dir=srcs - -# You can also use it define how the release builds are signed by declaring -# the following properties: -# 'key.store' for the location of your keystore and -# 'key.alias' for the name of the key to use. -# The password will be asked during the build when you use the 'release' target. - -key.store=release-keys.keystore -key.alias=releasekey - -java.source=1.7 -java.target=1.7 diff --git a/build.xml b/build.xml deleted file mode 100644 index 8e58243..0000000 --- a/build.xml +++ /dev/null @@ -1,92 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project name="Keyboard2" 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/project.properties b/project.properties deleted file mode 100644 index 8218193..0000000 --- a/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-29 @@ -14,9 +14,7 @@ in pkgs.mkShell { buildInputs = with pkgs; [ - ant openjdk8 android.androidsdk + findutils openjdk8 android.androidsdk ]; - shellHook = '' - export ANDROID_HOME=${android.androidsdk}/libexec/android-sdk - ''; + ANDROID_HOME = "${android.androidsdk}/libexec/android-sdk"; } |
