411 REFERENCE · Wikibooks
Ada Programming/Platform/Portable builds
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
Basic
__TOC__
GPRbuild can be used to make portable builds.
Platform-independent code
Create a project for platform-independent code which is common to all supported platforms.
portable.gpr
project Portable is
for Main use ("portable.adb");
GPS uses this to start the executable
for Exec_Dir use "bin";
for Source_Dirs use ("src");
end Portable;
Platform-specific code
For example, open portable-windows.gpr with GPS or GPRbuild to build a project for Windows.
portable-windows.gpr
project Portable.Windows extends "portable.gpr" is
Object for Windows Resources
for Languages use ("Ada", "WinRes");
for Source_Dirs use ("windows", "resources");
for Object_Dir use "windows-obj";
This should be the same as the parent project
or the executable will be placed on the object directory
for Exec_Dir use "bin";
package Linker is
for Default_Switches ("Ada") use
("-lgdi32", "windows-obj/resources.o", "-mwindows");
end Linker;
package Compiler is
for Driver ("WinRes") use "windres";
for Default_Switches ("WinRes") use ("--target=pe-x86-64");
for Leading_Required_Switches ("WinRes") use ("-i");
for Object_File_Suffix ("WinRes") use ".o";
end Compiler;
package Naming is
for Body_Suffix ("WinRes") use ".rc";
end Naming;
end Portable.Windows;