From: Po Lu Date: Sun, 30 Jun 2024 04:10:21 +0000 (+0800) Subject: Enable caching values generated by the Android build system X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=767cfb55335089912f19fe6ec0d0260731867484;p=emacs.git Enable caching values generated by the Android build system * build-aux/ndk-build-helper-1.mk: * build-aux/ndk-build-helper-2.mk: * build-aux/ndk-build-helper.mk: Do not generate file names with redundant directory separators, to port to systems where the semantics of this are undefined. * configure.ac: Provide a cache file to the recursive invocation of configure if one is specified for the initial. * cross/ndk-build/Makefile.in (my-dir): Better conform to the original ndk-build by generating directory names with no trailing separator. * m4/ndk-build.m4 (ndk_resolve_import_module, ndk_SEARCH_MODULE): Cache the names of Android.mk files and the commands produced from them. (cherry picked from commit cab91300d0df2250bc80c0cba15691fe5f8172fb) --- diff --git a/build-aux/ndk-build-helper-1.mk b/build-aux/ndk-build-helper-1.mk index 985f7cddfaf..4420eb433f4 100644 --- a/build-aux/ndk-build-helper-1.mk +++ b/build-aux/ndk-build-helper-1.mk @@ -35,7 +35,7 @@ NDK_CXX_FLAG_$(LOCAL_MODULE) := $(info Building $(build_kind)) $(info $(LOCAL_MODULE)) -$(info $(addprefix $(LOCAL_PATH)/,$(LOCAL_SRC_FILES) $(LOCAL_SRC_FILES$(EMACS_ABI)))) +$(info $(addprefix $(LOCAL_PATH:%/=%)/,$(LOCAL_SRC_FILES) $(LOCAL_SRC_FILES$(EMACS_ABI)))) ifeq ($(filter-out lib%,$(LOCAL_MODULE)),) NDK_SO_NAMES = $(LOCAL_MODULE)_emacs.so @@ -106,7 +106,7 @@ endif $(info $(foreach dir,$(NDK_INCLUDES),-I$(dir))) $(info $(LOCAL_EXPORT_CFLAGS)) -$(info $(LOCAL_EXPORT_LDFLAGS) $(abspath $(addprefix $(NDK_BUILD_DIR)/,$(NDK_A_NAMES))) -L$(abspath $(NDK_BUILD_DIR)) $(foreach soname,$(NDK_SO_NAMES),-l:$(soname))) +$(info $(LOCAL_EXPORT_LDFLAGS) $(abspath $(addprefix $(NDK_BUILD_DIR:%/=%)/,$(NDK_A_NAMES))) -L$(abspath $(NDK_BUILD_DIR)) $(foreach soname,$(NDK_SO_NAMES),-l:$(soname))) $(info $(NDK_SO_NAMES)) $(info $(NDK_CXX_FLAG_$(LOCAL_MODULE))) $(info End) diff --git a/build-aux/ndk-build-helper-2.mk b/build-aux/ndk-build-helper-2.mk index 697740b3d45..b8d22f5952d 100644 --- a/build-aux/ndk-build-helper-2.mk +++ b/build-aux/ndk-build-helper-2.mk @@ -29,7 +29,7 @@ NDK_CXX_FLAG_$(LOCAL_MODULE) := $(info Building $(build_kind)) $(info $(LOCAL_MODULE)) -$(info $(addprefix $(LOCAL_PATH)/,$(LOCAL_SRC_FILES) $(LOCAL_SRC_FILES$(EMACS_ABI)))) +$(info $(addprefix $(LOCAL_PATH:%/=%)/,$(LOCAL_SRC_FILES) $(LOCAL_SRC_FILES$(EMACS_ABI)))) ifeq ($(filter-out lib%,$(LOCAL_MODULE)),) NDK_A_NAMES = $(LOCAL_MODULE).a @@ -99,7 +99,7 @@ endif $(info $(foreach dir,$(NDK_INCLUDES),-I$(dir))) $(info $(LOCAL_EXPORT_CFLAGS)) -$(info $(LOCAL_EXPORT_LDFLAGS) $(abspath $(addprefix $(NDK_BUILD_DIR)/,$(NDK_A_NAMES))) $(and $(NDK_SO_NAMES), -L$(abspath $(NDK_BUILD_DIR)) $(foreach soname,$(NDK_SO_NAMES),-l:$(soname)))) +$(info $(LOCAL_EXPORT_LDFLAGS) $(abspath $(addprefix $(NDK_BUILD_DIR:%/=%)/,$(NDK_A_NAMES))) $(and $(NDK_SO_NAMES), -L$(abspath $(NDK_BUILD_DIR)) $(foreach soname,$(NDK_SO_NAMES),-l:$(soname)))) $(info $(NDK_A_NAMES) $(NDK_SO_NAMES)) $(info $(NDK_CXX_FLAG_$(LOCAL_MODULE))) $(info End) diff --git a/build-aux/ndk-build-helper.mk b/build-aux/ndk-build-helper.mk index 521e1b24ce3..b4746dd623f 100644 --- a/build-aux/ndk-build-helper.mk +++ b/build-aux/ndk-build-helper.mk @@ -42,7 +42,7 @@ EMACS_SRCDIR := $(absname $(EMACS_SRCDIR)) # my-dir is a function that returns the Android module directory. If # no Android.mk has been loaded, use ANDROID_MODULE_DIRECTORY. -my-dir = $(or $(and $(local-makefile),$(dir $(local-makefile))),$(ANDROID_MODULE_DIRECTORY)) +my-dir = $(patsubst %/,%,$(or $(and $(local-makefile),$(dir $(local-makefile))),$(ANDROID_MODULE_DIRECTORY))) # Return all Android.mk files under the first arg. all-makefiles-under = $(wildcard $(1)/*/Android.mk) diff --git a/configure.ac b/configure.ac index daff8195005..53eeb89df94 100644 --- a/configure.ac +++ b/configure.ac @@ -1263,6 +1263,11 @@ packages targeting Android 2.2.])]) emacs_val="--enable-check-lisp-object-type=$enable_check_lisp_object_type" passthrough="$passthrough $emacs_val" + # And derive a name for the recursive configure invocation's cache + # file if one should be specified for this. + AS_IF([test -n "$cache_file"], + [passthrough="$passthrough --cache-file=$cache_file.1"]) + AS_IF([test "x$with_mailutils" = "xyes"], [emacs_use_mailutils=yes]) AC_SUBST([emacs_use_mailutils]) diff --git a/cross/ndk-build/Makefile.in b/cross/ndk-build/Makefile.in index 0970a765b45..b5eac9bd089 100644 --- a/cross/ndk-build/Makefile.in +++ b/cross/ndk-build/Makefile.in @@ -79,7 +79,7 @@ local-makefile = $$(NDK_LAST_MAKEFILE) # my-dir is a function that returns the Android module directory. If # no Android.mk has been loaded, use the directory of the Makefile # being included. -my-dir = $$(or $$(and $$(local-makefile),$$(dir $$(local-makefile))),$(dir $(1))) +my-dir = $$(patsubst %/,%,$$(or $$(and $$(local-makefile),$$(dir $$(local-makefile))),$(dir $(1)))) # Return all Android.mk files under the first arg. all-makefiles-under = $$(wildcard $$(1)/*/Android.mk) diff --git a/cross/ndk-build/ndk-resolve.mk b/cross/ndk-build/ndk-resolve.mk index 896c29f7f90..289e3a8a003 100644 --- a/cross/ndk-build/ndk-resolve.mk +++ b/cross/ndk-build/ndk-resolve.mk @@ -50,7 +50,6 @@ ifeq ($$(filter $(1)$(and $(3),whole),$$(NDK_RESOLVED_CFLAGS_$(LOCAL_MODULE))),) # Always mark this module's cflags as having been resolved, even if # this is a whole library. NDK_RESOLVED_CFLAGS_$(LOCAL_MODULE) += $(1) - NDK_CFLAGS_$(LOCAL_MODULE) += $(NDK_LOCAL_EXPORT_CFLAGS_$(1)) NDK_CFLAGS_$(LOCAL_MODULE) += $(addprefix -I,$(NDK_LOCAL_EXPORT_C_INCLUDES_$(1))) endif diff --git a/m4/ndk-build.m4 b/m4/ndk-build.m4 index f86d4e4fc1e..a561c7c849d 100644 --- a/m4/ndk-build.m4 +++ b/m4/ndk-build.m4 @@ -143,22 +143,35 @@ ndk_resolve_import_module () { ndk_module=[$]1 AC_MSG_CHECKING([for imported $ndk_module]) + AC_CACHE_VAL([AS_TR_SH([ndk_cv_commands_$ndk_module])], + [for ndk_android_mk in $ndk_module_files; do + # Read this Android.mk file. Set NDK_ROOT to /tmp: the Android in + # tree build system sets it to a meaningful value, but build files + # just use it to test whether or not the NDK is being used. + ndk_commands=`ndk_run_test` + eval "$ndk_commands" + + if test -n "$module_name"; then + # Guarantee that evaluation of the cached value will also set + # `ndk_android_mk'. + ndk_commands="$ndk_commands ndk_android_mk=$ndk_android_mk" + break; + fi + done + AS_IF([test -z "$module_name"], + [AS_VAR_SET([AS_TR_SH([ndk_cv_commands_$ndk_module])], + [""])], + [AS_VAR_SET([AS_TR_SH([ndk_cv_commands_$ndk_module])], + [$ndk_commands])])]) + + # Copy the computed value into ndk_commands. + AS_VAR_COPY([ndk_commands], [AS_TR_SH([ndk_cv_commands_$ndk_module])]) + eval "$ndk_commands" - for ndk_android_mk in $ndk_module_files; do - # Read this Android.mk file. Set NDK_ROOT to /tmp: the Android in - # tree build system sets it to a meaningful value, but build files - # just use it to test whether or not the NDK is being used. - ndk_commands=`ndk_run_test` - eval "$ndk_commands" - - if test -n "$module_name"; then - break; - fi - done - - AS_IF([test -z "$module_name"], + # Print the outcome of the test. + AS_IF([test -n "$module_name"], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]) - AC_MSG_ERROR([The module currently being built depends on [$]1, but \ + AC_MSG_ERROR([The module currently being built has imported [$]1, but \ that could not be found in the list of directories specified in \ `--with-ndk-path'.])]) @@ -175,8 +188,6 @@ but none were found.])]) [AC_MSG_ERROR([The module [$]1 requires the C++ standard library, but a working C++ compiler was not found.])]) - AC_MSG_RESULT([yes]) - # Make sure the module is prepended. ndk_MODULES="$ndk_MODULES $module_target" ndk_MAKEFILES="$ndk_android_mk $ndk_MAKEFILES" @@ -552,19 +563,28 @@ AC_DEFUN([ndk_SEARCH_MODULE], module_name= ndk_module=$1 ndk_replace_pkg_config_package -AC_MSG_CHECKING([for Android.mk that builds $ndk_module]) - -for ndk_android_mk in $ndk_module_files; do - # Read this Android.mk file. Set NDK_ROOT to /tmp: the Android in - # tree build system sets it to a meaning value, but build files just - # use it to test whether or not the NDK is being used. - ndk_commands=`ndk_run_test` - - eval "$ndk_commands" - if test -n "$module_name"; then - break; - fi -done +AC_MSG_CHECKING([for Android.mk providing $ndk_module]) +AC_CACHE_VAL([AS_TR_SH([ndk_cv_commands_$ndk_module])], + [for ndk_android_mk in $ndk_module_files; do + # Read this Android.mk file. Set NDK_ROOT to /tmp: the Android in + # tree build system sets it to a meaningful value, but build files + # just use it to test whether or not the NDK is being used. + ndk_commands=`ndk_run_test` + eval "$ndk_commands" + + if test -n "$module_name"; then + # Guarantee that evaluation of the cached value will also set + # `ndk_android_mk'. + ndk_commands="$ndk_commands ndk_android_mk=$ndk_android_mk" + break; + fi + done + AS_IF([test -n "$module_name"], + [AS_VAR_SET([AS_TR_SH([ndk_cv_commands_$ndk_module])], + [$ndk_commands])], + [AS_VAR_SET([AS_TR_SH([ndk_cv_commands_$ndk_module])], [])])]) +AS_VAR_COPY([ndk_commands], [AS_TR_SH([ndk_cv_commands_$ndk_module])]) +eval "$ndk_commands" if test -z "$module_name"; then AC_MSG_RESULT([no])