+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,
static int optlevel;
static bool disable_assert;
static bool enable_checking;
+ static string cc_command;
+ [NoArrayLength]
+ static string[] cc_options;
private CodeContext context;
{ "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 }
};
if (!ccode_only) {
var ccompiler = new CCodeCompiler ();
- ccompiler.compile (context);
+ ccompiler.compile (context, cc_command, cc_options);
}
return quit ();
*
* @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";
// 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";
}
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 ();