aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--__main__.py20
-rwxr-xr-xmeson.py13
-rw-r--r--mesonbuild/coredata.py5
-rw-r--r--mesonbuild/interpreter.py8
-rw-r--r--mesonbuild/mesonmain.py2
-rwxr-xr-xrun_tests.py6
-rwxr-xr-xrun_unittests.py12
-rw-r--r--setup.py27
8 files changed, 70 insertions, 23 deletions
diff --git a/__main__.py b/__main__.py
new file mode 100644
index 0000000..c412e37
--- /dev/null
+++ b/__main__.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python3
+
+# Copyright 2016 The Meson development team
+
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+
+# http://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import meson
+import sys
+
+sys.exit(meson.main())
diff --git a/meson.py b/meson.py
index 492f70d..8c223e5 100755
--- a/meson.py
+++ b/meson.py
@@ -15,11 +15,12 @@
# limitations under the License.
from mesonbuild import mesonmain
-import sys, os, os.path
+import sys, os
-launcher = sys.argv[0]
-# resolve the command path if not launched from $PATH
-if os.path.split(launcher)[0]:
- launcher = os.path.realpath(launcher)
+def main():
+ # 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:])
-sys.exit(mesonmain.run(launcher, sys.argv[1:]))
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py
index 406cb4c..109bb32 100644
--- a/mesonbuild/coredata.py
+++ b/mesonbuild/coredata.py
@@ -36,11 +36,6 @@ class UserStringOption(UserOption):
def validate(self, value):
if not isinstance(value, str):
raise MesonException('Value "%s" for string option "%s" is not a string.' % (str(value), self.name))
- if self.name == 'prefix' and not os.path.isabs(value):
- raise MesonException('Prefix option value \'{0}\' must be an absolute path.'.format(value))
- if self.name in ('libdir', 'bindir', 'includedir', 'datadir', 'mandir', 'localedir') \
- and os.path.isabs(value):
- raise MesonException('Option %s must not be an absolute path.' % self.name)
def set_value(self, newvalue):
self.validate(newvalue)
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 92b997a..1ce87b7 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -1128,7 +1128,7 @@ class Interpreter():
raise me
self.sanity_check_ast()
self.variables = {}
- self.builtin = {}
+ self.builtin = {'meson': MesonMain(build, self)}
self.generators = []
self.visited_subdirs = {}
self.global_args_frozen = False
@@ -1150,7 +1150,6 @@ class Interpreter():
self.builtin['target_machine'] = CrossMachineInfo(cross_info.config['target_machine'])
else:
self.builtin['target_machine'] = self.builtin['host_machine']
- self.builtin['meson'] = MesonMain(build, self)
self.build_def_files = [os.path.join(self.subdir, environment.build_filename)]
def build_func_dict(self):
@@ -1254,9 +1253,6 @@ class Interpreter():
first = self.ast.lines[0]
if not isinstance(first, mparser.FunctionNode) or first.func_name != 'project':
raise InvalidCode('First statement must be a call to project')
- args = self.reduce_arguments(first.args)[0]
- if len(args) < 2:
- raise InvalidArguments('Not enough arguments to project(). Needs at least the project name and one language')
def check_cross_stdlibs(self):
@@ -1615,6 +1611,8 @@ class Interpreter():
self.build.project_name = args[0]
if self.environment.first_invocation and 'default_options' in kwargs:
self.parse_default_options(kwargs['default_options'])
+ if len(args) < 2:
+ raise InvalidArguments('Not enough arguments to project(). Needs at least the project name and one language')
self.active_projectname = args[0]
self.project_version = kwargs.get('version', 'undefined')
proj_license = mesonlib.stringlistify(kwargs.get('license', 'unknown'))
diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py
index bc5d35a..7f7ab43 100644
--- a/mesonbuild/mesonmain.py
+++ b/mesonbuild/mesonmain.py
@@ -70,7 +70,7 @@ class MesonApp():
def __init__(self, dir1, dir2, script_launcher, handshake, options, original_cmd_line_args):
(self.source_dir, self.build_dir) = self.validate_dirs(dir1, dir2, handshake)
if not os.path.isabs(options.prefix):
- raise RuntimeError('--prefix value \'{0}\' must be an absolute path: '.format(options.prefix))
+ raise RuntimeError('--prefix value must be an absolute path: {!r}'.format(options.prefix))
if options.prefix.endswith('/') or options.prefix.endswith('\\'):
# On Windows we need to preserve the trailing slash if the
# string is of type 'C:\' because 'C:' is not an absolute path.
diff --git a/run_tests.py b/run_tests.py
index 3396cab..ec8970a 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -25,11 +25,11 @@ if __name__ == '__main__':
myenv['CC'] = 'gcc'
myenv['CXX'] = 'g++'
print('Running unittests with GCC.\n')
- returncode += subprocess.call([sys.executable, 'run_unittests.py'], env=myenv)
+ returncode += subprocess.call([sys.executable, 'run_unittests.py', '-v'], env=myenv)
if shutil.which('clang'):
myenv['CC'] = 'clang'
myenv['CXX'] = 'clang++'
- print('\nRunnint unittests with clang.\n')
- returncode += subprocess.call([sys.executable, 'run_unittests.py'], env=myenv)
+ print('\nRunning unittests with clang.\n')
+ returncode += subprocess.call([sys.executable, 'run_unittests.py', '-v'], env=myenv)
returncode += subprocess.call([sys.executable, 'run_project_tests.py'] + sys.argv[1:])
sys.exit(returncode)
diff --git a/run_unittests.py b/run_unittests.py
index 5cd7d0f..9ea9e23 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import unittest, os, sys, shutil
+import unittest, os, sys, shutil, time
import subprocess
import re, json
import tempfile
@@ -77,9 +77,15 @@ class LinuxlikeTests(unittest.TestCase):
self.init(testdir)
compdb = self.get_compdb()
self.assertTrue('-fPIC' in compdb[0]['command'])
- self.setconf('-Db_staticpic=true')
+ # This is needed to increase the difference between build.ninja's
+ # timestamp and coredata.dat's timestamp due to a Ninja bug.
+ # https://github.com/ninja-build/ninja/issues/371
+ time.sleep(1)
+ self.setconf('-Db_staticpic=false')
+ # Regenerate build
self.build()
- self.assertFalse('-fPIC' not in compdb[0]['command'])
+ compdb = self.get_compdb()
+ self.assertTrue('-fPIC' not in compdb[0]['command'])
if __name__ == '__main__':
unittest.main()
diff --git a/setup.py b/setup.py
index d5b79ae..42f8d49 100644
--- a/setup.py
+++ b/setup.py
@@ -14,7 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import os
import sys
+from os import path
if sys.version_info[0] < 3:
print('Tried to install with Python 2, Meson only supports Python 3.')
@@ -25,8 +27,32 @@ if sys.version_info[0] < 3:
# plain distutils when setuptools is not available.
try:
from setuptools import setup
+ from setuptools.command.install_scripts import install_scripts as orig
except ImportError:
from distutils.core import setup
+ from distutils.command.install_scripts import install_scripts as orig
+
+from distutils.file_util import copy_file
+from distutils.dir_util import mkpath
+from stat import ST_MODE
+
+class install_scripts(orig):
+ def run(self):
+ if sys.platform == 'win32':
+ super().run()
+ return
+
+ self.outfiles = []
+ if not self.dry_run:
+ mkpath(self.install_dir)
+
+ # We want the files to be installed without a suffix on Unix
+ for infile in self.get_inputs():
+ in_stripped = infile[:-3] if infile.endswith('.py') else infile
+ outfile = path.join(self.install_dir, in_stripped)
+ # NOTE: Mode is preserved by default
+ copy_file(infile, outfile, dry_run=self.dry_run)
+ self.outfiles.append(outfile)
from mesonbuild.coredata import version
@@ -46,6 +72,7 @@ setup(name='meson',
'mesonconf.py',
'mesonintrospect.py',
'wraptool.py'],
+ cmdclass={'install_scripts': install_scripts},
data_files=[('share/man/man1', ['man/meson.1',
'man/mesonconf.1',
'man/mesonintrospect.1',