summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2019-03-26 14:57:54 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-05-10 10:43:54 -0700
commit22b1008446791f31d8841b8ae43bbbc0f4d9f143 (patch)
treecd9cf0afc83083980ee644ff415e04a47eabedba /util
parent8dadabb6810cba442e17025d292444f63880638d (diff)
downloadchrome-ec-22b1008446791f31d8841b8ae43bbbc0f4d9f143.tar.gz
cr50: rebuild board image if essential make variables change
When building Cr50 board image, some make variables get converted into compilation flags, which affect image composition. Changes of these variables go unnoticed as they do not directly affect make dependencies. Let's define the set of essential variables in ENV_VARS, and save the state of these variables at build time in a generated .h file, updating it only if any of the variables' values changed since the previous make run. The generated .h file is included in board.h, which guarantees that files dependent on board.h are recompiled if the generated .h file changes. BRANCH=cr50 BUG=none TEST=verified that changing of CR50_DEV and/or H1_RED_BOARD or CR50_SQA values triggers full rebuild of the Cr50 image. Verified that 'emerge-atlas ec-utils' also succeeds. Change-Id: Id0589a3b6a66fe4da90a9aea894bc83eb6337c8c Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/707915 Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'util')
-rwxr-xr-xutil/env_changed.sh23
1 files changed, 23 insertions, 0 deletions
diff --git a/util/env_changed.sh b/util/env_changed.sh
new file mode 100755
index 0000000000..5bab64760d
--- /dev/null
+++ b/util/env_changed.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+# Copyright 2019 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# This script accepts two parameters: a file name and a string.
+#
+# If the file does not exist, or does not contain the passed in string wrapped
+# in '/*... */, the file is written with the wrapped passed in string.
+
+h_file="$1"
+current_set="/* $2 */"
+
+if [[ -f "${h_file}" ]]; then
+ old_set="$(cat "${h_file}")"
+ if [[ "${current_set}" == "${old_set}" ]]; then
+ exit 0
+ fi
+else
+ dest_dir="$(dirname "${h_file}")"
+ [[ -d "${dest_dir}" ]] || mkdir -p "${dest_dir}"
+fi
+printf "${current_set}" > "${h_file}"