Dactyloidae/python/mozbuild/mozbuild/mozconfig_loader
athenian200 f7e2b86c94 MoonchildProductions#1251 - Part 2: Make the mozconfig loader POSIX-compliant.
https://bugzilla.mozilla.org/show_bug.cgi?id=1360571

Solaris uses ksh as the default shell, and furthermore bash doesn't seem to support the 'local' keyword feature when invoked as sh on OpenIndiana. We could just change the script to use bash (it is an option even on Solaris), but this fix is available and Mozilla has been using it since Firefox 55 with no issues on any other platforms. It was specfically done this way to avoid any need to change existing mozconfig files, so I feel confident saying the change is totally benign and if anything the way it is now is technically a POSIX compliance issue inherited from Mozilla that we'll hit if we ever try to compile this on any Unix platform where bash isn't sh.
2019-11-04 11:52:14 +08:00

78 lines
1.8 KiB
Bash

#!/bin/sh
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# This script provides an execution environment for mozconfig scripts.
# This script is not meant to be called by users. Instead, some
# higher-level driver invokes it and parses the machine-tailored output.
set -e
ac_add_options() {
for _mozconfig_opt; do
case "$_mozconfig_opt" in
--target=*)
echo "------BEGIN_MK_OPTION"
echo $_mozconfig_opt | sed s/--target/CONFIG_GUESS/
echo "------END_MK_OPTION"
;;
esac
echo "------BEGIN_AC_OPTION"
echo $_mozconfig_opt
echo "------END_AC_OPTION"
done
}
ac_add_app_options() {
_mozconfig_app=$1
shift
echo "------BEGIN_AC_APP_OPTION"
echo $_mozconfig_app
echo "$*"
echo "------END_AC_APP_OPTION"
}
mk_add_options() {
for _mozconfig_opt; do
echo "------BEGIN_MK_OPTION"
echo $_mozconfig_opt
# Remove any leading "export"
opt=${_mozconfig_opt#export}
case "$_mozconfig_opt" in
*\?=*) _mozconfig_op="?=" ;;
*:=*) _mozconfig_op=":=" ;;
*+=*) _mozconfig_op="+=" ;;
*=*) _mozconfig_op="=" ;;
esac
# Remove the operator and the value that follows
_mozconfig_name=${_mozconfig_opt%%${_mozconfig_op}*}
# Note: $(echo ${_mozconfig_name}) strips the variable from any leading and trailing
# whitespaces.
eval "$(echo ${_mozconfig_name})_IS_SET=1"
echo "------END_MK_OPTION"
done
}
echo "------BEGIN_ENV_BEFORE_SOURCE"
$3 $4
echo "------END_ENV_BEFORE_SOURCE"
echo "------BEGIN_BEFORE_SOURCE"
set
echo "------END_BEFORE_SOURCE"
topsrcdir=$1
. $2
unset topsrcdir
echo "------BEGIN_AFTER_SOURCE"
set
echo "------END_AFTER_SOURCE"
echo "------BEGIN_ENV_AFTER_SOURCE"
$3 $4
echo "------END_ENV_AFTER_SOURCE"