From a93e3d9985d7c9798634546a1d527d9e75b0eeec Mon Sep 17 00:00:00 2001 From: Sasha Smundak Date: Wed, 28 Jul 2021 14:34:33 -0700 Subject: [PATCH] Implement copy_files function Bug: 193540681 Test: treehugger Change-Id: Iffc64551e733747a9a29c14b1f674b3a533f44ba --- core/product_config.rbc | 5 +++++ tests/device.rbc | 6 ++++-- tests/run.rbc | 4 +++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/core/product_config.rbc b/core/product_config.rbc index c7ec79450f..d9a2a72ffc 100644 --- a/core/product_config.rbc +++ b/core/product_config.rbc @@ -369,6 +369,10 @@ def _inherit(handle, pcm_name, pcm): if type(val) == "list": val.append(_indirect(pcm_name)) +def _copy_files(l, outdir): + """Generate :/item for each item.""" + return ["%s:%s/%s" % (item, outdir, item) for item in __words(l)] + def _copy_if_exists(path_pair): """If from file exists, returns [from:to] pair.""" value = path_pair.split(":", 2) @@ -548,6 +552,7 @@ rblf = struct( add_soong_config_var_value = _add_soong_config_var_value, addprefix = _addprefix, addsuffix = _addsuffix, + copy_files = _copy_files, copy_if_exists = _copy_if_exists, cfg = __h_cfg, enforce_product_packages_exist = _enforce_product_packages_exist, diff --git a/tests/device.rbc b/tests/device.rbc index d9100fdf15..b57dbf9311 100644 --- a/tests/device.rbc +++ b/tests/device.rbc @@ -21,7 +21,8 @@ ### PRODUCT_COPY_FILES += device_from:device_to ### include $(LOCAL_PATH)/include1.mk ### PRODUCT_PACKAGES += dev_after -### PRODUCT_COPY_FILES += $(call find-copy-subdir-files,audio_platform_info*.xml,device/google/redfin/audio,$(TARGET_COPY_OUT_VENDOR)/etc) xyz +### PRODUCT_COPY_FILES += $(call find-copy-subdir-files,audio_platform_info*.xml,device/google/redfin/audio,$(TARGET_COPY_OUT_VENDOR)/etc) xyz:/etc/xyz +### PRODUCT_COPY_FILES += $(call copy-files,x.xml y.xml,/etc) ### $(call add_soong_namespace,NS1) ### $(call add_soong_config_var_value,NS1,v1,abc) ### $(call add_soong_config_var_value,NS1,v2,def) @@ -45,7 +46,8 @@ def init(g, handle): _include1_init(g, handle) cfg["PRODUCT_PACKAGES"] += ["dev_after"] cfg["PRODUCT_COPY_FILES"] += (rblf.find_and_copy("audio_platform_info*.xml", "device/google/redfin/audio", "||VENDOR-PATH-PH||/etc") + - ["xyz"]) + ["xyz:/etc/xyz"]) + cfg["PRODUCT_COPY_FILES"] += rblf.copy_files("x.xml y.xml", "/etc") rblf.add_soong_config_namespace(g, "NS1") rblf.add_soong_config_var_value(g, "NS1", "v1", "abc") rblf.add_soong_config_var_value(g, "NS1", "v2", "def") diff --git a/tests/run.rbc b/tests/run.rbc index da888865ed..15f6212dfe 100644 --- a/tests/run.rbc +++ b/tests/run.rbc @@ -51,7 +51,9 @@ assert_eq( "part_from:part_to", "device_from:device_to", "device/google/redfin/audio/audio_platform_info_noextcodec_snd.xml:||VENDOR-PATH-PH||/etc/audio_platform_info_noextcodec_snd.xml", - "xyz" + "xyz:/etc/xyz", + "x.xml:/etc/x.xml", + "y.xml:/etc/y.xml", ], "PRODUCT_HOST_PACKAGES": ["host"], "PRODUCT_PACKAGES": [