Overriding adb package body from a with-ed .gpr project - build-process

I'm using GNAT gprbuild.
I have a project file, A.gpr that withs project file B.gpr .
There is the possibility that the B.gpr project file could be a few with-ed levels deep from A.gpr
B.gpr has source files X.adb and X.ads .
A.gpr defines a main file Y.adb that withs X.ads
Its a requirement that A.gpr must with B.gpr.
By only extending or editing A.gpr I would like to use a different X.adb .
How do i do this?
The closest thing I have found so far is https://gcc.gnu.org/onlinedocs/gnat_ugn/Project-Extension.html.
However I keep hitting the error:
unit "X" cannot belong to several projects
project "A" {overriding X.adb file path}
unit "X" already belongs to project "B"
project "B" {original x.adb filepath}

If files (in this case different x.adb) are in different directories it is possible by use of case statement.
For example in some of my gpr files I have following lines:
type OS_Type is ("Unix", "Windows");
OS: OS_Type := external ("OS", "Unix");
case OS is
when "Unix" =>
for Source_Dirs use ("src", "src/unix");
when "Windows" =>
for Source_Dirs use ("src", "src/windows");
end case;
As you can see, depending on variable different source directories are used.
(OS defaults to "Unix", to set variable you add
-Xvariable=value to you gprbuild call [which in this example would be
-XOS=Windows]).

Here's an example that uses both paths and body-selection based on project variables:
project Example is
for Object_Dir use "obj";
for Exec_Dir use ".";
type Language_Type is
("Spanish", "English");
Language : Language_Type := external ("Language", "English");
for Source_Dirs use ("src", "src/" & Language);
for Main use ("testbed.adb");
type Starts_Week_Type is
("mon", "tue", "wed", "thu", "fri", "sat", "sun");
Starts_Week : Starts_Week_Type := external ("Starts_Week", "sun");
package Ide is
for Documentation_Dir use "doc";
end Ide;
package Prove is
for Switches use ("-j4");
end Prove;
package Builder is
for Default_Switches ("ada") use ("-j4", "-C", "-g");
end Builder;
package Compiler is
for Default_Switches ("ada") use
("-gnato", "-fstack-check", "-gnatE", "-gnata", "-gnat12", "-g", "-gnatf");
end Compiler;
package Binder is
for Default_Switches ("ada") use ("-shared");
end Binder;
package Linker is
for Default_Switches ("ada") use ("-g");
end Linker;
package Naming is
for Specification("Example.Types.Week") use
"Example-types-"&Starts_Week&"_week.ada";
end Naming;
end Example;
As you can see the line for Source_Dirs use ("src", "src/" & Language); makes the src and either src/English or src/Spanish the directories that will be searched/used when looking for source files.
Later, in Naming, we have a file whose name is dependent on a project variable being selected as the body of the indicated file. -- Namely the file types-XXX_week.ada where XXX is one of the three-letter day-abbreviations the Starts_Week scenario-variable may take.

Related

How to make GPR accept multiple sources in the same project having the same file name?

I set out to rewrite an OSS project in C piece by piece to Ada. First stop being to replace the build system with GPR. On doing so I stumbled upon a problem: it does not allow for multiple sources in the repository with the same name:
duplicate source file name "slp_debug.h"
The file exists in two different directories; one for implementation, and one for test (stub I reckon). This should be just fine since the preprocessor will deterministically choose the source relative the source including it, or according to the order of include directories. But GPR would appear not fond of that idea.
How to make GPR accept it?
I had a go with openslp-2.0.0 and managed to make one GPR that builds the library and another, which withs the first, to build the tests - no complaints about the duplicate file.
Both project files are at the top level.
As common for projects like openslp, the configure process generates a lengthy config.h, at the top level, with a shedload of #define HAVE_FOO 1’s.
This is the 'common' project file - I think there may also be an executable in there (slptool), which might have to be a separate GPR since this one builds a library:
project Openslp is
for Languages use ("c");
for Source_Dirs use ("common", "libslp", "libslpattr");
for Excluded_Source_Files use
(
"slp_win32.c", -- not on Darwin! or Linux, ofc
"libslpattr_tiny.c" -- I think this must be an alternate version
);
for Library_Name use "slp";
for Library_Kind use "static";
for Library_Dir use "lib";
for Object_Dir use "obj-openslp";
for Create_Missing_Dirs use "true";
package Compiler is
for Switches ("c") use
(
"-DDARWIN",
"-DHAVE_CONFIG_H",
"-I" & project'Project_Dir, -- for config.h, created by configure
"-I" & project'Project_Dir & "/common",
"-I" & project'Project_Dir & "/libslp",
"-I" & project'Project_Dir & "/libslpattr",
"-DETCDIR=""" & project'Project_Dir & "/etc"""
);
end Compiler;
end Openslp;
and this is the 'test' one:
with "openslp";
project Openslp_Test is
for Languages use ("c");
for Source_Dirs use ("test/**");
for Object_Dir use "obj-openslp_test";
for Exec_Dir use "test/bin";
for Main use ("SLPFindAttrs.c"); -- etc, etc
for Create_Missing_Dirs use "true";
package Compiler is
for Switches ("c") use
("-I" & project'Project_Dir & "/test") -- for the local slp_debug.h
& Openslp.Compiler'Switches ("c");
end Compiler;
end Openslp_Test;

How do I make gnattest only consider code in my src dir?

What command do I have to give to gnattest to make it only consider the code in my src directory (and ignore all subprojects such as the Ada Drivers Library)?
I've read this question, which says to tag every subprogram I want to test with the 'Test_Case' aspect. I'll go that route if I have to but I'd like the protection of gnattest automatically adding new test cases for new code so that I don't miss anything.
Here's my gpr file:
with "c:\Domains\ada\Ada_Drivers_Library\boards\MicroBit\microbit_zfp.gpr";
project Demo_Project is
for Runtime ("ada") use Microbit_Zfp'Runtime ("Ada");
for Target use "arm-eabi";
for Main use ("main.adb");
for Languages use ("Ada");
for Source_Dirs use ("src");
for Object_Dir use "obj";
for Create_Missing_Dirs use "True";
package Compiler renames Microbit_Zfp.Compiler;
package Linker is
for Default_Switches ("ada") use Microbit_Zfp.Linker_Switches & ("-Wl,--print-memory-usage", "-Wl,--gc-sections", "-U__gnat_irq_trap");
end Linker;
package Ide is
for Program_Host use ":1234";
for Communication_Protocol use "remote";
for Connection_Tool use "pyocd";
end Ide;
package Prove is
for Proof_Switches ("Ada") use ("-j0");
end Prove;
package Builder is
for Switches ("ada") use ("-j0", "-s");
end Builder;
end Demo_Project;
Here's the gnattest command that GPS created (which incorrectly created tests for the ada drivers library):
arm-eabi-gnat test -Pdemo_project.gpr --tests-dir=C:\Domains\ada\demo_project\microbit\tests
Update: 2019-12-17:
Here's what I got when I ran the suggested answer:
>c:\GNAT\2019\bin\gnattest -Pdemo_project.gpr --tests-dir=tests
Could not locate exec arm-eabi-gnatls
gprconfig: can't find a toolchain for the following configuration:
gprconfig: language 'ada', target 'arm-eabi', runtime 'zfp-cortex-m0'
microbit_zfp.gpr:61:25: warning: libraries are not supported on this platform
object path not found for runtime zfp-cortex-m0
gnattest: initialization failed
Update: 2019-12-17 (2):
I made some progress by adding the "--test-case-only" flag like so and adding a test_case aspect to a single procedure in the Battery package. Here's the command I ran:
arm-eabi-gnat test -dd -PC:\Domains\ada\Demo_Project\microbit\demo_project.gpr --tests-dir=C:\Domains\ada\Demo_Project\tests --test-case-only
Gnattest was successful. I can see my Battery package in the project view for the tests. However, when I try to build and run it from GPS, I get this mess:
gprbuild --target=arm-eabi -d -PC:\Domains\ada\Demo_Project\microbit\obj\gnattest\harness\test_driver.gpr -XADL_BUILD_CHECKS=Enabled -XADL_BUILD=Debug -XTEST_DRIVER_BUILD_MODE=no-config-file C:\Domains\ada\Demo_Project\microbit\obj\gnattest\harness\test_runner.adb -largs -Wl,-Map=map.txt
Compile
[Ada] test_runner.adb
[Ada] gnattest_main_suite.adb
[Ada] battery-test_data.adb
[Ada] battery-test_data-tests.adb
battery-test_data-tests.adb:40:13: warning: pragma Restrictions (No_Exception_Propagation) in effect
battery-test_data-tests.adb:40:13: warning: this handler can never be entered, and has been removed
battery-test_data-tests.adb:53:13: warning: pragma Restrictions (No_Exception_Propagation) in effect
battery-test_data-tests.adb:53:13: warning: this handler can never be entered, and has been removed
[Ada] battery-test_data-tests-suite.adb
[Ada] gnattest_generated.ads
Bind
[gprbind] test_runner.bexch
[Ada] test_runner.ali
Link
[link] test_runner.adb
c:/gnat/2019-arm-elf/bin/../lib/gcc/arm-eabi/7.4.1/../../../../arm-eabi/bin/ld.exe: C:\Domains\ada\Ada_Drivers_Library\boards\MicroBit\obj\zfp_lib_Debug\libada_drivers_library.a(crt0.o): in function `hang':
(.text+0x40): undefined reference to `__stack_end'
c:/gnat/2019-arm-elf/bin/../lib/gcc/arm-eabi/7.4.1/../../../../arm-eabi/bin/ld.exe: (.text+0x48): undefined reference to `__data_words'
c:/gnat/2019-arm-elf/bin/../lib/gcc/arm-eabi/7.4.1/../../../../arm-eabi/bin/ld.exe: (.text+0x4c): undefined reference to `__data_load'
c:/gnat/2019-arm-elf/bin/../lib/gcc/arm-eabi/7.4.1/../../../../arm-eabi/bin/ld.exe: (.text+0x54): undefined reference to `__bss_words'
c:/gnat/2019-arm-elf/bin/../lib/gcc/arm-eabi/7.4.1/../../../../arm-eabi/bin/ld.exe: C:\Domains\ada\Ada_Drivers_Library\boards\MicroBit\obj\zfp_lib_Debug\libada_drivers_library.a(crt0.o): in function `__vectors':
(.vectors+0x0): undefined reference to `__stack_end'
c:/gnat/2019-arm-elf/bin/../lib/gcc/arm-eabi/7.4.1/../../../../arm-eabi/bin/ld.exe: C:\gnat\2019-arm-elf\arm-eabi\lib\gnat\zfp-cortex-m0\adalib\libgnat.a(s-memory.o): in function `__gnat_malloc':
s-memory.adb:(.text.__gnat_malloc+0x40): undefined reference to `__heap_end'
c:/gnat/2019-arm-elf/bin/../lib/gcc/arm-eabi/7.4.1/../../../../arm-eabi/bin/ld.exe: C:\gnat\2019-arm-elf\arm-eabi\lib\gnat\zfp-cortex-m0\adalib\libgnat.a(s-memory.o):(.data.system__memory__top+0x0): undefined reference to `__heap_start'
collect2.exe: error: ld returned 1 exit status
gprbuild: link of test_runner.adb failed
gprbuild: failed command was: c:\gnat\2019-arm-elf\bin\arm-eabi-gcc.exe test_runner.o b__test_runner.o C:\Domains\ada\Demo_Project\microbit\obj\battery.o C:\Domains\ada\Demo_Project\microbit\obj\gnattest\harness\battery-test_data.o C:\Domains\ada\Demo_Project\microbit\obj\gnattest\harness\gnattest_generated.o C:\Domains\ada\Demo_Project\microbit\obj\gnattest\harness\battery-test_data-tests.o C:\Domains\ada\Demo_Project\microbit\obj\gnattest\harness\battery-test_data-tests-suite.o C:\Domains\
ada\Demo_Project\microbit\obj\gnattest\harness\gnattest_main_suite.o C:\Domains\ada\Ada_Drivers_Library\boards\MicroBit\obj\zfp_lib_Debug\libada_drivers_library.a C:\gnat\2019-arm-elf\arm-eabi\zfp-cortex-m0\lib\aunit\libaunit.a -g -Wl,-Map=map.txt -LC:\Domains\ada\Demo_Project\microbit\obj\gnattest\harness\ -LC:\Domains\ada\Demo_Project\microbit\obj\gnattest\harness\ -LC:\gnat\2019-arm-elf\arm-eabi\zfp-cortex-m0\lib\aunit\ -LC:\Domains\ada\Demo_Project\microbit\obj\ -LC:\Domains\ada\Ada_Drive
rs_Library\boards\MicroBit\obj\zfp_lib_Debug\ -LC:\gnat\2019-arm-elf\arm-eabi\lib\gnat\zfp-cortex-m0\adalib\ -static-libgcc C:\gnat\2019-arm-elf\arm-eabi\lib\gnat\zfp-cortex-m0\adalib\libgnat.a -Wl,-LC:\gnat\2019-arm-elf\arm-eabi\lib\gnat\zfp-cortex-m0\/adalib -nostartfiles -nolibc -mlittle-endian -mthumb -msoft-float -mcpu=cortex-m0 -o test_runner
[2019-12-17 10:47:38] process exited with status 4, 100% (174/174), elapsed time: 03.00s
Traceback (most recent call last):
File "C:\GNAT\2019\share\gps\support\ui\workflows\__init__.py", line 351, in internal_run_as_wf
r = workflow(*args, **kwargs)
File "C:\GNAT\2019\share\gps\plug-ins\memory_usage_providers\ld.py", line 242, in async_fetch_memory_usage_data
visitor.on_memory_usage_data_fetched(regions, sections, modules)
GPS.Unexpected_Exception: unexpected internal exception raised CONSTRAINT_ERROR : Memory_Usage_Views.Memory_Region_Description_Maps.Reference: key not in map
[C:\GNAT\2019\bin\gps.exe]
0x21a541b
0x197c5b5
[C:\GNAT\2019\bin\gps.libgnatcoll_python\libgnatcoll_python.dll]
0xc7d79bc at ???
[C:\GNAT\2019\bin\gps.libgnatcoll_python\libgnatcoll_python.dll]
0xc7d8b16 at ???
[C:\GNAT\2019\bin\gps.python27\python27.dll]
0x1e0c3d54
0x1e113eb9
0x1e114778
0x1e117ee2
0x1e119780
0x1e0b5831
0x1e08dae3
0x1e1141cb
0x1e117fbd
0x1e119780
0x1e0b5831
0x1e08dae3
0x1e09bfcf
0x1e08dae3
[C:\GNAT\2019\bin\gps.libgnatcoll_python\libgnatcoll_python.dll]
0xc7e459f at ???
[C:\GNAT\2019\bin\gps.libgnatcoll_python\libgnatcoll_python.dll]
0xc7e55e0 at ???
[C:\GNAT\2019\bin\gps.libgnatcoll_python\libgnatcoll_python.dll]
0xc7e5833 at ???
[C:\GNAT\2019\bin\gps.libgnatcoll\libgnatcoll.dll]
0xc08dbb4 at ???
[C:\GNAT\2019\bin\gps.exe]
0x197ecf7
0x1975d5f
0x10687c2
0x14ba66a
0x145cc61
0x15e0780
0xfcfa72
0x10b4114
0x10b4672
0x10b7893
0x10b7cf7
0xe30b4c
0xe31022
0xe2deaa
[C:\GNAT\2019\bin\gps.libglib-2.0-0\libglib-2.0-0.dll]
g_timeout_dispatch at gmain.c:4545
g_main_context_dispatch at gmain.c:3122
g_main_context_iterate.isra.10 at gmain.c:3808
g_main_context_iteration at gmain.c:3869
[C:\GNAT\2019\bin\gps.libgio-2.0-0\libgio-2.0-0.dll]
g_application_run at gapplication.c:2308
[C:\GNAT\2019\bin\gps.exe]
0x425199
0x2150c58
0x4013f6
0x4014e9
[C:\windows\system32\kernel32.dll]
0x7768556b
[C:\windows\SYSTEM32\ntdll.dll]
0x777e372b
Build error. [workflow stopped]
There are three problems:
the autogenerated test code wants to throw exceptions but my project doesn't allow them.
I don't understand any of the output after that.
And I don't really understand how the gpr files work. I'm sure there's a magic incantation I can type there and get this sorted out but I've been googling and trying things for a whole day and I'm stuck.
FYI: I'm running the 2019 community versions of gnat, the ARM cross-compiler, and GPS on windows 7.
Update: 2019-12-18:
I've made some progress but it's still not working correctly. I edited the test_driver.gpr as Fabien suggested. I had to comment out the original linker package because it wouldn't work with two of them in the file.
test_driver.gpr now looks like this:
with "test_demo_project.gpr";
with "gnattest_common.gpr";
with "c:\Domains\ada\Ada_Drivers_Library\boards\MicroBit\microbit_zfp.gpr";
project Test_Driver is
for Origin_Project use "..\..\..\demo_project.gpr";
for Target use Gnattest_Common'Target;
for Runtime ("Ada") use Gnattest_Common'Runtime ("Ada");
for Languages use ("Ada", "ASM_CPP");
for Main use ("test_runner.adb");
for Exec_Dir use ".";
package Builder renames Gnattest_Common.Builder;
-- package Linker renames Gnattest_Common.Linker;
package Linker is
for Default_Switches ("Ada") use MicroBit_ZFP.Linker_Switches &
("-Wl,--print-memory-usage",
"-Wl,--gc-sections");
end Linker;
package Binder renames Gnattest_Common.Binder;
package Compiler renames Gnattest_Common.Compiler;
package Ide renames test_demo_project.Ide;
package GNATtest is
for GNATTest_Mapping_File use "gnattest.xml";
end GNATtest;
end Test_Driver;
It doesn't fix the problem with test cases being generated for the ada drivers library but I can live with running gnattest with the "--test-case-only" flag, which largely accomplishes my goal.
But when I build the project it complains about the "ASM_CPP" language and the use of assertions. See below:
gprbuild --target=arm-eabi -d -PC:\Domains\ada\Demo_Project\microbit\obj\gnattest\harness\test_driver.gpr -XADL_BUILD_CHECKS=Enabled -XADL_BUILD=Debug -XTEST_DRIVER_BUILD_MODE=no-config-file -largs -Wl,-Map=map.txt
test_driver.gpr:5:09: warning: there are no sources of language "ASM_CPP" in this project
Compile
[Ada] battery-test_data-tests.adb
battery-test_data-tests.adb:40:13: warning: pragma Restrictions (No_Exception_Propagation) in effect
battery-test_data-tests.adb:40:13: warning: this handler can never be entered, and has been removed
battery-test_data-tests.adb:53:13: warning: pragma Restrictions (No_Exception_Propagation) in effect
battery-test_data-tests.adb:53:13: warning: this handler can never be entered, and has been removed
Bind
[gprbind] test_runner.bexch
[Ada] test_runner.ali
Link
[link] test_runner.adb
Memory region Used Size Region Size %age Used
flash: 21668 B 256 KB 8.27%
ram: 3056 B 16 KB 18.65%
[2019-12-19 08:39:18] process terminated successfully, elapsed time: 02.08s
[2019-12-19 08:39:21] The selected rows in the Locations view cannot be exported, please select files and/or categories.
I tried removing the "ASM_CPP" text and the warning goes away. I don't know now to remove the warnings about the use of exceptions.
When I run my tests I get this:
arm-eabi-gnatemu -PC:\Domains\ada\Demo_Project\microbit\obj\gnattest\harness\test_driver.gpr C:\Domains\ada\Demo_Project\microbit\obj\gnattest\harness\test_runner
[2019-12-19 08:40:01] process terminated successfully, elapsed time: 00.66s
I get the same output when I make my tests fail or pass. Is the warning about the use of exceptions causing the compiler to remove them, which breaks the tests? What do I have to do allow exceptions in my tests?
The question you linked is about testing only a few subprograms, not all the sources in one project, which should be as easy as:
gnattest -Pproject.gpr
You can specify one or more specific files:
gnattest -Pproject.gpr file1.ads file2.ads
Just avoid -r, and you should be fine:
-r Consider recursively all sources from all projects
The compilation errors in your last update seems to show that you did not specify the linker script and startup code.
Those are provided in Ada Drivers Library in the project file boards/MicroBit/microbit_zfp.gpr.
So you first have to "with" this project from the test_driver.gpr project, and then add those lines to the test_driver.gpr project:
package Linker is
for Default_Switches ("Ada") use MicroBit_ZFP.Linker_Switches &
("-Wl,--print-memory-usage",
"-Wl,--gc-sections");
end Linker;
You also have to add assembly in the list of languages in test_driver.gpr:
for Languages use ("Ada", "ASM_CPP");

Compilation with GNATColl

I have installed GNAT 2018 (64 bits) on a PC Windows 8.1.
GNATColl seems well present and compiled through repertories :
C:/GNAT/2018/include/gnatcoll
C:/GNAT/2018/lib/gnatcoll.static
I try to compile this small test program :
with Ada.Text_IO; use Ada.Text_IO;
with GNATCOLL.Terminal; use GNATCOLL.Terminal;
procedure Test_Colors is
Info : Terminal_Info;
begin
Info.Init_For_Stdout (Auto);
Info.Set_Color (Standard_Output, Blue, Yellow);
Put_Line ("A blue on yellow line");
Info.Set_Color (Standard_Output, Style => Reset_All);
Put_Line ("Back to standard colors -- much better");
end Test_Colors;
with the command :
gnatmake -gnat12 -gnatf -O3 "Test_Colors.adb" -aIC:/GNAT/2018/include/gnatcoll -aLC:/GNAT/2018/lib/gnatcoll.static
The file Test_Colors.ali is well created but then the binding goes wrong :
gnatbind -aIC:/GNAT/2018/include/gnatcoll -aOC:/GNAT/2018/lib/gnatcoll.static -x test_colors.ali
gnatlink test_colors.ali -O3
.\gnatcoll-terminal.o:gnatcoll-terminal.adb:(.text+0x46d): undefined reference to `gnatcoll_get_console_screen_buffer_info'
.\gnatcoll-terminal.o:gnatcoll-terminal.adb:(.text+0x4f6): undefined reference to `gnatcoll_terminal_has_colors'
.\gnatcoll-terminal.o:gnatcoll-terminal.adb:(.text+0x6c6): undefined reference to `gnatcoll_get_console_screen_buffer_info'
.\gnatcoll-terminal.o:gnatcoll-terminal.adb:(.text+0x729): undefined reference to `gnatcoll_terminal_has_colors'
.\gnatcoll-terminal.o:gnatcoll-terminal.adb:(.text+0x73d): undefined reference to `gnatcoll_terminal_has_colors'
.\gnatcoll-terminal.o:gnatcoll-terminal.adb:(.text+0x9f3): undefined reference to `gnatcoll_set_console_text_attribute'
.\gnatcoll-terminal.o:gnatcoll-terminal.adb:(.text+0xc93): undefined reference to `gnatcoll_set_console_text_attribute'
.\gnatcoll-terminal.o:gnatcoll-terminal.adb:(.text+0xfb4): undefined reference to `gnatcoll_set_console_text_attribute'
.\gnatcoll-terminal.o:gnatcoll-terminal.adb:(.text+0x1372): undefined reference to `gnatcoll_set_console_text_attribute'
.\gnatcoll-terminal.o:gnatcoll-terminal.adb:(.text+0x23e): undefined reference to `gnatcoll_beginning_of_line'
.\gnatcoll-terminal.o:gnatcoll-terminal.adb:(.text+0x28e): undefined reference to `gnatcoll_clear_to_end_of_line'
.\gnatcoll-terminal.o:gnatcoll-terminal.adb:(.text+0x2d8): undefined reference to `gnatcoll_terminal_width'
collect2.exe: error: ld returned 1 exit status
gnatlink: error when calling C:\GNAT\2018\bin\gcc.exe
gnatmake: *** link failed.
Compilation échouée.
Do you know what to do to use successfully GNATColl ?
Jacob’s project file will indeed build (assuming you have your source in a subdirectory \src and are happy with having your executable in \bin), but this one is a lot simpler:
with "gnatcoll";
project Test_Colors is
for Main use ("test_colors.adb");
end Test_Colors;
The other options he shows will be extremely useful as you develop more advanced projects.
Use a project file and gprbuild. Something along these lines:
with "gnatcoll";
project Colors is
for Languages use ("Ada");
for Main use ("test_colors.adb");
for Source_Dirs use ("src/");
for Object_Dir use "obj/";
for Exec_Dir use "bin/";
package Builder is
for Default_Switches ("Ada")
use ("-m",
"-s");
end Builder;
package Compiler is
for Default_Switches ("Ada")
use ("-fstack-check", -- Generate stack checking code (part of Ada)
"-gnata", -- Enable assertions (part of Ada)
"-gnato13", -- Overflow checking (part of Ada)
"-gnatf", -- Full, verbose error messages
"-gnatwa", -- All optional warnings
"-gnatVa", -- All validity checks
"-gnaty3aAbcdefhiklnOprstux", -- Style checks
"-gnatyM125", -- Style checks
"-gnatwe", -- Treat warnings as errors
"-gnat2012", -- Use Ada 2012
"-Wall", -- All GCC warnings
"-O2"); -- Optimise (level 2/3)
end Compiler;
end Colors;
Now you can build your program with the command:
gprbuild -j0 -p -P colors.gpr
If you don't have any other project files in the directory you run the command from, it is even simpler:
gprbuild -j0 -p

Premake5 android makefile declare prebuilt library

Using premake5 file to generate make files for android. I am trying to produce the prebuilt library declaration as described in https://developer.android.com/ndk/guides/prebuilts.html
More precisely
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := foo-prebuilt
LOCAL_SRC_FILES := libfoo.so
include $(PREBUILT_SHARED_LIBRARY)
What kind of project would introduce the include include $(PREBUILT_SHARED_LIBRARY) or what other option do I need to include?
I have little knowledge in this, but I was able to use android PREBUILT_SHARED_LIBRARY - in premake4 using the following lua script:
The script is customised for the example you've give above.
linklibs = {"foo"}
libdirpaths = {"../../path/to/libs/"}
project "project_using_foo"
language "C"
kind "SharedLib"
files (android.srcfiles)
includedirs (includepaths)
location "build"
links (linklibs)
libdirs (libdirpaths)
buildoptions (buildoptions)
androidappabi {"armeabi-v7a"}
androidsdk "android-19"
where libfoo.so will be in ../../path/to/libs/$(TARGET_ARCH_ABI)/libfoo.so
[$(TARGET_ARCH_ABI) in this case is "armeabi-v7a"]

ADA File Names vs. Package Names

I inherited an ADA program where the source file names and package file names don't follow the default naming convention. ADA is new to me, so I may be missing something simple, but I can't see it in the GNAT Pro User's Guide. (This similar question didn't help me.)
Here are a couple of examples:
File Name: C_Comm_Config_S.Ada
Package Name: Comm_Configuration
File Name: D_Bus_Buffers_S.Ada
Package Name: Bus_Buffers
I think I have the _S.Ada and _B.Ada sorted out, but I can't find anything in the program source or build files that show the binding between the Package Name and the rest of the File Name.
When I compile a file that doesn't use any other packages, I get a warning: file name does not match unit name... This appears to be from the prefix of C_ or D_, in this particular case.
Also, I'm not clear if the prefixes C_ and D_ have any special meaning in the context of ADA, but if it does, I'd like to know about it.
So I appear to have two issues, the Prefix of C_ or D_ and in some cases the rest of the file name doesn't match the package.
You could use gnatname: see the User’s Guide.
I copied subdirectories a/ and d/ from the ACATS test suite to a working directory and created a project file p.gpr:
project p is
for source_dirs use ("a", "d");
end p;
and ran gnatname with
gnatname -P p -d a -d d \*.ada
which resulted in an edited p.gpr and two new files, p_naming.gpr and p_source_list.txt. These are rather long, but look like
p.gpr:
with "p_naming.gpr";
project P is
for Source_List_File use "p_source_list.txt";
for Source_Dirs use ("a", "d");
package Naming renames P_Naming.Naming;
end P;
p_naming.gpr:
project P_Naming is
for Source_Files use ();
package Naming is
for Body ("d4a004b") use "d4a004b.ada";
for Body ("d4a004a") use "d4a004a.ada";
for Body ("d4a002b") use "d4a002b.ada";
...
for Body ("aa2010a_parent.boolean") use "aa2010a.ada" at 4;
for Body ("aa2010a_parent") use "aa2010a.ada" at 3;
for Spec ("aa2010a_parent") use "aa2010a.ada" at 2;
for Spec ("aa2010a_typedef") use "aa2010a.ada" at 1;
...
for Body ("a22006d") use "a22006d.ada";
for Body ("a22006c") use "a22006c.ada";
for Body ("a22006b") use "a22006b.ada”;
end Naming;
end P_Naming;
The for Body ("aa2010a_parent") use "aa2010a.ada" at 3; is used when there’s more than one unit in the source file.
p_source_list.txt:
a22006b.ada
a22006c.ada
a22006d.ada
a27003a.ada
a29003a.ada
...
d4a002b.ada
d4a004a.ada
d4a004b.ada
When building, for example, test d4a004b, you have to use the file name and suffix:
gnatmake -P p d4a004b.ada
The Ada standard does not say anything about source file naming conventions. As it appears that you use GNAT, I assume that you mean the "GNAT default naming convention".
You can tell GNAT about alternatively named files in a Naming package inside your project files.
A simple example:
project OpenID is
...
package Naming is
for Implementation ("Util.Log.Loggers.Traceback")
use "util-log-loggers-traceback-gnat.adb";
for Implementation ("Util.Serialize.IO.XML.Get_Location")
use "util-serialize-io-xml-get_location-xmlada-4.adb";
end Naming;
end OpenID;

Resources