OSDN Git Service

DO NOT MERGE: libfec: allow fec_header to be located anywhere
[android-x86/system-extras.git] / brillo_config / Android.mk
index 68032f1..8946e78 100644 (file)
@@ -24,9 +24,12 @@ LOCAL_MODULE_CLASS := ETC
 LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)
 include $(BUILD_SYSTEM)/base_rules.mk
 
+# Attempt to populate the product id from a file in the product path.
+LOADED_BRILLO_PRODUCT_ID := $(call cfgtree-get-if-exists,brillo/product_id)
+
 # We don't really have a default value for the product id as the backend
 # interaction will not work if this is not set correctly.
-$(LOCAL_BUILT_MODULE): BRILLO_PRODUCT_ID ?= ""
+$(LOCAL_BUILT_MODULE): BRILLO_PRODUCT_ID ?= "$(LOADED_BRILLO_PRODUCT_ID)"
 $(LOCAL_BUILT_MODULE):
        $(hide)mkdir -p $(dir $@)
        echo $(BRILLO_PRODUCT_ID) > $@
@@ -37,22 +40,34 @@ LOCAL_MODULE_CLASS := ETC
 LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)
 include $(BUILD_SYSTEM)/base_rules.mk
 
-# The version is set to 0.0.0 if the user did not set the actual version.
+
+# The version is set to 0.0.0 if the user did not set the actual version and
+# a version cannot be loaded from the product cfgtree.
 # This allows us to have a valid version number while being easy to filter.
-BRILLO_PRODUCT_VERSION ?= "0.0.0"
+ifeq ($(BRILLO_PRODUCT_VERSION),)
+# Load from file first
+BRILLO_PRODUCT_VERSION := $(call cfgtree-get-if-exists,brillo/product_version)
+endif
+# If the version is still empty, override it with 0.0.0
+ifeq ($(BRILLO_PRODUCT_VERSION),)
+BRILLO_PRODUCT_VERSION := "0.0.0"
+endif
 ifeq ($(shell echo $(BRILLO_PRODUCT_VERSION) | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$$'),)
 $(error Invalid BRILLO_PRODUCT_VERSION "$(BRILLO_PRODUCT_VERSION)", must be \
   three numbers separated by dots. Example: "1.2.0")
 endif
 
 # Append BUILD_NUMBER if it is a number or a build timestamp otherwise.
-# Use DATE to generate the timestamp based on BUILD_DATETIME.
+# We don't want to use BUILD_DATETIME_FROM_FILE as this timestamp must be
+# different at every build.
+# If you don' want this to change at every build, you can define BUILD_NUMBER in
+# your product makefile and increase it manually.
 $(LOCAL_BUILT_MODULE):
        $(hide)mkdir -p $(dir $@)
 ifeq ($(shell echo $(BUILD_NUMBER) | grep -E '[^0-9]'),)
        echo $(BRILLO_PRODUCT_VERSION).$(BUILD_NUMBER) > $@
 else
-       echo $(BRILLO_PRODUCT_VERSION).$(BUILD_DATETIME_FROM_FILE) > $@
+       echo $(BRILLO_PRODUCT_VERSION).$(BUILD_DATETIME) > $@
 endif
 
 endif