From bc97fb5c85bd7d5c1d42f8409e3cf1f7f193003e Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Mon, 17 Mar 2014 22:09:28 +0200 Subject: [PATCH] Backend work is start. --- backends.py | 10 +++++++++- build.py | 1 + coredata.py | 4 +++- interpreter.py | 6 +++++- meson.py | 10 ++++++++-- 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/backends.py b/backends.py index 8e3e07a14..0731c8683 100644 --- a/backends.py +++ b/backends.py @@ -474,7 +474,7 @@ class NinjaBuildElement(): class NinjaBackend(Backend): def __init__(self, build, interp): - Backend.__init__(self, build, interp) + super().__init__(build, interp) self.ninja_filename = 'build.ninja' def generate(self): @@ -1214,3 +1214,11 @@ class NinjaBackend(Backend): elem.write(outfile) self.generate_cppcheck_target(outfile) + +class Vs2010Backend(Backend): + def __init__(self, build, interp): + super().__init__(build, interp) + + def generate(self): + sln_filename = os.path.join(self.environment.get_build_dir(), self.build.project_name + '.sln') + open(sln_filename, 'w') diff --git a/build.py b/build.py index a27bff7d3..9e542f84b 100644 --- a/build.py +++ b/build.py @@ -26,6 +26,7 @@ class Build: """ def __init__(self, environment): + self.project_name = 'name of master project' self.environment = environment self.projects = {} self.targets = {} diff --git a/coredata.py b/coredata.py index 6ec58ad6f..42a70d1c9 100644 --- a/coredata.py +++ b/coredata.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pickle, os +import pickle, os, uuid version = '0.14.0-research' @@ -23,6 +23,8 @@ version = '0.14.0-research' class CoreData(): def __init__(self, options): + self.guid = str(uuid.uuid4()) + self.target_guids = {} self.version = version self.prefix = options.prefix self.libdir = options.libdir diff --git a/interpreter.py b/interpreter.py index bde38c12e..f1cdd8ea3 100644 --- a/interpreter.py +++ b/interpreter.py @@ -19,7 +19,7 @@ import dependencies import mlog import build import optinterpreter -import os, sys, platform, subprocess, shutil +import os, sys, platform, subprocess, shutil, uuid class InterpreterException(coredata.MesonException): pass @@ -857,6 +857,8 @@ class Interpreter(): for a in args: if not isinstance(a, str): raise InvalidArguments('Argument %s is not a string.' % str(a)) + if self.subproject == '': + self.build.project_name = args[0] if self.subproject in self.build.projects: raise InvalidCode('Second call to project().') self.build.projects[self.subproject] = args[0] @@ -1159,6 +1161,8 @@ class Interpreter(): self.check_sources_exist(os.path.join(self.source_root, self.subdir), sources) l = targetclass(name, self.subdir, is_cross, sources, objs, self.environment, kwargs) self.build.targets[name] = l.held_object + if name not in self.coredata.target_guids: + self.coredata.target_guids[name] = uuid.uuid4() if self.environment.is_cross_build() and l.is_cross: txt = ' cross build ' else: diff --git a/meson.py b/meson.py index a1408145c..55c84617a 100755 --- a/meson.py +++ b/meson.py @@ -31,6 +31,10 @@ build_types = ['plain', 'debug', 'optimized'] buildtype_help = 'build type, one of: %s' % ', '.join(build_types) buildtype_help += ' (default: %default)' +backendlist = ['ninja', 'vs2010'] +backend_help = 'backend to use, one of: %s' % ', '.join(backendlist) +backend_help += ' (default: %default)' + if environment.is_windows(): def_prefix = 'c:/' else: @@ -50,8 +54,8 @@ parser.add_option('--mandir' , default='share/man', dest='mandir', help='relative path of man files (default: %default)') parser.add_option('--localedir', default='share/locale', dest='localedir', help='relative path of locale data (default: %default)') -parser.add_option('--backend', default='ninja', dest='backend', - help='the backend to use (default: %default)') +parser.add_option('--backend', default='ninja', dest='backend', choices=backendlist, + help=backend_help) parser.add_option('--buildtype', default='debug', type='choice', choices=build_types, dest='buildtype', help=buildtype_help) parser.add_option('--strip', action='store_true', dest='strip', default=False,\ @@ -127,6 +131,8 @@ itself as required.''' intr.run() if options.backend == 'ninja': g = backends.NinjaBackend(b, intr) + elif options.backend == 'vs2010': + g = backends.Vs2010Backend(b, intr) else: raise RuntimeError('Unknown backend "%s".' % options.backend) g.generate()