summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2017-05-08 13:46:22 +0200
committerRico Tzschichholz <ricotz@ubuntu.com>2018-05-08 08:25:18 +0200
commit489895fbd7a550e661f9f6ea19d3dcd25d0cc790 (patch)
treecbbf9a2ef40e0f5b7bee098798f0006ba3ed11cb /compiler
parentf7e70338aee8717f4b2050f442d9a6fc41b50d5d (diff)
downloadvala-489895fbd7a550e661f9f6ea19d3dcd25d0cc790.tar.gz
Reintroduce POSIX profile
This reverts commit ca020bf04a09fe16e5583eea5a3a341e7796bff5.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/valacompiler.vala92
1 files changed, 54 insertions, 38 deletions
diff --git a/compiler/valacompiler.vala b/compiler/valacompiler.vala
index 31dd06ad5..733db4526 100644
--- a/compiler/valacompiler.vala
+++ b/compiler/valacompiler.vala
@@ -272,7 +272,10 @@ class Vala.Compiler {
if (ccode_only && save_temps) {
Report.warning (null, "--save-temps has no effect when -C or --ccode is set");
}
- if (profile == "gobject-2.0" || profile == "gobject" || profile == null) {
+ if (profile == "posix") {
+ context.profile = Profile.POSIX;
+ context.add_define ("POSIX");
+ } else if (profile == "gobject-2.0" || profile == "gobject" || profile == null) {
// default profile
context.profile = Profile.GOBJECT;
context.add_define ("GOBJECT");
@@ -301,26 +304,33 @@ class Vala.Compiler {
context.add_define ("VALA_0_%d".printf (i));
}
- int glib_major = 2;
- int glib_minor = 40;
- if (target_glib != null && target_glib.scanf ("%d.%d", out glib_major, out glib_minor) != 2) {
- Report.error (null, "Invalid format for --target-glib");
- }
+ if (context.profile == Profile.POSIX) {
+ if (!nostdpkg) {
+ /* default package */
+ context.add_external_package ("posix");
+ }
+ } else if (context.profile == Profile.GOBJECT) {
+ int glib_major = 2;
+ int glib_minor = 40;
+ if (target_glib != null && target_glib.scanf ("%d.%d", out glib_major, out glib_minor) != 2) {
+ Report.error (null, "Invalid format for --target-glib");
+ }
- context.target_glib_major = glib_major;
- context.target_glib_minor = glib_minor;
- if (context.target_glib_major != 2) {
- Report.error (null, "This version of valac only supports GLib 2");
- }
+ context.target_glib_major = glib_major;
+ context.target_glib_minor = glib_minor;
+ if (context.target_glib_major != 2) {
+ Report.error (null, "This version of valac only supports GLib 2");
+ }
- for (int i = 16; i <= glib_minor; i += 2) {
- context.add_define ("GLIB_2_%d".printf (i));
- }
+ for (int i = 16; i <= glib_minor; i += 2) {
+ context.add_define ("GLIB_2_%d".printf (i));
+ }
- if (!nostdpkg) {
- /* default packages */
- context.add_external_package ("glib-2.0");
- context.add_external_package ("gobject-2.0");
+ if (!nostdpkg) {
+ /* default packages */
+ context.add_external_package ("glib-2.0");
+ context.add_external_package ("gobject-2.0");
+ }
}
if (packages != null) {
@@ -346,7 +356,11 @@ class Vala.Compiler {
return quit ();
}
- context.codegen = new GDBusServerModule ();
+ if (context.profile == Profile.GOBJECT) {
+ context.codegen = new GDBusServerModule ();
+ } else {
+ context.codegen = new CCodeDelegateModule ();
+ }
bool has_c_files = false;
bool has_h_files = false;
@@ -423,28 +437,30 @@ class Vala.Compiler {
if (library != null) {
if (gir != null) {
- string gir_base = Path.get_basename(gir);
- long gir_len = gir_base.length;
- int last_hyphen = gir_base.last_index_of_char ('-');
-
- if (last_hyphen == -1 || !gir_base.has_suffix (".gir")) {
- Report.error (null, "GIR file name `%s' is not well-formed, expected NAME-VERSION.gir".printf (gir));
- } else {
- string gir_namespace = gir_base.substring (0, last_hyphen);
- string gir_version = gir_base.substring (last_hyphen + 1, gir_len - last_hyphen - 5);
- gir_version.canon ("0123456789.", '?');
- if (gir_namespace == "" || gir_version == "" || !gir_version[0].isdigit () || gir_version.contains ("?")) {
+ if (context.profile == Profile.GOBJECT) {
+ string gir_base = Path.get_basename (gir);
+ long gir_len = gir_base.length;
+ int last_hyphen = gir_base.last_index_of_char ('-');
+
+ if (last_hyphen == -1 || !gir_base.has_suffix (".gir")) {
Report.error (null, "GIR file name `%s' is not well-formed, expected NAME-VERSION.gir".printf (gir));
} else {
- var gir_writer = new GIRWriter ();
-
- // put .gir file in current directory unless -d has been explicitly specified
- string gir_directory = ".";
- if (directory != null) {
- gir_directory = context.directory;
+ string gir_namespace = gir_base.substring (0, last_hyphen);
+ string gir_version = gir_base.substring (last_hyphen + 1, gir_len - last_hyphen - 5);
+ gir_version.canon ("0123456789.", '?');
+ if (gir_namespace == "" || gir_version == "" || !gir_version[0].isdigit () || gir_version.contains ("?")) {
+ Report.error (null, "GIR file name `%s' is not well-formed, expected NAME-VERSION.gir".printf (gir));
+ } else {
+ var gir_writer = new GIRWriter ();
+
+ // put .gir file in current directory unless -d has been explicitly specified
+ string gir_directory = ".";
+ if (directory != null) {
+ gir_directory = context.directory;
+ }
+
+ gir_writer.write_file (context, gir_directory, gir, gir_namespace, gir_version, library, shared_library);
}
-
- gir_writer.write_file (context, gir_directory, gir, gir_namespace, gir_version, library, shared_library);
}
}