aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPo Lu2024-06-12 13:52:33 +0800
committerPo Lu2024-06-12 13:52:33 +0800
commit5fc75b051fc623a4f614a7abe09f08d127ed9ccd (patch)
treec67cc99644aff4dba521d5f0923c218923e43d27
parenta300db7ad4a16dc39bf1793c2e61f75145337ec6 (diff)
downloademacs-5fc75b051fc623a4f614a7abe09f08d127ed9ccd.tar.gz
emacs-5fc75b051fc623a4f614a7abe09f08d127ed9ccd.zip
Improve compression of Emacs packages on Android 2.2
* configure.ac (ZIP): Search for a `zip' executable and substitute the same if targeting SDK 8. * java/INSTALL: Document new requirement. * java/Makefile.in (GZIP_PROG, ZIP): New substitutions. (.PHONY): Delete references to directory-tree. (install_temp): On SDK 8 and earlier, compress large *.el and Info files with gzip, and divide install_temp into three separate directories, with one for large files, another for gzipped files, and one more for the remainder. (install_temp/assets/directory-tree, install_temp/assets/version) (install_temp/assets/build_info): Merge these rules into install_tmp, that they may execute before the assets directory is split. (emacs.apk-in): Package each directory separately, accounting for their varied compression requirements. * lisp/term/android-win.el (input-decode-map): Define select to return in input-decode-map.
-rw-r--r--configure.ac6
-rw-r--r--java/INSTALL11
-rw-r--r--java/Makefile.in120
-rw-r--r--lisp/term/android-win.el3
4 files changed, 109 insertions, 31 deletions
diff --git a/configure.ac b/configure.ac
index 1754ca4f977..f75c0a98820 100644
--- a/configure.ac
+++ b/configure.ac
@@ -878,6 +878,7 @@ AC_ARG_VAR([JAVAC], [Java compiler path. Used for Android.])
878AC_ARG_VAR([JARSIGNER], [Java package signer path. Used for Android.]) 878AC_ARG_VAR([JARSIGNER], [Java package signer path. Used for Android.])
879AC_ARG_VAR([APKSIGNER], [Android package signer path. Used for Android.]) 879AC_ARG_VAR([APKSIGNER], [Android package signer path. Used for Android.])
880AC_ARG_VAR([SDK_BUILD_TOOLS], [Path to the Android SDK build tools.]) 880AC_ARG_VAR([SDK_BUILD_TOOLS], [Path to the Android SDK build tools.])
881AC_ARG_VAR([ZIP], [Path to the `zip' utility.])
881 882
882if test "$with_android" = "yes"; then 883if test "$with_android" = "yes"; then
883 AC_MSG_ERROR([Please specify the path to the Android.jar file, like so: 884 AC_MSG_ERROR([Please specify the path to the Android.jar file, like so:
@@ -1223,8 +1224,13 @@ package will likely install on older systems but crash on startup.])
1223 ANDROID_SDK_8_OR_EARLIER= 1224 ANDROID_SDK_8_OR_EARLIER=
1224 if test "$android_sdk" -le "8"; then 1225 if test "$android_sdk" -le "8"; then
1225 ANDROID_SDK_8_OR_EARLIER=yes 1226 ANDROID_SDK_8_OR_EARLIER=yes
1227 AC_CHECK_PROGS([ZIP], [zip])
1228 AS_IF([test -z "$ZIP"],
1229 [AC_MSG_ERROR([The `zip' utility is required for generating \
1230packages targeting Android 2.2.])])
1226 fi 1231 fi
1227 AC_SUBST([ANDROID_SDK_8_OR_EARLIER]) 1232 AC_SUBST([ANDROID_SDK_8_OR_EARLIER])
1233 AC_SUBST([ZIP])
1228 1234
1229 # Save confdefs.h and config.log for now. 1235 # Save confdefs.h and config.log for now.
1230 mv -f confdefs.h _confdefs.h 1236 mv -f confdefs.h _confdefs.h
diff --git a/java/INSTALL b/java/INSTALL
index 1d6f1535647..91916c6586c 100644
--- a/java/INSTALL
+++ b/java/INSTALL
@@ -158,10 +158,13 @@ the NDK r10b or later. We wanted to make Emacs work on even older
158versions of Android, but they are missing the required JNI graphics 158versions of Android, but they are missing the required JNI graphics
159library that allows Emacs to display text from C code. 159library that allows Emacs to display text from C code.
160 160
161Due to an extremely nasty bug in the Android 2.2 system, the generated 161There is an extremely nasty bug in the Android 2.2 system, the upshot of
162Emacs package cannot be compressed in builds for Android 2.2. As a 162which is that large files within the generated Emacs package cannot be
163result, the Emacs package will be approximately 100 megabytes larger 163compressed in builds for Android 2.2, so that the Emacs package will be
164than a compressed package for a newer version of Android. 164approximately 15 megabytes larger than a compressed package for a newer
165version of Android. For such systems the `zip' utility is also required
166to produce packages that will not be misinterpreted by the package
167manager.
165 168
166 169
167BUILDING C++ DEPENDENCIES 170BUILDING C++ DEPENDENCIES
diff --git a/java/Makefile.in b/java/Makefile.in
index 802da0b9e36..20d595eb3ca 100644
--- a/java/Makefile.in
+++ b/java/Makefile.in
@@ -44,10 +44,20 @@ ANDROID_JAR = @ANDROID_JAR@
44ANDROID_ABI = @ANDROID_ABI@ 44ANDROID_ABI = @ANDROID_ABI@
45ANDROID_SDK_18_OR_EARLIER = @ANDROID_SDK_18_OR_EARLIER@ 45ANDROID_SDK_18_OR_EARLIER = @ANDROID_SDK_18_OR_EARLIER@
46ANDROID_SDK_8_OR_EARLIER = @ANDROID_SDK_8_OR_EARLIER@ 46ANDROID_SDK_8_OR_EARLIER = @ANDROID_SDK_8_OR_EARLIER@
47ZIP = @ZIP@
47WARN_JAVAFLAGS = @WARN_JAVAFLAGS@ 48WARN_JAVAFLAGS = @WARN_JAVAFLAGS@
48JAVAFLAGS = $(WARN_JAVAFLAGS) -classpath "$(ANDROID_JAR):$(srcdir)" 49JAVAFLAGS = $(WARN_JAVAFLAGS) -classpath "$(ANDROID_JAR):$(srcdir)"
49FIND_DELETE = @FIND_DELETE@ 50FIND_DELETE = @FIND_DELETE@
50 51
52ifneq (,$(ANDROID_SDK_8_OR_EARLIER))
53# gzip is invoked to compress installed .el and some .txt files, on SDK
54# 8 and earlier, where ZIP compression is unavailable.
55GZIP_PROG = @GZIP_PROG@
56else
57GZIP_PROG =
58endif
59
60
51# Android 4.3 and earlier require Emacs to be signed with a different 61# Android 4.3 and earlier require Emacs to be signed with a different
52# digital signature algorithm. 62# digital signature algorithm.
53 63
@@ -188,7 +198,7 @@ $(libsrc)/asset-directory-tool:
188# There is no need to depend on NDK_BUILD_SHARED as libemacs.so 198# There is no need to depend on NDK_BUILD_SHARED as libemacs.so
189# does already. 199# does already.
190 200
191.PHONY: install_temp install_temp/assets/directory-tree 201.PHONY: install_temp
192install_temp: $(CROSS_BINS) $(CROSS_LIBS) $(RESOURCE_FILES) 202install_temp: $(CROSS_BINS) $(CROSS_LIBS) $(RESOURCE_FILES)
193 $(AM_V_GEN) 203 $(AM_V_GEN)
194# Make the working directory for this stuff 204# Make the working directory for this stuff
@@ -223,6 +233,54 @@ install_temp: $(CROSS_BINS) $(CROSS_LIBS) $(RESOURCE_FILES)
223 rm -rf $${subdir}/[mM]akefile*[.-]in ; \ 233 rm -rf $${subdir}/[mM]akefile*[.-]in ; \
224 rm -rf $${subdir}/Makefile; \ 234 rm -rf $${subdir}/Makefile; \
225 done 235 done
236# Compress files if AAPT otherwise will not.
237 $(AM_V_SILENT) \
238 [ -z "${GZIP_PROG}" ] || { \
239 echo "Compressing large *.el *.info etc. ..." && \
240 cd "install_temp/assets/lisp" && \
241 for f in `find . -name "*.elc" \( -size +1536 -o \
242 -size 1536 \) -print \
243 | sed 's/.elc$$/.el/'`; do \
244 ${GZIP_PROG} -9n "$$f"; \
245 done; \
246 ${GZIP_PROG} -9n "../etc/publicsuffix.txt"; \
247 find ../info -name "*.elc" -size 1536 -o -size +1536 \
248 | xargs ${GZIP_PROG} -9n ; \
249 }
250# Produce metadata files providing build information and suchlike.
251 $(AM_V_SILENT) \
252 { (cd $(top_srcdir) \
253 && git rev-parse HEAD || echo "Unknown") \
254 && (git rev-parse --abbrev-ref HEAD \
255 || echo "Unknown") } 2> /dev/null > \
256 install_temp/assets/version
257 $(AM_V_SILENT) \
258 { hostname; date +%s; } > install_temp/assets/build_info
259# Produce the file index.
260 $(AM_V_SILENT) $(libsrc)/asset-directory-tool \
261 install_temp/assets install_temp/assets/directory-tree
262# If the package targets Android 2.2, move compressable and
263# non-compressable assets to separate directories.
264 $(AM_V_SILENT) \
265 if [ -z "${ANDROID_SDK_8_OR_EARLIER}" ]; then :; else \
266 echo "Moving large and gzipped files to separate directories...">&2;\
267 mkdir -p install_temp/assets_raw; \
268 cd install_temp/assets; \
269 find . \( -size +1536 -o -size 1536 \) \
270 \( \! -name '*.gz' \) -type f > files.txt; \
271 tar cf ../assets_raw/largefiles.tar -T files.txt; \
272 cat files.txt | xargs rm; \
273 cd ../assets_raw && tar xf largefiles.tar \
274 && rm largefiles.tar; \
275 cd ..; \
276 mkdir -p assets_gz; \
277 find assets -name '*.gz' -type f > files.txt; \
278 tar cf assets_gz/gzfiles.tar -T files.txt; \
279 cat files.txt | xargs rm; \
280 cd assets_gz && tar xf gzfiles.tar \
281 && rm gzfiles.tar; \
282 rm ../assets/files.txt; \
283 fi
226# Generate the directory tree for those directories. 284# Generate the directory tree for those directories.
227# Install architecture dependents to lib/$(ANDROID_ABI). This 285# Install architecture dependents to lib/$(ANDROID_ABI). This
228# perculiar naming scheme is required to make Android preserve these 286# perculiar naming scheme is required to make Android preserve these
@@ -252,35 +310,43 @@ ifneq ($(NDK_BUILD_SHARED),)
252 install_temp/lib/$(ANDROID_ABI) 310 install_temp/lib/$(ANDROID_ABI)
253endif 311endif
254 312
255install_temp/assets/directory-tree: $(libsrc)/asset-directory-tool \ 313emacs.apk-in: install_temp AndroidManifest.xml classes.dex
256 install_temp install_temp/assets/version \
257 install_temp/assets/build_info
258 $(AM_V_GEN) $(libsrc)/asset-directory-tool install_temp/assets \
259 install_temp/assets/directory-tree
260
261install_temp/assets/version: install_temp
262 $(AM_V_GEN) { (cd $(top_srcdir) \
263 && git rev-parse HEAD || echo "Unknown") \
264 && (git rev-parse --abbrev-ref HEAD \
265 || echo "Unknown") } 2> /dev/null > $@
266
267install_temp/assets/build_info: install_temp
268 $(AM_V_GEN) { hostname; date +%s; } > $@
269
270emacs.apk-in: install_temp install_temp/assets/directory-tree \
271 AndroidManifest.xml install_temp/assets/version \
272 install_temp/assets/build_info classes.dex
273# Package everything. Redirect the generated R.java to install_temp, as 314# Package everything. Redirect the generated R.java to install_temp, as
274# it must already have been generated as a prerequisite of 315# it must already have been generated as a prerequisite of
275# classes.dex's. 316# classes.dex's. If ANDROID_SDK_8_OR_EARLIER, compress those files
276 $(AM_V_AAPT) $(AAPT) p -I "$(ANDROID_JAR)" -F $@ \ 317# which are smaller than 1536 blocks (i.e. 768 kib), the maximum the
277 -f -M AndroidManifest.xml $(AAPT_ASSET_ARGS) \ 318# asset manager on such old systems can decompress.
278 -A install_temp/assets \ 319#
279 -S $(top_srcdir)/java/res -J install_temp 320# The elaborate dance with zip serves to disable the automatic
321# decompression of *.gz files in aapt.
322#
323# One more consideration is that timestamps should be preserved in
324# packaged libraries, as on Android 2.2 the package manager retains
325# existing libraries from previous installations if a new package's
326# libraries are not more recent.
327 $(AM_V_AAPT) \
328 if [ -z "$(ANDROID_SDK_8_OR_EARLIER)" ]; then \
329 $(AAPT) p -I "$(ANDROID_JAR)" -F $@ \
330 -f -M AndroidManifest.xml $(AAPT_ASSET_ARGS) \
331 -A install_temp/assets \
332 -S $(top_srcdir)/java/res -J install_temp; \
333 cd install_temp; \
334 $(AAPT) add ../$@ `find lib -type f`; \
335 else \
336 echo "Packaging files not eligible for compression...">&2;\
337 $(AAPT) p -I "$(ANDROID_JAR)" -F $@ \
338 -f -M AndroidManifest.xml -A install_temp/assets_raw\
339 -S $(top_srcdir)/java/res -J install_temp -0 ""; \
340 echo "Packaging files eligible for compression...">&2;\
341 cd install_temp; find assets -type f \
342 | xargs $(ZIP) ../$@ &> /dev/null; \
343 echo "Packagging files already compressed...">&2; \
344 cd assets_gz; find assets -type f \
345 | xargs $(ZIP) ../../$@ &> /dev/null; \
346 echo "Packaging shared libraries and code..." >&2; \
347 cd ..; $(ZIP) ../$@ `find lib -type f`; \
348 fi
280 $(AM_V_SILENT) $(AAPT) a $@ classes.dex 349 $(AM_V_SILENT) $(AAPT) a $@ classes.dex
281 $(AM_V_SILENT) pushd install_temp &> /dev/null; \
282 $(AAPT) add ../$@ `find lib -type f`; \
283 popd &> /dev/null
284 $(AM_V_SILENT) rm -rf install_temp 350 $(AM_V_SILENT) rm -rf install_temp
285 351
286# Makefile itself. 352# Makefile itself.
diff --git a/lisp/term/android-win.el b/lisp/term/android-win.el
index 3e0f71abf91..0d2d0299282 100644
--- a/lisp/term/android-win.el
+++ b/lisp/term/android-win.el
@@ -627,6 +627,9 @@ accessible to other programs."
627(global-set-key [\83] #'ignore) ; KEYCODE_NOTIFICATION on pre-Honeycomb 627(global-set-key [\83] #'ignore) ; KEYCODE_NOTIFICATION on pre-Honeycomb
628 ; releases. 628 ; releases.
629 629
630;; `select' key, which I suppose amounts to return.
631(define-key input-decode-map [select] [return])
632
630 633
631(provide 'android-win) 634(provide 'android-win)
632;; android-win.el ends here. 635;; android-win.el ends here.