зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1181040 - Set ${var}_IS_SET variables for mk_add_options-defined variables. r=gps
It is useful to be able, during mozconfig execution, to do tests depending on what was previously added with mk_add_options. Specifically, there is a need to do this for MOZ_PGO because developers pushing to try may add it to mozconfig.common.override. While, ideally, it would be nice if we just defined the variable itself in the mozconfig execution environment, that is a tedious task, having to jump through hoops with eval, and handle all cases of variable assigment properly. The hacky alternative is to just treat MOZ_PGO specially, but meh. So instead, we set a ${var}_IS_SET variable to 1, indicating that a mk_add_options defined ${var} to some value.
This commit is contained in:
Родитель
b199109bdf
Коммит
8a8b15e5db
|
@ -36,10 +36,23 @@ ac_add_app_options() {
|
|||
}
|
||||
|
||||
mk_add_options() {
|
||||
local opt
|
||||
local opt name op value
|
||||
for opt; do
|
||||
echo "------BEGIN_MK_OPTION"
|
||||
echo $opt
|
||||
# Remove any leading "export"
|
||||
opt=${opt#export}
|
||||
case "$opt" in
|
||||
*\?=*) op="?=" ;;
|
||||
*:=*) op=":=" ;;
|
||||
*+=*) op="+=" ;;
|
||||
*=*) op="=" ;;
|
||||
esac
|
||||
# Remove the operator and the value that follows
|
||||
name=${opt%%${op}*}
|
||||
# Note: $(echo ${name}) strips the variable from any leading and trailing
|
||||
# whitespaces.
|
||||
eval "$(echo ${name})_IS_SET=1"
|
||||
echo "------END_MK_OPTION"
|
||||
done
|
||||
}
|
||||
|
|
|
@ -319,6 +319,10 @@ class TestMozconfigLoader(unittest.TestCase):
|
|||
self.assertEqual(result['make_flags'], ['-j8', '-s'])
|
||||
self.assertEqual(result['make_extra'], ['FOO=BAR BAZ', 'BIZ=1'])
|
||||
|
||||
vars = result['vars']['added']
|
||||
for var in ('MOZ_OBJDIR', 'MOZ_MAKE_FLAGS', 'FOO', 'BIZ'):
|
||||
self.assertEqual(vars.get('%s_IS_SET' % var), '1')
|
||||
|
||||
def test_read_empty_mozconfig_objdir_environ(self):
|
||||
os.environ[b'MOZ_OBJDIR'] = b'obj-firefox'
|
||||
with NamedTemporaryFile(mode='w') as mozconfig:
|
||||
|
|
Загрузка…
Ссылка в новой задаче