aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPo Lu2023-02-24 22:25:48 +0800
committerPo Lu2023-02-24 22:25:48 +0800
commitea74f3c0678d0729a8d6307e35c2d228f665afa3 (patch)
tree123796d853d714bed9662301cff3c1a4a0baacef
parent4ff3904e3c2767b2840624db68b5cf9db2246d3b (diff)
downloademacs-ea74f3c0678d0729a8d6307e35c2d228f665afa3.tar.gz
emacs-ea74f3c0678d0729a8d6307e35c2d228f665afa3.zip
Improve Android configury
* configure.ac (JAVA_PUSH_LINT): New macro. (JAVAFLAGS): New variable. Check for various lint flags and macros and enable them. * java/Makefile.in (ANDROID_ABI): * java/org/gnu/emacs/EmacsSdk7FontDriver.java: Remove compiler warning.
-rw-r--r--configure.ac75
-rw-r--r--java/Makefile.in5
-rw-r--r--java/org/gnu/emacs/EmacsSdk7FontDriver.java2
3 files changed, 75 insertions, 7 deletions
diff --git a/configure.ac b/configure.ac
index 715d8790026..67ee0a1c413 100644
--- a/configure.ac
+++ b/configure.ac
@@ -739,6 +739,32 @@ AC_ARG_ENABLE([build-details],
739 [test "$enableval" = no && BUILD_DETAILS=--no-build-details]) 739 [test "$enableval" = no && BUILD_DETAILS=--no-build-details])
740AC_SUBST([BUILD_DETAILS]) 740AC_SUBST([BUILD_DETAILS])
741 741
742# JAVA_PUSH_LINT(OPT)
743# -------------------
744# Check if javac supports the diagnostic flag -Xlint:OPT.
745# If it does, add it to JAVAFLAGS.
746
747AC_DEFUN([JAVA_PUSH_LINT],
748[
749 AC_CACHE_CHECK([whether Java compiler accepts -Xlint:$1],
750 [emacs_cv_javac_knows_lint_$1],
751 AS_IF([rm -f conftest.class
752cat << EOF > conftest.java
753
754class conftest
755{
756
757}
758
759EOF
760("$JAVAC" -Xlint:$1 conftest.java 2>&AS_MESSAGE_LOG_FD) \
761 && rm -f conftest.class], [emacs_cv_javac_knows_lint_$1=yes],
762 [emacs_cv_javac_knows_lint_$1=no]))
763
764 AS_IF([test "$emacs_cv_javac_knows_lint_$1" = "yes"],
765 [JAVAFLAGS="$JAVAFLAGS -Xlint:$1"])
766])
767
742# Start Android configuration. This is done in three steps: 768# Start Android configuration. This is done in three steps:
743 769
744# First, the SDK tools needed to build the Android package on the host 770# First, the SDK tools needed to build the Android package on the host
@@ -760,6 +786,7 @@ ZIPALIGN=
760DX= 786DX=
761ANDROID_JAR= 787ANDROID_JAR=
762ANDROID_ABI= 788ANDROID_ABI=
789JAVAFLAGS=
763 790
764# This is a list of Makefiles that have alternative versions for 791# This is a list of Makefiles that have alternative versions for
765# Android. 792# Android.
@@ -807,7 +834,7 @@ specify its location before configuring Emacs, like so:
807 JARSIGNER=/opt/jdk/bin/jarsigner ./configure --with-android]) 834 JARSIGNER=/opt/jdk/bin/jarsigner ./configure --with-android])
808 fi 835 fi
809 836
810 AC_CACHE_CHECK([whether or not the Java compiler works], 837 AC_CACHE_CHECK([whether the Java compiler works],
811 [emacs_cv_working_javac], 838 [emacs_cv_working_javac],
812 AS_IF([rm -f conftest.class 839 AS_IF([rm -f conftest.class
813cat << EOF > conftest.java 840cat << EOF > conftest.java
@@ -836,7 +863,7 @@ EOF
836a valid path to android.jar. See config.log for more details.]) 863a valid path to android.jar. See config.log for more details.])
837 fi 864 fi
838 865
839 AC_CACHE_CHECK([whether or not android.jar is new enough], 866 AC_CACHE_CHECK([whether android.jar is new enough],
840 [emacs_cv_android_s_or_later], 867 [emacs_cv_android_s_or_later],
841 AS_IF([rm -f conftest.class 868 AS_IF([rm -f conftest.class
842cat << EOF > conftest.java 869cat << EOF > conftest.java
@@ -859,8 +886,52 @@ EOF
859Android 13 (Tiramisu) or later.]) 886Android 13 (Tiramisu) or later.])
860 fi 887 fi
861 888
889 dnl See if the Java compiler supports the `--release' option which
890 dnl makes it check for and prevent using features introduced after
891 dnl Java 1.7.
892
893 AC_CACHE_CHECK([whether javac accepts --release 7],
894 [emacs_cv_javac_release_7], AS_IF([rm -f conftest.class
895cat << EOF > conftest.java
896
897class conftest
898{
899
900}
901
902EOF
903("$JAVAC" --release 7 conftest.java 2>&AS_MESSAGE_LOG_FD) \
904 && rm -f conftest.class],
905 [emacs_cv_javac_release_7=yes],
906 [emacs_cv_javac_release_7=no]))
907
908 if test "$emacs_cv_javac_release_7" = "yes"; then
909 JAVAFLAGS="$JAVAFLAGS --release 7"
910 else
911 dnl If not, just make sure the generated bytecode is correct.
912 JAVAFLAGS="$JAVAFLAGS -target 1.7 -source 1.7"
913 fi
914
915 dnl Enable some useful Java linting options.
916 JAVA_PUSH_LINT([deprecation])
917 JAVA_PUSH_LINT([cast])
918 JAVA_PUSH_LINT([divzero])
919 JAVA_PUSH_LINT([nonempty])
920 JAVA_PUSH_LINT([empty])
921 JAVA_PUSH_LINT([finally])
922 JAVA_PUSH_LINT([overrides])
923 JAVA_PUSH_LINT([path])
924 JAVA_PUSH_LINT([serial])
925 JAVA_PUSH_LINT([unchecked])
926
927 # Get the name of the android.jar file.
862 ANDROID_JAR="$with_android" 928 ANDROID_JAR="$with_android"
863 929
930 dnl Set up the class path to include android.jar, along with the cwd
931 dnl (which is $(top_builddir)/java.)
932 JAVAFLAGS="$JAVAFLAGS -classpath \"$ANDROID_JAR:.\""
933 AC_SUBST([JAVAFLAGS])
934
864 AC_PATH_PROGS([AAPT], [aapt], [], "${SDK_BUILD_TOOLS}:$PATH") 935 AC_PATH_PROGS([AAPT], [aapt], [], "${SDK_BUILD_TOOLS}:$PATH")
865 if test "$AAPT" = ""; then 936 if test "$AAPT" = ""; then
866 AC_MSG_ERROR([The Android asset packaging tool was not found. 937 AC_MSG_ERROR([The Android asset packaging tool was not found.
diff --git a/java/Makefile.in b/java/Makefile.in
index af44d551701..7ba05f6c9a3 100644
--- a/java/Makefile.in
+++ b/java/Makefile.in
@@ -40,10 +40,7 @@ ANDROID_JAR = @ANDROID_JAR@
40ANDROID_ABI = @ANDROID_ABI@ 40ANDROID_ABI = @ANDROID_ABI@
41ANDROID_SDK_18_OR_EARLIER = @ANDROID_SDK_18_OR_EARLIER@ 41ANDROID_SDK_18_OR_EARLIER = @ANDROID_SDK_18_OR_EARLIER@
42ANDROID_SDK_8_OR_EARLIER = @ANDROID_SDK_8_OR_EARLIER@ 42ANDROID_SDK_8_OR_EARLIER = @ANDROID_SDK_8_OR_EARLIER@
43 43JAVAFLAGS = @JAVAFLAGS@
44WARN_JAVAFLAGS = -Xlint:deprecation
45JAVAFLAGS = -classpath "$(ANDROID_JAR):." -target 1.7 -source 1.7 \
46 $(WARN_JAVAFLAGS)
47 44
48# Android 4.3 and earlier require Emacs to be signed with a different 45# Android 4.3 and earlier require Emacs to be signed with a different
49# digital signature algorithm. 46# digital signature algorithm.
diff --git a/java/org/gnu/emacs/EmacsSdk7FontDriver.java b/java/org/gnu/emacs/EmacsSdk7FontDriver.java
index a964cadb74c..ba92d4cef49 100644
--- a/java/org/gnu/emacs/EmacsSdk7FontDriver.java
+++ b/java/org/gnu/emacs/EmacsSdk7FontDriver.java
@@ -325,7 +325,7 @@ public class EmacsSdk7FontDriver extends EmacsFontDriver
325 list.add (new Sdk7FontEntity (typefaceList[i])); 325 list.add (new Sdk7FontEntity (typefaceList[i]));
326 } 326 }
327 327
328 return (FontEntity[]) list.toArray (new FontEntity[0]); 328 return list.toArray (new FontEntity[0]);
329 } 329 }
330 330
331 @Override 331 @Override