aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2018-10-04 21:57:27 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2018-10-07 22:52:54 +0300
commit4d986563dc3e9f850015619297dec92a102b6bbc (patch)
tree66d37ba1f4da4ae83ad93795820d95e642b41861
parent24ea95abb1b770b296bdf591bb2eb5e53715fa35 (diff)
downloadmeson-4d986563dc3e9f850015619297dec92a102b6bbc.zip
meson-4d986563dc3e9f850015619297dec92a102b6bbc.tar.gz
meson-4d986563dc3e9f850015619297dec92a102b6bbc.tar.bz2
Expose wrap_mode as an option. Closes #4266.
-rw-r--r--mesonbuild/coredata.py12
-rw-r--r--mesonbuild/interpreter.py8
-rw-r--r--mesonbuild/msetup.py4
-rw-r--r--mesonbuild/wrap/__init__.py14
-rw-r--r--test cases/common/44 options/meson.build2
5 files changed, 29 insertions, 11 deletions
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py
index 1ab7d72..819481b 100644
--- a/mesonbuild/coredata.py
+++ b/mesonbuild/coredata.py
@@ -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
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index f2b8f34..2d5dd92 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -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:
diff --git a/mesonbuild/msetup.py b/mesonbuild/msetup.py
index 1576556..9588555 100644
--- a/mesonbuild/msetup.py
+++ b/mesonbuild/msetup.py
@@ -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',
diff --git a/mesonbuild/wrap/__init__.py b/mesonbuild/wrap/__init__.py
index b792dfa..6be2c44 100644
--- a/mesonbuild/wrap/__init__.py
+++ b/mesonbuild/wrap/__init__.py
@@ -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)
diff --git a/test cases/common/44 options/meson.build b/test cases/common/44 options/meson.build
index f177aa4..c6cf9c8 100644
--- a/test cases/common/44 options/meson.build
+++ b/test cases/common/44 options/meson.build
@@ -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.')