Commit fb59f803 authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

add --cc and -X options to be able to specify custom command and options

2007-07-24  Juerg Billeter  <j@bitron.ch>

	* 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
parent 47a06b0c
2007-07-24 Jürg Billeter <j@bitron.ch>
* 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 <j@bitron.ch>
* gobject/valacodegenerator.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 ();
......
......@@ -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 ();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment