base_rules.mk: Copy LOCAL_TEST_DATA to testcase folders.

* Moves the test data logic up to before suite logic.
* Saves the source to relative dest pairs.
* Re-uses the saved source to relative dest pairs when generating
  the src:dst pairs for suites.

Bug: 69802886
Test: Build a native test with test data and ensured test data
      ended up in each arch specific destination folder.

Change-Id: I52cf8771487fb52276f5e6aae5b8eecb222544d7
This commit is contained in:
Simran Basi 2017-12-04 14:44:16 -08:00
parent 5313503663
commit 5691cb8b9a
1 changed files with 40 additions and 27 deletions

View File

@ -460,6 +460,36 @@ ifdef LOCAL_2ND_ARCH_VAR_PREFIX
endif
endif
###########################################################
## Test Data
###########################################################
my_test_data_pairs :=
my_installed_test_data :=
# Source to relative dst file paths for reuse in LOCAL_COMPATIBILITY_SUITE.
my_test_data_file_pairs :=
ifneq ($(filter NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
ifneq ($(strip $(LOCAL_TEST_DATA)),)
ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
my_test_data_pairs := $(strip $(foreach td,$(LOCAL_TEST_DATA), \
$(eval _file := $(call word-colon,2,$(td))) \
$(if $(_file), \
$(eval _src_base := $(call word-colon,1,$(td))), \
$(eval _src_base := $(LOCAL_PATH)) \
$(eval _file := $(call word-colon,1,$(td)))) \
$(if $(findstring ..,$(_file)),$(error $(LOCAL_MODULE_MAKEFILE): LOCAL_TEST_DATA may not include '..': $(_file))) \
$(if $(filter /%,$(_src_base) $(_file)),$(error $(LOCAL_MODULE_MAKEFILE): LOCAL_TEST_DATA may not include absolute paths: $(_src_base) $(_file))) \
$(eval my_test_data_file_pairs := $(my_test_data_file_pairs) $(call append-path,$(_src_base),$(_file)):$(_file)) \
$(call append-path,$(_src_base),$(_file)):$(call append-path,$(my_module_path),$(_file))))
my_installed_test_data := $(call copy-many-files,$(my_test_data_pairs))
$(LOCAL_INSTALLED_MODULE): $(my_installed_test_data)
endif
endif
endif
###########################################################
## Compatibility suite files.
###########################################################
@ -522,37 +552,20 @@ $(foreach extra_config, $(wildcard $(LOCAL_PATH)/$(LOCAL_MODULE)_*.config), \
endif
endif # $(my_prefix)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_compat_files
ifneq ($(my_test_data_file_pairs),)
$(foreach pair, $(my_test_data_file_pairs), \
$(eval parts := $(subst :,$(space),$(pair))) \
$(eval src_path := $(word 1,$(parts))) \
$(eval file := $(word 2,$(parts))) \
$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
$(eval my_compat_dist_$(suite) += $(foreach dir, $(call compatibility_suite_dirs,$(suite),$(arch_dir)), \
$(src_path):$(call append-path,$(dir),$(file))))))
endif
$(call create-suite-dependencies)
endif # LOCAL_COMPATIBILITY_SUITE
###########################################################
## Test Data
###########################################################
my_test_data_pairs :=
my_installed_test_data :=
ifneq ($(filter NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
ifneq ($(strip $(LOCAL_TEST_DATA)),)
ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
my_test_data_pairs := $(strip $(foreach td,$(LOCAL_TEST_DATA), \
$(eval _file := $(call word-colon,2,$(td))) \
$(if $(_file), \
$(eval _base := $(call word-colon,1,$(td))), \
$(eval _base := $(LOCAL_PATH)) \
$(eval _file := $(call word-colon,1,$(td)))) \
$(if $(findstring ..,$(_file)),$(error $(LOCAL_MODULE_MAKEFILE): LOCAL_TEST_DATA may not include '..': $(_file))) \
$(if $(filter /%,$(_base) $(_file)),$(error $(LOCAL_MODULE_MAKEFILE): LOCAL_TEST_DATA may not include absolute paths: $(_base) $(_file))) \
$(call append-path,$(_base),$(_file)):$(call append-path,$(my_module_path),$(_file))))
my_installed_test_data := $(call copy-many-files,$(my_test_data_pairs))
$(LOCAL_INSTALLED_MODULE): $(my_installed_test_data)
endif
endif
endif
###########################################################
## Register with ALL_MODULES
###########################################################