mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 12:25:53 +00:00
d33300555c
With all the things that still depend on all the variables derived from --host and --target in both old-configure and moz.build, we still need to keep variables such as OS_ARCH, OS_TARGET, CPU_ARCH, OS_TEST, etc. Eventually, we'd settle on the output of split_triplet. This /tries/ to preserve the current values for all these variables, while also trying to make things a little more consistent. It also effectively rejects OSes such as HPUX or AIX, because it is unclear the decades old accumulated scripts related to them still do anything useful, and we might as well have them start again from scratch, which, in the coming weeks, will be even easier.
111 lines
2.5 KiB
Python
111 lines
2.5 KiB
Python
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
|
|
# vim: set filetype=python:
|
|
# 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/.
|
|
|
|
@template
|
|
@advanced
|
|
def warn(*args):
|
|
import sys
|
|
print(*args, file=sys.stderr)
|
|
sys.stderr.flush()
|
|
|
|
|
|
@template
|
|
@advanced
|
|
def error(*args):
|
|
import sys
|
|
print(*args, file=sys.stderr)
|
|
sys.stderr.flush()
|
|
sys.exit(1)
|
|
|
|
|
|
@template
|
|
@advanced
|
|
def is_absolute_or_relative(path):
|
|
import os
|
|
if os.altsep and os.altsep in path:
|
|
return True
|
|
return os.sep in path
|
|
|
|
|
|
@template
|
|
@advanced
|
|
def normsep(path):
|
|
import mozpack.path as mozpath
|
|
return mozpath.normsep(path)
|
|
|
|
|
|
@template
|
|
@advanced
|
|
def find_program(file):
|
|
if is_absolute_or_relative(file):
|
|
return os.path.abspath(file) if os.path.isfile(file) else None
|
|
from which import which, WhichError
|
|
try:
|
|
return normsep(which(file))
|
|
except WhichError:
|
|
return None
|
|
|
|
|
|
@depends('--help')
|
|
def _defines(help):
|
|
ret = {}
|
|
set_config('DEFINES', ret)
|
|
return ret
|
|
|
|
|
|
@template
|
|
def set_define(name, value):
|
|
@depends(_defines)
|
|
@advanced
|
|
def _add_define(defines):
|
|
from mozbuild.configure import ConfigureError
|
|
if name in defines:
|
|
raise ConfigureError("'%s' is already defined" % name)
|
|
defines[name] = value
|
|
|
|
del _defines
|
|
|
|
|
|
@template
|
|
def unique_list(l):
|
|
result = []
|
|
for i in l:
|
|
if l not in result:
|
|
result.append(i)
|
|
return result
|
|
|
|
|
|
# Denotes a deprecated option. Combines option() and @depends:
|
|
# @deprecated_option('--option')
|
|
# def option(value):
|
|
# ...
|
|
# @deprecated_option() takes the same arguments as option(), except `help`.
|
|
# The function may handle the option like a typical @depends function would,
|
|
# but it is recommended it emits a deprecation error message suggesting an
|
|
# alternative option to use if there is one.
|
|
@template
|
|
def deprecated_option(*args, **kwargs):
|
|
assert 'help' not in kwargs
|
|
kwargs['help'] = 'Deprecated'
|
|
opt = option(*args, **kwargs)
|
|
|
|
def decorator(func):
|
|
@depends(opt.option)
|
|
def deprecated(value):
|
|
if value.origin != 'default':
|
|
return func(value)
|
|
return deprecated
|
|
|
|
return decorator
|
|
|
|
|
|
# from mozbuild.util import ReadOnlyNamespace as namespace
|
|
@template
|
|
@advanced
|
|
def namespace(**kwargs):
|
|
from mozbuild.util import ReadOnlyNamespace
|
|
return ReadOnlyNamespace(**kwargs)
|