summaryrefslogtreecommitdiff
path: root/valadoc
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2019-01-03 12:15:21 +0100
committerRico Tzschichholz <ricotz@ubuntu.com>2020-03-25 12:28:50 +0100
commitbd73f1ba11c387c919ad06d44badfd7065d1e35f (patch)
tree0f80303ac04d57a60988e07c8de50ddb34484215 /valadoc
parent66c23e839b63c81ce5da1c0212b22e2c4c6b8c81 (diff)
downloadvala-bd73f1ba11c387c919ad06d44badfd7065d1e35f.tar.gz
vala: Move setting of target profile and standard packages into CodeContext
Diffstat (limited to 'valadoc')
-rw-r--r--valadoc/treebuilder.vala23
-rw-r--r--valadoc/valadoc.vala15
2 files changed, 16 insertions, 22 deletions
diff --git a/valadoc/treebuilder.vala b/valadoc/treebuilder.vala
index 433938af2..662a8583e 100644
--- a/valadoc/treebuilder.vala
+++ b/valadoc/treebuilder.vala
@@ -489,35 +489,18 @@ public class Valadoc.TreeBuilder : Vala.CodeVisitor {
context.directory = context.basedir;
}
+ context.set_target_profile (settings.profile, true);
- // add default packages:
- if (settings.profile == "gobject-2.0" || settings.profile == "gobject" || settings.profile == null) {
- context.profile = Vala.Profile.GOBJECT;
- context.add_define ("GOBJECT");
+ if (settings.target_glib != null) {
+ context.set_target_glib_version (settings.target_glib);
}
-
if (settings.defines != null) {
foreach (string define in settings.defines) {
context.add_define (define);
}
}
- if (context.profile == Vala.Profile.GOBJECT) {
- if (settings.target_glib != null) {
- context.set_target_glib_version (settings.target_glib);
- }
-
- // default packages
- if (!this.add_package (context, "glib-2.0")) { //
- Vala.Report.error (null, "glib-2.0 not found in specified Vala API directories");
- }
-
- if (!this.add_package (context, "gobject-2.0")) { //
- Vala.Report.error (null, "gobject-2.0 not found in specified Vala API directories");
- }
- }
-
// add user defined files:
add_depencies (context, settings.packages);
if (reporter.errors > 0) {
diff --git a/valadoc/valadoc.vala b/valadoc/valadoc.vala
index 87695b1e6..b9ae48c50 100644
--- a/valadoc/valadoc.vala
+++ b/valadoc/valadoc.vala
@@ -55,7 +55,7 @@ public class ValaDoc : Object {
private static string[] defines;
private static bool experimental;
private static bool experimental_non_null = false;
- private static string profile;
+ private static Vala.Profile profile;
[CCode (array_length = false, array_null_terminated = true)]
private static string[] import_packages;
[CCode (array_length = false, array_null_terminated = true)]
@@ -79,7 +79,7 @@ public class ValaDoc : Object {
{ "basedir", 'b', 0, OptionArg.FILENAME, ref basedir, "Base source directory", "DIRECTORY" },
{ "define", 'D', 0, OptionArg.STRING_ARRAY, ref defines, "Define SYMBOL", "SYMBOL..." },
- { "profile", 0, 0, OptionArg.STRING, ref profile, "Use the given profile instead of the default", "PROFILE" },
+ { "profile", 0, OptionFlags.OPTIONAL_ARG, OptionArg.CALLBACK, (void*) option_parse_profile, "Use the given profile instead of the default, options are 'gobject' or 'posix'", "PROFILE" },
{ "enable-experimental", 0, 0, OptionArg.NONE, ref experimental, "Enable experimental features", null },
{ "enable-experimental-non-null", 0, 0, OptionArg.NONE, ref experimental_non_null, "Enable experimental enhancements for non-null types", null },
@@ -123,6 +123,17 @@ public class ValaDoc : Object {
{ null }
};
+ static bool option_parse_profile (string option_name, string? val, void* data) throws OptionError {
+ switch (val) {
+ case null:
+ case "gobject-2.0":
+ case "gobject": profile = Vala.Profile.GOBJECT; break;
+ case "posix": profile = Vala.Profile.POSIX; break;
+ default: throw new OptionError.FAILED ("Invalid --profile argument '%s'", val);
+ }
+ return true;
+ }
+
static bool option_deprecated (string option_name, string? val, void* data) throws OptionError {
stdout.printf ("Command-line option `%s` is deprecated and will be ignored\n", option_name);
return true;