aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2025-05-08 15:23:07 +1200
committerJedidiah Barber <contact@jedbarber.id.au>2025-05-08 15:23:07 +1200
commita75042055c9045d310c3ff1d30607be736e9cf5f (patch)
tree5bd2ea86948410b6440585a4e5742ea721c5dd8f
parent87e42e46a5d898698ad5cbcd71b3877d2c319084 (diff)
Improved project files with common switches, debug info, and optimisation
-rw-r--r--aao.gpr20
-rw-r--r--example.gpr35
-rw-r--r--proj/common.gpr102
3 files changed, 135 insertions, 22 deletions
diff --git a/aao.gpr b/aao.gpr
index 07588ad..db43e0e 100644
--- a/aao.gpr
+++ b/aao.gpr
@@ -1,22 +1,24 @@
+with
+
+ "proj/common";
+
+
library project AAO 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 "aao";
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 AAO;
diff --git a/example.gpr b/example.gpr
index c702ae7..5129612 100644
--- a/example.gpr
+++ b/example.gpr
@@ -1,6 +1,9 @@
-with "aao";
+with
+
+ "aao",
+ "proj/common";
project Example is
@@ -8,25 +11,31 @@ project Example is
for languages use ("Ada", "C");
-
for Source_Dirs use ("example");
- for Object_Dir use "obj";
- for Exec_Dir use "bin";
- for Main use ("aao_example.adb", "ao_example.c", "info_list.adb", "format_options.adb");
+ for Object_Dir use "obj";
+ for Exec_Dir use "bin";
+ for Main use
+ ("aao_example.adb",
+ "ao_example.c",
+ "info_list.adb",
+ "format_options.adb");
package Builder is
- for Executable("aao_example.adb") use "ada_example";
- for Executable("ao_example.c") use "c_example";
- for Executable("info_list.adb") use "info_list";
+ for Executable("aao_example.adb") use "ada_example";
+ for Executable("ao_example.c") use "c_example";
+ for Executable("info_list.adb") use "info_list";
for Executable("format_options.adb") use "format_options";
- end Builder;
+ 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");
- for Default_Switches("C") use ("-Wall", "-Wextra");
- end Compiler;
+ package Compiler renames Common.Compiler;
+ package Binder renames Common.Binder;
+ package Linker renames Common.Linker;
end Example;
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;
+
+