From: Juerg Billeter Date: Tue, 24 Jul 2007 14:37:09 +0000 (+0000) Subject: add --cc and -X options to be able to specify custom command and options X-Git-Tag: VALA_0_1_2~26 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fb59f803072e5102ee2bf63d858674bfdff97e70;p=thirdparty%2Fvala.git 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 --- diff --git a/ChangeLog b/ChangeLog index 6bdf9d4a1..beda22185 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +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, diff --git a/compiler/valacompiler.vala b/compiler/valacompiler.vala index e824f0e20..d7be88cb1 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 2de7a591d..8517cf4c5 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 ();