[Vala] [PATCH]Add an option to valac for passing args to pkg-config
- From: Kder <kder live cn>
- To: vala-list gnome org
- Subject: [Vala] [PATCH]Add an option to valac for passing args to pkg-config
- Date: Sat, 15 Sep 2012 06:07:03 +0000 (UTC)
I added a feature(command line option) for the vala compiler:
-p, --pkg-config-args=ARGS Pass ARGS to pkg-config utility
to pass customized arguments to pkg-config utility.
For example, we can use this to static compile a gtk program with valac:
valac test_static.vala -p "--static --libs gtk+-2.0 gee-0.8" --pkg gee-0.8 --
pkg gtk+-2.0 -X -static
Here is the patch:
diff -Nuar vala-0.17.5/codegen/valaccodecompiler.vala vala-0.17.5-patched/
codegen/valaccodecompiler.vala
--- vala-0.17.5/codegen/valaccodecompiler.vala 2012-08-06 19:19:28 +0800
+++ vala-0.17.5-patched/codegen/valaccodecompiler.vala 2012-08-24 12:56:05
+0800
@@ -51,9 +51,13 @@
public void compile (CodeContext context, string? cc_command, string[]
cc_options) {
bool use_pkgconfig = false;
- string pc = "pkg-config --cflags";
+ string pc = "pkg-config --cflags ";
if (!context.compile_only) {
- pc += " --libs";
+ if (context.pkg_config_args != null) {
+ pc += context.pkg_config_args;
+ } else {
+ pc += " --libs";
+ }
}
use_pkgconfig = true;
pc += " gobject-2.0";
diff -Nuar vala-0.17.5/compiler/valacompiler.vala vala-0.17.5-patched/compiler/
valacompiler.vala
--- vala-0.17.5/compiler/valacompiler.vala 2012-08-06 19:57:53 +0800
+++ vala-0.17.5-patched/compiler/valacompiler.vala 2012-08-24 12:44:35
+0800
@@ -79,6 +79,8 @@
static bool disable_version_header;
static bool fatal_warnings;
static string dependencies;
+
+ static string pkg_config_args;
static string entry_point;
@@ -108,6 +110,7 @@
{ "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 },
+ { "pkg-config-args", 'p', 0, OptionArg.STRING, ref
pkg_config_args, "Pass ARGS to pkg-config utility", "ARGS" },
{ "output", 'o', 0, OptionArg.FILENAME, ref output, "Place
output in file FILE", "FILE" },
{ "debug", 'g', 0, OptionArg.NONE, ref debug, "Produce debug
information", null },
{ "thread", 0, 0, OptionArg.NONE, ref thread, "Enable
multithreading support", null },
@@ -181,6 +184,7 @@
context.ccode_only = ccode_only;
context.compile_only = compile_only;
+ context.pkg_config_args = pkg_config_args;
context.header_filename = header_filename;
if (header_filename == null && use_header) {
Report.error (null, "--use-header may only be used in
combination with --header");
diff -Nuar vala-0.17.5/vala/valacodecontext.vala vala-0.17.5-patched/vala/
valacodecontext.vala
--- vala-0.17.5/vala/valacodecontext.vala 2012-08-07 02:15:43 +0800
+++ vala-0.17.5-patched/vala/valacodecontext.vala 2012-08-24 12:52:41
+0800
@@ -89,6 +89,11 @@
public bool compile_only { get; set; }
/**
+ * Pass args to pkg-config.
+ */
+ public string pkg_config_args { get; set; }
+
+ /**
* Output filename.
*/
public string output { get; set; }
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]