diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2016-01-15 21:12:23 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2016-01-15 21:22:09 +0200 |
commit | 8b1039fa30a405e2d07ac70eb0284ee4654c619a (patch) | |
tree | 6cc326bf97c235c9e67b4a34534316fdaaa2eb19 | |
parent | 926b55076f1fa94f887dd62443c66a886af0b78b (diff) | |
download | meson-8b1039fa30a405e2d07ac70eb0284ee4654c619a.zip meson-8b1039fa30a405e2d07ac70eb0284ee4654c619a.tar.gz meson-8b1039fa30a405e2d07ac70eb0284ee4654c619a.tar.bz2 |
Organise files into a module structure.
-rwxr-xr-x | meson.py | 225 | ||||
-rw-r--r-- | meson/__init__.py | 0 | ||||
-rw-r--r-- | meson/backends.py (renamed from backends.py) | 8 | ||||
-rw-r--r-- | meson/build.py (renamed from build.py) | 10 | ||||
-rwxr-xr-x | meson/commandrunner.py (renamed from commandrunner.py) | 0 | ||||
-rw-r--r-- | meson/compilers.py (renamed from compilers.py) | 8 | ||||
-rw-r--r-- | meson/coredata.py (renamed from coredata.py) | 0 | ||||
-rwxr-xr-x | meson/delwithsuffix.py (renamed from delwithsuffix.py) | 0 | ||||
-rw-r--r-- | meson/dependencies.py (renamed from dependencies.py) | 6 | ||||
-rwxr-xr-x | meson/depfixer.py (renamed from depfixer.py) | 0 | ||||
-rwxr-xr-x | meson/dirchanger.py (renamed from dirchanger.py) | 0 | ||||
-rw-r--r-- | meson/environment.py (renamed from environment.py) | 4 | ||||
-rwxr-xr-x | meson/gtkdochelper.py (renamed from gtkdochelper.py) | 0 | ||||
-rw-r--r-- | meson/interpreter.py (renamed from interpreter.py) | 19 | ||||
-rwxr-xr-x | meson/meson_benchmark.py (renamed from meson_benchmark.py) | 2 | ||||
-rwxr-xr-x | meson/meson_install.py (renamed from meson_install.py) | 0 | ||||
-rwxr-xr-x | meson/meson_test.py (renamed from meson_test.py) | 8 | ||||
-rwxr-xr-x | meson/mesonconf.py (renamed from mesonconf.py) | 0 | ||||
-rwxr-xr-x | meson/mesongui.py (renamed from mesongui.py) | 0 | ||||
-rwxr-xr-x | meson/mesonintrospect.py (renamed from mesonintrospect.py) | 0 | ||||
-rw-r--r-- | meson/mesonlib.py (renamed from mesonlib.py) | 2 | ||||
-rwxr-xr-x | meson/mesonmain.py | 225 | ||||
-rw-r--r-- | meson/mlog.py (renamed from mlog.py) | 0 | ||||
-rw-r--r-- | meson/modules/__init__.py | 0 | ||||
-rw-r--r-- | meson/modules/gnome.py (renamed from modules/gnome.py) | 0 | ||||
-rw-r--r-- | meson/modules/modtest.py (renamed from modules/modtest.py) | 0 | ||||
-rw-r--r-- | meson/modules/pkgconfig.py (renamed from modules/pkgconfig.py) | 0 | ||||
-rw-r--r-- | meson/modules/qt4.py (renamed from modules/qt4.py) | 0 | ||||
-rw-r--r-- | meson/modules/qt5.py (renamed from modules/qt5.py) | 0 | ||||
-rw-r--r-- | meson/modules/rpm.py (renamed from modules/rpm.py) | 0 | ||||
-rw-r--r-- | meson/modules/windows.py (renamed from modules/windows.py) | 0 | ||||
-rw-r--r-- | meson/mparser.py (renamed from mparser.py) | 2 | ||||
-rw-r--r-- | meson/ninjabackend.py (renamed from ninjabackend.py) | 18 | ||||
-rw-r--r-- | meson/optinterpreter.py (renamed from optinterpreter.py) | 4 | ||||
-rwxr-xr-x | meson/regen_checker.py (renamed from regen_checker.py) | 0 | ||||
-rwxr-xr-x | meson/symbolextractor.py (renamed from symbolextractor.py) | 0 | ||||
-rwxr-xr-x | meson/vcstagger.py (renamed from vcstagger.py) | 0 | ||||
-rw-r--r-- | meson/vs2010backend.py (renamed from vs2010backend.py) | 0 | ||||
-rw-r--r-- | meson/wrap.py (renamed from wrap.py) | 4 | ||||
-rwxr-xr-x | meson/wraptool.py (renamed from wraptool.py) | 0 | ||||
-rw-r--r-- | meson/xcodebackend.py (renamed from xcodebackend.py) | 0 | ||||
-rwxr-xr-x | run_tests.py | 10 |
42 files changed, 283 insertions, 272 deletions
@@ -1,225 +1,6 @@ #!/usr/bin/env python3 -# Copyright 2012-2015 The Meson development team +from meson import mesonmain +import sys -# 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 sys, stat, traceback, pickle, argparse -import datetime -import os.path -import environment, interpreter, mesonlib -import build -import platform -import mlog, coredata - -from coredata import MesonException, build_types, layouts, warning_levels, libtypelist - -backendlist = ['ninja', 'vs2010', 'xcode'] - -parser = argparse.ArgumentParser() - -default_warning = '1' - -if mesonlib.is_windows(): - def_prefix = 'c:/' -else: - def_prefix = '/usr/local' - -parser.add_argument('--prefix', default=def_prefix, dest='prefix', - help='the installation prefix (default: %(default)s)') -parser.add_argument('--libdir', default=mesonlib.default_libdir(), dest='libdir', - help='the installation subdir of libraries (default: %(default)s)') -parser.add_argument('--bindir', default='bin', dest='bindir', - help='the installation subdir of executables (default: %(default)s)') -parser.add_argument('--includedir', default='include', dest='includedir', - help='relative path of installed headers (default: %(default)s)') -parser.add_argument('--datadir', default='share', dest='datadir', - help='relative path to the top of data file subdirectory (default: %(default)s)') -parser.add_argument('--mandir', default='share/man', dest='mandir', - help='relative path of man files (default: %(default)s)') -parser.add_argument('--localedir', default='share/locale', dest='localedir', - help='relative path of locale data (default: %(default)s)') -parser.add_argument('--backend', default='ninja', dest='backend', choices=backendlist, - help='backend to use (default: %(default)s)') -parser.add_argument('--buildtype', default='debug', choices=build_types, dest='buildtype', - help='build type go use (default: %(default)s)') -parser.add_argument('--strip', action='store_true', dest='strip', default=False,\ - help='strip targets on install (default: %(default)s)') -parser.add_argument('--enable-gcov', action='store_true', dest='coverage', default=False,\ - help='measure test coverage') -parser.add_argument('--disable-pch', action='store_false', dest='use_pch', default=True,\ - help='do not use precompiled headers') -parser.add_argument('--unity', action='store_true', dest='unity', default=False,\ - help='unity build') -parser.add_argument('--werror', action='store_true', dest='werror', default=False,\ - help='Treat warnings as errors') -parser.add_argument('--layout', choices=layouts, dest='layout', default='mirror',\ - help='Build directory layout.') -parser.add_argument('--default-library', choices=libtypelist, dest='default_library', - default='shared', help='Default library type.') -parser.add_argument('--warnlevel', default=default_warning, dest='warning_level', choices=warning_levels,\ - help='Level of compiler warnings to use (larger is more, default is %(default)s)') -parser.add_argument('--cross-file', default=None, dest='cross_file', - help='file describing cross compilation environment') -parser.add_argument('-D', action='append', dest='projectoptions', default=[], - help='Set project options.') -parser.add_argument('-v', '--version', action='store_true', dest='print_version', default=False, - help='Print version.') -parser.add_argument('directories', nargs='*') - -class MesonApp(): - - def __init__(self, dir1, dir2, script_file, handshake, options): - (self.source_dir, self.build_dir) = self.validate_dirs(dir1, dir2, handshake) - if not os.path.isabs(options.prefix): - raise RuntimeError('--prefix must be an absolute path.') - self.meson_script_file = script_file - self.options = options - - def has_build_file(self, dirname): - fname = os.path.join(dirname, environment.build_filename) - return os.path.exists(fname) - - def validate_core_dirs(self, dir1, dir2): - ndir1 = os.path.abspath(dir1) - ndir2 = os.path.abspath(dir2) - if not stat.S_ISDIR(os.stat(ndir1).st_mode): - raise RuntimeError('%s is not a directory' % dir1) - if not stat.S_ISDIR(os.stat(ndir2).st_mode): - raise RuntimeError('%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.') - if self.has_build_file(ndir1): - if self.has_build_file(ndir2): - raise RuntimeError('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) - - def validate_dirs(self, dir1, dir2, handshake): - (src_dir, build_dir) = self.validate_core_dirs(dir1, dir2) - priv_dir = os.path.join(build_dir, 'meson-private/coredata.dat') - if os.path.exists(priv_dir): - if not handshake: - msg = '''Trying to run Meson on a build directory that has already been configured. -If you want to build it, just run your build command (e.g. ninja) inside the -build directory. Meson will autodetect any changes in your setup and regenerate -itself as required.''' - raise RuntimeError(msg) - else: - if handshake: - raise RuntimeError('Something went terribly wrong. Please file a bug.') - return (src_dir, build_dir) - - def generate(self): - env = environment.Environment(self.source_dir, self.build_dir, self.meson_script_file, self.options) - mlog.initialize(env.get_log_dir()) - mlog.debug('Build started at', datetime.datetime.now().isoformat()) - mlog.debug('Python binary:', sys.executable) - mlog.debug('Python system:', platform.system()) - mlog.log(mlog.bold('The Meson build system')) - mlog.log('Version:', coredata.version) - mlog.log('Source dir:', mlog.bold(self.source_dir)) - mlog.log('Build dir:', mlog.bold(self.build_dir)) - if env.is_cross_build(): - mlog.log('Build type:', mlog.bold('cross build')) - else: - mlog.log('Build type:', mlog.bold('native build')) - b = build.Build(env) - if self.options.backend == 'ninja': - import ninjabackend - g = ninjabackend.NinjaBackend(b) - elif self.options.backend == 'vs2010': - import vs2010backend - g = vs2010backend.Vs2010Backend(b) - elif self.options.backend == 'xcode': - import xcodebackend - g = xcodebackend.XCodeBackend(b) - else: - raise RuntimeError('Unknown backend "%s".' % self.options.backend) - - intr = interpreter.Interpreter(b, g) - if env.is_cross_build(): - mlog.log('Host machine cpu family:', mlog.bold(intr.builtin['host_machine'].cpu_family_method([], {}))) - mlog.log('Host machine cpu:', mlog.bold(intr.builtin['host_machine'].cpu_method([], {}))) - mlog.log('Target machine cpu family:', mlog.bold(intr.builtin['target_machine'].cpu_family_method([], {}))) - mlog.log('Target machine cpu:', mlog.bold(intr.builtin['target_machine'].cpu_method([], {}))) - mlog.log('Build machine cpu family:', mlog.bold(intr.builtin['build_machine'].cpu_family_method([], {}))) - mlog.log('Build machine cpu:', mlog.bold(intr.builtin['build_machine'].cpu_method([], {}))) - intr.run() - g.generate(intr) - env.generating_finished() - dumpfile = os.path.join(env.get_scratch_dir(), 'build.dat') - pickle.dump(b, open(dumpfile, 'wb')) - -def run(args): - if sys.version_info < (3, 3): - print('Meson works correctly only with python 3.3+.') - print('You have python %s.' % sys.version) - print('Please update your environment') - return 1 - if args[-1] == 'secret-handshake': - args = args[:-1] - handshake = True - else: - handshake = False - args = mesonlib.expand_arguments(args) - if not args: - return 1 - options = parser.parse_args(args[1:]) - if options.print_version: - print(coredata.version) - return 0 - args = options.directories - if len(args) == 0 or len(args) > 2: - print('%s <source directory> <build directory>' % sys.argv[0]) - print('If you omit either directory, the current directory is substituted.') - return 1 - dir1 = args[0] - if len(args) > 1: - dir2 = args[1] - else: - dir2 = '.' - this_file = os.path.abspath(__file__) - while os.path.islink(this_file): - resolved = os.readlink(this_file) - if resolved[0] != '/': - this_file = os.path.join(os.path.dirname(this_file), resolved) - else: - this_file = resolved - - try: - app = MesonApp(dir1, dir2, this_file, handshake, options) - except Exception as e: - # Log directory does not exist, so just print - # to stdout. - print('Error during basic setup:\n') - print(e) - return 1 - try: - app.generate() - except Exception as e: - if isinstance(e, MesonException): - if hasattr(e, 'file') and hasattr(e, 'lineno') and hasattr(e, 'colno'): - mlog.log(mlog.red('\nMeson encountered an error in file %s, line %d, column %d:' % (e.file, e.lineno, e.colno))) - else: - mlog.log(mlog.red('\nMeson encountered an error:')) - mlog.log(e) - else: - traceback.print_exc() - return 1 - return 0 - -if __name__ == '__main__': - sys.exit(run(sys.argv[:])) +sys.exit(mesonmain.run(sys.argv[:])) diff --git a/meson/__init__.py b/meson/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/meson/__init__.py diff --git a/backends.py b/meson/backends.py index 748a742..2706368 100644 --- a/backends.py +++ b/meson/backends.py @@ -13,11 +13,11 @@ # limitations under the License. import os, pickle, re -import build -import dependencies -import mesonlib +from . import build +from . import dependencies +from . import mesonlib import json -from coredata import MesonException +from .coredata import MesonException class TestSerialisation: def __init__(self, name, suite, fname, is_cross, exe_wrapper, is_parallel, cmd_args, env, diff --git a/build.py b/meson/build.py index 7dededa..c0ba895 100644 --- a/build.py +++ b/meson/build.py @@ -12,12 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -import coredata -import environment -import dependencies -import mlog +from . import coredata +from . import environment +from . import dependencies +from . import mlog import copy, os -from mesonlib import File, flatten +from .mesonlib import File, flatten known_basic_kwargs = {'install' : True, 'c_pch' : True, diff --git a/commandrunner.py b/meson/commandrunner.py index 0dad585..0dad585 100755 --- a/commandrunner.py +++ b/meson/commandrunner.py diff --git a/compilers.py b/meson/compilers.py index 55b41dc..ec0181e 100644 --- a/compilers.py +++ b/meson/compilers.py @@ -14,10 +14,10 @@ import subprocess, os.path import tempfile -import mesonlib -import mlog -from coredata import MesonException -import coredata +from .import mesonlib +from . import mlog +from .coredata import MesonException +from . import coredata """This file contains the data files of all compilers Meson knows about. To support a new compiler, add its information below. diff --git a/coredata.py b/meson/coredata.py index 5b1102c..5b1102c 100644 --- a/coredata.py +++ b/meson/coredata.py diff --git a/delwithsuffix.py b/meson/delwithsuffix.py index 4b8a60d..4b8a60d 100755 --- a/delwithsuffix.py +++ b/meson/delwithsuffix.py diff --git a/dependencies.py b/meson/dependencies.py index cc9a941..974559f 100644 --- a/dependencies.py +++ b/meson/dependencies.py @@ -21,9 +21,9 @@ import re import os, stat, glob, subprocess, shutil -from coredata import MesonException -import mlog -import mesonlib +from . coredata import MesonException +from . import mlog +from . import mesonlib class DependencyException(MesonException): def __init__(self, *args, **kwargs): diff --git a/depfixer.py b/meson/depfixer.py index 4f7ce3d..4f7ce3d 100755 --- a/depfixer.py +++ b/meson/depfixer.py diff --git a/dirchanger.py b/meson/dirchanger.py index fd3dc23..fd3dc23 100755 --- a/dirchanger.py +++ b/meson/dirchanger.py diff --git a/environment.py b/meson/environment.py index e905b2f..3e10bd4 100644 --- a/environment.py +++ b/meson/environment.py @@ -13,8 +13,8 @@ # limitations under the License. import os, re, subprocess -import coredata, mesonlib -from compilers import * +from . import coredata, mesonlib +from .compilers import * import configparser build_filename = 'meson.build' diff --git a/gtkdochelper.py b/meson/gtkdochelper.py index 7e476b8..7e476b8 100755 --- a/gtkdochelper.py +++ b/meson/gtkdochelper.py diff --git a/interpreter.py b/meson/interpreter.py index 21cc6cf..ec1bda0 100644 --- a/interpreter.py +++ b/meson/interpreter.py @@ -12,15 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mparser -import environment -import coredata -import dependencies -import mlog -import build -import optinterpreter -import wrap -import mesonlib +from . import mparser +from . import environment +from . import coredata +from . import dependencies +from . import mlog +from . import build +from . import optinterpreter +from . import wrap +from . import mesonlib + import os, sys, platform, subprocess, shutil, uuid, re from functools import wraps diff --git a/meson_benchmark.py b/meson/meson_benchmark.py index 4888d9f..26f1f95 100755 --- a/meson_benchmark.py +++ b/meson/meson_benchmark.py @@ -16,7 +16,7 @@ import subprocess, sys, os, argparse import pickle, statistics, json -import meson_test +from . import meson_test parser = argparse.ArgumentParser() parser.add_argument('--wd', default=None, dest='wd', diff --git a/meson_install.py b/meson/meson_install.py index c5c17ba..c5c17ba 100755 --- a/meson_install.py +++ b/meson/meson_install.py diff --git a/meson_test.py b/meson/meson_test.py index 7758e5a..d9b4993 100755 --- a/meson_test.py +++ b/meson/meson_test.py @@ -17,7 +17,11 @@ import sys, os, subprocess, time, datetime, pickle, multiprocessing, json import concurrent.futures as conc import argparse -import mesonlib +import platform + +def is_windows(): + platname = platform.system().lower() + return platname == 'windows' or 'mingw' in platname tests_failed = [] @@ -70,7 +74,7 @@ def write_json_log(jsonlogfile, test_name, result): jsonlogfile.write(json.dumps(result) + '\n') def run_with_mono(fname): - if fname.endswith('.exe') and not mesonlib.is_windows(): + if fname.endswith('.exe') and not is_windows(): return True return False diff --git a/mesonconf.py b/meson/mesonconf.py index e53875f..e53875f 100755 --- a/mesonconf.py +++ b/meson/mesonconf.py diff --git a/mesongui.py b/meson/mesongui.py index bdd44bb..bdd44bb 100755 --- a/mesongui.py +++ b/meson/mesongui.py diff --git a/mesonintrospect.py b/meson/mesonintrospect.py index 9fcd4db..9fcd4db 100755 --- a/mesonintrospect.py +++ b/meson/mesonintrospect.py diff --git a/mesonlib.py b/meson/mesonlib.py index 99d6154..2ab5ce4 100644 --- a/mesonlib.py +++ b/meson/mesonlib.py @@ -18,7 +18,7 @@ import platform, subprocess, operator, os, shutil, re, sys from glob import glob -from coredata import MesonException +from .coredata import MesonException class File: def __init__(self, is_built, subdir, fname): diff --git a/meson/mesonmain.py b/meson/mesonmain.py new file mode 100755 index 0000000..c4a9ada --- /dev/null +++ b/meson/mesonmain.py @@ -0,0 +1,225 @@ +#!/usr/bin/env python3 + +# Copyright 2012-2015 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 sys, stat, traceback, pickle, argparse +import datetime +import os.path +from . import environment, interpreter, mesonlib +from .import build +import platform +from . import mlog, coredata + +from .coredata import MesonException, build_types, layouts, warning_levels, libtypelist + +backendlist = ['ninja', 'vs2010', 'xcode'] + +parser = argparse.ArgumentParser() + +default_warning = '1' + +if mesonlib.is_windows(): + def_prefix = 'c:/' +else: + def_prefix = '/usr/local' + +parser.add_argument('--prefix', default=def_prefix, dest='prefix', + help='the installation prefix (default: %(default)s)') +parser.add_argument('--libdir', default=mesonlib.default_libdir(), dest='libdir', + help='the installation subdir of libraries (default: %(default)s)') +parser.add_argument('--bindir', default='bin', dest='bindir', + help='the installation subdir of executables (default: %(default)s)') +parser.add_argument('--includedir', default='include', dest='includedir', + help='relative path of installed headers (default: %(default)s)') +parser.add_argument('--datadir', default='share', dest='datadir', + help='relative path to the top of data file subdirectory (default: %(default)s)') +parser.add_argument('--mandir', default='share/man', dest='mandir', + help='relative path of man files (default: %(default)s)') +parser.add_argument('--localedir', default='share/locale', dest='localedir', + help='relative path of locale data (default: %(default)s)') +parser.add_argument('--backend', default='ninja', dest='backend', choices=backendlist, + help='backend to use (default: %(default)s)') +parser.add_argument('--buildtype', default='debug', choices=build_types, dest='buildtype', + help='build type go use (default: %(default)s)') +parser.add_argument('--strip', action='store_true', dest='strip', default=False,\ + help='strip targets on install (default: %(default)s)') +parser.add_argument('--enable-gcov', action='store_true', dest='coverage', default=False,\ + help='measure test coverage') +parser.add_argument('--disable-pch', action='store_false', dest='use_pch', default=True,\ + help='do not use precompiled headers') +parser.add_argument('--unity', action='store_true', dest='unity', default=False,\ + help='unity build') +parser.add_argument('--werror', action='store_true', dest='werror', default=False,\ + help='Treat warnings as errors') +parser.add_argument('--layout', choices=layouts, dest='layout', default='mirror',\ + help='Build directory layout.') +parser.add_argument('--default-library', choices=libtypelist, dest='default_library', + default='shared', help='Default library type.') +parser.add_argument('--warnlevel', default=default_warning, dest='warning_level', choices=warning_levels,\ + help='Level of compiler warnings to use (larger is more, default is %(default)s)') +parser.add_argument('--cross-file', default=None, dest='cross_file', + help='file describing cross compilation environment') +parser.add_argument('-D', action='append', dest='projectoptions', default=[], + help='Set project options.') +parser.add_argument('-v', '--version', action='store_true', dest='print_version', default=False, + help='Print version.') +parser.add_argument('directories', nargs='*') + +class MesonApp(): + + def __init__(self, dir1, dir2, script_file, handshake, options): + (self.source_dir, self.build_dir) = self.validate_dirs(dir1, dir2, handshake) + if not os.path.isabs(options.prefix): + raise RuntimeError('--prefix must be an absolute path.') + self.meson_script_file = script_file + self.options = options + + def has_build_file(self, dirname): + fname = os.path.join(dirname, environment.build_filename) + return os.path.exists(fname) + + def validate_core_dirs(self, dir1, dir2): + ndir1 = os.path.abspath(dir1) + ndir2 = os.path.abspath(dir2) + if not stat.S_ISDIR(os.stat(ndir1).st_mode): + raise RuntimeError('%s is not a directory' % dir1) + if not stat.S_ISDIR(os.stat(ndir2).st_mode): + raise RuntimeError('%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.') + if self.has_build_file(ndir1): + if self.has_build_file(ndir2): + raise RuntimeError('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) + + def validate_dirs(self, dir1, dir2, handshake): + (src_dir, build_dir) = self.validate_core_dirs(dir1, dir2) + priv_dir = os.path.join(build_dir, 'meson-private/coredata.dat') + if os.path.exists(priv_dir): + if not handshake: + msg = '''Trying to run Meson on a build directory that has already been configured. +If you want to build it, just run your build command (e.g. ninja) inside the +build directory. Meson will autodetect any changes in your setup and regenerate +itself as required.''' + raise RuntimeError(msg) + else: + if handshake: + raise RuntimeError('Something went terribly wrong. Please file a bug.') + return (src_dir, build_dir) + + def generate(self): + env = environment.Environment(self.source_dir, self.build_dir, self.meson_script_file, self.options) + mlog.initialize(env.get_log_dir()) + mlog.debug('Build started at', datetime.datetime.now().isoformat()) + mlog.debug('Python binary:', sys.executable) + mlog.debug('Python system:', platform.system()) + mlog.log(mlog.bold('The Meson build system')) + mlog.log('Version:', coredata.version) + mlog.log('Source dir:', mlog.bold(self.source_dir)) + mlog.log('Build dir:', mlog.bold(self.build_dir)) + if env.is_cross_build(): + mlog.log('Build type:', mlog.bold('cross build')) + else: + mlog.log('Build type:', mlog.bold('native build')) + b = build.Build(env) + if self.options.backend == 'ninja': + from . import ninjabackend + g = ninjabackend.NinjaBackend(b) + elif self.options.backend == 'vs2010': + from . import vs2010backend + g = vs2010backend.Vs2010Backend(b) + elif self.options.backend == 'xcode': + from . import xcodebackend + g = xcodebackend.XCodeBackend(b) + else: + raise RuntimeError('Unknown backend "%s".' % self.options.backend) + + intr = interpreter.Interpreter(b, g) + if env.is_cross_build(): + mlog.log('Host machine cpu family:', mlog.bold(intr.builtin['host_machine'].cpu_family_method([], {}))) + mlog.log('Host machine cpu:', mlog.bold(intr.builtin['host_machine'].cpu_method([], {}))) + mlog.log('Target machine cpu family:', mlog.bold(intr.builtin['target_machine'].cpu_family_method([], {}))) + mlog.log('Target machine cpu:', mlog.bold(intr.builtin['target_machine'].cpu_method([], {}))) + mlog.log('Build machine cpu family:', mlog.bold(intr.builtin['build_machine'].cpu_family_method([], {}))) + mlog.log('Build machine cpu:', mlog.bold(intr.builtin['build_machine'].cpu_method([], {}))) + intr.run() + g.generate(intr) + env.generating_finished() + dumpfile = os.path.join(env.get_scratch_dir(), 'build.dat') + pickle.dump(b, open(dumpfile, 'wb')) + +def run(args): + if sys.version_info < (3, 3): + print('Meson works correctly only with python 3.3+.') + print('You have python %s.' % sys.version) + print('Please update your environment') + return 1 + if args[-1] == 'secret-handshake': + args = args[:-1] + handshake = True + else: + handshake = False + args = mesonlib.expand_arguments(args) + if not args: + return 1 + options = parser.parse_args(args[1:]) + if options.print_version: + print(coredata.version) + return 0 + args = options.directories + if len(args) == 0 or len(args) > 2: + print('%s <source directory> <build directory>' % sys.argv[0]) + print('If you omit either directory, the current directory is substituted.') + return 1 + dir1 = args[0] + if len(args) > 1: + dir2 = args[1] + else: + dir2 = '.' + this_file = os.path.abspath(__file__) + while os.path.islink(this_file): + resolved = os.readlink(this_file) + if resolved[0] != '/': + this_file = os.path.join(os.path.dirname(this_file), resolved) + else: + this_file = resolved + + try: + app = MesonApp(dir1, dir2, this_file, handshake, options) + except Exception as e: + # Log directory does not exist, so just print + # to stdout. + print('Error during basic setup:\n') + print(e) + return 1 + try: + app.generate() + except Exception as e: + if isinstance(e, MesonException): + if hasattr(e, 'file') and hasattr(e, 'lineno') and hasattr(e, 'colno'): + mlog.log(mlog.red('\nMeson encountered an error in file %s, line %d, column %d:' % (e.file, e.lineno, e.colno))) + else: + mlog.log(mlog.red('\nMeson encountered an error:')) + mlog.log(e) + else: + traceback.print_exc() + return 1 + return 0 + +if __name__ == '__main__': + sys.exit(run(sys.argv[:])) diff --git a/meson/modules/__init__.py b/meson/modules/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/meson/modules/__init__.py diff --git a/modules/gnome.py b/meson/modules/gnome.py index 60c994e..60c994e 100644 --- a/modules/gnome.py +++ b/meson/modules/gnome.py diff --git a/modules/modtest.py b/meson/modules/modtest.py index c9247e6..c9247e6 100644 --- a/modules/modtest.py +++ b/meson/modules/modtest.py diff --git a/modules/pkgconfig.py b/meson/modules/pkgconfig.py index 5fa4bd0..5fa4bd0 100644 --- a/modules/pkgconfig.py +++ b/meson/modules/pkgconfig.py diff --git a/modules/qt4.py b/meson/modules/qt4.py index bcf42a3..bcf42a3 100644 --- a/modules/qt4.py +++ b/meson/modules/qt4.py diff --git a/modules/qt5.py b/meson/modules/qt5.py index 0e732a1..0e732a1 100644 --- a/modules/qt5.py +++ b/meson/modules/qt5.py diff --git a/modules/rpm.py b/meson/modules/rpm.py index eebecdd..eebecdd 100644 --- a/modules/rpm.py +++ b/meson/modules/rpm.py diff --git a/modules/windows.py b/meson/modules/windows.py index e01b454..e01b454 100644 --- a/modules/windows.py +++ b/meson/modules/windows.py diff --git a/mparser.py b/meson/mparser.py index 455182a..1d569d5 100644 --- a/mparser.py +++ b/meson/mparser.py @@ -13,7 +13,7 @@ # limitations under the License. import re -from coredata import MesonException +from .coredata import MesonException class ParseException(MesonException): def __init__(self, text, lineno, colno): diff --git a/ninjabackend.py b/meson/ninjabackend.py index c818f1d..53b59a1 100644 --- a/ninjabackend.py +++ b/meson/ninjabackend.py @@ -12,15 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -import backends -import environment, mesonlib -import build -import mlog -import dependencies -from mesonlib import File -from meson_install import InstallData -from build import InvalidArguments -from coredata import MesonException +from . import backends +from . import environment, mesonlib +from . import build +from . import mlog +from . import dependencies +from .mesonlib import File +from .meson_install import InstallData +from .build import InvalidArguments +from .coredata import MesonException import os, sys, pickle, re import subprocess, shutil diff --git a/optinterpreter.py b/meson/optinterpreter.py index 672df51..f0c93ae 100644 --- a/optinterpreter.py +++ b/meson/optinterpreter.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mparser -import coredata, mesonlib +from . import mparser +from . import coredata, mesonlib import os, re forbidden_option_names = coredata.builtin_options diff --git a/regen_checker.py b/meson/regen_checker.py index a0fe028..a0fe028 100755 --- a/regen_checker.py +++ b/meson/regen_checker.py diff --git a/symbolextractor.py b/meson/symbolextractor.py index f2c709d..f2c709d 100755 --- a/symbolextractor.py +++ b/meson/symbolextractor.py diff --git a/vcstagger.py b/meson/vcstagger.py index ccc584e..ccc584e 100755 --- a/vcstagger.py +++ b/meson/vcstagger.py diff --git a/vs2010backend.py b/meson/vs2010backend.py index 76e024c..76e024c 100644 --- a/vs2010backend.py +++ b/meson/vs2010backend.py @@ -12,12 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mlog +from . import mlog import urllib.request, os, hashlib, shutil import subprocess import sys -import wraptool +from . import wraptool class PackageDefinition: def __init__(self, fname): diff --git a/wraptool.py b/meson/wraptool.py index 2366b78..2366b78 100755 --- a/wraptool.py +++ b/meson/wraptool.py diff --git a/xcodebackend.py b/meson/xcodebackend.py index d72cbdf..d72cbdf 100644 --- a/xcodebackend.py +++ b/meson/xcodebackend.py diff --git a/run_tests.py b/run_tests.py index f1ed1c7..f1ea2a9 100755 --- a/run_tests.py +++ b/run_tests.py @@ -18,15 +18,15 @@ from glob import glob import os, subprocess, shutil, sys, signal from io import StringIO import sys -import environment -import mesonlib -import mlog -import meson, meson_test, meson_benchmark +from meson import environment +from meson import mesonlib +from meson import mlog +from meson import meson, meson_test, meson_benchmark import argparse import xml.etree.ElementTree as ET import time -from meson import backendlist +from meson.meson import backendlist class TestResult: def __init__(self, msg, stdo, stde, conftime=0, buildtime=0, testtime=0): |