[vala] valac: Add --enable-version-header option
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] valac: Add --enable-version-header option
- Date: Sun, 21 Mar 2010 07:53:40 +0000 (UTC)
commit 82eaf6f167ba40e05dfd96448b575ffe3282f362
Author: Jürg Billeter <j bitron ch>
Date: Thu Jan 28 01:57:41 2010 +0100
valac: Add --enable-version-header option
Writes Vala version in generated files. Disabled by default for
bootstrapping reasons.
Based on patch by Marc-André Lureau, fixes bug 608371.
ccode/Makefile.am | 2 +-
ccode/valaccodewriter.vala | 7 +++++--
codegen/valaccodebasemodule.vala | 6 +++---
compiler/valacompiler.vala | 7 ++++++-
vala/valacodecontext.vala | 2 ++
vala/valacodewriter.vala | 5 ++++-
6 files changed, 21 insertions(+), 8 deletions(-)
---
diff --git a/ccode/Makefile.am b/ccode/Makefile.am
index fdc07bb..f3b5d2e 100644
--- a/ccode/Makefile.am
+++ b/ccode/Makefile.am
@@ -77,7 +77,7 @@ ccodeinclude_HEADERS = \
$(NULL)
ccode.vapi ccode.vala.stamp: $(libvalaccode_la_VALASOURCES)
- $(VALAC) $(COVERAGE_VALAFLAGS) $(VALAFLAGS) -C --vapidir $(srcdir)/../vapi --pkg gobject-2.0 --vapidir ../gee --pkg gee -H valaccode.h --library ccode $^
+ $(VALAC) $(COVERAGE_VALAFLAGS) $(VALAFLAGS) -C --vapidir $(srcdir)/../vapi --pkg gobject-2.0 --vapidir ../gee --pkg gee --pkg config -H valaccode.h --library ccode $^
touch $@
libvalaccode_la_LIBADD = \
diff --git a/ccode/valaccodewriter.vala b/ccode/valaccodewriter.vala
index f2ddb7e..ea10cbe 100644
--- a/ccode/valaccodewriter.vala
+++ b/ccode/valaccodewriter.vala
@@ -71,7 +71,7 @@ public class Vala.CCodeWriter {
* @return true if the file has been opened successfully,
* false otherwise
*/
- public bool open () {
+ public bool open (bool write_version) {
file_exists = FileUtils.test (filename, FileTest.EXISTS);
if (file_exists) {
temp_filename = "%s.valatmp".printf (filename);
@@ -84,7 +84,10 @@ public class Vala.CCodeWriter {
return false;
}
- write_string ("/* %s generated by valac, the Vala compiler".printf (Path.get_basename (filename)));
+ var opening = write_version ?
+ "/* %s generated by valac %s, the Vala compiler".printf (Path.get_basename (filename), Config.BUILD_VERSION) :
+ "/* %s generated by valac, the Vala compiler".printf (Path.get_basename (filename));
+ write_string (opening);
// Write the file name if known
if (source_filename != null) {
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index f134d79..dd2a158 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -390,7 +390,7 @@ internal class Vala.CCodeBaseModule : CCodeModule {
// generate C header file for public API
if (context.header_filename != null) {
var writer = new CCodeWriter (context.header_filename);
- if (!writer.open ()) {
+ if (!writer.open (context.version_header)) {
Report.error (null, "unable to open `%s' for writing".printf (writer.filename));
return;
}
@@ -429,7 +429,7 @@ internal class Vala.CCodeBaseModule : CCodeModule {
// generate C header file for internal API
if (context.internal_header_filename != null) {
var writer = new CCodeWriter (context.internal_header_filename);
- if (!writer.open ()) {
+ if (!writer.open (context.version_header)) {
Report.error (null, "unable to open `%s' for writing".printf (writer.filename));
return;
}
@@ -677,7 +677,7 @@ internal class Vala.CCodeBaseModule : CCodeModule {
}
var writer = new CCodeWriter (source_file.get_csource_filename (), source_file.filename);
- if (!writer.open ()) {
+ if (!writer.open (context.version_header)) {
Report.error (null, "unable to open `%s' for writing".printf (writer.filename));
return;
}
diff --git a/compiler/valacompiler.vala b/compiler/valacompiler.vala
index 628c6cd..b636037 100644
--- a/compiler/valacompiler.vala
+++ b/compiler/valacompiler.vala
@@ -70,6 +70,8 @@ class Vala.Compiler {
static bool verbose_mode;
static string profile;
static bool nostdpkg;
+ static bool enable_version_header;
+ static bool disable_version_header;
static string entry_point;
@@ -115,6 +117,8 @@ class Vala.Compiler {
{ "quiet", 'q', 0, OptionArg.NONE, ref quiet_mode, "Do not print messages to the console", null },
{ "verbose", 'v', 0, OptionArg.NONE, ref verbose_mode, "Print additional messages to the console", null },
{ "target-glib", 0, 0, OptionArg.STRING, ref target_glib, "Target version of glib for code generation", "MAJOR.MINOR" },
+ { "enable-version-header", 0, 0, OptionArg.NONE, ref enable_version_header, "Write vala build version in generated files", null },
+ { "disable-version-header", 0, 0, OptionArg.NONE, ref disable_version_header, "Do not write vala build version in generated files", null },
{ "", 0, 0, OptionArg.FILENAME_ARRAY, ref sources, null, "FILE..." },
{ null }
};
@@ -209,6 +213,7 @@ class Vala.Compiler {
context.report.enable_warnings = !disable_warnings;
context.report.set_verbose_errors (!quiet_mode);
context.verbose_mode = verbose_mode;
+ context.version_header = enable_version_header;
context.ccode_only = ccode_only;
context.compile_only = compile_only;
@@ -407,7 +412,7 @@ class Vala.Compiler {
}
context.codegen.emit (context);
-
+
if (context.report.get_errors () > 0) {
return quit ();
}
diff --git a/vala/valacodecontext.vala b/vala/valacodecontext.vala
index 9b24fcb..41571ad 100644
--- a/vala/valacodecontext.vala
+++ b/vala/valacodecontext.vala
@@ -147,6 +147,8 @@ public class Vala.CodeContext {
public bool verbose_mode { get; set; }
+ public bool version_header { get; set; }
+
/**
* Returns true if the target version of glib is greater than or
* equal to the specified version.
diff --git a/vala/valacodewriter.vala b/vala/valacodewriter.vala
index 0a10126..a41b388 100644
--- a/vala/valacodewriter.vala
+++ b/vala/valacodewriter.vala
@@ -75,7 +75,10 @@ public class Vala.CodeWriter : CodeVisitor {
return;
}
- write_string ("/* %s generated by %s, do not modify. */".printf (Path.get_basename (filename), Environment.get_prgname ()));
+ var header = context.version_header ?
+ "/* %s generated by %s %s, do not modify. */".printf (Path.get_basename (filename), Environment.get_prgname (), Config.BUILD_VERSION) :
+ "/* %s generated by %s, do not modify. */".printf (Path.get_basename (filename), Environment.get_prgname ());
+ write_string (header);
write_newline ();
write_newline ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]