summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Fagerburg <pfagerburg@chromium.org>2019-08-23 11:28:22 -0600
committerCommit Bot <commit-bot@chromium.org>2019-09-06 20:51:12 +0000
commita213ebd7017c120cd19b4fd510a0ff829786617e (patch)
tree1f3732d39d50689ead3851b2606f5a28d5fbebd9
parentcc6db929b7e2b2b840528574ba77aa8b15363775 (diff)
downloadchrome-ec-a213ebd7017c120cd19b4fd510a0ff829786617e.tar.gz
ec: create initial EC image for a new variant
Creating an initial EC image for a variant is just a copy of the base board's files. After all of the CLs to create the variant have landed, then we can make changes specific to the variant. BUG=b:140261109, chromium:999705 BRANCH=none TEST=``./initial_ec_image.sh hatch sushi && git show`` Compare board/hatch/* to board/sushi/* Also run the script with an existing board name to verify that you can't create a variant that already exists. Also run the script with a non-existent base board to verify that you can't clone something that doesn't exist. Change-Id: Ic54b0b5a8b41476779dcbb6af63bd0ddfaff2896 Signed-off-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1782686 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
-rwxr-xr-xutil/create_variant.sh64
1 files changed, 64 insertions, 0 deletions
diff --git a/util/create_variant.sh b/util/create_variant.sh
new file mode 100755
index 0000000000..469e820e88
--- /dev/null
+++ b/util/create_variant.sh
@@ -0,0 +1,64 @@
+#!/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.
+
+if [[ "$#" -ne 2 ]]; then
+ echo "Usage: $0 base_name variant_name"
+ echo "e.g. $0 hatch kohaku"
+ echo "Creates the initial EC image as a copy of the base board's EC."
+ exit 1
+fi
+
+# This is the name of the base board that we're cloning to make the variant.
+# ${var,,} converts to all lowercase
+base="${1,,}"
+# This is the name of the variant that is being cloned
+variant="${2,,}"
+
+# All of the necessary files are in the ../board directory:
+pushd "${BASH_SOURCE%/*}/../board" || exit
+
+# Make sure that the base exists
+if [[ ! -e "${base}" ]]; then
+ echo "${base} does not exist; please specify a valid baseboard"
+ popd || exit
+ exit 2
+fi
+
+# Make sure the variant doesn't already exist
+if [[ -e "${variant}" ]]; then
+ echo "${variant} already exists; have you already created this variant?"
+ popd || exit
+ exit 2
+fi
+
+# Start a branch. Use YMD timestamp to avoid collisions.
+DATE=$(date +%Y%m%d)
+repo start "create_${variant}_${DATE}" || exit
+
+mkdir "${variant}"
+cp "${base}"/* "${variant}"
+# TODO replace the base name with the variant name in the copied files,
+# TODO except for the BASEBOARD=${base^^} line in build.mk
+
+# Build the code; exit if it fails
+pushd .. || exit
+make BOARD=${variant} || exit
+popd || exit
+
+git add "${variant}"/*
+
+# Now commit the files
+git commit -sm "${variant}: Initial EC image
+
+The starting point for the ${variant} EC image
+
+BUG=none
+BRANCH=none
+TEST=make BOARD=${variant}"
+
+popd || exit
+
+echo "Please check all the files (git show), make any changes you want,"
+echo "and then repo upload."