From 8724f8024530530328b2dc84e431fc88d722ce07 Mon Sep 17 00:00:00 2001 From: Edouard Dupin Date: Wed, 12 Sep 2012 18:17:54 +0200 Subject: [PATCH] Generate all needed file for android code generation --- Makefile.Android.mk | 143 ++++++++++++++++++-------------------------- core/defs.mk | 18 ++++++ 2 files changed, 77 insertions(+), 84 deletions(-) diff --git a/Makefile.Android.mk b/Makefile.Android.mk index 1472225..ce15144 100644 --- a/Makefile.Android.mk +++ b/Makefile.Android.mk @@ -1,7 +1,5 @@ -PROJECT_PACKAGE=$(PROJECT_NAME)package - TARGET_OS = Android TARGET_ARCH = ARM TARGET_CROSS = $(PROJECT_NDK)/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi- @@ -13,55 +11,69 @@ TARGET_GLOBAL_LDLIBS_SHARED = --sysroot=$(PROJECT_NDK)/platforms/android-$(ANDRO #generic makefile include $(EWOL_FOLDER)/Build/core/main.mk -FINAL_FOLDER_JAVA=$(TARGET_OUT_FINAL) -FINAL_FOLDER_JAVA_PROJECT=$(FINAL_FOLDER_JAVA)/src/$(CONFIG___EWOL_APPL_ORGANISATION_TYPE__)/$(PROJECT_VENDOR)/$(PROJECT_NAME) +CONFIG2___EWOL_APPL_ORGANISATION_TYPE__ := $(call convert-special-char,$(CONFIG___EWOL_APPL_ORGANISATION_TYPE__)) -FINAL_FILE_ABSTRACTION = $(FINAL_FOLDER_JAVA_PROJECT)/$(PROJECT_NAME).java +CONFIG2___EWOL_APPL_COMPAGNY__ := $(call convert-special-char,$(CONFIG___EWOL_APPL_COMPAGNY__)) + +CONFIG2___EWOL_APPL_NAME__ := $(call convert-special-char,$(CONFIG___EWOL_APPL_NAME__)) + +CONFIG2___EWOL_ANDROID_ICON__ := $(subst $(quote),$(empty),$(CONFIG___EWOL_ANDROID_ICON__)) + +FINAL_FOLDER_JAVA=$(TARGET_OUT_FINAL) +FINAL_FOLDER_JAVA_PROJECT=$(FINAL_FOLDER_JAVA)/src/$(CONFIG2___EWOL_APPL_ORGANISATION_TYPE__)/$(CONFIG2___EWOL_APPL_COMPAGNY__)/$(CONFIG2___EWOL_APPL_NAME__) + +FINAL_FILE_ABSTRACTION = $(FINAL_FOLDER_JAVA_PROJECT)/$(CONFIG2___EWOL_APPL_NAME__).java javaclean: - @rm -rf $(FINAL_FOLDER_JAVA)/ + rm -rf $(FINAL_FOLDER_JAVA)/ @mkdir -p $(FINAL_FOLDER_JAVA_PROJECT)/ + $(FINAL_FILE_ABSTRACTION) : $(EWOL_FOLDER)/Java/PROJECT_NAME.java $(CONFIG_GLOBAL_FILE) @mkdir -p $(dir $@) @cp $(EWOL_FOLDER)/Java/PROJECT_NAME.java $@ - @sed -i "s|__PROJECT_ORG_TYPE__|$(CONFIG___EWOL_APPL_ORGANISATION_TYPE__)|" $@ - @sed -i "s|__PROJECT_VENDOR__|$(PROJECT_VENDOR)|" $@ - @sed -i "s|__PROJECT_NAME__|$(PROJECT_NAME)|" $@ - @sed -i "s|__PROJECT_PACKAGE__|$(PROJECT_PACKAGE)|" $@ - #ifeq ("$(CONFIG___VIDEO__OPENGL_ES_2)","y") + @sed -i "s|__PROJECT_ORG_TYPE__|$(CONFIG2___EWOL_APPL_ORGANISATION_TYPE__)|" $@ + @sed -i "s|__PROJECT_VENDOR__|$(CONFIG2___EWOL_APPL_COMPAGNY__)|" $@ + @sed -i "s|__PROJECT_NAME__|$(CONFIG2___EWOL_APPL_NAME__)|" $@ + @sed -i "s|__PROJECT_PACKAGE__|$(CONFIG2___EWOL_APPL_NAME__)|" $(EWOL_TMP_PATH)/$@ +ifeq ("$(CONFIG___VIDEO__OPENGL_ES_2)","y") @sed -i "s|__CONF_OGL_ES_V__|2|" $@ - #else - #@sed -i "s|__CONF_OGL_ES_V__|1|" $@ - #endif +else + @sed -i "s|__CONF_OGL_ES_V__|1|" $@ +endif +APPL_VERSION:=$(shell git describe --tags) +# --abbrev=0) + + $(FINAL_FOLDER_JAVA)/AndroidManifest.xml : $(CONFIG_GLOBAL_FILE) @echo "AndroidManifest.xml <== configFile" @echo " " > $@ @echo "" >> $@ @echo "> $@ - # TODO ... - @echo " package=\"$(CONFIG___EWOL_APPL_ORGANISATION_TYPE__).$(PROJECT_VENDOR).$(PROJECT_NAME)\" " >> $@ - # TODO ... + @echo " package=\"$(CONFIG2___EWOL_APPL_ORGANISATION_TYPE__).$(CONFIG2___EWOL_APPL_COMPAGNY__).$(CONFIG2___EWOL_APPL_NAME__)\" " >> $@ @echo " android:versionCode=\"1\" " >> $@ - # TODO ... - @echo " android:versionName=\"1.0\"> " >> $@ + @echo " android:versionName=\"$(APPL_VERSION)\"> " >> $@ ifeq ("$(CONFIG___VIDEO__OPENGL_ES_2)","y") @echo " " >> $@ - @echo " " >> $@ + @echo " " >> $@ endif @echo " " >> $@ @echo " " >> $@ @echo " " >> $@ - # TODO ... @echo " > $@ - @echo " android:icon=\"@$(CONFIG___EWOL_ANDROID_ICON__)\"> " >> $@ - # TODO ... - @echo " > $@ - # TODO ... +ifneq ("$(wildcard ./$(CONFIG2___EWOL_ANDROID_ICON__).png)","") + @mkdir -p $(FINAL_FOLDER_JAVA)/res/drawable/ + @cp ./$(CONFIG2___EWOL_ANDROID_ICON__).png $(FINAL_FOLDER_JAVA)/res/drawable/icon.png + @echo " android:icon=\"@drawable/icon\" " >> $@ +endif + @echo " > " >> $@ + @echo " > $@ @echo " android:label=\"$(CONFIG___EWOL_APPL_BASIC_TITLE__)\" " >> $@ - @echo " android:icon=\"@$(CONFIG___EWOL_ANDROID_ICON__)\" " >> $@ +ifneq ("$(wildcard ./$(CONFIG2___EWOL_ANDROID_ICON__).png)","") + @echo " android:icon=\"@drawable/icon\" " >> $@ +endif @echo " android:configChanges=\"orientation\"> " >> $@ @echo " " >> $@ @echo " " >> $@ @@ -111,10 +123,7 @@ endif @echo " " >> $@ final : javaclean $(FINAL_FILE_ABSTRACTION) $(FINAL_FOLDER_JAVA)/AndroidManifest.xml - - @#echo "AndroidManifest.xml <== os-Android/AndroidManifest.xml" - @#cp os-Android/AndroidManifest.xml $(FINAL_FOLDER_JAVA)/ - @cp -r os-Android/res $(FINAL_FOLDER_JAVA)/res + @mkdir -p $(FINAL_FOLDER_JAVA)/res/ @echo ".apk/assets/ <== assets" @mkdir -p $(FINAL_FOLDER_JAVA)/data/assets/ @@ -123,7 +132,7 @@ final : javaclean $(FINAL_FILE_ABSTRACTION) $(FINAL_FOLDER_JAVA)/AndroidManifest @echo ".apk/lib/armeabi/ <== *.so" @mkdir -p $(FINAL_FOLDER_JAVA)/data/lib/armeabi/ - @cp $(TARGET_OUT_STAGING)/usr/lib/$(PROJECT_PACKAGE).so $(FINAL_FOLDER_JAVA)/data/lib/armeabi/lib$(PROJECT_PACKAGE).so + @cp $(TARGET_OUT_STAGING)/usr/lib/$(CONFIG2___EWOL_APPL_NAME__).so $(FINAL_FOLDER_JAVA)/data/lib/armeabi/lib$(CONFIG2___EWOL_APPL_NAME__).so @# Doc : @# http://asantoso.wordpress.com/2009/09/15/how-to-build-android-application-package-apk-from-the-command-line-using-the-sdk-tools-continuously-integrated-using-cruisecontrol/ @@ -152,28 +161,28 @@ final : javaclean $(FINAL_FILE_ABSTRACTION) $(FINAL_FOLDER_JAVA)/AndroidManifest @echo ".dex <== .class" @$(PROJECT_SDK)/platform-tools/dx \ --dex --no-strict \ - --output=$(FINAL_FOLDER_JAVA)/build/$(PROJECT_PACKAGE).dex \ + --output=$(FINAL_FOLDER_JAVA)/build/$(CONFIG2___EWOL_APPL_NAME__).dex \ $(FINAL_FOLDER_JAVA)/build/classes/ @echo ".apk <== .dex, assets, .so, res" @$(PROJECT_SDK)/tools/apkbuilder \ - $(FINAL_FOLDER_JAVA)/build/$(PROJECT_PACKAGE)-unalligned.apk \ + $(FINAL_FOLDER_JAVA)/build/$(CONFIG2___EWOL_APPL_NAME__)-unalligned.apk \ -u \ -z $(FINAL_FOLDER_JAVA)/resources.res \ - -f $(FINAL_FOLDER_JAVA)/build/$(PROJECT_PACKAGE).dex \ + -f $(FINAL_FOLDER_JAVA)/build/$(CONFIG2___EWOL_APPL_NAME__).dex \ -rf $(FINAL_FOLDER_JAVA)/data @# doc : @# http://developer.android.com/tools/publishing/app-signing.html @# keytool is situated in $(JAVA_HOME)/bin ... - $(if $(wildcard ./$(PROJECT_NAME)-$(BUILD_DIRECTORY_MODE).jks),$(empty), \ - @echo "./$(PROJECT_NAME).jks <== dynamic key (NOTE : It might ask some question to generate the key for android)" ; \ + $(if $(wildcard ./$(CONFIG2___EWOL_APPL_NAME__)-$(BUILD_DIRECTORY_MODE).jks),$(empty), \ + @echo "./$(CONFIG2___EWOL_APPL_NAME__).jks <== dynamic key (NOTE : It might ask some question to generate the key for android)" ; \ keytool -genkeypair -v \ - -keystore ./$(PROJECT_NAME)-$(BUILD_DIRECTORY_MODE).jks \ - -storepass Pass$(PROJECT_NAME) \ - -alias alias$(PROJECT_NAME) \ - -keypass PassK$(PROJECT_NAME) \ + -keystore ./$(CONFIG2___EWOL_APPL_NAME__)-$(BUILD_DIRECTORY_MODE).jks \ + -storepass Pass$(CONFIG2___EWOL_APPL_NAME__) \ + -alias alias$(CONFIG2___EWOL_APPL_NAME__) \ + -keypass PassK$(CONFIG2___EWOL_APPL_NAME__) \ -keyalg RSA \ -validity 365 \ ) @@ -200,69 +209,35 @@ final : javaclean $(FINAL_FILE_ABSTRACTION) $(FINAL_FOLDER_JAVA)/AndroidManifest @# keytool is situated in $(JAVA_HOME)/bin ... @echo "apk(Signed) <== apk" @#generate the pass file : - @echo "Pass$(PROJECT_NAME)" > tmpPass.boo - @echo "PassK$(PROJECT_NAME)" >> tmpPass.boo + @echo "Pass$(CONFIG2___EWOL_APPL_NAME__)" > tmpPass.boo + @echo "PassK$(CONFIG2___EWOL_APPL_NAME__)" >> tmpPass.boo @# verbose mode : -verbose @jarsigner \ -sigalg MD5withRSA \ -digestalg SHA1 \ - -keystore ./$(PROJECT_NAME)-$(BUILD_DIRECTORY_MODE).jks \ - $(FINAL_FOLDER_JAVA)/build/$(PROJECT_PACKAGE)-unalligned.apk \ - alias$(PROJECT_NAME) \ + -keystore ./$(CONFIG2___EWOL_APPL_NAME__)-$(BUILD_DIRECTORY_MODE).jks \ + $(FINAL_FOLDER_JAVA)/build/$(CONFIG2___EWOL_APPL_NAME__)-unalligned.apk \ + alias$(CONFIG2___EWOL_APPL_NAME__) \ < tmpPass.boo @rm tmpPass.boo @echo "apk(aligned) <== apk" @# verbose mode : -v @zipalign 4 \ - $(FINAL_FOLDER_JAVA)/build/$(PROJECT_PACKAGE)-unalligned.apk \ - $(FINAL_FOLDER_JAVA)/$(PROJECT_PACKAGE).apk - - -FINAL_FOLDER_ANT=$(TARGET_OUT_FINAL)/ant -FINAL_FOLDER_ANT_PROJECT=$(FINAL_FOLDER_ANT)/src/com/$(PROJECT_VENDOR)/$(PROJECT_NAME) -FINAL_FILE_ANT_ABSTRACTION = $(FINAL_FOLDER_JAVA_PROJECT)/$(PROJECT_NAME).java - - -with_ant: - @mkdir -p $(FINAL_FOLDER_ANT_PROJECT)/ - @cp $(EWOL_FOLDER)/Java/PROJECT_NAME.java $(FINAL_FILE_ANT_ABSTRACTION) - @sed -i "s|__PROJECT_VENDOR__|$(PROJECT_VENDOR)|" $(FINAL_FILE_ANT_ABSTRACTION) - @sed -i "s|__PROJECT_NAME__|$(PROJECT_NAME)|" $(FINAL_FILE_ANT_ABSTRACTION) - @sed -i "s|__PROJECT_PACKAGE__|$(PROJECT_PACKAGE)|" $(FINAL_FILE_ANT_ABSTRACTION) - @# copy the Ewol java files : - @mkdir -p $(FINAL_FOLDER_ANT)/src/org/ewol - @cp $(EWOL_FOLDER)/Java/src/org/ewol/interfaceJNI.java $(FINAL_FOLDER_ANT)/src/org/ewol - @cp $(EWOL_FOLDER)/Java/src/org/ewol/interfaceOpenGL.java $(FINAL_FOLDER_ANT)/src/org/ewol/ - @cp $(EWOL_FOLDER)/Java/src/org/ewol/interfaceSurfaceView.java $(FINAL_FOLDER_ANT)/src/org/ewol/ - @cp $(EWOL_FOLDER)/Java/src/org/ewol/interfaceAudio.java $(FINAL_FOLDER_ANT)/src/org/ewol/ - - @# copy android specific data : - @cp -r os-Android/* $(FINAL_FOLDER_ANT)/ - @# copy user data - @mkdir -p $(FINAL_FOLDER_ANT)/assets/ - @cp -r share/* $(FINAL_FOLDER_ANT)/assets/ - @mkdir -p $(FINAL_FOLDER_ANT)/libs/armeabi/ - @# note : this change the lib name ... - @cp $(TARGET_OUT_STAGING)/usr/lib/$(PROJECT_PACKAGE).so $(FINAL_FOLDER_ANT)/libs/armeabi/lib$(PROJECT_PACKAGE).so - @echo " (ant) build java code" - @cd $(FINAL_FOLDER_ANT) ; PATH=$(PROJECT_SDK)/tools/:$(PROJECT_SDK)/platform-tools/:$(PATH) ant -Dsdk.dir=$(PROJECT_SDK) $(BUILD_DIRECTORY_MODE) - @# cp the release package in the final folder to facilitate the find - @cp -f $(FINAL_FOLDER_ANT)/bin/$(PROJECT_NAME)-$(BUILD_DIRECTORY_MODE).apk $(FINAL_FOLDER_JAVA)/$(PROJECT_PACKAGE).apk - - + $(FINAL_FOLDER_JAVA)/build/$(CONFIG2___EWOL_APPL_NAME__)-unalligned.apk \ + $(FINAL_FOLDER_JAVA)/$(CONFIG2___EWOL_APPL_NAME__).apk install: @echo ------------------------------------------------------------------------ - @echo Install : $(TARGET_OUT_FINAL)/$(PROJECT_NAME)-$(BUILD_DIRECTORY_MODE).apk + @echo Install : $(TARGET_OUT_FINAL)/$(CONFIG2___EWOL_APPL_NAME__).apk @echo ------------------------------------------------------------------------ @# $(PROJECT_SDK)/platform-tools/adb kill-server @# install application - sudo $(PROJECT_SDK)/platform-tools/adb install -r $(FINAL_FOLDER_JAVA)/$(PROJECT_PACKAGE).apk + sudo $(PROJECT_SDK)/platform-tools/adb install -r $(FINAL_FOLDER_JAVA)/$(CONFIG2___EWOL_APPL_NAME__).apk uninstall: @echo ------------------------------------------------------------------------ - @echo UnInstall : $(ANDROID_BASIC_FOLDER)bin/$(PROJECT_NAME)-$(BUILD_DIRECTORY_MODE).apk + @echo UnInstall : $(ANDROID_BASIC_FOLDER)bin/$(CONFIG2___EWOL_APPL_NAME__).apk @echo ------------------------------------------------------------------------ @echo ... TODO ... diff --git a/core/defs.mk b/core/defs.mk index 2acf1a1..67583a4 100644 --- a/core/defs.mk +++ b/core/defs.mk @@ -10,6 +10,12 @@ ############################################################################### ## Some useful macros. ############################################################################### + +quote := " +#" +simplequote := ' +#' +coma := , empty := space := $(empty) $(empty) space4 := $(space)$(space)$(space)$(space) @@ -50,6 +56,18 @@ locase = $(shell echo $1 | tr [:upper:] [:lower:]) # $1 : text to convert. get-define = $(strip $(call upcase,$(call tr,$1,-,_))) +# remove many special char of a string ... +# Replace '-' by '_' +# Replace ' ' by '_' +# Replace '"' by '' +# Replace ''' by '' +# $1 : text to convert. +convert-special-char = $(call locase,\ + $(subst $(quote),$(empty),\ + $(subst $(simplequote),$(empty),\ + $(subst -,_,\ + $(subst $(space),_,$1))))) + # Remove quotes from string remove-quotes = $(strip $(subst ",,$1)) #"