From: Jürg Billeter Date: Tue, 15 Dec 2009 19:06:05 +0000 (+0100) Subject: valac: Add --symbols option X-Git-Tag: 0.7.9~13 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2aa61900cb7ba616dd54803cf4de7d59e7537a9b;p=thirdparty%2Fvala.git valac: Add --symbols option Writes the name of each exported function to the specified file. Based on patch by Haakon Sporsheim, fixes bug 586494. --- diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala index 0a7779f33..3ca3c6fac 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 3f37fbd6c..bddaa1f49 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 5f573231c..e9e694df7 100644 --- a/vala/valacodecontext.vala +++ b/vala/valacodecontext.vala @@ -78,6 +78,11 @@ public class Vala.CodeContext { */ public string? includedir { get; set; } + /** + * Output symbols file. + */ + public string? symbols_filename { get; set; } + /** * Compile but do not link. */