diff --git a/build/build-clang/build-clang.py b/build/build-clang/build-clang.py index 853c70a78b12..f4260555ec4d 100755 --- a/build/build-clang/build-clang.py +++ b/build/build-clang/build-clang.py @@ -599,6 +599,7 @@ if __name__ == "__main__": parser.add_argument( "-c", "--config", + action="append", required=True, type=argparse.FileType("r"), help="Clang configuration file", @@ -650,11 +651,35 @@ if __name__ == "__main__": cc_name = "clang-cl" cxx_name = "clang-cl" - config_dir = os.path.dirname(args.config.name) - config = json.load(args.config) - patches = config.get("patches") - if patches: - config["patches"] = [os.path.join(this_config_dir, p) for p in patches] + config = {} + # Merge all the configs we got from the command line. + for c in args.config: + this_config_dir = os.path.dirname(c.name) + this_config = json.load(c) + patches = this_config.get("patches") + if patches: + this_config["patches"] = [os.path.join(this_config_dir, p) for p in patches] + for key, value in this_config.items(): + old_value = config.get(key) + if old_value is None: + config[key] = value + elif value is None: + if key in config: + del config[key] + elif type(old_value) != type(value): + raise Exception( + "{} is overriding `{}` with a value of the wrong type".format( + c.name, key + ) + ) + elif isinstance(old_value, list): + for v in value: + if v not in old_value: + old_value.append(v) + elif isinstance(old_value, dict): + raise Exception("{} is setting `{}` to a dict?".format(c.name, key)) + else: + config[key] = value stages = 2 if "stages" in config: diff --git a/taskcluster/scripts/misc/build-clang.sh b/taskcluster/scripts/misc/build-clang.sh index e9add71ecf02..378727c9cbe7 100755 --- a/taskcluster/scripts/misc/build-clang.sh +++ b/taskcluster/scripts/misc/build-clang.sh @@ -4,7 +4,7 @@ set -x -e -v # This script is for building clang. ORIGPWD="$PWD" -JSON_CONFIG="$1" +CONFIGS=$(for c; do echo -n " -c $GECKO_PATH/$c"; done) cd $GECKO_PATH @@ -16,7 +16,7 @@ if [ -d "$MOZ_FETCHES_DIR/binutils/bin" ]; then export PATH="$MOZ_FETCHES_DIR/binutils/bin:$PATH" fi -case "$JSON_CONFIG" in +case "$CONFIGS" in *macosx64*) # these variables are used in build-clang.py export CROSS_CCTOOLS_PATH=$MOZ_FETCHES_DIR/cctools @@ -38,7 +38,7 @@ case "$JSON_CONFIG" in *linux64*|*android*) ;; *) - echo Cannot figure out build configuration for $JSON_CONFIG + echo Cannot figure out build configuration for $CONFIGS exit 1 ;; esac @@ -47,7 +47,7 @@ esac set +x cd $MOZ_FETCHES_DIR/llvm-project -python3 $GECKO_PATH/build/build-clang/build-clang.py -c $GECKO_PATH/$1 +python3 $GECKO_PATH/build/build-clang/build-clang.py $CONFIGS set -x