Merge changes I129136e8,I278bd8ed,I1d22ed6f
* changes:
Implement add_soong_namespace and add_soong_config_var_value functions
Trim spaces in the rule actions
Add copy-files macro
diff --git a/core/Makefile b/core/Makefile
index a7df61f..1ab0fe5 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -206,7 +206,7 @@
@mkdir -p $(dir $@)
$(hide) grep -v "$(subst $(space),\|,$(strip \
$(sdk_build_prop_remove)))" $< > $@.tmp
- $(hide) for x in $(sdk_build_prop_remove); do \
+ $(hide) for x in $(strip $(sdk_build_prop_remove)); do \
echo "$$x"generic >> $@.tmp; done
$(hide) mv $@.tmp $@
@@ -320,11 +320,11 @@
define build-image-kernel-modules-depmod
$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: .KATI_IMPLICIT_OUTPUTS := $(3)/$(DEPMOD_STAGING_SUBDIR)/modules.alias $(3)/$(DEPMOD_STAGING_SUBDIR)/modules.softdep $(3)/$(DEPMOD_STAGING_SUBDIR)/$(5)
$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(DEPMOD)
-$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULES := $(1)
+$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULES := $(strip $(1))
$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MOUNT_POINT := $(2)
$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_DIR := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(2)/lib/modules/$(8)
$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_STAGING_DIR := $(3)
-$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_MODULES := $(4)
+$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_MODULES := $(strip $(4))
$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_FILE := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(5)
$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_ARCHIVE := $(6)
$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_OUTPUT_DIR := $(7)
@@ -5148,10 +5148,10 @@
ifeq ($(AB_OTA_UPDATER),true)
@# When using the A/B updater, include the updater config files in the zip.
$(hide) cp $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt
- $(hide) for part in $(AB_OTA_PARTITIONS); do \
+ $(hide) for part in $(strip $(AB_OTA_PARTITIONS)); do \
echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \
done
- $(hide) for conf in $(AB_OTA_POSTINSTALL_CONFIG); do \
+ $(hide) for conf in $(strip $(AB_OTA_POSTINSTALL_CONFIG)); do \
echo "$${conf}" >> $(zip_root)/META/postinstall_config.txt; \
done
ifdef OSRELEASED_DIRECTORY
@@ -5948,7 +5948,7 @@
$(INTERNAL_SDK_TARGET): $(deps)
@echo "Package SDK: $@"
$(hide) rm -rf $(PRIVATE_DIR) $@
- $(hide) for f in $(target_gnu_MODULES); do \
+ $(hide) for f in $(strip $(target_gnu_MODULES)); do \
if [ -f $$f ]; then \
echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
including GNU target $$f >&2; \
diff --git a/core/main.mk b/core/main.mk
index 21f4387..cb97503 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -355,7 +355,7 @@
ADDITIONAL_PRODUCT_PROPERTIES += ro.build.characteristics=$(TARGET_AAPT_CHARACTERISTICS)
ifeq ($(AB_OTA_UPDATER),true)
-ADDITIONAL_PRODUCT_PROPERTIES += ro.product.ab_ota_partitions=$(subst $(space),$(comma),$(AB_OTA_PARTITIONS))
+ADDITIONAL_PRODUCT_PROPERTIES += ro.product.ab_ota_partitions=$(subst $(space),$(comma),$(strip $(AB_OTA_PARTITIONS)))
endif
# -----------------------------------------------------------------
diff --git a/core/product_config.mk b/core/product_config.mk
index a9f3d34..99ff8aa 100644
--- a/core/product_config.mk
+++ b/core/product_config.mk
@@ -77,6 +77,16 @@
$(sort $(shell find $(2) -name "$(1)" -type f | $(SED_EXTENDED) "s:($(2)/?(.*)):\\1\\:$(3)/\\2:" | sed "s://:/:g"))
endef
+#
+# Convert file file to the PRODUCT_COPY_FILES/PRODUCT_SDK_ADDON_COPY_FILES
+# format: for each file F return $(F):$(PREFIX)/$(notdir $(F))
+# $(1): files list
+# $(2): prefix
+
+define copy-files
+$(foreach f,$(1),$(f):$(2)/$(notdir $(f)))
+endef
+
# ---------------------------------------------------------------
# Check for obsolete PRODUCT- and APP- goals
ifeq ($(CALLED_FROM_SETUP),true)
diff --git a/core/product_config.rbc b/core/product_config.rbc
index 8e85c4b..c7ec794 100644
--- a/core/product_config.rbc
+++ b/core/product_config.rbc
@@ -16,6 +16,7 @@
"""Runtime functions."""
+_soong_config_namespaces_key = "$SOONG_CONFIG_NAMESPACES"
def _global_init():
"""Returns dict created from the runtime environment."""
globals = dict()
@@ -29,6 +30,7 @@
globals[k] = getattr(rblf_cli, k)
globals.setdefault("PRODUCT_SOONG_NAMESPACES", [])
+ globals.setdefault(_soong_config_namespaces_key, {})
_envsetup_init(globals)
# Variables that should be defined.
@@ -74,7 +76,12 @@
if _options.print_globals:
print()
for attr, val in sorted(globals.items()):
- if attr not in _globals_base:
+ if attr == _soong_config_namespaces_key:
+ __print_attr("SOONG_CONFIG_NAMESPACES", val.keys())
+ for nsname, nsvars in sorted(val.items()):
+ for var, val in sorted(nsvars.items()):
+ __print_attr("SOONG_CONFIG_%s_%s" % (nsname, var), val)
+ elif attr not in _globals_base:
__print_attr(attr, val)
def __printvars_rearrange_list(value_list):
@@ -268,6 +275,20 @@
"""Returns configuration item for the inherited module."""
return (pcm_name,)
+def _add_soong_config_namespace(g, nsname):
+ """Adds given namespace."""
+
+ # A value cannot be updated, so we need to create a new dictionary
+ old = g[_soong_config_namespaces_key]
+ g[_soong_config_namespaces_key] = dict([(k,v) for k,v in old.items()] + [(nsname, {})])
+
+def _add_soong_config_var_value(g, nsname, var, value):
+ """Defines a variable and adds it to the given namespace."""
+ ns = g[_soong_config_namespaces_key].get(nsname)
+ if ns == None:
+ fail("no such namespace: " + nsname)
+ ns[var] = value
+
def _addprefix(prefix, string_or_list):
"""Adds prefix and returns a list.
@@ -523,6 +544,8 @@
# Settings used during debugging.
_options = __get_options()
rblf = struct(
+ add_soong_config_namespace = _add_soong_config_namespace,
+ add_soong_config_var_value = _add_soong_config_var_value,
addprefix = _addprefix,
addsuffix = _addsuffix,
copy_if_exists = _copy_if_exists,
diff --git a/tests/device.rbc b/tests/device.rbc
index 5d4e70c..d9100fd 100644
--- a/tests/device.rbc
+++ b/tests/device.rbc
@@ -22,6 +22,12 @@
### 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
+### $(call add_soong_namespace,NS1)
+### $(call add_soong_config_var_value,NS1,v1,abc)
+### $(call add_soong_config_var_value,NS1,v2,def)
+### $(call add_soong_namespace,NS2)
+### $(call add_soong_config_var_value,NS2,v3,abc)
+### $(call add_soong_config_var_value,NS2,v3,xyz)
load("//build/make/core:product_config.rbc", "rblf")
load(":part1.rbc", _part1_init = "init")
@@ -40,3 +46,10 @@
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"])
+ 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")
+ rblf.add_soong_config_namespace(g, "NS2")
+ rblf.add_soong_config_var_value(g, "NS2", "v3", "abc")
+ rblf.add_soong_config_var_value(g, "NS2", "v3", "xyz")
+
diff --git a/tests/run.rbc b/tests/run.rbc
index 4cda180..da88886 100644
--- a/tests/run.rbc
+++ b/tests/run.rbc
@@ -63,3 +63,17 @@
},
{ k:v for k, v in sorted(config.items()) }
)
+
+ns = globals["$SOONG_CONFIG_NAMESPACES"]
+assert_eq(
+ {
+ "NS1": {
+ "v1": "abc",
+ "v2": "def"
+ },
+ "NS2": {
+ "v3": "xyz"
+ }
+ },
+ {k:v for k, v in sorted(ns.items()) }
+)