var vs = new ValaSourceCompiler(gproj, add_file, BuilderApplication.opt_compile_target, skip_file);
+ if (BuilderApplication.opt_compile_output != null) {
+ vs.output = BuilderApplication.opt_compile_output;
+ }
vs.compile();
public string filepath;
public string original_filepath;
public int line_offset = 0;
+ public string output;
// file.project , file.path, file.build_module, ""
public ValaSourceCompiler(Project.Gtk project, string filepath, string build_module, string original_filepath) {
this.build_module = build_module;
this.original_filepath = original_filepath;
this.project = project;
+ this.output = "";
}
public void dumpCode(string str)
context.experimental = false;
context.experimental_non_null = false;
-
-#if VALA_0_28
+#if VALA_0_32
+ var ver=32;
+#elif VALA_0_30
+ var ver=30;
+#elif VALA_0_28
var ver=28;
#elif VALA_0_26
var ver=26;
var vapidirs = this.project.vapidirs();
- vapidirs += Path.get_dirname (context.get_vapi_path("glib-2.0")) ; // usr/share/vala-XXX/vapi
+ // order is important ...
vapidirs += Path.get_dirname (context.get_vapi_path("gee-1.0")) ; //usr/share/vala/vapi
-
+ vapidirs += Path.get_dirname (context.get_vapi_path("glib-2.0")) ; // usr/share/vala-XXX/vapi
+
for(var i =0 ; i < vapidirs.length; i++) {
valac += " --vapidir=" + vapidirs[i];
}
context.metadata_directories = { };
context.gir_directories = {};
context.thread = true;
-
+ valac += " --thread ";
+
+ // we should parse the compilegroup to find out the flags..
+ context.debug = true;
+ valac += " -g ";
this.report = new ValaSourceReport(this.original_filepath, this.filepath);
context.report = this.report;
-
- context.basedir = "/tmp"; //Posix.realpath (".");
+ valac += " -b " + GLib.Environment.get_home_dir() + " ";
+ context.basedir = GLib.Environment.get_home_dir(); //Posix.realpath (".");
- context.directory = context.basedir;
+ context.directory = null; //??? causes target to end up in the right place at present..
// add default packages:
// add all the files (except the current one) - this.file.path
var pr = this.project;
+
+
if (this.build_module.length > 0) {
var cg = pr.compilegroups.get(this.build_module);
+ if (this.output.length < 1 && cg.target_bin.length > 0) {
+ this.output = cg.target_bin;
+ }
+
+
for (var i = 0; i < cg.sources.size; i++) {
var path = pr.resolve_path(
pr.resolve_path_combine_path(pr.firstPath(),cg.sources.get(i)));
}
}
+
+ // print("%s\n", valac); -
// default.. packages..
context.add_external_package ("glib-2.0");
context.add_external_package ("gobject-2.0");
var dcg = pr.compilegroups.get("_default_");
for (var i = 0; i < dcg.packages.size; i++) {
+
+ var pkg = dcg.packages.get(i);
+ // do not add libvala versions except the one that matches the one we are compiled against..
+ if (Regex.match_simple("^libvala", pkg) && pkg != ("libvala-0." + ver.to_string())) {
+ continue;
+ }
valac += " --pkg " + dcg.packages.get(i);
if (!this.has_vapi(context.vapi_directories, dcg.packages.get(i))) {
GLib.debug("Skip vapi '%s' - does not exist", dcg.packages.get(i));
// add the modules...
- context.output = "/tmp/testbuild";
- valac += " -o " +context.output;
+ context.output = this.output == "" ? "/tmp/testrun" : this.output;
+ valac += " -o " + context.output;
GLib.debug("%s", valac);
-
-
+ context.target_glib_major = 2;
+ context.target_glib_minor = 32;
+ valac += " --target-glib=2.32 ";
//add_documented_files (context, settings.source_files);
return;
}
- //context.codegen = new Vala.GDBusServerModule ();
-
+ if (this.output == "") {
+ Vala.CodeContext.pop ();
+ this.outputResult();
+ return;
+ }
+
+ context.codegen = new Vala.GDBusServerModule ();
- //context.codegen.emit (context);
- /*
+ context.codegen.emit (context);
+
var ccompiler = new Vala.CCodeCompiler ();
var cc_command = Environment.get_variable ("CC");
+
+
+ string [] cc_options = { "-lm", "-pg" };
+ valac += " -X -lm -X -pg";
+
+#if VALA_0_28 || VALA_0_30 || VALA_0_32
var pkg_config_command = Environment.get_variable ("PKG_CONFIG");
-#if VALA_0_28
- ccompiler.compile (context, cc_command, new string[] { }, pkg_config_command);
+ ccompiler.compile (context, cc_command, cc_options, pkg_config_command);
#else
- ccompiler.compile (context, cc_command, new string[] { });
+ ccompiler.compile (context, cc_command, cc_options);
#endif
- */
-
+
+ print("%s\n", valac);
Vala.CodeContext.pop ();
- this.outputResult();
+ GLib.Process.exit(Posix.EXIT_SUCCESS);
+ //this.outputResult();
}
public bool has_vapi(string[] dirs, string vapi)
}
-/*
-
-
- public Gee.HashMap<int,string> checkString(string contents)
- {
- // init context:
- var valac = "valac " ;
-
- context = new Vala.CodeContext ();
- Vala.CodeContext.push (context);
-
- context.experimental = false;
- context.experimental_non_null = false;
-
-#if VALA_0_28
- var ver=28;
-#elif VALA_0_26
- var ver=26;
-#elif VALA_0_24
- var ver=24;
-#elif VALA_0_22
- var ver=22;
-#endif
-
- for (int i = 2; i <= ver; i += 2) {
- context.add_define ("VALA_0_%d".printf (i));
- }
-
-
-
-
-
-
-
- var vapidirs = ((Project.Gtk)this.file.project).vapidirs();
- // what's the current version of vala???
-
-
- vapidirs += Path.get_dirname (context.get_vapi_path("glib-2.0")) ;
-
- for(var i =0 ; i < vapidirs.length; i++) {
- valac += " --vapidir=" + vapidirs[i];
- }
-
-
- // or context.get_vapi_path("glib-2.0"); // should return path..
- context.vapi_directories = vapidirs;
- context.report.enable_warnings = true;
- context.metadata_directories = { };
- context.gir_directories = {};
- context.thread = true;
-
-
- this.report = new ValaSourceReport(this.file.path);
- context.report = this.report;
-
-
- context.basedir = "/tmp"; //Posix.realpath (".");
-
- context.directory = context.basedir;
-
-
- // add default packages:
- //if (settings.profile == "gobject-2.0" || settings.profile == "gobject" || settings.profile == null) {
- context.profile = Vala.Profile.GOBJECT;
-
- var ns_ref = new Vala.UsingDirective (new Vala.UnresolvedSymbol (null, "GLib", null));
- context.root.add_using_directive (ns_ref);
-
- var source_file = new Vala.SourceFile (
- context,
- Vala.SourceFileType.SOURCE,
- "~~~~~testfile.vala",
- contents
- );
- source_file.add_using_directive (ns_ref);
- context.add_source_file (source_file);
-
- // add all the files (except the current one) - this.file.path
- var pr = ((Project.Gtk)this.file.project);
- if (this.file.build_module.length > 0) {
- var cg = pr.compilegroups.get(this.file.build_module);
- for (var i = 0; i < cg.sources.size; i++) {
- var path = pr.resolve_path(
- pr.resolve_path_combine_path(pr.firstPath(),cg.sources.get(i)));
-
- if (!FileUtils.test(path, FileTest.EXISTS)) {
- continue;
- }
-
- if (path == this.file.path.replace(".bjs", ".vala")) {
- valac += " " + path;
- continue;
- }
- if (FileUtils.test(path, FileTest.IS_DIR)) {
- continue;
- }
- //print("Add source file %s\n", path);
-
- valac += " " + path;
-
- if (Regex.match_simple("\\.c$", path)) {
- context.add_c_source_file(path);
- continue;
- }
-
-
- var xsf = new Vala.SourceFile (
- context,
- Vala.SourceFileType.SOURCE,
- path
- );
- xsf.add_using_directive (ns_ref);
- context.add_source_file(xsf);
-
- }
- }
- // default.. packages..
- context.add_external_package ("glib-2.0");
- context.add_external_package ("gobject-2.0");
- // user defined ones..
-
- var dcg = pr.compilegroups.get("_default_");
- for (var i = 0; i < dcg.packages.size; i++) {
- valac += " --pkg " + dcg.packages.get(i);
- context.add_external_package (dcg.packages.get(i));
- }
-
- //Vala.Config.PACKAGE_SUFFIX.substring (1)
-
- // add the modules...
-
-
-
- //context.add_external_package ("libvala-0.24");
-
- this.report.compile_notice("START", "", 0, "");
-
-
- //add_documented_files (context, settings.source_files);
-
- Vala.Parser parser = new Vala.Parser ();
- parser.parse (context);
- //gir_parser.parse (context);
- if (context.report.get_errors () > 0) {
- print("parse got errors");
- ((ValaSourceReport)context.report).dump();
-
- Vala.CodeContext.pop ();
- this.report.compile_notice("END", "", 0, "");
- return this.report.line_errors;
- }
-
-
-
- // check context:
- context.check ();
- if (context.report.get_errors () > 0) {
- print("check got errors");
- ((ValaSourceReport)context.report).dump();
- Vala.CodeContext.pop ();
- this.report.compile_notice("END", "", 0, "");
- return this.report.line_errors;
-
- }
-
- //context.codegen = new Vala.GDBusServerModule ();
-
-
- context.output = "/tmp/testbuild";
- valac += " -o " +context.output;
- //context.codegen.emit (context);
- odeContext.pop ();
- //(new Vala.CodeNode()).get_error_types().clear();
- //(new Vala.NullType()).get_type_arguments().clear();
- (new Vala.NullType(null)).get_type_arguments().clear();
- parser = null;
- this.report.compile_notice("END", "", 0, "");
- print("%s\n", valac);
- print("ALL OK?\n");
- return this.report.line_errors;
- }
- //
- // startpoint:
- //
- */
+
}
}
/*