mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-31 07:53:36 +00:00
ANDROID: Allow out-of-src-tree builds, cleanup
- move all android specific make stuff from module.mk to android.mk - don't create automatically generated files in the source tree - don't fail when building outside of the source tree - clean android build files on "make clean" - cleanup
This commit is contained in:
parent
57bc9b3f95
commit
29d1df94db
5
.gitignore
vendored
5
.gitignore
vendored
@ -22,9 +22,6 @@ lib*.a
|
||||
/.project
|
||||
/.cproject
|
||||
|
||||
/backends/platform/android/org/inodes/gus/scummvm/R.java
|
||||
/backends/platform/android/org/inodes/gus/scummvm/Manifest.java
|
||||
|
||||
/backends/platform/dc/gui
|
||||
/backends/platform/dc/graphics
|
||||
/backends/platform/dc/sound
|
||||
@ -142,4 +139,4 @@ _ReSharper*/
|
||||
|
||||
#Ignore default Visual Studio build folders
|
||||
[Dd]ebug/
|
||||
[Rr]elease/
|
||||
[Rr]elease/
|
||||
|
@ -1,59 +1,173 @@
|
||||
# Android specific build targets
|
||||
|
||||
AAPT = aapt
|
||||
DX = dx
|
||||
APKBUILDER = apkbuilder
|
||||
ADB = adb -e
|
||||
JAVAC ?= javac
|
||||
JAVACFLAGS = -source 1.5 -target 1.5
|
||||
# These must be incremented for each market upload
|
||||
#ANDROID_VERSIONCODE = 6 Specified in dists/android/AndroidManifest.xml.in
|
||||
ANDROID_PLUGIN_VERSIONCODE = 6
|
||||
|
||||
JAVA_FILES = \
|
||||
ScummVM.java \
|
||||
ScummVMApplication.java \
|
||||
ScummVMActivity.java \
|
||||
EditableSurfaceView.java \
|
||||
Unpacker.java
|
||||
|
||||
JAVA_FILES_PLUGIN = \
|
||||
PluginProvider.java
|
||||
|
||||
JAVA_FILES_GEN = \
|
||||
Manifest.java \
|
||||
R.java
|
||||
|
||||
PATH_DIST = $(srcdir)/dists/android
|
||||
PATH_RESOURCES = $(PATH_DIST)/res
|
||||
|
||||
RESOURCES = \
|
||||
$(PATH_RESOURCES)/values/strings.xml \
|
||||
$(PATH_RESOURCES)/layout/main.xml \
|
||||
$(PATH_RESOURCES)/layout/splash.xml \
|
||||
$(PATH_RESOURCES)/drawable/gradient.xml \
|
||||
$(PATH_RESOURCES)/drawable/scummvm.png \
|
||||
$(PATH_RESOURCES)/drawable/scummvm_big.png
|
||||
|
||||
PLUGIN_RESOURCES = \
|
||||
$(PATH_RESOURCES)/values/strings.xml \
|
||||
$(PATH_RESOURCES)/drawable/scummvm.png
|
||||
|
||||
# FIXME: find/mark plugin entry points and add all this back again:
|
||||
#LDFLAGS += -Wl,--gc-sections
|
||||
#CXXFLAGS += -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden
|
||||
|
||||
resources.ap_: $(srcdir)/dists/android/AndroidManifest.xml $(RESOURCES) $(ASSETS) $(ANDROID_JAR8) $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA)
|
||||
$(INSTALL) -d build.tmp/assets/
|
||||
$(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) build.tmp/assets/
|
||||
$(AAPT) package -f -M $< -S $(srcdir)/dists/android/res -A build.tmp/assets -I $(ANDROID_JAR8) -F $@
|
||||
AAPT = $(ANDROID_SDK)/platform-tools/aapt
|
||||
ADB = $(ANDROID_SDK)/platform-tools/adb
|
||||
DX = $(ANDROID_SDK)/platform-tools/dx
|
||||
APKBUILDER = $(ANDROID_SDK)/tools/apkbuilder
|
||||
JAVAC ?= javac
|
||||
JAVACFLAGS = -source 1.5 -target 1.5
|
||||
|
||||
build.tmp/%/resources.ap_: build.tmp/%/AndroidManifest.xml build.stage/%/res/values/strings.xml build.stage/%/res/drawable/scummvm.png $(ANDROID_JAR8)
|
||||
$(AAPT) package -f -M $< -S build.stage/$*/res -I $(ANDROID_JAR8) -F $@
|
||||
# This is a bit silly. I want to compile against the 1.6 android.jar,
|
||||
# to make the compiler check that I don't use something that requires
|
||||
# a newer Android. However, in order to use android:installLocation,
|
||||
# we need to give aapt a version >=8 android.jar - even though the
|
||||
# result will work ok on 1.5+.
|
||||
ANDROID_JAR = $(ANDROID_SDK)/platforms/android-4/android.jar
|
||||
ANDROID_JAR8 = $(ANDROID_SDK)/platforms/android-8/android.jar
|
||||
|
||||
scummvm.apk: build.tmp/libscummvm.so resources.ap_ classes.dex
|
||||
# Package installer won't delete old libscummvm.so on upgrade so
|
||||
# replace it with a zero size file
|
||||
$(INSTALL) -d build.stage/common/lib/armeabi
|
||||
touch build.stage/common/lib/armeabi/libscummvm.so
|
||||
# We now handle the library unpacking ourselves from mylib/
|
||||
$(INSTALL) -d build.stage/common/mylib/armeabi
|
||||
$(INSTALL) -c -m 644 build.tmp/libscummvm.so build.stage/common/mylib/armeabi/
|
||||
$(STRIP) build.stage/common/mylib/armeabi/libscummvm.so
|
||||
# "-nf lib/armeabi/libscummvm.so" builds bogus paths?
|
||||
$(APKBUILDER) $@ -z resources.ap_ -f classes.dex -rf build.stage/common || { $(RM) $@; exit 1; }
|
||||
PATH_BUILD = build.tmp
|
||||
PATH_BUILD_ASSETS = $(PATH_BUILD)/assets
|
||||
PATH_BUILD_CLASSES_MAIN_TOP = $(PATH_BUILD)/classes.main
|
||||
PATH_BUILD_CLASSES_PLUGIN_TOP = $(PATH_BUILD)/classes.plugin
|
||||
|
||||
scummvm-engine-%.apk: plugins/lib%.so build.tmp/%/resources.ap_ build.tmp/plugins/classes.dex
|
||||
$(INSTALL) -d build.stage/$*/apk/mylib/armeabi/
|
||||
$(INSTALL) -c -m 644 plugins/lib$*.so build.stage/$*/apk/mylib/armeabi/
|
||||
$(STRIP) build.stage/$*/apk/mylib/armeabi/lib$*.so
|
||||
$(APKBUILDER) $@ -z build.tmp/$*/resources.ap_ -f build.tmp/plugins/classes.dex -rf build.stage/$*/apk || { $(RM) $@; exit 1; }
|
||||
PATH_STAGE_PREFIX = build.stage
|
||||
PATH_STAGE_MAIN = $(PATH_STAGE_PREFIX).main
|
||||
|
||||
PATH_REL = org/inodes/gus/scummvm
|
||||
PATH_SRC_TOP = $(srcdir)/backends/platform/android
|
||||
PATH_SRC = $(PATH_SRC_TOP)/$(PATH_REL)
|
||||
|
||||
PATH_GEN_TOP = $(PATH_BUILD)/java
|
||||
PATH_GEN = $(PATH_GEN_TOP)/$(PATH_REL)
|
||||
PATH_CLASSES_MAIN = $(PATH_BUILD_CLASSES_MAIN_TOP)/$(PATH_REL)
|
||||
PATH_CLASSES_PLUGIN = $(PATH_BUILD_CLASSES_PLUGIN_TOP)/$(PATH_REL)
|
||||
|
||||
FILE_MANIFEST = $(srcdir)/dists/android/AndroidManifest.xml
|
||||
FILE_DEX = $(PATH_BUILD)/classes.dex
|
||||
FILE_DEX_PLUGIN = $(PATH_BUILD)/plugins/classes.dex
|
||||
FILE_RESOURCES = resources.ap_
|
||||
FILE_RESOURCES_MAIN = $(PATH_BUILD)/$(FILE_RESOURCES)
|
||||
|
||||
SRC_GEN = $(addprefix $(PATH_GEN)/, $(JAVA_FILES_GEN))
|
||||
|
||||
CLASSES_MAIN = $(addprefix $(PATH_CLASSES_MAIN)/, $(JAVA_FILES:%.java=%.class))
|
||||
CLASSES_GEN = $(addprefix $(PATH_CLASSES_MAIN)/, $(JAVA_FILES_GEN:%.java=%.class))
|
||||
CLASSES_PLUGIN = $(addprefix $(PATH_CLASSES_PLUGIN)/, $(JAVA_FILES_PLUGIN:%.java=%.class))
|
||||
|
||||
APK_MAIN = scummvm.apk
|
||||
APK_PLUGINS = $(patsubst plugins/lib%.so, scummvm-engine-%.apk, $(PLUGINS))
|
||||
|
||||
$(SRC_GEN): $(FILE_MANIFEST) $(filter %.xml,$(RESOURCES)) $(ANDROID_JAR8)
|
||||
@$(MKDIR) -p $(PATH_GEN_TOP)
|
||||
$(AAPT) package -m -J $(PATH_GEN_TOP) -M $< -S $(PATH_RESOURCES) -I $(ANDROID_JAR8)
|
||||
|
||||
$(PATH_CLASSES_MAIN)/%.class: $(PATH_GEN)/%.java $(SRC_GEN)
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(JAVAC) $(JAVACFLAGS) -cp $(PATH_SRC_TOP) -d $(PATH_BUILD_CLASSES_MAIN_TOP) -bootclasspath $(ANDROID_JAR) $<
|
||||
|
||||
$(PATH_CLASSES_MAIN)/%.class: $(PATH_SRC)/%.java $(SRC_GEN)
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(JAVAC) $(JAVACFLAGS) -cp $(PATH_SRC_TOP):$(PATH_GEN_TOP) -d $(PATH_BUILD_CLASSES_MAIN_TOP) -bootclasspath $(ANDROID_JAR) $<
|
||||
|
||||
$(PATH_CLASSES_PLUGIN)/%.class: $(PATH_SRC)/%.java
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(JAVAC) $(JAVACFLAGS) -cp $(PATH_SRC_TOP) -d $(PATH_BUILD_CLASSES_PLUGIN_TOP) -bootclasspath $(ANDROID_JAR) $<
|
||||
|
||||
$(FILE_DEX): $(CLASSES_MAIN) $(CLASSES_GEN)
|
||||
$(DX) --dex --output=$@ $(PATH_BUILD_CLASSES_MAIN_TOP)
|
||||
|
||||
$(FILE_DEX_PLUGIN): $(CLASSES_PLUGIN)
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(DX) --dex --output=$@ $(PATH_BUILD_CLASSES_PLUGIN_TOP)
|
||||
|
||||
$(PATH_BUILD)/%/AndroidManifest.xml $(PATH_STAGE_PREFIX).%/res/values/strings.xml: $(PATH_DIST)/mkmanifest.pl $(srcdir)/configure $(PATH_DIST)/AndroidManifest.xml
|
||||
$(PATH_DIST)/mkmanifest.pl --id=$* --configure=$(srcdir)/configure \
|
||||
--version-name=$(VERSION) \
|
||||
--version-code=$(ANDROID_PLUGIN_VERSIONCODE) \
|
||||
--stringres=$(PATH_STAGE_PREFIX).$*/res/values/strings.xml \
|
||||
--manifest=$(PATH_BUILD)/$*/AndroidManifest.xml \
|
||||
--master-manifest=$(PATH_DIST)/AndroidManifest.xml \
|
||||
--unpacklib=mylib/armeabi/lib$*.so
|
||||
|
||||
$(PATH_STAGE_PREFIX).%/res/drawable/scummvm.png: $(PATH_RESOURCES)/drawable/scummvm.png
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(CP) $< $@
|
||||
|
||||
$(FILE_RESOURCES_MAIN): $(FILE_MANIFEST) $(RESOURCES) $(ANDROID_JAR8) $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA)
|
||||
$(INSTALL) -d $(PATH_BUILD_ASSETS)
|
||||
$(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) $(PATH_BUILD_ASSETS)/
|
||||
$(AAPT) package -f -M $< -S $(PATH_RESOURCES) -A $(PATH_BUILD_ASSETS) -I $(ANDROID_JAR8) -F $@
|
||||
|
||||
$(PATH_BUILD)/%/$(FILE_RESOURCES): $(PATH_BUILD)/%/AndroidManifest.xml $(PATH_STAGE_PREFIX).%/res/values/strings.xml $(PATH_STAGE_PREFIX).%/res/drawable/scummvm.png $(ANDROID_JAR8)
|
||||
$(AAPT) package -f -M $< -S $(PATH_STAGE_PREFIX).$*/res -I $(ANDROID_JAR8) -F $@
|
||||
|
||||
# Package installer won't delete old libscummvm.so on upgrade so
|
||||
# replace it with a zero size file
|
||||
$(APK_MAIN): $(EXECUTABLE) $(FILE_RESOURCES_MAIN) $(FILE_DEX)
|
||||
$(INSTALL) -d $(PATH_STAGE_MAIN)/common/lib/armeabi
|
||||
touch $(PATH_STAGE_MAIN)/common/lib/armeabi/libscummvm.so
|
||||
$(INSTALL) -d $(PATH_STAGE_MAIN)/common/mylib/armeabi
|
||||
$(INSTALL) -c -m 644 libscummvm.so $(PATH_STAGE_MAIN)/common/mylib/armeabi/
|
||||
$(STRIP) $(PATH_STAGE_MAIN)/common/mylib/armeabi/libscummvm.so
|
||||
$(APKBUILDER) $@ -z $(FILE_RESOURCES_MAIN) -f $(FILE_DEX) -rf $(PATH_STAGE_MAIN)/common || { $(RM) $@; exit 1; }
|
||||
|
||||
scummvm-engine-%.apk: plugins/lib%.so $(PATH_BUILD)/%/$(FILE_RESOURCES) $(FILE_DEX_PLUGIN)
|
||||
$(INSTALL) -d $(PATH_STAGE_PREFIX).$*/apk/mylib/armeabi/
|
||||
$(INSTALL) -c -m 644 plugins/lib$*.so $(PATH_STAGE_PREFIX).$*/apk/mylib/armeabi/
|
||||
$(STRIP) $(PATH_STAGE_PREFIX).$*/apk/mylib/armeabi/lib$*.so
|
||||
$(APKBUILDER) $@ -z $(PATH_BUILD)/$*/$(FILE_RESOURCES) -f $(FILE_DEX_PLUGIN) -rf $(PATH_STAGE_PREFIX).$*/apk || { $(RM) $@; exit 1; }
|
||||
|
||||
all: $(APK_MAIN) $(APK_PLUGINS)
|
||||
|
||||
clean: androidclean
|
||||
|
||||
androidclean:
|
||||
@$(RM) -rf $(PATH_BUILD) $(PATH_STAGE_PREFIX).* *.apk release
|
||||
|
||||
# remove debugging signature
|
||||
release/%.apk: %.apk
|
||||
@$(MKDIR) -p $(@D)
|
||||
@$(RM) $@
|
||||
$(CP) $< $@.tmp
|
||||
# remove debugging signature
|
||||
zip -d $@.tmp META-INF/\*
|
||||
jarsigner $(JARSIGNER_FLAGS) $@.tmp release
|
||||
zipalign 4 $@.tmp $@
|
||||
$(RM) $@.tmp
|
||||
|
||||
androidrelease: release/scummvm.apk $(patsubst plugins/lib%.so,release/scummvm-engine-%.apk,$(PLUGINS))
|
||||
androidrelease: $(addprefix release/, $(APK_MAIN) $(APK_PLUGINS))
|
||||
|
||||
androidtest: scummvm.apk scummvm-engine-scumm.apk scummvm-engine-kyra.apk
|
||||
androidtest: $(APK_MAIN) $(APK_PLUGINS)
|
||||
@set -e; for apk in $^; do \
|
||||
echo $(ADB) install -r $$apk; \
|
||||
$(ADB) install -r $$apk; \
|
||||
done
|
||||
$(ADB) shell am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n org.inodes.gus.scummvm/.Unpacker
|
||||
|
||||
.PHONY: androidrelease androidtest
|
||||
|
||||
|
@ -1,84 +1,12 @@
|
||||
MODULE := backends/platform/android
|
||||
|
||||
MODULE_OBJS := \
|
||||
android.o asset-archive.o video.o
|
||||
android.o \
|
||||
asset-archive.o \
|
||||
video.o
|
||||
|
||||
# We don't use rules.mk but rather manually update OBJS and MODULE_DIRS.
|
||||
MODULE_OBJS := $(addprefix $(MODULE)/, $(MODULE_OBJS))
|
||||
OBJS := $(MODULE_OBJS) $(OBJS)
|
||||
MODULE_DIRS += $(sort $(dir $(MODULE_OBJS)))
|
||||
|
||||
JAVA_SRC = \
|
||||
$(MODULE)/org/inodes/gus/scummvm/ScummVM.java \
|
||||
$(MODULE)/org/inodes/gus/scummvm/ScummVMApplication.java \
|
||||
$(MODULE)/org/inodes/gus/scummvm/ScummVMActivity.java \
|
||||
$(MODULE)/org/inodes/gus/scummvm/EditableSurfaceView.java \
|
||||
$(MODULE)/org/inodes/gus/scummvm/Unpacker.java \
|
||||
$(MODULE)/org/inodes/gus/scummvm/Manifest.java \
|
||||
$(MODULE)/org/inodes/gus/scummvm/R.java
|
||||
|
||||
JAVA_PLUGIN_SRC = \
|
||||
$(MODULE)/org/inodes/gus/scummvm/PluginProvider.java
|
||||
|
||||
RESOURCES = \
|
||||
$(srcdir)/dists/android/res/values/strings.xml \
|
||||
$(srcdir)/dists/android/res/layout/main.xml \
|
||||
$(srcdir)/dists/android/res/layout/splash.xml \
|
||||
$(srcdir)/dists/android/res/drawable/gradient.xml \
|
||||
$(srcdir)/dists/android/res/drawable/scummvm.png \
|
||||
$(srcdir)/dists/android/res/drawable/scummvm_big.png
|
||||
|
||||
ASSETS = $(DIST_FILES_ENGINEDATA) $(DIST_FILES_THEMES)
|
||||
|
||||
PLUGIN_RESOURCES = \
|
||||
$(srcdir)/dists/android/res/values/strings.xml \
|
||||
$(srcdir)/dists/android/res/drawable/scummvm.png
|
||||
|
||||
# These must be incremented for each market upload
|
||||
#ANDROID_VERSIONCODE = 6 Specified in dists/android/AndroidManifest.xml.in
|
||||
ANDROID_PLUGIN_VERSIONCODE = 6
|
||||
|
||||
# This is a bit silly. I want to compile against the 1.6 android.jar,
|
||||
# to make the compiler check that I don't use something that requires
|
||||
# a newer Android. However, in order to use android:installLocation,
|
||||
# we need to give aapt a version >=8 android.jar - even though the
|
||||
# result will work ok on 1.5+.
|
||||
ANDROID_JAR = $(ANDROID_SDK)/platforms/android-1.5/android.jar
|
||||
ANDROID_JAR8 = $(ANDROID_SDK)/platforms/android-8/android.jar
|
||||
|
||||
# This library contains scummvm proper
|
||||
build.tmp/libscummvm.so: $(OBJS)
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(QUIET_LINK)$(CXX) -shared $(LDFLAGS) -Wl,-Bsymbolic -Wl,-soname,$(@F) -Wl,--no-undefined -o $@ $(PRE_OBJS_FLAGS) $(OBJS) $(POST_OBJS_FLAGS) $(LIBS)
|
||||
|
||||
|
||||
backends/platform/android/org/inodes/gus/scummvm/R.java backends/platform/android/org/inodes/gus/scummvm/Manifest.java: $(srcdir)/dists/android/AndroidManifest.xml $(filter %.xml,$(RESOURCES)) $(ANDROID_JAR8)
|
||||
$(AAPT) package -m -J backends/platform/android -M $< -S $(srcdir)/dists/android/res -I $(ANDROID_JAR8)
|
||||
|
||||
build.tmp/classes/%.class: $(srcdir)/backends/platform/android/%.java $(srcdir)/backends/platform/android/org/inodes/gus/scummvm/R.java
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(JAVAC) $(JAVACFLAGS) -cp $(srcdir)/backends/platform/android -d build.tmp/classes -bootclasspath $(ANDROID_JAR) $<
|
||||
|
||||
build.tmp/classes.plugin/%.class: $(srcdir)/backends/platform/android/%.java
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(JAVAC) $(JAVACFLAGS) -cp $(srcdir)/backends/platform/android -d build.tmp/classes.plugin -bootclasspath $(ANDROID_JAR) $<
|
||||
|
||||
classes.dex: $(JAVA_SRC:backends/platform/android/%.java=build.tmp/classes/%.class)
|
||||
$(DX) --dex --output=$@ build.tmp/classes
|
||||
|
||||
build.tmp/plugins/classes.dex: $(JAVA_PLUGIN_SRC:backends/platform/android/%.java=build.tmp/classes.plugin/%.class)
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(DX) --dex --output=$@ build.tmp/classes.plugin
|
||||
|
||||
build.tmp/%/AndroidManifest.xml build.stage/%/res/values/strings.xml: dists/android/mkmanifest.pl configure dists/android/AndroidManifest.xml
|
||||
dists/android/mkmanifest.pl --id=$* --configure=configure \
|
||||
--version-name=$(VERSION) \
|
||||
--version-code=$(ANDROID_PLUGIN_VERSIONCODE) \
|
||||
--stringres=build.stage/$*/res/values/strings.xml \
|
||||
--manifest=build.tmp/$*/AndroidManifest.xml \
|
||||
--master-manifest=dists/android/AndroidManifest.xml \
|
||||
--unpacklib=mylib/armeabi/lib$*.so
|
||||
|
||||
build.stage/%/res/drawable/scummvm.png: dists/android/res/drawable/scummvm.png
|
||||
@$(MKDIR) -p $(@D)
|
||||
$(CP) $< $@
|
||||
|
Loading…
x
Reference in New Issue
Block a user