diff options
author | Jedidiah Barber <contact@jedbarber.id.au> | 2025-05-09 09:13:32 +1200 |
---|---|---|
committer | Jedidiah Barber <contact@jedbarber.id.au> | 2025-05-09 09:13:32 +1200 |
commit | 8acdbfe2299ec7a96db69ee0b2ec298401c92ae8 (patch) | |
tree | e7bb24865a880d3f347cee9d2c1abe559f065eaa | |
parent | 48d85874c4cf4018df9ee83b002e313ca721d892 (diff) |
Improved project files with common switches, debug info, and optimisation
-rw-r--r-- | example.gpr | 31 | ||||
-rw-r--r-- | portadao.gpr | 20 | ||||
-rw-r--r-- | proj/common.gpr | 102 |
3 files changed, 133 insertions, 20 deletions
diff --git a/example.gpr b/example.gpr index 3d48940..8de669d 100644 --- a/example.gpr +++ b/example.gpr @@ -1,6 +1,9 @@ -with "portadao"; +with + + "portadao", + "proj/common"; project Example is @@ -8,23 +11,29 @@ project Example is for languages use ("Ada"); - for Source_Dirs use ("example"); - for Object_Dir use "obj"; - for Exec_Dir use "bin"; - for Main use ("device_list.adb", "saw_back.adb", "sine_block.adb"); + for Object_Dir use "obj"; + for Exec_Dir use "bin"; + for Main use + ("device_list.adb", + "saw_back.adb", + "sine_block.adb"); package Builder is for Executable ("device_list.adb") use "device_list"; - for Executable ("saw_back.adb") use "saw_back"; - for Executable ("sine_block.adb") use "sine_block"; - end Builder; + for Executable ("saw_back.adb") use "saw_back"; + for Executable ("sine_block.adb") use "sine_block"; + for Default_Switches ("Ada") use + Common.Builder'Default_Switches ("Ada"); + for Global_Compilation_Switches ("Ada") use + Common.Builder'Global_Compilation_Switches ("Ada"); + end Builder; - package Compiler is - for Default_Switches("Ada") use ("-gnaty4aAbcefhiklM100nprt"); - end Compiler; + package Compiler renames Common.Compiler; + package Binder renames Common.Binder; + package Linker renames Common.Linker; end Example; diff --git a/portadao.gpr b/portadao.gpr index abe4d26..d5591b7 100644 --- a/portadao.gpr +++ b/portadao.gpr @@ -1,22 +1,24 @@ +with + + "proj/common"; + + library project PortAdao is for Languages use ("Ada", "C"); - - for Source_Dirs use ("src"); - for Object_Dir use "obj"; - for Library_Dir use "lib"; + for Source_Dirs use ("src"); + for Object_Dir use "obj"; + for Library_Dir use "lib"; for Library_Name use "portadao"; for Library_Kind use "dynamic"; - - package Compiler is - for Default_Switches ("Ada") use ("-gnaty4aAbcefhiklM100nprt"); - for Default_Switches ("C") use ("-Wall", "-Wextra"); - end Compiler; + package Builder renames Common.Builder; + package Compiler renames Common.Compiler; + package Binder renames Common.Binder; end PortAdao; diff --git a/proj/common.gpr b/proj/common.gpr new file mode 100644 index 0000000..a251d70 --- /dev/null +++ b/proj/common.gpr @@ -0,0 +1,102 @@ + + +abstract project Common is + + + type Build_Kind is ("release", "debug"); + + Ver : Build_Kind := external ("build", "release"); + + + package Builder is + for Default_Switches ("Ada") use ("-j4", "-m"); + for Global_Compilation_Switches ("Ada") use ("-shared"); + + case Ver is + + when "release" => + null; + + when "debug" => + for Default_Switches ("Ada") use Builder'Default_Switches ("Ada") & "-g"; + + end case; + end Builder; + + + Ada_Common := + ("-gnaty" + & "4" -- indentation + & "a" -- attribute casing + & "A" -- array attribute indices + & "b" -- blanks at end of lines + & "c" -- two space comments + & "e" -- end/exit labels + & "f" -- no form feeds or vertical tabs + & "h" -- no horizontal tabs + & "i" -- if/then layout + & "k" -- keyword casing + & "l" -- reference manual layout + & "M100" -- max line length + & "n" -- package Standard casing + & "p" -- pragma casing + & "r" -- identifier casing + & "t", -- token separation + "-gnatw" + & "a" -- various warning modes + & "F" -- don't check for unreferenced formal parameters + & "J" -- don't check for obsolescent feature use + & "U"); -- don't check for unused entities + + C_Common := + ("-Wall", + "-Werror", + "-Wextra", + "-Wpedantic"); + + package Compiler is + case Ver is + + when "release" => + for Default_Switches ("Ada") use Ada_Common & "-O3" & "-gnatn"; + for Default_Switches ("C") use C_Common & "-O3"; + + when "debug" => + for Default_Switches ("Ada") use Ada_Common & "-O0" & "-gnata" & "-gnato" & "-g"; + for Default_Switches ("C") use C_Common & "-O0"; + + end case; + end Compiler; + + + package Binder is + for Default_Switches ("Ada") use ("-shared"); + + case Ver is + + when "release" => + null; + + when "debug" => + for Default_Switches ("Ada") use Binder'Default_Switches ("Ada") & "-Es"; + + end case; + end Binder; + + + package Linker is + case Ver is + + when "release" => + null; + + when "debug" => + for Default_Switches ("Ada") use ("-g"); + + end case; + end Linker; + + +end Common; + + |