aboutsummaryrefslogtreecommitdiff
path: root/util/mainboard/google/create_coreboot_variant.sh
blob: 14b2115d180811ddf1952ba38340092228c001cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
#
# This file is part of the coreboot project.
#
# Copyright 2019 Google LLC.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

VERSION="1.0.2"
SCRIPT=$(basename -- "${0}")

export LC_ALL=C

if [[ "$#" -lt 2 ]]; then
  echo "Usage: ${SCRIPT} base_name variant_name [bug_number]"
  echo "e.g. ${SCRIPT} hatch kohaku b:140261109"
  echo "* Adds a new variant of the baseboard to Kconfig and Kconfig.name"
  echo "* Copies the template files for the baseboard to the new variant"
  exit 1
fi

# This is the name of the base board that we're using to make the variant.
# ${var,,} converts to all lowercase.
BASE="${1,,}"
# This is the name of the variant that is being cloned.
# ${var,,} converts to all lowercase; ${var^^} is all uppercase.
VARIANT="${2,,}"
VARIANT_UPPER="${VARIANT^^}"

# Assign BUG= text, or "None" if that parameter wasn't specified.
BUG=${3:-None}

# This script lives in util/mainboard/google
# The template files are in util/mainboard/google/${BASE}/templates
# We need to create files in src/mainboard/google/${BASE}/variants/${VARIANT}
pushd "${BASH_SOURCE%/*}" || exit 1
SRC=$(pwd)
popd || exit 1
pushd "${SRC}/../../../src/mainboard/google/${BASE}" || {
  echo "The baseboard directory for ${BASE} does not exist.";
  exit 1; }

# Make sure the variant doesn't already exist.
if [[ -e variants/${VARIANT} ]]; then
  echo "variants/${VARIANT} already exists."
  echo "Have you already created this variant?"
  exit 1
fi

# Start a branch. Use YMD timestamp to avoid collisions.
DATE=$(date +%Y%m%d)
git checkout -b "coreboot_${VARIANT}_${DATE}" || exit 1

# Copy the template tree to the target.
mkdir -p "variants/${VARIANT}/"
cp -pr "${SRC}/${BASE}/template/." "variants/${VARIANT}/"
git add "variants/${VARIANT}/"

# Now add the new variant to Kconfig and Kconfig.name
# These files are in the current directory, e.g. src/mainboard/google/hatch
"${SRC}/kconfig.py" --board "${BASE}" --variant "${VARIANT}" || exit 1

mv Kconfig.new Kconfig
mv Kconfig.name.new Kconfig.name

git add Kconfig Kconfig.name

# Now commit the files.
git commit -sm "${BASE}: Create ${VARIANT} variant

Create the ${VARIANT} variant of the ${BASE} baseboard by
copying the baseboard template files to a new directory
named for the variant.

(Auto-Generated by ${SCRIPT} version ${VERSION}).

BUG=${BUG}
TEST=util/abuild/abuild -p none -t google/${BASE} -x -a
make sure the build includes GOOGLE_${VARIANT_UPPER}"