diff options
-rw-r--r-- | backends.py | 3 | ||||
-rw-r--r-- | interpreter.py | 30 | ||||
-rwxr-xr-x | meson.py | 14 | ||||
-rw-r--r-- | ninjabackend.py | 8 | ||||
-rw-r--r-- | test cases/frameworks/7 gnome/gir/meson.build | 4 | ||||
-rw-r--r-- | vs2010backend.py | 7 | ||||
-rw-r--r-- | xcodebackend.py | 7 |
7 files changed, 40 insertions, 33 deletions
diff --git a/backends.py b/backends.py index f99a271..438e4f9 100644 --- a/backends.py +++ b/backends.py @@ -37,10 +37,9 @@ class TestSerialisation: # This class contains the basic functionality that is needed by all backends. # Feel free to move stuff in and out of it as you see fit. class Backend(): - def __init__(self, build, interp): + def __init__(self, build): self.build = build self.environment = build.environment - self.interpreter = interp self.processed_targets = {} self.dep_rules = {} self.build_to_src = os.path.relpath(self.environment.get_source_dir(), diff --git a/interpreter.py b/interpreter.py index 8fa55c2..264fcf6 100644 --- a/interpreter.py +++ b/interpreter.py @@ -449,17 +449,22 @@ class GeneratedObjectsHolder(InterpreterObject): self.held_object = held_object class BuildTargetHolder(InterpreterObject): - def __init__(self, target): + def __init__(self, target, interp): super().__init__() self.held_object = target + self.interpreter = interp self.methods.update({'extract_objects' : self.extract_objects_method, 'extract_all_objects' : self.extract_all_objects_method, 'get_id': self.get_id_method, + 'outdir' : self.outdir_method, }) def is_cross(self): return self.held_object.is_cross() + def outdir_method(self, args, kwargs): + return self.interpreter.backend.get_target_dir(self.held_object) + def extract_objects_method(self, args, kwargs): gobjs = self.held_object.extract_objects(args) return GeneratedObjectsHolder(gobjs) @@ -472,20 +477,20 @@ class BuildTargetHolder(InterpreterObject): return self.held_object.get_id() class ExecutableHolder(BuildTargetHolder): - def __init__(self, target): - super().__init__(target) + def __init__(self, target, interp): + super().__init__(target, interp) class StaticLibraryHolder(BuildTargetHolder): - def __init__(self, target): - super().__init__(target) + def __init__(self, target, interp): + super().__init__(target, interp) class SharedLibraryHolder(BuildTargetHolder): - def __init__(self, target): - super().__init__(target) + def __init__(self, target, interp): + super().__init__(target, interp) class JarHolder(BuildTargetHolder): - def __init__(self, target): - super().__init__(target) + def __init__(self, target, interp): + super().__init__(target, interp) class CustomTargetHolder(InterpreterObject): def __init__(self, object_to_hold): @@ -811,8 +816,9 @@ class MesonMain(InterpreterObject): class Interpreter(): - def __init__(self, build, subproject='', subdir='', subproject_dir='subprojects'): + def __init__(self, build, backend, subproject='', subdir='', subproject_dir='subprojects'): self.build = build + self.backend = backend self.subproject = subproject self.subdir = subdir self.source_root = build.environment.get_source_dir() @@ -1181,7 +1187,7 @@ class Interpreter(): os.makedirs(os.path.join(self.build.environment.get_build_dir(), subdir), exist_ok=True) self.global_args_frozen = True mlog.log('\nExecuting subproject ', mlog.bold(dirname), '.\n', sep='') - subi = Interpreter(self.build, dirname, subdir, self.subproject_dir) + subi = Interpreter(self.build, self.backend, dirname, subdir, self.subproject_dir) subi.subprojects = self.subprojects subi.subproject_stack = self.subproject_stack + [dirname] @@ -1725,7 +1731,7 @@ class Interpreter(): mlog.debug('Unknown target type:', str(targetholder)) raise RuntimeError('Unreachable code') target = targetclass(name, self.subdir, self.subproject, is_cross, sources, objs, self.environment, kwargs) - l = targetholder(target) + l = targetholder(target, self) self.add_target(name, l.held_object) self.global_args_frozen = True return l @@ -130,24 +130,24 @@ itself as required.''' else: mlog.log('Build type:', mlog.bold('native build')) b = build.Build(env) - intr = interpreter.Interpreter(b) - mlog.log('Build machine cpu:', mlog.bold(intr.builtin['build_machine'].cpu_method([], {}))) if env.is_cross_build(): mlog.log('Host machine cpu:', mlog.bold(intr.builtin['host_machine'].cpu_method([], {}))) mlog.log('Target machine cpu:', mlog.bold(intr.builtin['target_machine'].cpu_method([], {}))) - intr.run() if self.options.backend == 'ninja': import ninjabackend - g = ninjabackend.NinjaBackend(b, intr) + g = ninjabackend.NinjaBackend(b) elif self.options.backend == 'vs2010': import vs2010backend - g = vs2010backend.Vs2010Backend(b, intr) + g = vs2010backend.Vs2010Backend(b) elif self.options.backend == 'xcode': import xcodebackend - g = xcodebackend.XCodeBackend(b, intr) + g = xcodebackend.XCodeBackend(b) else: raise RuntimeError('Unknown backend "%s".' % self.options.backend) - g.generate() + intr = interpreter.Interpreter(b, g) + 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')) diff --git a/ninjabackend.py b/ninjabackend.py index 47068e7..2fa60df 100644 --- a/ninjabackend.py +++ b/ninjabackend.py @@ -109,13 +109,14 @@ class NinjaBuildElement(): class NinjaBackend(backends.Backend): - def __init__(self, build, interp): - super().__init__(build, interp) + def __init__(self, build): + super().__init__(build) self.source_suffix_in_objs = True self.ninja_filename = 'build.ninja' self.fortran_deps = {} - def generate(self): + def generate(self, interp): + self.interpreter = interp outfilename = os.path.join(self.environment.get_build_dir(), self.ninja_filename) tempfilename = outfilename + '~' outfile = open(tempfilename, 'w') @@ -485,7 +486,6 @@ class NinjaBackend(backends.Backend): d.man.append(i) def generate_data_install(self, d): - dataroot = self.environment.get_datadir() data = self.build.get_data() for de in data: subdir = de.get_install_dir() diff --git a/test cases/frameworks/7 gnome/gir/meson.build b/test cases/frameworks/7 gnome/gir/meson.build index f76f071..287c0d7 100644 --- a/test cases/frameworks/7 gnome/gir/meson.build +++ b/test cases/frameworks/7 gnome/gir/meson.build @@ -27,6 +27,6 @@ gnome.generate_gir( test('gobject introspection/c', girexe) test('gobject introspection/py', find_program('prog.py'), - env : ['GI_TYPELIB_PATH=meson-out', # HACK to get this running. - 'LD_LIBRARY_PATH=meson-out', + env : ['GI_TYPELIB_PATH=' + girlib.outdir(), + 'LD_LIBRARY_PATH=' + girlib.outdir(), ]) diff --git a/vs2010backend.py b/vs2010backend.py index e5cb3fe..e834584 100644 --- a/vs2010backend.py +++ b/vs2010backend.py @@ -19,8 +19,8 @@ import xml.dom.minidom from coredata import MesonException class Vs2010Backend(backends.Backend): - def __init__(self, build, interp): - super().__init__(build, interp) + def __init__(self, build): + super().__init__(build) self.project_file_version = '10.0.30319.1' # foo.c compiles to foo.obj, not foo.c.obj self.source_suffix_in_obj = False @@ -62,7 +62,8 @@ class Vs2010Backend(backends.Backend): ET.SubElement(pg, 'CustomBuildBeforeTargets').text = 'ClCompile' return all_output_files - def generate(self): + def generate(self, interp): + self.interpreter = interp self.generate_pkgconfig_files() sln_filename = os.path.join(self.environment.get_build_dir(), self.build.project_name + '.sln') projlist = self.generate_projects() diff --git a/xcodebackend.py b/xcodebackend.py index a5df6a5..847b5af 100644 --- a/xcodebackend.py +++ b/xcodebackend.py @@ -19,8 +19,8 @@ import uuid, os, sys from coredata import MesonException class XCodeBackend(backends.Backend): - def __init__(self, build, interp): - super().__init__(build, interp) + def __init__(self, build): + super().__init__(build) self.project_uid = self.environment.coredata.guid.replace('-', '')[:24] self.project_conflist = self.gen_id() self.indent = ' ' @@ -61,7 +61,8 @@ class XCodeBackend(backends.Backend): if not text.endswith('\n'): self.ofile.write('\n') - def generate(self): + def generate(self, interp): + self.interpreter = interp self.serialise_tests() self.generate_filemap() self.generate_buildmap() |