[vala/parallel] compiler: output make-style dependency file
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/parallel] compiler: output make-style dependency file
- Date: Thu, 26 Aug 2010 23:12:14 +0000 (UTC)
commit 94ed48f306c538a34f33b6648dc8b875ba6ad190
Author: Ryan Lortie <desrt desrt ca>
Date: Wed Aug 25 16:10:30 2010 +0200
compiler: output make-style dependency file
compiler/valacompiler.vala | 6 ++++++
vala/valacodecontext.vala | 24 ++++++++++++++++++++++++
vala/valasourcefile.vala | 6 ++++++
vala/valasymbol.vala | 11 ++++++++++-
vala/valasymbolresolver.vala | 2 ++
5 files changed, 48 insertions(+), 1 deletions(-)
---
diff --git a/compiler/valacompiler.vala b/compiler/valacompiler.vala
index 41b0d46..9018227 100644
--- a/compiler/valacompiler.vala
+++ b/compiler/valacompiler.vala
@@ -76,6 +76,7 @@ class Vala.Compiler {
static bool enable_version_header;
static bool disable_version_header;
static bool fatal_warnings;
+ static string dependencies;
static string entry_point;
@@ -101,6 +102,7 @@ class Vala.Compiler {
{ "internal-vapi", 0, 0, OptionArg.FILENAME, ref internal_vapi_filename, "Output vapi with internal api", "FILE" },
{ "fast-vapi", 0, 0, OptionArg.STRING, ref fast_vapi_filename, "Output vapi without performing symbol resolution", null },
{ "use-fast-vapi", 0, 0, OptionArg.STRING_ARRAY, ref fast_vapis, "Use --fast-vapi output during this compile", null },
+ { "deps", 0, 0, OptionArg.STRING, ref dependencies, "Write make-style dependency information to this file", null },
{ "symbols", 0, 0, OptionArg.FILENAME, ref symbols_filename, "Output symbols file", "FILE" },
{ "compile", 'c', 0, OptionArg.NONE, ref compile_only, "Compile but do not link", null },
{ "output", 'o', 0, OptionArg.FILENAME, ref output, "Place output in file FILE", "FILE" },
@@ -545,6 +547,10 @@ class Vala.Compiler {
internal_vapi_filename = null;
}
+ if (dependencies != null) {
+ context.write_dependencies (dependencies);
+ }
+
if (!ccode_only) {
var ccompiler = new CCodeCompiler ();
if (cc_command == null && Environment.get_variable ("CC") != null) {
diff --git a/vala/valacodecontext.vala b/vala/valacodecontext.vala
index 476142c..3e371a4 100644
--- a/vala/valacodecontext.vala
+++ b/vala/valacodecontext.vala
@@ -362,4 +362,28 @@ public class Vala.CodeContext {
return null;
}
+
+ public void write_dependencies (string filename) {
+ var stream = FileStream.open (filename, "w");
+
+ if (stream == null) {
+ Report.error (null, "unable to open `%s' for writing".printf (filename));
+ return;
+ }
+
+ foreach (var src in source_files) {
+ if (src.file_type == SourceFileType.SOURCE) {
+ /* XXX: basename may not be correct. */
+ stream.printf ("%s:", Path.get_basename (src.get_csource_filename ()));
+ foreach (var fast in source_files) {
+ if (fast.file_type == SourceFileType.FAST && fast.used) {
+ stream.printf (" %s", fast.filename);
+ }
+ }
+ stream.printf ("\n\n");
+ } else if (src.file_type == SourceFileType.FAST && src.used) {
+ stream.printf ("%s:\n\n", src.filename);
+ }
+ }
+ }
}
diff --git a/vala/valasourcefile.vala b/vala/valasourcefile.vala
index a4ef7a7..c9d53ac 100644
--- a/vala/valasourcefile.vala
+++ b/vala/valasourcefile.vala
@@ -67,6 +67,12 @@ public class Vala.SourceFile {
}
}
+ /**
+ * If the file has been used (ie: if anything in the file has
+ * been found by symbol resolution).
+ */
+ public bool used { get; set; }
+
private ArrayList<Comment> comments = new ArrayList<Comment> ();
public List<UsingDirective> current_using_directives { get; set; default = new ArrayList<UsingDirective> (); }
diff --git a/vala/valasymbol.vala b/vala/valasymbol.vala
index f11537e..6403e8c 100644
--- a/vala/valasymbol.vala
+++ b/vala/valasymbol.vala
@@ -85,7 +85,16 @@ public abstract class Vala.Symbol : CodeNode {
/**
* Specifies whether this symbol has been accessed.
*/
- public bool used { get; set; }
+ public bool used {
+ get { return _used; }
+ set {
+ _used = value;
+ if (_used && source_reference != null) {
+ source_reference.file.used = true;
+ }
+ }
+ }
+ bool _used;
/**
* Specifies the accessibility of this symbol. Public accessibility
diff --git a/vala/valasymbolresolver.vala b/vala/valasymbolresolver.vala
index 026d6ea..ef61c36 100644
--- a/vala/valasymbolresolver.vala
+++ b/vala/valasymbolresolver.vala
@@ -271,6 +271,7 @@ public class Vala.SymbolResolver : CodeVisitor {
Report.error (unresolved_symbol.inner.source_reference, "The symbol `%s' could not be found".printf (unresolved_symbol.inner.name));
return null;
}
+ parent_symbol.used = true;
return parent_symbol.scope.lookup (unresolved_symbol.name);
}
@@ -354,6 +355,7 @@ public class Vala.SymbolResolver : CodeVisitor {
type.source_reference = unresolved_type.source_reference;
type.value_owned = unresolved_type.value_owned;
+ sym.used = true;
if (type is GenericType) {
// type parameters are always considered nullable
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]