aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/coredata.py3
-rw-r--r--mesonbuild/interpreter.py30
-rw-r--r--mesonbuild/mconf.py5
-rw-r--r--mesonbuild/mesonmain.py12
-rw-r--r--mesonbuild/mintro.py3
-rw-r--r--mesonbuild/mlog.py3
-rw-r--r--mesonbuild/wrap/wraptool.py4
7 files changed, 24 insertions, 36 deletions
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py
index afd39c8..4b32c19 100644
--- a/mesonbuild/coredata.py
+++ b/mesonbuild/coredata.py
@@ -19,6 +19,7 @@ from pathlib import PurePath
from collections import OrderedDict
from .mesonlib import MesonException
from .mesonlib import default_libdir, default_libexecdir, default_prefix
+from .wrap import WrapMode
import ast
import argparse
@@ -222,7 +223,7 @@ 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
+ 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()
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 0b4cbce..04e963a 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -2279,21 +2279,19 @@ external dependencies (including libraries) must go to "dependencies".''')
return self.subprojects[dirname]
def get_option_internal(self, optname):
+ # Some base options are not defined in some environments, return the
+ # default value from compilers.base_options in that case.
+ for d in [self.coredata.base_options, compilers.base_options,
+ self.coredata.builtins, self.coredata.compiler_options]:
+ try:
+ return d[optname]
+ except KeyError:
+ pass
+
raw_optname = optname
- try:
- return self.coredata.base_options[optname]
- except KeyError:
- pass
- try:
- return self.coredata.builtins[optname]
- except KeyError:
- pass
- try:
- return self.coredata.compiler_options[optname]
- except KeyError:
- pass
- if not coredata.is_builtin_option(optname) and self.is_subproject():
+ if self.is_subproject():
optname = self.subproject + ':' + optname
+
try:
opt = self.coredata.user_options[optname]
if opt.yielding and ':' in optname and raw_optname in self.coredata.user_options:
@@ -2313,11 +2311,7 @@ external dependencies (including libraries) must go to "dependencies".''')
return opt
except KeyError:
pass
- # Some base options are not defined in some environments, return the default value.
- try:
- return compilers.base_options[optname]
- except KeyError:
- pass
+
raise InterpreterException('Tried to access unknown option "%s".' % optname)
@stringArgs
diff --git a/mesonbuild/mconf.py b/mesonbuild/mconf.py
index 513c238..2fd69b0 100644
--- a/mesonbuild/mconf.py
+++ b/mesonbuild/mconf.py
@@ -13,7 +13,6 @@
# limitations under the License.
import os
-import sys
import argparse
from . import (coredata, mesonlib, build)
@@ -172,7 +171,3 @@ def run(args):
print('Meson configurator encountered an error:')
raise e
return 0
-
-
-if __name__ == '__main__':
- sys.exit(run(sys.argv[1:]))
diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py
index 68a2ddb..e8b7b30 100644
--- a/mesonbuild/mesonmain.py
+++ b/mesonbuild/mesonmain.py
@@ -36,7 +36,7 @@ def create_parser():
p.add_argument('-v', '--version', action='version',
version=coredata.version)
# See the mesonlib.WrapMode enum for documentation
- p.add_argument('--wrap-mode', default=WrapMode.default,
+ p.add_argument('--wrap-mode', default=None,
type=wrapmodetype, choices=WrapMode,
help='Special wrap mode to use')
p.add_argument('--profile-self', action='store_true', dest='profile',
@@ -71,18 +71,18 @@ class MesonApp:
if not os.path.exists(ndir2):
os.makedirs(ndir2)
if not stat.S_ISDIR(os.stat(ndir1).st_mode):
- raise RuntimeError('%s is not a directory' % dir1)
+ raise MesonException('%s is not a directory' % dir1)
if not stat.S_ISDIR(os.stat(ndir2).st_mode):
- raise RuntimeError('%s is not a directory' % dir2)
+ raise MesonException('%s is not a directory' % dir2)
if os.path.samefile(dir1, dir2):
- raise RuntimeError('Source and build directories must not be the same. Create a pristine build directory.')
+ raise MesonException('Source and build directories must not be the same. Create a pristine build directory.')
if self.has_build_file(ndir1):
if self.has_build_file(ndir2):
- raise RuntimeError('Both directories contain a build file %s.' % environment.build_filename)
+ raise MesonException('Both directories contain a build file %s.' % environment.build_filename)
return ndir1, ndir2
if self.has_build_file(ndir2):
return ndir2, ndir1
- raise RuntimeError('Neither directory contains a build file %s.' % environment.build_filename)
+ raise MesonException('Neither directory contains a build file %s.' % environment.build_filename)
def validate_dirs(self, dir1, dir2, handshake):
(src_dir, build_dir) = self.validate_core_dirs(dir1, dir2)
diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py
index 94bc00b..188459a 100644
--- a/mesonbuild/mintro.py
+++ b/mesonbuild/mintro.py
@@ -249,6 +249,3 @@ def run(args):
print('No command specified')
return 1
return 0
-
-if __name__ == '__main__':
- sys.exit(run(sys.argv[1:]))
diff --git a/mesonbuild/mlog.py b/mesonbuild/mlog.py
index 1654824..b8d3ccc 100644
--- a/mesonbuild/mlog.py
+++ b/mesonbuild/mlog.py
@@ -59,9 +59,12 @@ def set_timestamp_start(start):
def shutdown():
global log_file
if log_file is not None:
+ path = log_file.name
exception_around_goer = log_file
log_file = None
exception_around_goer.close()
+ return path
+ return None
class AnsiDecorator:
plain_code = "\033[0m"
diff --git a/mesonbuild/wrap/wraptool.py b/mesonbuild/wrap/wraptool.py
index 570e691..364452d 100644
--- a/mesonbuild/wrap/wraptool.py
+++ b/mesonbuild/wrap/wraptool.py
@@ -213,6 +213,4 @@ def run(args):
add_arguments(parser)
options = parser.parse_args(args)
options.wrap_func(options)
-
-if __name__ == '__main__':
- sys.exit(run(sys.argv[1:]))
+ return 0