aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md10
-rwxr-xr-xmeson.py15
-rw-r--r--mesonbuild/compilers.py30
-rw-r--r--mesonbuild/dependencies.py6
-rw-r--r--mesonbuild/environment.py3
-rw-r--r--mesonbuild/interpreter.py6
-rw-r--r--mesonbuild/mesonlib.py2
-rw-r--r--mesonbuild/mesonmain.py8
-rw-r--r--mesonbuild/wrap/wrap.py30
-rw-r--r--setup.py1
10 files changed, 69 insertions, 42 deletions
diff --git a/README.md b/README.md
index 273398f..645dd97 100644
--- a/README.md
+++ b/README.md
@@ -4,9 +4,11 @@
MesonĀ® is a project to create the best possible next-generation
build system.
-####Build status
+#### Status
-[![Build Status](https://travis-ci.org/mesonbuild/meson.svg?branch=master)](https://travis-ci.org/mesonbuild/meson) [![Build status](https://ci.appveyor.com/api/projects/status/l5c8v71ninew2i3p?svg=true)](https://ci.appveyor.com/project/jpakkane/meson)
+[![PyPI](https://img.shields.io/pypi/v/meson.svg)](https://pypi.python.org/pypi/meson)
+[![Travis](https://travis-ci.org/mesonbuild/meson.svg?branch=master)](https://travis-ci.org/mesonbuild/meson)
+[![Appveyor](https://ci.appveyor.com/api/projects/status/l5c8v71ninew2i3p?svg=true)](https://ci.appveyor.com/project/jpakkane/meson)
####Dependencies
@@ -38,6 +40,10 @@ executable run the following command:
Note that the source checkout may not be `meson` because it would
clash with the generated binary name.
+This will zip all files inside the source checkout into the script
+which includes hundreds of tests, so you might want to temporarily
+remove those before running it.
+
####Running
Meson requires that you have a source directory and a build directory
diff --git a/meson.py b/meson.py
index 8c223e5..6dc5c7a 100755
--- a/meson.py
+++ b/meson.py
@@ -14,10 +14,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from mesonbuild import mesonmain
-import sys, os
+from mesonbuild import mlog, mesonmain
+import sys, os, locale
def main():
+ # Warn if the locale is not UTF-8. This can cause various unfixable issues
+ # such as os.stat not being able to decode filenames with unicode in them.
+ # There is no way to reset both the preferred encoding and the filesystem
+ # encoding, so we can just warn about it.
+ e = locale.getpreferredencoding()
+ if e.upper() != 'UTF-8':
+ mlog.warning('You are using {!r} which is not a a Unicode-compatible '
+ 'locale.'.format(e))
+ mlog.warning('You might see errors if you use UTF-8 strings as '
+ 'filenames, as strings, or as file contents.')
+ mlog.warning('Please switch to a UTF-8 locale for your platform.')
# Always resolve the command path so Ninja can find it for regen, tests, etc.
launcher = os.path.realpath(sys.argv[0])
return mesonmain.run(launcher, sys.argv[1:])
diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py
index ced2b6f..8f8851f 100644
--- a/mesonbuild/compilers.py
+++ b/mesonbuild/compilers.py
@@ -1846,11 +1846,7 @@ class VisualStudioCCompiler(CCompiler):
}
def get_option_link_args(self, options):
- # FIXME: See GnuCCompiler.get_option_link_args
- if 'c_winlibs' in options:
- return options['c_winlibs'].value[:]
- else:
- return msvc_winlibs[:]
+ return options['c_winlibs'].value[:]
def unix_link_flags_to_native(self, args):
result = []
@@ -1955,11 +1951,7 @@ class VisualStudioCPPCompiler(VisualStudioCCompiler, CPPCompiler):
return args
def get_option_link_args(self, options):
- # FIXME: See GnuCCompiler.get_option_link_args
- if 'cpp_winlibs' in options:
- return options['cpp_winlibs'].value[:]
- else:
- return msvc_winlibs[:]
+ return options['cpp_winlibs'].value[:]
GCC_STANDARD = 0
GCC_OSX = 1
@@ -2071,17 +2063,7 @@ class GnuCCompiler(GnuCompiler, CCompiler):
def get_option_link_args(self, options):
if self.gcc_type == GCC_MINGW:
- # FIXME: This check is needed because we currently pass
- # cross-compiler options to the native compiler too and when
- # cross-compiling from Windows to Linux, `options` will contain
- # Linux-specific options which doesn't include `c_winlibs`. The
- # proper fix is to allow cross-info files to specify compiler
- # options and to maintain both cross and native compiler options in
- # coredata: https://github.com/mesonbuild/meson/issues/1029
- if 'c_winlibs' in options:
- return options['c_winlibs'].value[:]
- else:
- return gnu_winlibs[:]
+ return options['c_winlibs'].value[:]
return []
class GnuCPPCompiler(GnuCompiler, CPPCompiler):
@@ -2119,11 +2101,7 @@ class GnuCPPCompiler(GnuCompiler, CPPCompiler):
def get_option_link_args(self, options):
if self.gcc_type == GCC_MINGW:
- # FIXME: See GnuCCompiler.get_option_link_args
- if 'cpp_winlibs' in options:
- return options['cpp_winlibs'].value[:]
- else:
- return gnu_winlibs[:]
+ return options['cpp_winlibs'].value[:]
return []
def get_compiler_check_args(self):
diff --git a/mesonbuild/dependencies.py b/mesonbuild/dependencies.py
index 38945b4..4e87e4e 100644
--- a/mesonbuild/dependencies.py
+++ b/mesonbuild/dependencies.py
@@ -233,7 +233,7 @@ class PkgConfigDependency(Dependency):
'(%s)' % out.decode().strip())
PkgConfigDependency.pkgconfig_found = True
return
- except Exception:
+ except (FileNotFoundError, PermissionError):
pass
PkgConfigDependency.pkgconfig_found = False
if not self.silent:
@@ -358,7 +358,7 @@ class WxDependency(Dependency):
self.wxc = wxc
WxDependency.wx_found = True
return
- except Exception:
+ except (FileNotFoundError, PermissionError):
pass
WxDependency.wxconfig_found = False
mlog.log('Found wx-config:', mlog.red('NO'))
@@ -1040,7 +1040,7 @@ class GnuStepDependency(Dependency):
gp = subprocess.Popen([confprog, '--help'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
gp.communicate()
- except FileNotFoundError:
+ except (FileNotFoundError, PermissionError):
self.args = None
mlog.log('Dependency GnuStep found:', mlog.red('NO'), '(no gnustep-config)')
return
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index cc62010..098f8ca 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -43,7 +43,8 @@ def detect_ninja():
for n in ['ninja', 'ninja-build']:
try:
p = subprocess.Popen([n, '--version'], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
- except FileNotFoundError:
+ except (FileNotFoundError, PermissionError):
+ # Doesn't exist in PATH or isn't executable
continue
version = p.communicate()[0].decode(errors='ignore')
# Perhaps we should add a way for the caller to know the failure mode
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 3b9f975..ef99511 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -1762,12 +1762,12 @@ class Interpreter():
raise InvalidCode('Tried to use unknown language "%s".' % lang)
comp.sanity_check(self.environment.get_scratch_dir(), self.environment)
self.coredata.compilers[lang] = comp
+ # Native compiler always exist so always add its options.
+ new_options = comp.get_options()
if cross_comp is not None:
cross_comp.sanity_check(self.environment.get_scratch_dir(), self.environment)
self.coredata.cross_compilers[lang] = cross_comp
- new_options = cross_comp.get_options()
- else:
- new_options = comp.get_options()
+ new_options.update(cross_comp.get_options())
optprefix = lang + '_'
for i in new_options:
if not i.startswith(optprefix):
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py
index b92be5f..4d9cc69 100644
--- a/mesonbuild/mesonlib.py
+++ b/mesonbuild/mesonlib.py
@@ -303,7 +303,7 @@ def do_conf_file(src, dst, confdata):
replace_if_different(dst, dst_tmp)
def dump_conf_header(ofilename, cdata):
- with open(ofilename, 'w') as ofile:
+ with open(ofilename, 'w', encoding='utf-8') as ofile:
ofile.write('''/*
* Autogenerated by the Meson build system.
* Do not edit, your changes will be lost.
diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py
index 57c814c..1d4863c 100644
--- a/mesonbuild/mesonmain.py
+++ b/mesonbuild/mesonmain.py
@@ -240,7 +240,13 @@ def run(mainfile, args):
return 1
if len(args) >= 2 and args[0] == '--internal':
if args[1] != 'regenerate':
- sys.exit(run_script_command(args[1:]))
+ script = args[1]
+ try:
+ sys.exit(run_script_command(args[1:]))
+ except MesonException as e:
+ mlog.log(mlog.red('\nError in {} helper script:'.format(script)))
+ mlog.log(e)
+ sys.exit(1)
args = args[2:]
handshake = True
else:
diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py
index e05c641..19ed39a 100644
--- a/mesonbuild/wrap/wrap.py
+++ b/mesonbuild/wrap/wrap.py
@@ -93,9 +93,19 @@ class Resolver:
def resolve(self, packagename):
fname = os.path.join(self.subdir_root, packagename + '.wrap')
dirname = os.path.join(self.subdir_root, packagename)
- if os.path.isdir(dirname):
- # The directory is there? Great, use it.
- return packagename
+ try:
+ if os.listdir(dirname):
+ # The directory is there and not empty? Great, use it.
+ return packagename
+ else:
+ mlog.warning('Subproject directory %s is empty, possibly because of an unfinished'
+ 'checkout, removing to reclone' % dirname)
+ os.rmdir(checkoutdir)
+ except NotADirectoryError:
+ raise RuntimeError('%s is not a directory, can not use as subproject.' % dirname)
+ except FileNotFoundError:
+ pass
+
if not os.path.isfile(fname):
# No wrap file with this name? Give up.
return None
@@ -118,6 +128,15 @@ class Resolver:
revno = p.get('revision')
is_there = os.path.isdir(checkoutdir)
if is_there:
+ try:
+ subprocess.check_call(['git', 'rev-parse'])
+ is_there = True
+ except subprocess.CalledProcessError:
+ raise RuntimeError('%s is not empty but is not a valid '
+ 'git repository, we can not work with it'
+ ' as a subproject directory.' % (
+ checkoutdir))
+
if revno.lower() == 'head':
# Failure to do pull is not a fatal error,
# because otherwise you can't develop without
@@ -134,6 +153,11 @@ class Resolver:
if revno.lower() != 'head':
subprocess.check_call(['git', 'checkout', revno],
cwd=checkoutdir)
+ push_url = p.get('push-url')
+ if push_url:
+ subprocess.check_call(['git', 'remote', 'set-url',
+ '--push', 'origin', push_url],
+ cwd=checkoutdir)
def get_hg(self, p):
checkoutdir = os.path.join(self.subdir_root, p.get('directory'))
revno = p.get('revision')
diff --git a/setup.py b/setup.py
index 42f8d49..46f2750 100644
--- a/setup.py
+++ b/setup.py
@@ -70,6 +70,7 @@ setup(name='meson',
'mesonbuild.wrap'],
scripts=['meson.py',
'mesonconf.py',
+ 'mesontest.py',
'mesonintrospect.py',
'wraptool.py'],
cmdclass={'install_scripts': install_scripts},