aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2013-02-06 22:40:18 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2013-02-06 22:40:18 +0200
commit5dd4122c65f1f5ac8444fc2475cf5bd31bb533ea (patch)
treefa2441755e4291c7b5694d87c98b26bbcd0beb11
parent53ba6282016ae6c941f202c9e8a99d66b53c722a (diff)
downloadmeson-5dd4122c65f1f5ac8444fc2475cf5bd31bb533ea.zip
meson-5dd4122c65f1f5ac8444fc2475cf5bd31bb533ea.tar.gz
meson-5dd4122c65f1f5ac8444fc2475cf5bd31bb533ea.tar.bz2
Ninja compiles! With only the slightest of manual ninjafile editing.
-rwxr-xr-xgenerators.py56
1 files changed, 40 insertions, 16 deletions
diff --git a/generators.py b/generators.py
index 501e749..6d2e590 100755
--- a/generators.py
+++ b/generators.py
@@ -121,6 +121,15 @@ class Generator():
commands += dep.get_compile_flags()
return commands
+ def build_target_link_arguments(self, deps):
+ args = []
+ for d in deps:
+ if not isinstance(d, interpreter.StaticLibrary) and\
+ not isinstance(d, interpreter.SharedLibrary):
+ raise RuntimeError('Tried to link with a non-library target "%s".' % d.get_basename())
+ args.append(self.get_target_filename(d))
+ return args
+
class NinjaGenerator(Generator):
def __init__(self, build, interp):
@@ -160,10 +169,9 @@ class NinjaGenerator(Generator):
for compiler in self.build.compilers:
langname = compiler.get_language()
rule = 'rule %s_LINKER\n' % langname
- command = ' command = %s $FLAGS $LINK_FLAGS %s $out %s $in\n' % \
+ command = ' command = %s $FLAGS $LINK_FLAGS %s $out $in\n' % \
(' '.join(compiler.get_exelist()),\
- ' '.join(compiler.get_output_flags()),\
- ' '.join(compiler.get_compile_only_flags()))
+ ' '.join(compiler.get_output_flags()))
description = ' description = Linking target $out'
outfile.write(rule)
outfile.write(command)
@@ -208,9 +216,34 @@ class NinjaGenerator(Generator):
flags = ' FLAGS = %s\n\n' % ' '.join([ninja_quote(t) for t in commands])
outfile.write(build)
outfile.write(flags)
-
+ return abs_obj
+
def generate_link(self, target, outfile, outname, obj_list):
- pass
+ if isinstance(target, interpreter.StaticLibrary):
+ linker = self.build.static_linker
+ linker_base = 'STATIC'
+ else:
+ linker = self.build.compilers[0]
+ linker_base = linker.get_language() # Fixme.
+ linker_rule = linker_base + '_LINKER'
+ commands = []
+ if isinstance(target, interpreter.Executable):
+ commands += linker.get_std_exe_link_flags()
+ elif isinstance(target, interpreter.SharedLibrary):
+ commands += linker.get_std_shared_lib_link_flags()
+ commands += linker.get_pic_flags()
+ elif isinstance(target, interpreter.StaticLibrary):
+ commands += linker.get_std_link_flags()
+ else:
+ raise RuntimeError('Unknown build target type.')
+ for dep in target.get_external_deps():
+ commands += dep.get_link_flags()
+ commands += self.build_target_link_arguments(target.get_dependencies())
+ build = 'build %s: %s %s\n' % \
+ (ninja_quote(outname), linker_rule, ' '.join([ninja_quote(i) for i in obj_list]))
+ flags = ' LINK_FLAGS = %s\n\n' % ' '.join([ninja_quote(a) for a in commands])
+ outfile.write(build)
+ outfile.write(flags)
def generate_shlib_aliases(self, target, outdir, outfile):
pass
@@ -276,8 +309,8 @@ echo Run compile.sh before this or bad things will happen.
self.generate_data_install(outfile)
outfile.close()
- def make_subdir(self, outfile, dir):
- cmdlist = ['mkdir', '-p', dir]
+ def make_subdir(self, outfile, sdir):
+ cmdlist = ['mkdir', '-p', sdir]
outfile.write(' '.join(shell_quote(cmdlist)) + ' || exit\n')
def copy_file(self, outfile, filename, outdir):
@@ -413,15 +446,6 @@ echo Run compile.sh before this or bad things will happen.
outfile.write(' '.join(quoted) + ' || exit\n')
return abs_obj
- def build_target_link_arguments(self, deps):
- args = []
- for d in deps:
- if not isinstance(d, interpreter.StaticLibrary) and\
- not isinstance(d, interpreter.SharedLibrary):
- raise RuntimeError('Tried to link with a non-library target "%s".' % d.get_basename())
- args.append(self.get_target_filename(d))
- return args
-
def generate_link(self, target, outfile, outname, obj_list):
if isinstance(target, interpreter.StaticLibrary):
linker = self.build.static_linker