Expose wrap_mode as an option. Closes #4266.

pull/4236/head
Jussi Pakkanen 6 years ago
parent 24ea95abb1
commit 4d986563dc
  1. 12
      mesonbuild/coredata.py
  2. 8
      mesonbuild/interpreter.py
  3. 4
      mesonbuild/msetup.py
  4. 14
      mesonbuild/wrap/__init__.py
  5. 2
      test cases/common/44 options/meson.build

@ -223,7 +223,6 @@ class CoreData:
self.base_options = {}
self.external_preprocess_args = {} # CPPFLAGS only
self.cross_file = self.__load_cross_file(options.cross_file)
self.wrap_mode = options.wrap_mode if options.wrap_mode is not None else WrapMode.default
self.compilers = OrderedDict()
self.cross_compilers = OrderedDict()
self.deps = OrderedDict()
@ -338,7 +337,10 @@ class CoreData:
def get_builtin_option(self, optname):
if optname in self.builtins:
return self.builtins[optname].value
v = self.builtins[optname]
if optname == 'wrap_mode':
return WrapMode.from_string(v.value)
return v.value
raise RuntimeError('Tried to get unknown builtin option %s.' % optname)
def set_builtin_option(self, optname, value):
@ -616,7 +618,11 @@ builtin_options = {
'install_umask': [UserUmaskOption, 'Default umask to apply on permissions of installed files', '022'],
'auto_features': [UserFeatureOption, "Override value of all 'auto' features", 'auto'],
'optimization': [UserComboOption, 'Optimization level', ['0', 'g', '1', '2', '3', 's'], '0'],
'debug': [UserBooleanOption, 'Debug', True]
'debug': [UserBooleanOption, 'Debug', True],
'wrap_mode': [UserComboOption, 'Wrap mode', ['default',
'nofallback',
'nodownload',
'forcefallback'], 'default'],
}
# Special prefix-dependent defaults for installation directories that reside in

@ -2265,7 +2265,7 @@ external dependencies (including libraries) must go to "dependencies".''')
return subproject
subproject_dir_abs = os.path.join(self.environment.get_source_dir(), self.subproject_dir)
r = wrap.Resolver(subproject_dir_abs, self.coredata.wrap_mode)
r = wrap.Resolver(subproject_dir_abs, self.coredata.get_builtin_option('wrap_mode'))
try:
resolved = r.resolve(dirname)
except RuntimeError as e:
@ -2940,7 +2940,7 @@ external dependencies (including libraries) must go to "dependencies".''')
dep = NotFoundDependency(self.environment)
# Unless a fallback exists and is forced ...
if self.coredata.wrap_mode == WrapMode.forcefallback and 'fallback' in kwargs:
if self.coredata.get_builtin_option('wrap_mode') == WrapMode.forcefallback and 'fallback' in kwargs:
pass
# ... search for it outside the project
elif name != '':
@ -3007,12 +3007,12 @@ root and issuing %s.
def dependency_fallback(self, name, kwargs):
display_name = name if name else '(anonymous)'
if self.coredata.wrap_mode in (WrapMode.nofallback, WrapMode.nodownload):
if self.coredata.get_builtin_option('wrap_mode') in (WrapMode.nofallback, WrapMode.nodownload):
mlog.log('Not looking for a fallback subproject for the dependency',
mlog.bold(display_name), 'because:\nUse of fallback'
'dependencies is disabled.')
return None
elif self.coredata.wrap_mode == WrapMode.forcefallback:
elif self.coredata.get_builtin_option('wrap_mode') == WrapMode.forcefallback:
mlog.log('Looking for a fallback subproject for the dependency',
mlog.bold(display_name), 'because:\nUse of fallback dependencies is forced.')
else:

@ -32,10 +32,6 @@ def add_arguments(parser):
help='File describing cross compilation environment.')
parser.add_argument('-v', '--version', action='version',
version=coredata.version)
# See the mesonlib.WrapMode enum for documentation
parser.add_argument('--wrap-mode', default=None,
type=wrapmodetype, choices=WrapMode,
help='Special wrap mode to use')
parser.add_argument('--profile-self', action='store_true', dest='profile',
help=argparse.SUPPRESS)
parser.add_argument('--fatal-meson-warnings', action='store_true', dest='fatal_warnings',

@ -33,6 +33,15 @@ from enum import Enum
# Note that these options do not affect subprojects that
# are git submodules since those are only usable in git
# repositories, and you almost always want to download them.
# This did _not_ work when inside the WrapMode class.
# I don't know why. If you can fix this, patches welcome.
string_to_value = {'default': 1,
'nofallback': 2,
'nodownload': 3,
'forcefallback': 4,
}
class WrapMode(Enum):
default = 1
nofallback = 2
@ -41,3 +50,8 @@ class WrapMode(Enum):
def __str__(self):
return self.name
@staticmethod
def from_string(mode_name):
g = string_to_value[mode_name]
return WrapMode(g)

@ -29,3 +29,5 @@ endif
if get_option('integer_opt') != 3
error('Incorrect value in integer option.')
endif
assert(get_option('wrap_mode') == 'default', 'Wrap mode option is broken.')

Loading…
Cancel
Save