[vala] valac: Add --symbols option



commit 2aa61900cb7ba616dd54803cf4de7d59e7537a9b
Author: Jürg Billeter <j bitron ch>
Date:   Tue Dec 15 20:06:05 2009 +0100

    valac: Add --symbols option
    
    Writes the name of each exported function to the specified file.
    
    Based on patch by Haakon Sporsheim, fixes bug 586494.

 codegen/valaccodebasemodule.vala |   15 +++++++++++++++
 compiler/valacompiler.vala       |    3 +++
 vala/valacodecontext.vala        |    5 +++++
 3 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 0a7779f..3ca3c6f 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -364,6 +364,21 @@ internal class Vala.CCodeBaseModule : CCodeModule {
 			}
 		}
 
+		// generate symbols file for public API
+		if (context.symbols_filename != null) {
+			var stream = FileStream.open (context.symbols_filename, "w");
+
+			foreach (CCodeNode node in header_declarations.type_member_declaration.get_children ()) {
+				if (node is CCodeFunction) {
+					var func = (CCodeFunction) node;
+					stream.puts (func.name);
+					stream.putc ('\n');
+				}
+			}
+
+			stream = null;
+		}
+
 		// generate C header file for public API
 		if (context.header_filename != null) {
 			var writer = new CCodeWriter (context.header_filename);
diff --git a/compiler/valacompiler.vala b/compiler/valacompiler.vala
index 3f37fbd..bddaa1f 100644
--- a/compiler/valacompiler.vala
+++ b/compiler/valacompiler.vala
@@ -49,6 +49,7 @@ class Vala.Compiler {
 	static bool use_header;
 	static string internal_header_filename;
 	static string internal_vapi_filename;
+	static string symbols_filename;
 	static string includedir;
 	static bool compile_only;
 	static string output;
@@ -94,6 +95,7 @@ class Vala.Compiler {
 		{ "includedir", 0, 0, OptionArg.FILENAME, ref includedir, "Directory used to include the C header file", "DIRECTORY" },
 		{ "internal-header", 'h', 0, OptionArg.FILENAME, ref internal_header_filename, "Output internal C header file", "FILE" },
 		{ "internal-vapi", 0, 0, OptionArg.FILENAME, ref internal_vapi_filename, "Output vapi with internal api", "FILE" },
+		{ "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" },
 		{ "debug", 'g', 0, OptionArg.NONE, ref debug, "Produce debug information", null },
@@ -218,6 +220,7 @@ class Vala.Compiler {
 		}
 		context.use_header = use_header;
 		context.internal_header_filename = internal_header_filename;
+		context.symbols_filename = symbols_filename;
 		context.includedir = includedir;
 		context.output = output;
 		if (basedir == null) {
diff --git a/vala/valacodecontext.vala b/vala/valacodecontext.vala
index 5f57323..e9e694d 100644
--- a/vala/valacodecontext.vala
+++ b/vala/valacodecontext.vala
@@ -79,6 +79,11 @@ public class Vala.CodeContext {
 	public string? includedir { get; set; }
 
 	/**
+	 * Output symbols file.
+	 */
+	public string? symbols_filename { get; set; }
+
+	/**
 	 * Compile but do not link.
 	 */
 	public bool compile_only { get; set; }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]