More builder -> Meson renaming.

pull/15/head
Jussi Pakkanen 12 years ago
parent 603625b61c
commit 10fc496bbc
  1. 16
      environment.py
  2. 2
      generators.py
  3. 6
      interpreter.py
  4. 28
      meson.py

@ -16,7 +16,7 @@
import subprocess, os.path import subprocess, os.path
builder_filename = 'meson.build' build_filename = 'meson.build'
class EnvironmentException(Exception): class EnvironmentException(Exception):
def __init(self, *args, **kwargs): def __init(self, *args, **kwargs):
@ -226,13 +226,13 @@ def find_coverage_tools():
header_suffixes = ['h', 'hh', 'hpp', 'hxx', 'H'] header_suffixes = ['h', 'hh', 'hpp', 'hxx', 'H']
class Environment(): class Environment():
def __init__(self, source_dir, build_dir, builder_script_file, options): def __init__(self, source_dir, build_dir, main_script_file, options):
assert(builder_script_file[0] == '/') assert(main_script_file[0] == '/')
self.source_dir = source_dir self.source_dir = source_dir
self.build_dir = build_dir self.build_dir = build_dir
self.builder_script_file = builder_script_file self.meson_script_file = main_script_file
self.options = options self.options = options
self.scratch_dir = os.path.join(build_dir, 'builder-private') self.scratch_dir = os.path.join(build_dir, 'meson-private')
os.makedirs(self.scratch_dir, exist_ok=True) os.makedirs(self.scratch_dir, exist_ok=True)
self.default_c = ['cc'] self.default_c = ['cc']
@ -247,7 +247,7 @@ class Environment():
self.object_suffix = 'o' self.object_suffix = 'o'
def get_script_dir(self): def get_script_dir(self):
fullfile = self.builder_script_file fullfile = self.meson_script_file
while os.path.islink(fullfile): while os.path.islink(fullfile):
resolved = os.readlink(fullfile) resolved = os.readlink(fullfile)
if resolved[0] != '/': if resolved[0] != '/':
@ -256,8 +256,8 @@ class Environment():
fullfile = resolved fullfile = resolved
return os.path.dirname(fullfile) return os.path.dirname(fullfile)
def get_builder_command(self): def get_build_command(self):
return self.builder_script_file return self.meson_script_file
def get_c_compiler_exelist(self): def get_c_compiler_exelist(self):
ccachelist = self.detect_ccache() ccachelist = self.detect_ccache()

@ -294,7 +294,7 @@ class NinjaGenerator(Generator):
outfile.write(' command = $COMMAND\n') outfile.write(' command = $COMMAND\n')
outfile.write(' restat = 1\n\n') outfile.write(' restat = 1\n\n')
outfile.write('rule REGENERATE_BUILD\n') outfile.write('rule REGENERATE_BUILD\n')
c = (ninja_quote(self.environment.get_builder_command()), c = (ninja_quote(self.environment.get_build_command()),
ninja_quote(self.environment.get_source_dir()), ninja_quote(self.environment.get_source_dir()),
ninja_quote(self.environment.get_build_dir())) ninja_quote(self.environment.get_build_dir()))
outfile.write(" command = '%s' '%s' '%s' -G ninja\n" % c) outfile.write(" command = '%s' '%s' '%s' -G ninja\n" % c)

@ -338,7 +338,7 @@ class Interpreter():
def __init__(self, build): def __init__(self, build):
self.build = build self.build = build
code = open(os.path.join(build.environment.get_source_dir(),\ code = open(os.path.join(build.environment.get_source_dir(),\
environment.builder_filename)).read() environment.build_filename)).read()
if len(code.strip()) == 0: if len(code.strip()) == 0:
raise InvalidCode('Builder file is empty.') raise InvalidCode('Builder file is empty.')
assert(isinstance(code, str)) assert(isinstance(code, str))
@ -349,7 +349,7 @@ class Interpreter():
self.builtin['host'] = Host() self.builtin['host'] = Host()
self.environment = build.environment self.environment = build.environment
self.build_func_dict() self.build_func_dict()
self.build_def_files = [environment.builder_filename] self.build_def_files = [environment.build_filename]
self.subdir = '' self.subdir = ''
def build_func_dict(self): def build_func_dict(self):
@ -519,7 +519,7 @@ class Interpreter():
self.validate_arguments(args, 1, [str]) self.validate_arguments(args, 1, [str])
prev_subdir = self.subdir prev_subdir = self.subdir
self.subdir = os.path.join(prev_subdir, args[0]) self.subdir = os.path.join(prev_subdir, args[0])
buildfilename = os.path.join(self.subdir, environment.builder_filename) buildfilename = os.path.join(self.subdir, environment.build_filename)
self.build_def_files.append(buildfilename) self.build_def_files.append(buildfilename)
code = open(os.path.join(self.environment.get_source_dir(), buildfilename)).read() code = open(os.path.join(self.environment.get_source_dir(), buildfilename)).read()
assert(isinstance(code, str)) assert(isinstance(code, str))

@ -51,17 +51,17 @@ parser.add_option('--strip', action='store_true', dest='strip', default=False,\
parser.add_option('--enable-gcov', action='store_true', dest='coverage', default=False,\ parser.add_option('--enable-gcov', action='store_true', dest='coverage', default=False,\
help='measure test coverage') help='measure test coverage')
class BuilderApp(): class MesonApp():
def __init__(self, dir1, dir2, script_file, options): def __init__(self, dir1, dir2, script_file, options):
(self.source_dir, self.build_dir) = self.validate_dirs(dir1, dir2) (self.source_dir, self.build_dir) = self.validate_dirs(dir1, dir2)
if options.prefix[0] != '/': if options.prefix[0] != '/':
raise RuntimeError('--prefix must be an absolute path.') raise RuntimeError('--prefix must be an absolute path.')
self.builder_script_file = script_file self.meson_script_file = script_file
self.options = options self.options = options
def has_builder_file(self, dirname): def has_build_file(self, dirname):
fname = os.path.join(dirname, environment.builder_filename) fname = os.path.join(dirname, environment.build_filename)
try: try:
ifile = open(fname, 'r') ifile = open(fname, 'r')
ifile.close() ifile.close()
@ -79,16 +79,16 @@ class BuilderApp():
self.options = options self.options = options
if os.path.samefile(dir1, dir2): if os.path.samefile(dir1, dir2):
raise RuntimeError('Source and build directories must not be the same. Create a pristine build directory.') raise RuntimeError('Source and build directories must not be the same. Create a pristine build directory.')
if self.has_builder_file(ndir1): if self.has_build_file(ndir1):
if self.has_builder_file(ndir2): if self.has_build_file(ndir2):
raise RuntimeError('Both directories contain a build file %s.' % environment.builder_filename) raise RuntimeError('Both directories contain a build file %s.' % environment.build_filename)
return (ndir1, ndir2) return (ndir1, ndir2)
if self.has_builder_file(ndir2): if self.has_build_file(ndir2):
return (ndir2, ndir1) return (ndir2, ndir1)
raise RuntimeError('Neither directory contains a build file %s.' % environment.builder_filename) raise RuntimeError('Neither directory contains a build file %s.' % environment.build_filename)
def generate(self): def generate(self):
env = environment.Environment(self.source_dir, self.build_dir, self.builder_script_file, options) env = environment.Environment(self.source_dir, self.build_dir, self.meson_script_file, options)
b = build.Build(env) b = build.Build(env)
intr = interpreter.Interpreter(b) intr = interpreter.Interpreter(b)
intr.run() intr.run()
@ -112,8 +112,8 @@ if __name__ == '__main__':
else: else:
dir2 = '.' dir2 = '.'
this_file = os.path.abspath(__file__) this_file = os.path.abspath(__file__)
builder = BuilderApp(dir1, dir2, this_file, options) app = MesonApp(dir1, dir2, this_file, options)
print ('Source dir: ' + builder.source_dir) print ('Source dir: ' + app.source_dir)
print ('Build dir: ' + builder.build_dir) print ('Build dir: ' + app.build_dir)
builder.generate() app.generate()

Loading…
Cancel
Save