1#!/usr/bin/env bash 2# 3# Copyright 2020 The ChromiumOS Authors 4# Use of this source code is governed by a BSD-style license that can be 5# found in the LICENSE file. 6 7# Used to generate program and project configuration. Expects to be able 8# to find the protocol buffer generating script in the directory with the 9# config file at config/generate.sh and expects to be able to find the 10# lucicfg binary on the path from depot_tools. 11 12# Exit if any command fails. 13set -e 14 15readonly script_dir="$(dirname "$(realpath -e "${BASH_SOURCE[0]}")")" 16source "${script_dir}/common.sh" 17 18output_dir="." 19help="" 20while [[ $# -gt 0 ]]; do 21 case $1 in 22 --output-dir|-o) 23 output_dir="$2" 24 shift 25 shift 26 ;; 27 --help|-h) 28 help="yes" 29 shift 30 ;; 31 --*) 32 echo "Unknown long option $1" >&2 33 shift 34 ;; 35 *) 36 break 37 ;; 38 esac 39done 40 41if [[ -n "${help}" ]]; then 42 config_usage 43 exit 0 44fi 45 46if [[ $# -ne 1 ]]; then 47 config_usage 48fi 49 50readonly file_path="${1}" 51readonly config_dir="$(dirname "$(realpath -e "${file_path}")")" 52 53if [[ -e "${config_dir}"/program/config.star ]]; then 54 echo "Making sure program config is fresh..." 55 "${script_dir}"/gen_config "${config_dir}"/program/config.star 56fi 57 58echo "Building config from source starlark config files." 59"${script_dir}"/build_config -o "${output_dir}" "$@" 60echo "Transforming generated protojson config enums" 61cd "${config_dir}" 62"${script_dir}"/transform_config_enums "${output_dir}" 63echo "Transforming generated protojson config to build config" 64cd "${config_dir}" 65"${script_dir}"/transform_config "${output_dir}" 66