-- -- Copyright (C) 2018-2026, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 -- with "../config/spawn_config.gpr"; library project Spawn is type OS_API_Kind is ("unix", "osx", "Windows_NT"); OS_API : OS_API_Kind := external ("SPAWN_OS", external ("OS", "unix")); type Library_Kind is ("static", "static-pic", "relocatable"); Library_Type : Library_Kind := external ("SPAWN_LIBRARY_TYPE", external ("LIBRARY_TYPE", "static")); type Spawn_Build_Kind is ("dev", "prod", "coverage", "AddressSanitizer"); Build_Mode : Spawn_Build_Kind := external ("SPAWN_BUILD_MODE", external ("BUILD_MODE", "prod")); Superproject := external ("SUPERPROJECT", ""); for Languages use ("Ada", "c"); 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"); Common_Excluded := ("spawn-channels__glib_posix.ads", "spawn-channels__glib_posix.adb"); case OS_API is when "unix" => for Excluded_Source_Files use Common_Excluded & ("pipe2.c", "spawn-windows_api.ads", "spawn-windows_api.adb", "spawn-internal-windows.ads", "spawn-internal-windows.adb"); when "Windows_NT" => for Excluded_Source_Files use Common_Excluded & ("pipe2.c", "posix_const.c", "spawn-polls-posix_polls.ads", "spawn-polls-posix_polls.adb"); when "osx" => for Excluded_Source_Files use Common_Excluded & ("spawn-windows_api.ads", "spawn-windows_api.adb", "spawn-internal-windows.ads", "spawn-internal-windows.adb"); end case; Spawn_Ada_Compiler_Switches := (); Coverage_Ada_Compiler_Switches := (); Linker_Options := (); case Build_Mode is when "prod" => Spawn_Ada_Compiler_Switches := Spawn_Ada_Compiler_Switches & ( -- Compile with optimizations "-O2", -- Generate debug information: this is useful to get meaningful -- tracebacks. "-g" ); when "dev" => Spawn_Ada_Compiler_Switches := Spawn_Ada_Compiler_Switches & ( -- 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" => Spawn_Ada_Compiler_Switches := Spawn_Ada_Compiler_Switches & (); Coverage_Ada_Compiler_Switches := ( -- Enable coverage code instrumentation. "--coverage"); Linker_Options := Linker_Options & ("--coverage"); when "AddressSanitizer" => Spawn_Ada_Compiler_Switches := Spawn_Ada_Compiler_Switches & ( -- Standard development flags "-O0", "-g", -- Enable the AddressSanitizer "-fsanitize=address"); Linker_Options := Linker_Options & ("-fsanitize=address"); end case; Ada_Compiler_Switches := Spawn_Config.Ada_Compiler_Switches & Spawn_Ada_Compiler_Switches & Coverage_Ada_Compiler_Switches; package Compiler is for Switches ("ada") use Spawn_Ada_Compiler_Switches; end Compiler; package Linker is for Linker_Options use Linker_Options; end Linker; package Naming is case OS_API is when "unix" | "osx" => for Spec ("Spawn.Channels") use "spawn-channels__posix.ads"; for Body ("Spawn.Channels") use "spawn-channels__posix.adb"; for Spec ("Spawn.Internal") use "spawn-internal__posix.ads"; for Body ("Spawn.Internal") use "spawn-internal__posix.adb"; for Body ("Spawn.Environments.Initialize_Default") use "spawn-environments-initialize_default__posix.adb"; for Spec ("Spawn.Environments.Internal") use "spawn-environments-internal__posix.ads"; for Body ("Spawn.Environments.Internal") use "spawn-environments-internal__posix.adb"; for Body ("Spawn.Environments.Search_In_Path") use "spawn-environments-search_in_path__posix.adb"; 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"; when "Windows_NT" => for Spec ("Spawn.Internal") use "spawn-internal__windows.ads"; for Body ("Spawn.Internal") use "spawn-internal__windows.adb"; for Body ("Spawn.Environments.Initialize_Default") use "spawn-environments-initialize_default__windows.adb"; for Spec ("Spawn.Environments.Internal") use "spawn-environments-internal__windows.ads"; for Body ("Spawn.Environments.Internal") use "spawn-environments-internal__windows.adb"; for Body ("Spawn.Environments.Search_In_Path") use "spawn-environments-search_in_path__windows.adb"; for Body ("Spawn.Internal.Monitor") use "spawn-internal-monitor__windows.adb"; end case; end Naming; end Spawn;