diff --git a/Makefile b/Makefile index 9a2521d..1d29a33 100644 --- a/Makefile +++ b/Makefile @@ -1,31 +1,25 @@ -.PHONY: build fast debug clean prove tests coverage +.PHONY: build clean prove tests coverage build: - cd json && alr build - -fast: - cd json && alr build -- -XJSON_RUNTIME_CHECKS=none -XJSON_CONTRACTS=disabled - -debug: - cd json && alr build -- -XJSON_BUILD_MODE=debug + cd json && alr build --validation clean: - -gnatprove --clean -P json/json.gpr + -alr gnatprove --clean cd json && alr clean cd tests && alr clean - rm -rf json/build tests/build tests/cov tests/TEST-*.xml + rm -rf json/build tests/build tests/build/cov tests/TEST-*.xml prove: - gnatprove -P json/json.gpr + alr gnatprove tests: - cd tests && alr build -- -XJSON_BUILD_MODE=coverage + cd tests && alr build --development cd tests && alr run -s coverage: - mkdir -p tests/cov - lcov -q -c -d json/build/obj -d tests/build/obj -o tests/cov/unit.info - lcov -q -r tests/cov/unit.info */adainclude/* -o tests/cov/unit.info - lcov -q -r tests/cov/unit.info */tests/* -o tests/cov/unit.info - genhtml -q --ignore-errors source -o tests/cov/html tests/cov/unit.info - lcov -l tests/cov/unit.info + mkdir -p tests/build/cov + lcov -q -c -d json/build/obj -d tests/build/obj -o tests/build/cov/unit.info + lcov -q -r tests/build/cov/unit.info */adainclude/* -o tests/build/cov/unit.info + lcov -q -r tests/build/cov/unit.info */tests/* -o tests/build/cov/unit.info + genhtml -q --ignore-errors source -o tests/build/cov/html tests/build/cov/unit.info + lcov -l tests/build/cov/unit.info diff --git a/json/alire.toml b/json/alire.toml index ec7e5a5..1cfe0c6 100644 --- a/json/alire.toml +++ b/json/alire.toml @@ -13,5 +13,6 @@ authors = ["onox"] maintainers = ["onox "] maintainers-logins = ["onox"] -[configuration] -disabled = true +[build-switches] +validation.compile_checks = "warnings" +"*".style_checks = ["-gnatygAO-Is"] diff --git a/json/json.gpr b/json/json.gpr index dedc269..5e27bab 100644 --- a/json/json.gpr +++ b/json/json.gpr @@ -1,23 +1,28 @@ -with "json_config"; +with "config/json_config"; -project Json is +project JSON is - for Library_Name use "json"; - for Library_Version use "5.0.0"; + for Library_Name use "json-ada"; + for Library_Version use Project'Library_Name & ".so." & Json_Config.Crate_Version; - for Source_Dirs use ("src"); + for Create_Missing_Dirs use "True"; - for Object_Dir use "build/obj"; + for Source_Dirs use ("src"); + for Object_Dir use "build/obj/" & Json_Config.Build_Profile; for Library_Dir use "build/lib"; - package Compiler extends JSON_Config.Compiler is + type Library_Type_Type is ("relocatable", "static", "static-pic"); + Library_Type : Library_Type_Type := + external ("JSON_LIBRARY_TYPE", external ("LIBRARY_TYPE", "static")); + for Library_Kind use Library_Type; + + package Compiler is + for Default_Switches ("Ada") use Json_Config.Ada_Compiler_Switches & ("-gnatyM99"); for Local_Configuration_Pragmas use "gnat.adc"; end Compiler; - package Binder renames JSON_Config.Binder; - - package Prove is - for Proof_Switches ("Ada") use ("--checks-as-errors", "--level=4", "--no-axiom-guard", "--mode=check", "--prover=all", "--cwe", "--pedantic", "-k", "-j0", "--output-header"); - end Prove; + package Binder is + for Switches ("Ada") use ("-Es"); -- Symbolic traceback + end Binder; -end Json; +end JSON; diff --git a/json/json_config.gpr b/json/json_config.gpr deleted file mode 100644 index 6d2094a..0000000 --- a/json/json_config.gpr +++ /dev/null @@ -1,107 +0,0 @@ -abstract project JSON_Config is - - for Create_Missing_Dirs use "True"; - - type Library_Type_Type is ("relocatable", "static", "static-pic"); - Library_Type : Library_Type_Type := - external ("JSON_LIBRARY_TYPE", external ("LIBRARY_TYPE", "static")); - for Library_Kind use Library_Type; - - type Compile_Checks_Kind is ("errors", "warnings", "none"); - type Runtime_Checks_Kind is ("all", "overflow", "default", "none"); - - type Enabled_Kind is ("enabled", "disabled"); - - Compile_Checks : Compile_Checks_Kind := External ("JSON_COMPILE_CHECKS", "errors"); - Runtime_Checks : Runtime_Checks_Kind := External ("JSON_RUNTIME_CHECKS", "default"); - Style_Checks : Enabled_Kind := External ("JSON_STYLE_CHECKS", "enabled"); - Contracts_Checks : Enabled_Kind := External ("JSON_CONTRACTS", "enabled"); - Debug_Symbols : Enabled_Kind := External ("JSON_DEBUG_SYMBOLS", "disabled"); - - type Build_Kind is ("debug", "release", "coverage", "profiling"); - Build_Mode : Build_Kind := External ("JSON_BUILD_MODE", "release"); - - Compile_Checks_Switches := (); - case Compile_Checks is - when "errors" => - compile_checks_switches := - ("-gnatwa", -- all warnings - "-gnatVa", -- all validity checks - "-gnatf", -- full errors --- "-gnatwe", -- warnings as errors - "-gnatwfl.s"); - when "warnings" => - compile_checks_switches := - ("-gnatwa", -- all warnings - "-gnatVa", -- all validity checks - "-gnatf", -- full errors - "-gnatwfl.s"); - when "none" => null; - end case; - - Runtime_Checks_Switches := (); - case Runtime_Checks is - when "all" => Runtime_Checks_Switches := ("-gnato"); - when "overflow" => Runtime_Checks_Switches := ("-gnato", "-gnatp"); - when "default" => null; - when "none" => Runtime_Checks_Switches := ("-gnatp"); -- Supress checks - end case; - - Style_Checks_Switches := (); - case Style_Checks is - when "enabled" => - Style_Checks_Switches := - ("-gnatyg", -- GNAT Style checks - "-gnaty-Is", -- Disable check mode in and separate subprogram spec - "-gnatyM99", -- Maximum line length - "-gnatyA", -- Array attribute indexes - "-gnatyO"); -- Overriding subprograms explicitly marked as such - when "disabled" => null; - end case; - - Contracts_Switches := (); - case Contracts_Checks is - when "enabled" => Contracts_Switches := ("-gnata"); -- Enable assertions and contracts - when "disabled" => null; - end case; - - Build_Switches := (); - case Build_Mode is - when "release" => - Build_Switches := ("-O2", -- Optimization - "-gnatn"); -- Enable inlining - when "debug" => - Build_Switches := ("-Og"); -- No optimization - when "coverage" => - Build_Switches := ("-O0", "-fprofile-arcs", "-ftest-coverage"); - when "profiling" => - Build_Switches := ("-pg"); - end case; - - Debug_Switches := (); - case Debug_Symbols is - when "enabled" => Debug_Switches := ("-g"); - when "disabled" => Debug_Switches := ("-fomit-frame-pointer"); - end case; - - package Compiler is - for Default_Switches ("Ada") use - Compile_Checks_Switches & - Debug_Switches & - Build_Switches & - Runtime_Checks_Switches & - Style_Checks_Switches & - Contracts_Switches & - ("-march=native", - "-ffunction-sections", - "-fdata-sections", -- In Linker: -Wl,-gc-sections - "-gnatw.X", -- Disable warnings for No_Exception_Propagation - "-gnatQ"); -- Don't quit. Generate ALI and tree files even if illegalities - for Local_Configuration_Pragmas use "gnat.adc"; - end Compiler; - - package Binder is - for Switches ("Ada") use ("-Es"); -- Symbolic traceback - end Binder; - -end JSON_Config; diff --git a/json/json_pretty_print.gpr b/json/json_pretty_print.gpr index 6cf9455..203acc2 100644 --- a/json/json_pretty_print.gpr +++ b/json/json_pretty_print.gpr @@ -1,12 +1,12 @@ -with "json_config"; with "json"; +with "config/json_config"; project JSON_Pretty_Print is for Create_Missing_Dirs use "True"; for Source_Dirs use ("src/tools"); - for Object_Dir use "build/tools/obj"; + for Object_Dir use "build/tools/obj/" & Json_Config.Build_Profile; for Library_Dir use "build/tools/lib"; for Exec_Dir use "build/bin"; @@ -16,13 +16,4 @@ project JSON_Pretty_Print is package Compiler renames JSON.Compiler; package Binder renames JSON.Binder; - package Linker is - case JSON_Config.Build_Mode is - when "coverage" => - for Switches ("Ada") use ("-lgcov"); - when others => - null; - end case; - end Linker; - end JSON_Pretty_Print; diff --git a/tests/alire.toml b/tests/alire.toml index 8968a10..b73f8d7 100644 --- a/tests/alire.toml +++ b/tests/alire.toml @@ -11,12 +11,13 @@ authors = ["onox"] maintainers = ["onox "] maintainers-logins = ["onox"] -[configuration] -disabled = true - [[depends-on]] aunit = "^21.0.0" json = "^5.0.2" [[pins]] json = { path = "../json" } + +[build-switches] +validation.compile_checks = "warnings" +"*".style_checks = ["-gnatygAO-Is"] diff --git a/tests/json_tests.gpr b/tests/json_tests.gpr index 12ec5c7..e5ef81e 100644 --- a/tests/json_tests.gpr +++ b/tests/json_tests.gpr @@ -14,36 +14,33 @@ -- See the License for the specific language governing permissions and -- limitations under the License. -with "../json/json_config"; -with "json"; with "aunit"; +with "json"; +with "config/json_tests_config"; project JSON_Tests is for Create_Missing_Dirs use "True"; for Source_Dirs use ("src"); - - for Object_Dir use "build/obj"; - for Library_Dir use "build/lib"; + for Object_Dir use "build/obj/" & JSON_Tests_Config.Build_Profile; for Exec_Dir use "build/bin"; for Main use ("test_bindings.adb"); - package Binder renames JSON.Binder; - - package Compiler extends JSON.Compiler is + package Compiler is + for Default_Switches ("Ada") use Json_Tests_Config.Ada_Compiler_Switches & + ("-gnatyM99", "--coverage"); for Local_Configuration_Pragmas use "gnat.adc"; end Compiler; + package Binder is + for Switches ("Ada") use ("-Es"); -- Symbolic traceback + end Binder; + package Linker is - case JSON_Config.Build_Mode is - when "coverage" => - for Switches ("Ada") use ("-lgcov"); - when others => - null; - end case; + for Switches ("Ada") use ("-lgcov"); end Linker; end JSON_Tests;