| Bertrand SIMONNET | a659ce9 | 2015-10-08 13:06:35 -0700 | [diff] [blame] | 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 | # ======================================================== |
| 19 | ifdef OSRELEASED_DIRECTORY |
| 20 | |
| 21 | include $(CLEAR_VARS) |
| 22 | LOCAL_MODULE := product_id |
| Sen Jiang | b6cfdd3 | 2016-11-03 16:24:14 -0700 | [diff] [blame] | 23 | LOCAL_MODULE_CLASS := FAKE |
| 24 | LOCAL_MODULE_PATH := $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY) |
| Bertrand SIMONNET | a659ce9 | 2015-10-08 13:06:35 -0700 | [diff] [blame] | 25 | include $(BUILD_SYSTEM)/base_rules.mk |
| 26 | |
| Will Drewry | 00302c2 | 2015-11-04 18:51:35 -0800 | [diff] [blame] | 27 | # Attempt to populate the product id from a file in the product path. |
| 28 | LOADED_BRILLO_PRODUCT_ID := $(call cfgtree-get-if-exists,brillo/product_id) |
| 29 | |
| Bertrand SIMONNET | a659ce9 | 2015-10-08 13:06:35 -0700 | [diff] [blame] | 30 | # 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 Drewry | 00302c2 | 2015-11-04 18:51:35 -0800 | [diff] [blame] | 32 | $(LOCAL_BUILT_MODULE): BRILLO_PRODUCT_ID ?= "$(LOADED_BRILLO_PRODUCT_ID)" |
| Bertrand SIMONNET | a659ce9 | 2015-10-08 13:06:35 -0700 | [diff] [blame] | 33 | $(LOCAL_BUILT_MODULE): |
| Sen Jiang | b6cfdd3 | 2016-11-03 16:24:14 -0700 | [diff] [blame] | 34 | $(hide) mkdir -p $(dir $@) |
| Bertrand SIMONNET | a659ce9 | 2015-10-08 13:06:35 -0700 | [diff] [blame] | 35 | echo $(BRILLO_PRODUCT_ID) > $@ |
| Sen Jiang | b6cfdd3 | 2016-11-03 16:24:14 -0700 | [diff] [blame] | 36 | $(hide) mkdir -p $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY) |
| 37 | ln -sf /oem/$(OSRELEASED_DIRECTORY)/product_id $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY) |
| 38 | |
| Bertrand SIMONNET | a659ce9 | 2015-10-08 13:06:35 -0700 | [diff] [blame] | 39 | |
| 40 | include $(CLEAR_VARS) |
| 41 | LOCAL_MODULE := product_version |
| Sen Jiang | b6cfdd3 | 2016-11-03 16:24:14 -0700 | [diff] [blame] | 42 | LOCAL_MODULE_CLASS := FAKE |
| 43 | LOCAL_MODULE_PATH := $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY) |
| Bertrand SIMONNET | a659ce9 | 2015-10-08 13:06:35 -0700 | [diff] [blame] | 44 | include $(BUILD_SYSTEM)/base_rules.mk |
| 45 | |
| Sen Jiang | 4e37d79 | 2017-02-21 17:16:35 -0800 | [diff] [blame] | 46 | # The version is set to 0 if the user did not set the actual version and |
| Will Drewry | f01bc21 | 2015-11-05 16:07:18 -0800 | [diff] [blame] | 47 | # a version cannot be loaded from the product cfgtree. |
| Bertrand SIMONNET | a659ce9 | 2015-10-08 13:06:35 -0700 | [diff] [blame] | 48 | # This allows us to have a valid version number while being easy to filter. |
| Will Drewry | f01bc21 | 2015-11-05 16:07:18 -0800 | [diff] [blame] | 49 | ifeq ($(BRILLO_PRODUCT_VERSION),) |
| 50 | # Load from file first |
| 51 | BRILLO_PRODUCT_VERSION := $(call cfgtree-get-if-exists,brillo/product_version) |
| 52 | endif |
| Sen Jiang | 4e37d79 | 2017-02-21 17:16:35 -0800 | [diff] [blame] | 53 | # If the version is still empty, override it with 0 |
| Will Drewry | f01bc21 | 2015-11-05 16:07:18 -0800 | [diff] [blame] | 54 | ifeq ($(BRILLO_PRODUCT_VERSION),) |
| Sen Jiang | 4e37d79 | 2017-02-21 17:16:35 -0800 | [diff] [blame] | 55 | BRILLO_PRODUCT_VERSION := "0" |
| Will Drewry | f01bc21 | 2015-11-05 16:07:18 -0800 | [diff] [blame] | 56 | endif |
| Sen Jiang | 4e37d79 | 2017-02-21 17:16:35 -0800 | [diff] [blame] | 57 | ifeq ($(shell echo $(BRILLO_PRODUCT_VERSION) | grep -E '^[0-9]+$$'),) |
| Bertrand SIMONNET | a659ce9 | 2015-10-08 13:06:35 -0700 | [diff] [blame] | 58 | $(error Invalid BRILLO_PRODUCT_VERSION "$(BRILLO_PRODUCT_VERSION)", must be \ |
| Sen Jiang | 4e37d79 | 2017-02-21 17:16:35 -0800 | [diff] [blame] | 59 | a single number. Example: "1") |
| 60 | endif |
| 61 | |
| 62 | $(LOCAL_BUILT_MODULE): |
| 63 | $(hide) mkdir -p $(dir $@) |
| 64 | echo $(BRILLO_PRODUCT_VERSION) > $@ |
| 65 | $(hide) mkdir -p $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY) |
| 66 | ln -sf /oem/$(OSRELEASED_DIRECTORY)/product_version $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY) |
| 67 | |
| 68 | |
| 69 | include $(CLEAR_VARS) |
| 70 | LOCAL_MODULE := system_version |
| 71 | LOCAL_MODULE_CLASS := ETC |
| 72 | LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY) |
| 73 | include $(BUILD_SYSTEM)/base_rules.mk |
| 74 | |
| 75 | # The version is set to 0.0 if the user did not set the actual version and |
| 76 | # a version cannot be loaded from the product cfgtree. |
| 77 | # This allows us to have a valid version number while being easy to filter. |
| 78 | ifeq ($(BRILLO_SYSTEM_VERSION),) |
| 79 | # Load from file first |
| 80 | BRILLO_SYSTEM_VERSION := $(call cfgtree-get-if-exists,brillo/system_version) |
| 81 | endif |
| 82 | # If the version is still empty, override it with 0.0 |
| 83 | ifeq ($(BRILLO_SYSTEM_VERSION),) |
| 84 | BRILLO_SYSTEM_VERSION := "0.0" |
| 85 | endif |
| 86 | ifeq ($(shell echo $(BRILLO_SYSTEM_VERSION) | grep -E '^[0-9]+\.[0-9]+$$'),) |
| 87 | $(error Invalid BRILLO_SYSTEM_VERSION "$(BRILLO_SYSTEM_VERSION)", must be \ |
| 88 | two numbers separated by dots. Example: "1.2") |
| Bertrand SIMONNET | a659ce9 | 2015-10-08 13:06:35 -0700 | [diff] [blame] | 89 | endif |
| 90 | |
| 91 | # Append BUILD_NUMBER if it is a number or a build timestamp otherwise. |
| Bertrand SIMONNET | 5f78882 | 2015-10-28 21:42:56 -0700 | [diff] [blame] | 92 | # We don't want to use BUILD_DATETIME_FROM_FILE as this timestamp must be |
| 93 | # different at every build. |
| 94 | # If you don' want this to change at every build, you can define BUILD_NUMBER in |
| 95 | # your product makefile and increase it manually. |
| Bertrand SIMONNET | a659ce9 | 2015-10-08 13:06:35 -0700 | [diff] [blame] | 96 | $(LOCAL_BUILT_MODULE): |
| Sen Jiang | b6cfdd3 | 2016-11-03 16:24:14 -0700 | [diff] [blame] | 97 | $(hide) mkdir -p $(dir $@) |
| Bertrand SIMONNET | a659ce9 | 2015-10-08 13:06:35 -0700 | [diff] [blame] | 98 | ifeq ($(shell echo $(BUILD_NUMBER) | grep -E '[^0-9]'),) |
| Sen Jiang | 4e37d79 | 2017-02-21 17:16:35 -0800 | [diff] [blame] | 99 | echo $(BRILLO_SYSTEM_VERSION).$(BUILD_NUMBER) > $@ |
| Bertrand SIMONNET | a659ce9 | 2015-10-08 13:06:35 -0700 | [diff] [blame] | 100 | else |
| Sen Jiang | 4e37d79 | 2017-02-21 17:16:35 -0800 | [diff] [blame] | 101 | echo $(BRILLO_SYSTEM_VERSION).$(BUILD_DATETIME) > $@ |
| Bertrand SIMONNET | a659ce9 | 2015-10-08 13:06:35 -0700 | [diff] [blame] | 102 | endif |
| Bertrand SIMONNET | a659ce9 | 2015-10-08 13:06:35 -0700 | [diff] [blame] | 103 | |
| 104 | endif |