Implement copy_files function

Bug: 193540681
Test: treehugger
Change-Id: Iffc64551e733747a9a29c14b1f674b3a533f44ba
This commit is contained in:
Sasha Smundak 2021-07-28 14:34:33 -07:00
parent c106138baf
commit a93e3d9985
3 changed files with 12 additions and 3 deletions

View File

@ -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>:<outdir>/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,

View File

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

View File

@ -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": [