1#
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
23LOCAL_MODULE_CLASS := FAKE
24LOCAL_MODULE_PATH := $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)
25include $(BUILD_SYSTEM)/base_rules.mk
26
27$(LOCAL_BUILT_MODULE):
28	$(hide) mkdir -p $(dir $@)
29	echo $(BRILLO_PRODUCT_ID) > $@
30	$(hide) mkdir -p $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)
31	ln -sf /oem/$(OSRELEASED_DIRECTORY)/product_id $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)
32
33include $(CLEAR_VARS)
34LOCAL_MODULE := system_id
35LOCAL_MODULE_CLASS := ETC
36LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)
37include $(BUILD_SYSTEM)/base_rules.mk
38
39$(LOCAL_BUILT_MODULE):
40	$(hide) mkdir -p $(dir $@)
41	echo $(BRILLO_SYSTEM_ID) > $@
42
43
44include $(CLEAR_VARS)
45LOCAL_MODULE := product_version
46LOCAL_MODULE_CLASS := FAKE
47LOCAL_MODULE_PATH := $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)
48include $(BUILD_SYSTEM)/base_rules.mk
49
50# The version is set to 0.0.0.0 if the user did not set the actual version.
51# This allows us to have a valid version number while being easy to filter.
52BRILLO_PRODUCT_VERSION ?= "0.0.0.0"
53ifeq ($(shell echo $(BRILLO_PRODUCT_VERSION) | grep -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$$'),)
54$(error Invalid BRILLO_PRODUCT_VERSION "$(BRILLO_PRODUCT_VERSION)", must be \
55  four numbers separated by dots. Example: "1.2.0.0")
56endif
57
58$(LOCAL_BUILT_MODULE):
59	$(hide) mkdir -p $(dir $@)
60	echo $(BRILLO_PRODUCT_VERSION) > $@
61	$(hide) mkdir -p $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)
62	ln -sf /oem/$(OSRELEASED_DIRECTORY)/product_version $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)
63
64
65include $(CLEAR_VARS)
66LOCAL_MODULE := system_version
67LOCAL_MODULE_CLASS := ETC
68LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)
69include $(BUILD_SYSTEM)/base_rules.mk
70
71# The version is set to 0.0.0 if the user did not set the actual version.
72# This allows us to have a valid version number while being easy to filter.
73BRILLO_SYSTEM_VERSION ?= "0.0.0"
74ifeq ($(shell echo $(BRILLO_SYSTEM_VERSION) | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$$'),)
75$(error Invalid BRILLO_SYSTEM_VERSION "$(BRILLO_SYSTEM_VERSION)", must be \
76  three numbers separated by dots. Example: "1.2.0")
77endif
78
79# Append BUILD_NUMBER if it is a number or a build timestamp otherwise.
80# If you don' want this to change at every build, you can define BUILD_NUMBER in
81# your product makefile and increase it manually.
82$(LOCAL_BUILT_MODULE):
83	$(hide) mkdir -p $(dir $@)
84ifeq ($(strip $(HAS_BUILD_NUMBER)),true)
85	echo $(BRILLO_SYSTEM_VERSION).$(shell cat $(BUILD_NUMBER_FILE)) > $@
86else
87	echo $(BRILLO_SYSTEM_VERSION).$(BUILD_DATETIME_FROM_FILE) > $@
88endif
89
90endif
91