1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-21 06:55:39 +00:00

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.
This commit is contained in:
Po Lu 2024-06-30 12:10:21 +08:00
parent e2561e267f
commit cab91300d0
7 changed files with 57 additions and 33 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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])

View File

@ -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)

View File

@ -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

View File

@ -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"
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])])])
if test -n "$module_name"; then
break;
fi
done
# Copy the computed value into ndk_commands.
AS_VAR_COPY([ndk_commands], [AS_TR_SH([ndk_cv_commands_$ndk_module])])
eval "$ndk_commands"
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])
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"
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
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])