aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2013-02-10 19:53:31 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2013-02-10 19:53:31 +0200
commit3880670a8606320cf0e2b412c92f83b72ad2c7bc (patch)
tree5fe258f9b2d519ff11da5b430b1df7c535ca31a1
parent84d6e85d373d4a40bd9258bbf614436caa6ef2eb (diff)
downloadmeson-3880670a8606320cf0e2b412c92f83b72ad2c7bc.zip
meson-3880670a8606320cf0e2b412c92f83b72ad2c7bc.tar.gz
meson-3880670a8606320cf0e2b412c92f83b72ad2c7bc.tar.bz2
Get dependency info from the compiler.
-rwxr-xr-xenvironment.py8
-rwxr-xr-xgenerators.py12
2 files changed, 16 insertions, 4 deletions
diff --git a/environment.py b/environment.py
index 6dd775b..a6719b4 100755
--- a/environment.py
+++ b/environment.py
@@ -31,7 +31,13 @@ class CCompiler():
else:
raise TypeError('Unknown argument to CCompiler')
self.language = 'c'
-
+
+ def get_dependency_gen_flags(self, outtarget, outfile):
+ return ['-MMD', '-MT', outtarget, '-MF', outfile]
+
+ def get_depfile_suffix(self):
+ return 'd'
+
def get_language(self):
return self.language
diff --git a/generators.py b/generators.py
index ea45352..8e7ab24 100755
--- a/generators.py
+++ b/generators.py
@@ -294,13 +294,17 @@ class NinjaGenerator(Generator):
for compiler in self.build.compilers:
langname = compiler.get_language()
rule = 'rule %s_COMPILER\n' % langname
- command = ' command = %s $FLAGS %s $out %s $in\n' % \
+ depflags = compiler.get_dependency_gen_flags('$out', '$DEPFILE')
+ command = " command = %s $FLAGS %s %s $out %s $in\n" % \
(' '.join(compiler.get_exelist()),\
+ ' '.join(['\'%s\''% d for d in depflags]),\
' '.join(compiler.get_output_flags()),\
' '.join(compiler.get_compile_only_flags()))
- description = ' description = Compiling %s object $out' % langname
+ description = ' description = Compiling %s object $out\n' % langname
+ dep = ' depfile = $DEPFILE\n'
outfile.write(rule)
outfile.write(command)
+ outfile.write(dep)
outfile.write(description)
outfile.write('\n')
outfile.write('\n')
@@ -311,6 +315,7 @@ class NinjaGenerator(Generator):
abs_src = os.path.join(self.build_to_src, target.get_source_subdir(), src)
abs_obj = os.path.join(self.get_target_private_dir(target), src)
abs_obj += '.' + self.environment.get_object_suffix()
+ dep_file = abs_obj + '.' + compiler.get_depfile_suffix()
pchlist = target.get_pch()
if len(pchlist) == 0:
pch_dep = ''
@@ -321,7 +326,6 @@ class NinjaGenerator(Generator):
os.path.split(pch)[-1] + '.' + compiler.get_pch_suffix())
arr.append(i)
pch_dep = '|| ' + ' '.join([ninja_quote(i) for i in arr])
-
for i in target.get_include_dirs():
basedir = i.get_curdir()
for d in i.get_incdirs():
@@ -336,8 +340,10 @@ class NinjaGenerator(Generator):
build = 'build %s: %s %s %s\n' % \
(ninja_quote(abs_obj), compiler_name, ninja_quote(abs_src),
pch_dep)
+ dep = ' DEPFILE = %s\n' % dep_file
flags = ' FLAGS = %s\n\n' % ' '.join(["'" + ninja_quote(t) + "'" for t in commands])
outfile.write(build)
+ outfile.write(dep)
outfile.write(flags)
return abs_obj