blob: b4d8c9324ec96130c7276713697278ec2ad0ad99 [file] [log] [blame]
Bertrand SIMONNETa659ce92015-10-08 13:06:35 -07001#
2# Copyright (C) 2015 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17# Build time settings used by system services
18# ========================================================
19ifdef OSRELEASED_DIRECTORY
20
21include $(CLEAR_VARS)
22LOCAL_MODULE := product_id
Sen Jiangb6cfdd32016-11-03 16:24:14 -070023LOCAL_MODULE_CLASS := FAKE
24LOCAL_MODULE_PATH := $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)
Bertrand SIMONNETa659ce92015-10-08 13:06:35 -070025include $(BUILD_SYSTEM)/base_rules.mk
26
Will Drewry00302c22015-11-04 18:51:35 -080027# Attempt to populate the product id from a file in the product path.
28LOADED_BRILLO_PRODUCT_ID := $(call cfgtree-get-if-exists,brillo/product_id)
29
Bertrand SIMONNETa659ce92015-10-08 13:06:35 -070030# We don't really have a default value for the product id as the backend
31# interaction will not work if this is not set correctly.
Will Drewry00302c22015-11-04 18:51:35 -080032$(LOCAL_BUILT_MODULE): BRILLO_PRODUCT_ID ?= "$(LOADED_BRILLO_PRODUCT_ID)"
Bertrand SIMONNETa659ce92015-10-08 13:06:35 -070033$(LOCAL_BUILT_MODULE):
Sen Jiangb6cfdd32016-11-03 16:24:14 -070034 $(hide) mkdir -p $(dir $@)
Bertrand SIMONNETa659ce92015-10-08 13:06:35 -070035 echo $(BRILLO_PRODUCT_ID) > $@
Sen Jiangb6cfdd32016-11-03 16:24:14 -070036 $(hide) mkdir -p $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)
37 ln -sf /oem/$(OSRELEASED_DIRECTORY)/product_id $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)
38
Bertrand SIMONNETa659ce92015-10-08 13:06:35 -070039
40include $(CLEAR_VARS)
41LOCAL_MODULE := product_version
Sen Jiangb6cfdd32016-11-03 16:24:14 -070042LOCAL_MODULE_CLASS := FAKE
43LOCAL_MODULE_PATH := $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)
Bertrand SIMONNETa659ce92015-10-08 13:06:35 -070044include $(BUILD_SYSTEM)/base_rules.mk
45
Will Drewryf01bc212015-11-05 16:07:18 -080046# The version is set to 0.0.0 if the user did not set the actual version and
47# a version cannot be loaded from the product cfgtree.
Bertrand SIMONNETa659ce92015-10-08 13:06:35 -070048# This allows us to have a valid version number while being easy to filter.
Will Drewryf01bc212015-11-05 16:07:18 -080049ifeq ($(BRILLO_PRODUCT_VERSION),)
50# Load from file first
51BRILLO_PRODUCT_VERSION := $(call cfgtree-get-if-exists,brillo/product_version)
52endif
53# If the version is still empty, override it with 0.0.0
54ifeq ($(BRILLO_PRODUCT_VERSION),)
55BRILLO_PRODUCT_VERSION := "0.0.0"
56endif
Bertrand SIMONNETa659ce92015-10-08 13:06:35 -070057ifeq ($(shell echo $(BRILLO_PRODUCT_VERSION) | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$$'),)
58$(error Invalid BRILLO_PRODUCT_VERSION "$(BRILLO_PRODUCT_VERSION)", must be \
59 three numbers separated by dots. Example: "1.2.0")
60endif
61
62# Append BUILD_NUMBER if it is a number or a build timestamp otherwise.
Bertrand SIMONNET5f788822015-10-28 21:42:56 -070063# We don't want to use BUILD_DATETIME_FROM_FILE as this timestamp must be
64# different at every build.
65# If you don' want this to change at every build, you can define BUILD_NUMBER in
66# your product makefile and increase it manually.
Bertrand SIMONNETa659ce92015-10-08 13:06:35 -070067$(LOCAL_BUILT_MODULE):
Sen Jiangb6cfdd32016-11-03 16:24:14 -070068 $(hide) mkdir -p $(dir $@)
Bertrand SIMONNETa659ce92015-10-08 13:06:35 -070069ifeq ($(shell echo $(BUILD_NUMBER) | grep -E '[^0-9]'),)
70 echo $(BRILLO_PRODUCT_VERSION).$(BUILD_NUMBER) > $@
71else
Bertrand SIMONNET5f788822015-10-28 21:42:56 -070072 echo $(BRILLO_PRODUCT_VERSION).$(BUILD_DATETIME) > $@
Bertrand SIMONNETa659ce92015-10-08 13:06:35 -070073endif
Sen Jiangb6cfdd32016-11-03 16:24:14 -070074 $(hide) mkdir -p $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)
75 ln -sf /oem/$(OSRELEASED_DIRECTORY)/product_version $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)
Bertrand SIMONNETa659ce92015-10-08 13:06:35 -070076
77endif