chiark / gitweb /
Mostly autogenerating string resources.
authorMark Wooding <mdw@distorted.org.uk>
Tue, 26 Jun 2018 10:09:00 +0000 (11:09 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Tue, 26 Jun 2018 10:09:27 +0000 (11:09 +0100)
AndroidManifest.xml
Makefile
admin.scala
res/values/strings.xml

index 85cac4b..aaa3fc5 100644 (file)
@@ -10,9 +10,9 @@
 
   <application
       android:icon="@drawable/icon"
-      android:label="@string/app_name">
+      android:label="@string/auto_package">
     <activity
-       android:label="@string/app_name"
+       android:label="@string/auto_package"
        android:name=".ToyActivity">
       <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
index c6a85ba..7982820 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -279,6 +279,9 @@ ext-stamp-builddir   = \
 ext-stamp-absprefix     = $(call ext-absprefix,$(call stamp-type,$1))
 ext-stamp-tool          = $(call tool,$(call stamp-type,$1),$2)
 
+$(foreach e,$(EXTERNALS),\
+       $(eval $e_VERSION := $$(shell cd $$(call ext-srcdir,$e) && $$(abs_srcdir)/auto-version)))
+
 EXTSTAMPS               = $(call ext-stamps,$(EXTERNALS),$(FLAVOURS))
 
 $(EXTSTAMPS): \
@@ -404,6 +407,35 @@ $(foreach a,$(APKLIBS), \
 CLEANFILES             += $(OUTDIR)/pkg/lib/*/lib*.so $(OUTDIR)/lib*.so
 
 ###--------------------------------------------------------------------------
+### Android string resource generation.
+
+GENSTRINGS             += package=PACKAGE
+GENSTRINGS             += version=VERSION
+GENSTRINGS             += vsn=VSN
+
+$(foreach e,$(EXTERNALS),\
+       $(eval GENSTRINGS += $e_version=$e_VERSION))
+
+BUILD                  := $(shell uuid -v4)
+GENSTRINGS             += build_uuid=BUILD
+
+genstring-name          = $(firstword $(subst =, ,$1))
+genstring-value                 = $($(word 2,$(subst =, ,$1)))
+
+define gen-strings
+       $(V_AT)mkdir -p $(dir $1)
+       $(call v_tag,GEN)set -e; rm -f $1.new; exec >$1.new; \
+               echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>"; \
+               echo "<resources>"; \
+               $(foreach g,$(GENSTRINGS), \
+                       echo "  <string name=\"auto_$(call genstring-name,$g)\">$(call genstring-value,$g)</string>";) \
+               echo "</resources>"
+       $(V_AT)mv $1.new $1
+endef
+$(OUTDIR)/res.dummy/values/auto.xml: Makefile
+       $(call gen-strings,$@)
+
+###--------------------------------------------------------------------------
 ### Java and Scala building.
 
 JARDIR                  = $(OUTDIR)/jar
@@ -483,12 +515,13 @@ CLEANFILES                += $(OUTDIR)/*.apk
 
 AAPTFLAGS               = \
        --min-sdk-version $(MINAPI) --target-sdk-version $(TARGETAPI) \
-       --version-name "$(VERSION)" --version-code $(VSN)
+       --version-name "$(VERSION)" --version-code $(VSN) --auto-add-overlay
 
-$(OUTDIR)/src/R.java: AndroidManifest.xml
+$(OUTDIR)/src/R.java: AndroidManifest.xml $(OUTDIR)/res.dummy/values/auto.xml
        $(V_AT)mkdir -p $(dir $@)
        $(call v_tag,AAPT)aapt package $(AAPTFLAGS) \
-               -M AndroidManifest.xml -S res/ -I $(ANDROID_JAR) \
+               -M AndroidManifest.xml -S res/ -S $(OUTDIR)/res.dummy/ \
+               -I $(ANDROID_JAR) \
                -J $(dir $@) --generate-dependencies
 CLEANFILES             += $(OUTDIR)/src/R.java $(OUTDIR)/src/R.java.d
 -include $(OUTDIR)/src/R.java.d
@@ -518,11 +551,14 @@ $(OUTDIR)/pkg/classes.dex: $(CLASSSTAMPS) $(DEXJARS)
        $(V_AT)mkdir -p $(dir $@)
        $(call v_tag,DX)dx --dex --output=$@ $(CLASSDIR) $(JARDIR)
 
+$(OUTDIR)/res.volatile/values/auto.xml: $(INSTFILES)
+       $(call gen-strings,$@)
+
 $(foreach v,$(VARIANTS),$(OUTDIR)/tripe-$v.unsigned.apk): \
-$(OUTDIR)/tripe-%.unsigned.apk: $(INSTFILES)
+$(OUTDIR)/tripe-%.unsigned.apk: $(INSTFILES) $(OUTDIR)/res.volatile/values/auto.xml
        $(call v_tag,AAPT)aapt package -f $(AAPTFLAGS) $(AAPTFLAGS.$*) \
-               -M AndroidManifest.xml -S res/ -I $(ANDROID_JAR) \
-               -F $@ $(OUTDIR)/pkg/
+               -M AndroidManifest.xml -S res/ -S $(OUTDIR)/res.volatile/ \
+               -I $(ANDROID_JAR) -F $@ $(OUTDIR)/pkg/
 
 $(foreach v,$(VARIANTS),$(OUTDIR)/tripe-$v.signed.apk): \
 $(OUTDIR)/tripe-%.signed.apk: $(OUTDIR)/tripe-%.unsigned.apk $$(KEYSTORE.$$*)
index 321fb56..9796cd9 100644 (file)
@@ -113,7 +113,7 @@ object Connection extends Hook[AsyncMessage]
     override def next(): Seq[String] = {
       fetchNext();
       nextmsg match {
-       case None => ???
+       case None => unreachable;
        case Some(JobOK) => throw new NoSuchElementException;
        case Some(JobFail(msg)) => throw new CommandFailed(msg);
        case Some(JobLostConnection) => throw new ConnectionLostException;
index ea80ce2..b2df1e1 100644 (file)
@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 
 <resources>
-  <string name="app_name">TrIPE</string>
   <string name="toy_greeting">Hello, world!</string>
   <string name="toy_ok">OK</string>
 </resources>