From fb59f803072e5102ee2bf63d858674bfdff97e70 Mon Sep 17 00:00:00 2001 From: Juerg Billeter Date: Tue, 24 Jul 2007 14:37:09 +0000 Subject: [PATCH] add --cc and -X options to be able to specify custom command and options 2007-07-24 Juerg Billeter * gobject/valaccodecompiler.vala, compiler/valacompiler.vala: add --cc and -X options to be able to specify custom command and options for the C compiler svn path=/trunk/; revision=381 --- ChangeLog | 6 ++++++ compiler/valacompiler.vala | 7 ++++++- gobject/valaccodecompiler.vala | 13 +++++++++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6bdf9d4..beda221 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2007-07-24 Jürg Billeter + * gobject/valaccodecompiler.vala, compiler/valacompiler.vala: add --cc + and -X options to be able to specify custom command and options for + the C compiler + +2007-07-24 Jürg Billeter + * gobject/valacodegenerator.vala, gobject/valacodegeneratormemberaccess.vala, gobject/valacodegeneratormethod.vala: remove unnecessary runtime diff --git a/compiler/valacompiler.vala b/compiler/valacompiler.vala index e824f0e..d7be88c 100644 --- a/compiler/valacompiler.vala +++ b/compiler/valacompiler.vala @@ -42,6 +42,9 @@ class Vala.Compiler { static int optlevel; static bool disable_assert; static bool enable_checking; + static string cc_command; + [NoArrayLength] + static string[] cc_options; private CodeContext context; @@ -60,6 +63,8 @@ class Vala.Compiler { { "optimize", 'O', 0, OptionArg.INT, ref optlevel, "Optimization level", "OPTLEVEL" }, { "disable-assert", 0, 0, OptionArg.NONE, ref disable_assert, "Disable assertions", null }, { "enable-checking", 0, 0, OptionArg.NONE, ref enable_checking, "Enable run-time checks", null }, + { "cc", 0, 0, OptionArg.STRING, out cc_command, "Use COMMAND as C compiler command", "COMMAND" }, + { "Xcc", 'X', 0, OptionArg.STRING_ARRAY, out cc_options, "Pass OPTION to the C compiler", "OPTION..." }, { "", 0, 0, OptionArg.FILENAME_ARRAY, out sources, null, "FILE..." }, { null } }; @@ -245,7 +250,7 @@ class Vala.Compiler { if (!ccode_only) { var ccompiler = new CCodeCompiler (); - ccompiler.compile (context); + ccompiler.compile (context, cc_command, cc_options); } return quit (); diff --git a/gobject/valaccodecompiler.vala b/gobject/valaccodecompiler.vala index 2de7a59..8517cf4 100644 --- a/gobject/valaccodecompiler.vala +++ b/gobject/valaccodecompiler.vala @@ -35,7 +35,8 @@ public class Vala.CCodeCompiler { * * @param context a code context */ - public void compile (CodeContext! context) { + [NoArrayLength] + public void compile (CodeContext! context, string cc_command, string[] cc_options) { string pc = "pkg-config --cflags"; if (!context.compile_only) { pc += " --libs"; @@ -62,7 +63,10 @@ public class Vala.CCodeCompiler { // TODO compile the C code files in parallel - string cmdline = "cc"; + if (cc_command == null) { + cc_command = "cc"; + } + string cmdline = cc_command; if (context.debug) { cmdline += " -g"; } @@ -73,6 +77,11 @@ public class Vala.CCodeCompiler { cmdline += " -o " + Shell.quote (context.output); } cmdline += " " + pkgflags; + if (cc_options != null) { + foreach (string cc_option in cc_options) { + cmdline += " " + cc_option; + } + } /* we're only interested in non-pkg source files */ var source_files = context.get_source_files (); -- 2.7.4