aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2025-05-08 21:57:52 +1200
committerJedidiah Barber <contact@jedbarber.id.au>2025-05-08 21:57:52 +1200
commit3ed0edef137c4b577646c35e0f5beddfb9f57555 (patch)
treee15a36a74d3edead096c2a1a74b80dae785ce5d1
parent0c774f937f169f31f9b11136d3375901597f9269 (diff)
Improved project files with common switches, debug info, and optimisation
-rw-r--r--asndfile.gpr20
-rw-r--r--example.gpr27
-rw-r--r--proj/common.gpr102
3 files changed, 131 insertions, 18 deletions
diff --git a/asndfile.gpr b/asndfile.gpr
index 07c41c5..52a80de 100644
--- a/asndfile.gpr
+++ b/asndfile.gpr
@@ -1,22 +1,24 @@
+with
+
+ "proj/common";
+
+
library project Asndfile 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 "asndfile";
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 Asndfile;
diff --git a/example.gpr b/example.gpr
index 9f8479e..e799be2 100644
--- a/example.gpr
+++ b/example.gpr
@@ -1,6 +1,9 @@
-with "asndfile";
+with
+
+ "asndfile",
+ "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 ("file_info_example.adb", "read_example.adb", "virtual_io_example.adb");
+ for Main use
+ ("file_info_example.adb",
+ "read_example.adb",
+ "virtual_io_example.adb");
package Builder is
- for Executable("file_info_example.adb") use "info_example";
- for Executable("read_example.adb") use "read_example";
+ for Executable("file_info_example.adb") use "info_example";
+ for Executable("read_example.adb") use "read_example";
for Executable("virtual_io_example.adb") use "virtual_example";
- 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");
- 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;
+
+