2022-06-21 11:30:33 +03:00
|
|
|
--
|
2026-01-26 15:15:10 +04:00
|
|
|
-- Copyright (C) 2018-2026, AdaCore
|
2022-06-21 11:30:33 +03:00
|
|
|
--
|
|
|
|
|
-- SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
--
|
2018-10-11 14:33:17 +03:00
|
|
|
|
2023-05-12 18:10:58 +03:00
|
|
|
with "../config/spawn_config.gpr";
|
|
|
|
|
|
2020-12-02 13:11:09 +02:00
|
|
|
library project Spawn is
|
2018-10-11 14:33:17 +03:00
|
|
|
|
2019-01-09 19:00:53 +02:00
|
|
|
type OS_API_Kind is ("unix", "osx", "Windows_NT");
|
2023-08-04 14:29:11 +01:00
|
|
|
OS_API : OS_API_Kind := external ("SPAWN_OS", external ("OS", "unix"));
|
2018-11-20 19:38:33 +02:00
|
|
|
|
2020-12-02 13:11:09 +02:00
|
|
|
type Library_Kind is ("static", "static-pic", "relocatable");
|
2023-04-04 08:32:07 +03:00
|
|
|
Library_Type : Library_Kind :=
|
|
|
|
|
external ("SPAWN_LIBRARY_TYPE", external ("LIBRARY_TYPE", "static"));
|
2020-12-02 13:11:09 +02:00
|
|
|
|
2021-08-26 06:51:04 +00:00
|
|
|
type Spawn_Build_Kind is ("dev", "prod", "coverage", "AddressSanitizer");
|
2021-03-08 15:31:37 +02:00
|
|
|
Build_Mode : Spawn_Build_Kind :=
|
2021-02-24 12:28:46 +02:00
|
|
|
external ("SPAWN_BUILD_MODE", external ("BUILD_MODE", "prod"));
|
2020-12-02 13:11:09 +02:00
|
|
|
|
2021-04-08 15:29:53 +03:00
|
|
|
Superproject := external ("SUPERPROJECT", "");
|
|
|
|
|
|
2019-01-09 19:00:53 +02:00
|
|
|
for Languages use ("Ada", "c");
|
2018-10-11 14:33:17 +03:00
|
|
|
|
2026-01-26 15:15:10 +04:00
|
|
|
for Library_Kind use Library_Type;
|
|
|
|
|
for Library_Name use "spawn";
|
|
|
|
|
for Run_Path_Option use ();
|
|
|
|
|
|
|
|
|
|
for Object_Dir use "../.obj/" & Superproject & "/spawn/" & Library_Type;
|
|
|
|
|
for Library_Dir use "../.libs/" & Superproject & "/spawn/" & Library_Type;
|
|
|
|
|
for Source_Dirs use ("../source/spawn");
|
|
|
|
|
|
2022-12-21 10:25:13 +02:00
|
|
|
Common_Excluded :=
|
|
|
|
|
("spawn-channels__glib_posix.ads", "spawn-channels__glib_posix.adb");
|
2018-11-26 18:13:26 +02:00
|
|
|
|
|
|
|
|
case OS_API is
|
2019-01-09 19:00:53 +02:00
|
|
|
when "unix" =>
|
2018-11-26 18:13:26 +02:00
|
|
|
for Excluded_Source_Files use Common_Excluded &
|
2019-01-09 19:00:53 +02:00
|
|
|
("pipe2.c",
|
|
|
|
|
"spawn-windows_api.ads",
|
2023-04-04 11:38:07 +04:00
|
|
|
"spawn-windows_api.adb",
|
2022-12-09 19:07:22 +02:00
|
|
|
"spawn-internal-windows.ads",
|
|
|
|
|
"spawn-internal-windows.adb");
|
2018-11-26 18:13:26 +02:00
|
|
|
|
|
|
|
|
when "Windows_NT" =>
|
2020-03-17 11:48:19 +02:00
|
|
|
for Excluded_Source_Files use Common_Excluded &
|
|
|
|
|
("pipe2.c",
|
2023-01-02 16:19:41 +02:00
|
|
|
"posix_const.c",
|
|
|
|
|
"spawn-polls-posix_polls.ads",
|
|
|
|
|
"spawn-polls-posix_polls.adb");
|
2019-01-22 17:21:38 +02:00
|
|
|
|
|
|
|
|
when "osx" =>
|
|
|
|
|
for Excluded_Source_Files use Common_Excluded &
|
|
|
|
|
("spawn-windows_api.ads",
|
2023-04-28 19:10:43 +03:00
|
|
|
"spawn-windows_api.adb",
|
2022-12-09 19:07:22 +02:00
|
|
|
"spawn-internal-windows.ads",
|
|
|
|
|
"spawn-internal-windows.adb");
|
2018-11-26 18:13:26 +02:00
|
|
|
end case;
|
|
|
|
|
|
2023-05-12 18:10:58 +03:00
|
|
|
Spawn_Ada_Compiler_Switches := ();
|
|
|
|
|
Coverage_Ada_Compiler_Switches := ();
|
2020-12-02 13:11:09 +02:00
|
|
|
Linker_Options := ();
|
2020-01-10 07:00:20 -05:00
|
|
|
|
2020-12-02 13:11:09 +02:00
|
|
|
case Build_Mode is
|
|
|
|
|
when "prod" =>
|
2023-05-12 18:10:58 +03:00
|
|
|
Spawn_Ada_Compiler_Switches := Spawn_Ada_Compiler_Switches & (
|
2020-12-02 13:11:09 +02:00
|
|
|
-- Compile with optimizations
|
|
|
|
|
"-O2",
|
|
|
|
|
|
|
|
|
|
-- Generate debug information: this is useful to get meaningful
|
|
|
|
|
-- tracebacks.
|
|
|
|
|
"-g"
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
when "dev" =>
|
2023-05-12 18:10:58 +03:00
|
|
|
Spawn_Ada_Compiler_Switches := Spawn_Ada_Compiler_Switches & (
|
2020-12-02 13:11:09 +02:00
|
|
|
-- Compile with no optimization and with debug information to ease
|
|
|
|
|
-- investigation in debuggers.
|
|
|
|
|
"-O0", "-g",
|
|
|
|
|
|
|
|
|
|
-- Enable all warnings and GNAT stylechecks (plus O: check for
|
|
|
|
|
-- overriding indicators).
|
|
|
|
|
"-gnatwa", "-gnatygO",
|
|
|
|
|
|
|
|
|
|
-- Enable assertions and all validity checking options
|
|
|
|
|
"-gnata", "-gnatVa",
|
|
|
|
|
|
|
|
|
|
-- Enable stack overflow checks
|
|
|
|
|
"-fstack-check"
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
when "coverage" =>
|
2023-05-12 18:10:58 +03:00
|
|
|
Spawn_Ada_Compiler_Switches := Spawn_Ada_Compiler_Switches & ();
|
|
|
|
|
Coverage_Ada_Compiler_Switches := (
|
2020-12-02 13:11:09 +02:00
|
|
|
|
|
|
|
|
-- Enable coverage code instrumentation.
|
|
|
|
|
"--coverage");
|
|
|
|
|
|
|
|
|
|
Linker_Options := Linker_Options & ("--coverage");
|
2021-08-26 06:51:04 +00:00
|
|
|
|
|
|
|
|
when "AddressSanitizer" =>
|
2023-05-12 18:10:58 +03:00
|
|
|
Spawn_Ada_Compiler_Switches := Spawn_Ada_Compiler_Switches & (
|
2021-08-26 06:51:04 +00:00
|
|
|
-- Standard development flags
|
|
|
|
|
"-O0", "-g",
|
|
|
|
|
-- Enable the AddressSanitizer
|
|
|
|
|
"-fsanitize=address");
|
|
|
|
|
|
|
|
|
|
Linker_Options := Linker_Options & ("-fsanitize=address");
|
2020-12-02 13:11:09 +02:00
|
|
|
end case;
|
|
|
|
|
|
2023-05-12 18:10:58 +03:00
|
|
|
Ada_Compiler_Switches :=
|
|
|
|
|
Spawn_Config.Ada_Compiler_Switches
|
|
|
|
|
& Spawn_Ada_Compiler_Switches
|
|
|
|
|
& Coverage_Ada_Compiler_Switches;
|
|
|
|
|
|
2018-10-11 14:33:17 +03:00
|
|
|
package Compiler is
|
2023-05-12 18:10:58 +03:00
|
|
|
for Switches ("ada") use Spawn_Ada_Compiler_Switches;
|
2018-10-11 14:33:17 +03:00
|
|
|
end Compiler;
|
|
|
|
|
|
2020-12-02 13:11:09 +02:00
|
|
|
package Linker is
|
|
|
|
|
for Linker_Options use Linker_Options;
|
|
|
|
|
end Linker;
|
|
|
|
|
|
2018-11-20 19:38:33 +02:00
|
|
|
package Naming is
|
|
|
|
|
case OS_API is
|
2019-01-09 19:00:53 +02:00
|
|
|
when "unix" | "osx" =>
|
2022-12-21 10:25:13 +02:00
|
|
|
for Spec ("Spawn.Channels")
|
|
|
|
|
use "spawn-channels__posix.ads";
|
|
|
|
|
for Body ("Spawn.Channels")
|
|
|
|
|
use "spawn-channels__posix.adb";
|
2018-11-20 19:38:33 +02:00
|
|
|
for Spec ("Spawn.Internal")
|
|
|
|
|
use "spawn-internal__posix.ads";
|
|
|
|
|
for Body ("Spawn.Internal")
|
|
|
|
|
use "spawn-internal__posix.adb";
|
2019-03-13 17:33:50 +03:00
|
|
|
for Body ("Spawn.Environments.Initialize_Default")
|
|
|
|
|
use "spawn-environments-initialize_default__posix.adb";
|
2018-11-20 19:38:33 +02:00
|
|
|
for Spec ("Spawn.Environments.Internal")
|
|
|
|
|
use "spawn-environments-internal__posix.ads";
|
|
|
|
|
for Body ("Spawn.Environments.Internal")
|
|
|
|
|
use "spawn-environments-internal__posix.adb";
|
2019-04-04 18:58:44 +03:00
|
|
|
for Body ("Spawn.Environments.Search_In_Path")
|
|
|
|
|
use "spawn-environments-search_in_path__posix.adb";
|
2022-12-09 19:07:22 +02:00
|
|
|
for Body ("Spawn.Internal.Monitor")
|
|
|
|
|
use "spawn-internal-monitor__posix.adb";
|
|
|
|
|
for Body ("Spawn.Internal.Monitor.Initialize")
|
|
|
|
|
use "spawn-internal-monitor-" & OS_API & "_initialize.adb";
|
2018-11-20 19:38:33 +02:00
|
|
|
when "Windows_NT" =>
|
|
|
|
|
for Spec ("Spawn.Internal")
|
|
|
|
|
use "spawn-internal__windows.ads";
|
|
|
|
|
for Body ("Spawn.Internal")
|
|
|
|
|
use "spawn-internal__windows.adb";
|
2019-03-13 17:33:50 +03:00
|
|
|
for Body ("Spawn.Environments.Initialize_Default")
|
|
|
|
|
use "spawn-environments-initialize_default__windows.adb";
|
2018-11-20 19:38:33 +02:00
|
|
|
for Spec ("Spawn.Environments.Internal")
|
|
|
|
|
use "spawn-environments-internal__windows.ads";
|
|
|
|
|
for Body ("Spawn.Environments.Internal")
|
|
|
|
|
use "spawn-environments-internal__windows.adb";
|
2019-04-04 18:58:44 +03:00
|
|
|
for Body ("Spawn.Environments.Search_In_Path")
|
|
|
|
|
use "spawn-environments-search_in_path__windows.adb";
|
2022-12-09 19:07:22 +02:00
|
|
|
for Body ("Spawn.Internal.Monitor")
|
|
|
|
|
use "spawn-internal-monitor__windows.adb";
|
2018-11-20 19:38:33 +02:00
|
|
|
end case;
|
|
|
|
|
end Naming;
|
|
|
|
|
|
2021-04-08 15:29:53 +03:00
|
|
|
end Spawn;
|