tldr; I have installed AUnit per the docs, but I cannot make GPRBuild “see it”
I like doing “test-driven learning” when learning a new language, and so I thought I would figure out how to write the most basic setup for code covered by unit tests.
I followed the AUnit Cookbook on installation, which basically said to run make install
, which would install aunit where gprbuild was installed (unless overridden). This seems to have worked fine:
❯ make --trace install
Makefile:61: update target 'install-clean' due to: install-clean-legacy
gprinstall -XAUNIT_BUILD_MODE=Install -XAUNIT_RUNTIME=full -XAUNIT_PLATFORM=native --uninstall --prefix=/opt/gprbuild-x86_64-linux-24.0.0-2 aunit
Uninstall project aunit
Makefile:65: update target 'install' due to: install-clean
gprinstall -XAUNIT_BUILD_MODE=Install -XAUNIT_RUNTIME=full -XAUNIT_PLATFORM=native -p -f --prefix=/opt/gprbuild-x86_64-linux-24.0.0-2 \
--no-build-var lib/gnat/aunit.gpr
Install project AUnit
❯ v /opt/gprbuild-x86_64-linux-24.0.0-2/lib/
total 4
drwxr-xr-x 2 oscko oscko 4096 mars 11 09:51 aunit
❯ which gprbuild
/opt/gprbuild-x86_64-linux-24.0.0-2/bin/gprbuild
All good so far. If I now build examples/simple_test
in the aunit repository, I get an error about it not finding aunit:
❯ gprbuild -P harness.gpr
harness.gpr:1:06: imported project file "aunit" not found
gprbuild: "harness.gpr" processing failed
I thought that it would now find it by virtue of being in /opt/gprbuild-x86_64-linux-24.0.0-2/lib/
? CoPilot also suggested adding the library to the path of GPR_PROJECT_PATH, but that had no effect:
export GPR_PROJECT_PATH=/opt/gprbuild-x86_64-linux-24.0.0-2/lib/aunit:$GPR_PROJECT_PATH
I tried reading a bit up on how shared libraries work, but that seemed to imply that the project file of whatever library that was to be shared should include “library project”, and grepping the aunit repo for that string showed 0 results, so I am not even sure if this is a shared library or not …
The only way I managed to compile the example was directly referencing the project file from the place it was included:
aunit/examples/simple_test on master [!?]
✦ ❯ git diff
diff --git a/examples/simple_test/harness.gpr b/examples/simple_test/harness.gpr
index f445b8d..f0347bf 100644
--- a/examples/simple_test/harness.gpr
+++ b/examples/simple_test/harness.gpr
@@ -1,4 +1,10 @@
-with "aunit";
+-- DOES NOT WORK
+-- with "aunit";
+
+-- WORKS:
+--with "../../lib/gnat/aunit.gpr";
+with "/opt/gprbuild-x86_64-linux-24.0.0-2/share/gpr/aunit.gpr";
Hardcoding those paths is not a very scalable approach
What am I supposed to do here to get GPRBuild to see aunit?