From 5ff0b72cd10e46929af597a01dd8c18f852fd5fb Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Fri, 23 Oct 2020 12:27:26 +0100 Subject: [PATCH 1/2] build: Respect VALAC setting everywhere This fixes some places where the VALAC setting was not respected --- Makefile | 7 +++---- src/generator.vala | 6 +++--- src/valadoc-example-tester.vala | 5 ++++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 31ade8b0..d8637829 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,9 @@ VALAC = valac PACKAGES ?= --all GENERATOR_OPTS ?= --disable-devhelp --skip-existing -VALAC_VERSION := $(shell vala --api-version | awk -F. '{ print "0."$$2 }') -VAPIDIR := $(shell pkg-config --variable vapidir libvala-$(VALAC_VERSION)) -VALAFLAGS = -g -X -w +VALAC_VERSION := $(shell $(VALAC) --api-version | awk -F. '{ print "0."$$2 }') +VAPIDIRS := --vapidir $(shell pkg-config --variable vapidir libvala-$(VALAC_VERSION)) --vapidir $(shell pkg-config --variable vapidir valadoc-$(VALAC_VERSION)) +VALAFLAGS = -g -X -w $(VAPIDIRS) PREFIX = "stable" INSTALL_DIR ?= /usr/local/share/devhelp/books @@ -107,7 +107,6 @@ build-data: build-docs: default $(RM) -r tmp/ ./generator \ - --vapidir $(VAPIDIR) \ --vapidir "extra-vapis/" --vapidir "girs/vala/vapi/" \ --prefix $(PREFIX) \ --target-glib 2.98 \ diff --git a/src/generator.vala b/src/generator.vala index 9ad1c19b..e04655ec 100644 --- a/src/generator.vala +++ b/src/generator.vala @@ -58,7 +58,7 @@ public class Valadoc.IndexGenerator : Valadoc.ValadocOrgDoclet { // Unversioned vapi directory: try { - Process.spawn_command_line_sync ("pkg-config --variable=vapidir vapigen", out standard_output, out standard_error, out exit_status); + Process.spawn_command_line_sync ("pkg-config --variable=vapidir vapigen-%s".printf (Vala.API_VERSION), out standard_output, out standard_error, out exit_status); if (exit_status == 0) { paths += standard_output.strip (); } @@ -828,8 +828,8 @@ public class Valadoc.IndexGenerator : Valadoc.ValadocOrgDoclet { StringBuilder builder = new StringBuilder (); - builder.append_printf ("valadoc --target-glib %s --importdir girs --doclet \"%s\" -o \"tmp/%s\" \"%s\" --vapidir \"%s\" --girdir \"%s\" %s --use-svg-images", - target_glib, docletpath, pkg.name, pkg.get_vapi_path (vapidirs), Path.get_dirname (pkg.get_vapi_path (vapidirs)), girdir, pkg.flags); + builder.append_printf ("valadoc-%s --target-glib %s --importdir girs --doclet \"%s\" -o \"tmp/%s\" \"%s\" --vapidir \"%s\" --girdir \"%s\" %s --use-svg-images", + Vala.API_VERSION, target_glib, docletpath, pkg.name, pkg.get_vapi_path (vapidirs), Path.get_dirname (pkg.get_vapi_path (vapidirs)), girdir, pkg.flags); if (disable_devhelp == true) { builder.append (" -X --disable-devhelp"); diff --git a/src/valadoc-example-tester.vala b/src/valadoc-example-tester.vala index db581737..edc7d04d 100644 --- a/src/valadoc-example-tester.vala +++ b/src/valadoc-example-tester.vala @@ -60,7 +60,8 @@ public class ExampleTester : ExampleParser { protected override void compile (string str) throws MarkupError { string cmnd = str.strip (); - bool is_valac_call = str.has_prefix ("valac "); + const string VALAC_PREFIX = "valac "; + bool is_valac_call = str.has_prefix (VALAC_PREFIX); bool is_schema_call = str.has_prefix ("glib-compile-schemas"); // We only check for sanity, not for safety @@ -70,6 +71,8 @@ public class ExampleTester : ExampleParser { } if (is_valac_call) { + cmnd = Environment.get_variable ("VALAC") + " " + + cmnd.substring (VALAC_PREFIX.length); cmnd += " --fatal-warnings"; if (example_deprecated == true) { cmnd += " --enable-deprecated"; From 64bcb9e6cbb1d4a1b6c5ce9272ea22001a0a04c4 Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Fri, 23 Oct 2020 12:28:14 +0100 Subject: [PATCH 2/2] build: Add the ability to use a different version of valac Document the need to use --disable-unversioned --- Makefile | 2 +- README.md | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d8637829..d13cdbb8 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VALAC = valac +VALAC ?= valac PACKAGES ?= --all GENERATOR_OPTS ?= --disable-devhelp --skip-existing VALAC_VERSION := $(shell $(VALAC) --api-version | awk -F. '{ print "0."$$2 }') diff --git a/README.md b/README.md index 2648c26b..2fbae5f9 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,12 @@ sudo make install to install the devhelp books in your system. Now launch Devhelp and use them! +Using a different version of Vala +================================= + +You may want or need to test Valadoc with a different version of Vala, for example to pick up fixes in Vala that are necessary to build example code. You can do this with a chroot or jhbuild; or if your valac’s API version is different from other versions you have installed, just set `VALAC=valac-X.YY` in your environment when running `make`. + + Searching =========