Bug 1745115 - Allow to give multiple configs to build-clang.py. r=firefox-build-system-reviewers,andi
And merge them. This will allow to deduplicate and uniformize them. Differential Revision: https://phabricator.services.mozilla.com/D133316
This commit is contained in:
@@ -599,6 +599,7 @@ if __name__ == "__main__":
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-c",
|
"-c",
|
||||||
"--config",
|
"--config",
|
||||||
|
action="append",
|
||||||
required=True,
|
required=True,
|
||||||
type=argparse.FileType("r"),
|
type=argparse.FileType("r"),
|
||||||
help="Clang configuration file",
|
help="Clang configuration file",
|
||||||
@@ -650,11 +651,35 @@ if __name__ == "__main__":
|
|||||||
cc_name = "clang-cl"
|
cc_name = "clang-cl"
|
||||||
cxx_name = "clang-cl"
|
cxx_name = "clang-cl"
|
||||||
|
|
||||||
config_dir = os.path.dirname(args.config.name)
|
config = {}
|
||||||
config = json.load(args.config)
|
# Merge all the configs we got from the command line.
|
||||||
patches = config.get("patches")
|
for c in args.config:
|
||||||
if patches:
|
this_config_dir = os.path.dirname(c.name)
|
||||||
config["patches"] = [os.path.join(this_config_dir, p) for p in patches]
|
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
|
stages = 2
|
||||||
if "stages" in config:
|
if "stages" in config:
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ set -x -e -v
|
|||||||
# This script is for building clang.
|
# This script is for building clang.
|
||||||
|
|
||||||
ORIGPWD="$PWD"
|
ORIGPWD="$PWD"
|
||||||
JSON_CONFIG="$1"
|
CONFIGS=$(for c; do echo -n " -c $GECKO_PATH/$c"; done)
|
||||||
|
|
||||||
cd $GECKO_PATH
|
cd $GECKO_PATH
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ if [ -d "$MOZ_FETCHES_DIR/binutils/bin" ]; then
|
|||||||
export PATH="$MOZ_FETCHES_DIR/binutils/bin:$PATH"
|
export PATH="$MOZ_FETCHES_DIR/binutils/bin:$PATH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "$JSON_CONFIG" in
|
case "$CONFIGS" in
|
||||||
*macosx64*)
|
*macosx64*)
|
||||||
# these variables are used in build-clang.py
|
# these variables are used in build-clang.py
|
||||||
export CROSS_CCTOOLS_PATH=$MOZ_FETCHES_DIR/cctools
|
export CROSS_CCTOOLS_PATH=$MOZ_FETCHES_DIR/cctools
|
||||||
@@ -38,7 +38,7 @@ case "$JSON_CONFIG" in
|
|||||||
*linux64*|*android*)
|
*linux64*|*android*)
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo Cannot figure out build configuration for $JSON_CONFIG
|
echo Cannot figure out build configuration for $CONFIGS
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@@ -47,7 +47,7 @@ esac
|
|||||||
set +x
|
set +x
|
||||||
|
|
||||||
cd $MOZ_FETCHES_DIR/llvm-project
|
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
|
set -x
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user