|
| 1 | +abstract project JSON_Config is |
| 2 | + |
| 3 | + for Create_Missing_Dirs use "True"; |
| 4 | + |
| 5 | + type Library_Type_Type is ("relocatable", "static", "static-pic"); |
| 6 | + Library_Type : Library_Type_Type := |
| 7 | + external ("JSON_LIBRARY_TYPE", external ("LIBRARY_TYPE", "static")); |
| 8 | + for Library_Kind use Library_Type; |
| 9 | + |
| 10 | + type Compile_Checks_Kind is ("errors", "warnings", "none"); |
| 11 | + type Runtime_Checks_Kind is ("all", "overflow", "default", "none"); |
| 12 | + |
| 13 | + type Enabled_Kind is ("enabled", "disabled"); |
| 14 | + |
| 15 | + Compile_Checks : Compile_Checks_Kind := External ("JSON_COMPILE_CHECKS", "errors"); |
| 16 | + Runtime_Checks : Runtime_Checks_Kind := External ("JSON_RUNTIME_CHECKS", "default"); |
| 17 | + Style_Checks : Enabled_Kind := External ("JSON_STYLE_CHECKS", "enabled"); |
| 18 | + Contracts_Checks : Enabled_Kind := External ("JSON_CONTRACTS", "enabled"); |
| 19 | + Debug_Symbols : Enabled_Kind := External ("JSON_DEBUG_SYMBOLS", "disabled"); |
| 20 | + |
| 21 | + type Build_Kind is ("debug", "release", "coverage", "profiling"); |
| 22 | + Build_Mode : Build_Kind := External ("JSON_BUILD_MODE", "release"); |
| 23 | + |
| 24 | + Compile_Checks_Switches := (); |
| 25 | + case Compile_Checks is |
| 26 | + when "errors" => |
| 27 | + compile_checks_switches := |
| 28 | + ("-gnatwa", -- all warnings |
| 29 | + "-gnatVa", -- all validity checks |
| 30 | + "-gnatf", -- full errors |
| 31 | + "-gnatwe", -- warnings as errors |
| 32 | + "-gnatwfl.s"); |
| 33 | + when "warnings" => |
| 34 | + compile_checks_switches := |
| 35 | + ("-gnatwa", -- all warnings |
| 36 | + "-gnatVa", -- all validity checks |
| 37 | + "-gnatf", -- full errors |
| 38 | + "-gnatwfl.s"); |
| 39 | + when "none" => null; |
| 40 | + end case; |
| 41 | + |
| 42 | + Runtime_Checks_Switches := (); |
| 43 | + case Runtime_Checks is |
| 44 | + when "all" => Runtime_Checks_Switches := ("-gnato"); |
| 45 | + when "overflow" => Runtime_Checks_Switches := ("-gnato", "-gnatp"); |
| 46 | + when "default" => null; |
| 47 | + when "none" => Runtime_Checks_Switches := ("-gnatp"); -- Supress checks |
| 48 | + end case; |
| 49 | + |
| 50 | + Style_Checks_Switches := (); |
| 51 | + case Style_Checks is |
| 52 | + when "enabled" => |
| 53 | + Style_Checks_Switches := |
| 54 | + ("-gnatyg", -- GNAT Style checks |
| 55 | + "-gnaty-Is", -- Disable check mode in and separate subprogram spec |
| 56 | + "-gnatyM99", -- Maximum line length |
| 57 | + "-gnatyA", -- Array attribute indexes |
| 58 | + "-gnatyO"); -- Overriding subprograms explicitly marked as such |
| 59 | + when "disabled" => null; |
| 60 | + end case; |
| 61 | + |
| 62 | + Contracts_Switches := (); |
| 63 | + case Contracts_Checks is |
| 64 | + when "enabled" => Contracts_Switches := ("-gnata"); -- Enable assertions and contracts |
| 65 | + when "disabled" => null; |
| 66 | + end case; |
| 67 | + |
| 68 | + Build_Switches := (); |
| 69 | + case Build_Mode is |
| 70 | + when "release" => |
| 71 | + Build_Switches := ("-O2", -- Optimization |
| 72 | + "-gnatn"); -- Enable inlining |
| 73 | + when "debug" => |
| 74 | + Build_Switches := ("-Og"); -- No optimization |
| 75 | + when "coverage" => |
| 76 | + Build_Switches := ("-O0", "-fprofile-arcs", "-ftest-coverage"); |
| 77 | + when "profiling" => |
| 78 | + Build_Switches := ("-pg"); |
| 79 | + end case; |
| 80 | + |
| 81 | + Debug_Switches := (); |
| 82 | + case Debug_Symbols is |
| 83 | + when "enabled" => Debug_Switches := ("-g"); |
| 84 | + when "disabled" => Debug_Switches := ("-fomit-frame-pointer"); |
| 85 | + end case; |
| 86 | + |
| 87 | + package Compiler is |
| 88 | + for Default_Switches ("Ada") use |
| 89 | + Compile_Checks_Switches & |
| 90 | + Debug_Switches & |
| 91 | + Build_Switches & |
| 92 | + Runtime_Checks_Switches & |
| 93 | + Style_Checks_Switches & |
| 94 | + Contracts_Switches & |
| 95 | + ("-march=native", |
| 96 | + "-ffunction-sections", |
| 97 | + "-fdata-sections", -- In Linker: -Wl,-gc-sections |
| 98 | + "-gnatw.X", -- Disable warnings for No_Exception_Propagation |
| 99 | + "-gnatQ"); -- Don't quit. Generate ALI and tree files even if illegalities |
| 100 | + for Local_Configuration_Pragmas use "gnat.adc"; |
| 101 | + end Compiler; |
| 102 | + |
| 103 | + package Binder is |
| 104 | + for Switches ("Ada") use ("-Es"); -- Symbolic traceback |
| 105 | + end Binder; |
| 106 | + |
| 107 | +end JSON_Config; |
0 commit comments