From 5af98d16b93139f11f8b42cc0c4d613548dd1d69 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Sun, 13 May 2018 10:36:58 -0400 Subject: Delay backend creation until project() is parsed The project() function could have a different value for the backend option in its default_options kwargs. Also set backend options, passing them in command line had no effect previously. --- mesonbuild/mesonmain.py | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) (limited to 'mesonbuild/mesonmain.py') diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py index f7a57d8..50a8c7e 100644 --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -148,30 +148,8 @@ class MesonApp: else: mlog.log('Build type:', mlog.bold('native build')) b = build.Build(env) - if self.options.backend == 'ninja': - from .backend import ninjabackend - g = ninjabackend.NinjaBackend(b) - elif self.options.backend == 'vs': - from .backend import vs2010backend - g = vs2010backend.autodetect_vs_version(b) - env.coredata.set_builtin_option('backend', g.name) - mlog.log('Auto detected Visual Studio backend:', mlog.bold(g.name)) - elif self.options.backend == 'vs2010': - from .backend import vs2010backend - g = vs2010backend.Vs2010Backend(b) - elif self.options.backend == 'vs2015': - from .backend import vs2015backend - g = vs2015backend.Vs2015Backend(b) - elif self.options.backend == 'vs2017': - from .backend import vs2017backend - g = vs2017backend.Vs2017Backend(b) - elif self.options.backend == 'xcode': - from .backend import xcodebackend - g = xcodebackend.XCodeBackend(b) - else: - raise RuntimeError('Unknown backend "%s".' % self.options.backend) - intr = interpreter.Interpreter(b, g) + intr = interpreter.Interpreter(b) 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([], {}))) @@ -194,14 +172,14 @@ class MesonApp: # possible, but before build files, and if any error occurs, delete it. cdf = env.dump_coredata() if self.options.profile: - fname = 'profile-{}-backend.log'.format(self.options.backend) + fname = 'profile-{}-backend.log'.format(intr.backend.name) fname = os.path.join(self.build_dir, 'meson-private', fname) - profile.runctx('g.generate(intr)', globals(), locals(), filename=fname) + profile.runctx('intr.backend.generate(intr)', globals(), locals(), filename=fname) else: - g.generate(intr) + intr.backend.generate(intr) build.save(b, dumpfile) # Post-conf scripts must be run after writing coredata or else introspection fails. - g.run_postconf_scripts() + intr.backend.run_postconf_scripts() except: if 'cdf' in locals(): old_cdf = cdf + '.prev' -- cgit v1.1