Skip to content

Commit b049c9d

Browse files
committed
Move all GPR switches to a shared abstract project file and remove -flto
Switch -flto requires a GCC plugin, which does not seem to be present when a dependent project uses gnat_native toolchain. Signed-off-by: onox <[email protected]>
1 parent 2800de3 commit b049c9d

File tree

8 files changed

+136
-97
lines changed

8 files changed

+136
-97
lines changed

.github/workflows/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
runs-on: ${{matrix.os}}
1919
strategy:
2020
matrix:
21-
os: [ubuntu-18.04, ubuntu-latest, windows-latest]
21+
os: [ubuntu-latest, windows-latest]
2222
compiler: [fsf, community]
2323
exclude:
2424
- os: windows-latest

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jobs:
3333
- name: Install Alire
3434
uses: alire-project/setup-alire@v1
3535
with:
36+
branch: "master"
3637
toolchain: "gnat_external"
3738

3839
- name: Run tests

Makefile

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
1-
GNATPROVE = gnatprove --cwe --pedantic -k -j0 --output-header
2-
31
.PHONY: build fast debug clean prove tests coverage
42

53
build:
64
cd json && alr build
75

86
fast:
9-
cd json && alr build -XJSON_RUNTIME_CHECKS=disabled -XJSON_CONTRACTS=disabled
7+
cd json && alr build -- -XJSON_RUNTIME_CHECKS=none -XJSON_CONTRACTS=disabled
108

119
debug:
12-
cd json && alr build -XJSON_BUILD_MODE=debug
10+
cd json && alr build -- -XJSON_BUILD_MODE=debug
1311

1412
clean:
15-
-$(GNATPROVE) --clean -P json/json.gpr
13+
-gnatprove --clean -P json/json.gpr
1614
cd json && alr clean
1715
cd tests && alr clean
1816
rm -rf json/build tests/build tests/cov tests/TEST-*.xml
1917

2018
prove:
21-
$(GNATPROVE) --level=4 --prover=all --mode=check -P json/json.gpr
19+
gnatprove -P json/json.gpr
2220

2321
tests:
24-
cd tests && alr build -XJSON_BUILD_MODE=coverage
22+
cd tests && alr build -- -XJSON_BUILD_MODE=coverage
2523
cd tests && alr run -s
2624

2725
coverage:

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@ Optional dependencies:
118118

119119
* `make`
120120

121-
## Installing dependencies on Ubuntu 18.04 LTS
121+
## Installing dependencies on Ubuntu
122122

123123
Install the dependencies using apt:
124124

125125
```sh
126-
$ sudo apt install gnat-7 gprbuild lcov make
126+
$ sudo apt install gnat gprbuild lcov make
127127
```
128128

129129
and then install Alire.

json/json.gpr

Lines changed: 8 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,23 @@
1+
with "json_config";
2+
13
project Json is
24

35
for Library_Name use "json";
46
for Library_Version use "5.0.0";
57

6-
for Create_Missing_Dirs use "True";
7-
88
for Source_Dirs use ("src");
99

1010
for Object_Dir use "build/obj";
1111
for Library_Dir use "build/lib";
1212

13-
type Library_Type_Type is ("relocatable", "static", "static-pic");
14-
Library_Type : Library_Type_Type :=
15-
external ("JSON_LIBRARY_TYPE", external ("LIBRARY_TYPE", "static"));
16-
for Library_Kind use Library_Type;
17-
18-
type Enabled_Kind is ("enabled", "disabled");
19-
Compile_Checks : Enabled_Kind := External ("JSON_COMPILE_CHECKS", "enabled");
20-
Runtime_Checks : Enabled_Kind := External ("JSON_RUNTIME_CHECKS", "enabled");
21-
Style_Checks : Enabled_Kind := External ("JSON_STYLE_CHECKS", "enabled");
22-
Contracts_Checks : Enabled_Kind := External ("JSON_CONTRACTS", "enabled");
23-
24-
type Build_Kind is ("debug", "release", "coverage", "profiling");
25-
Build_Mode : Build_Kind := External ("JSON_BUILD_MODE", "release");
26-
27-
Compile_Checks_Switches := ();
28-
case Compile_Checks is
29-
when "enabled" =>
30-
Compile_Checks_Switches :=
31-
("-gnatwa", -- All warnings
32-
"-gnatVa", -- All validity checks
33-
"-gnatf", -- Full errors
34-
"-gnatwFl.l.s",
35-
"-gnatwe"); -- Warnings as errors
36-
when others => null;
37-
end case;
38-
39-
Runtime_Checks_Switches := ();
40-
case Runtime_Checks is
41-
when "enabled" => null;
42-
when others =>
43-
Runtime_Checks_Switches :=
44-
("-gnatp"); -- Supress checks
45-
end case;
46-
47-
Style_Checks_Switches := ();
48-
case Style_Checks is
49-
when "enabled" =>
50-
Style_Checks_Switches :=
51-
("-gnatyg", -- GNAT Style checks
52-
"-gnaty-Is", -- Disable check mode in and separate subprogram spec
53-
"-gnatyM99", -- Maximum line length
54-
"-gnatyA", -- Array attribute indexes
55-
"-gnatyO"); -- Overriding subprograms explicitly marked as such
56-
when others => null;
57-
end case;
58-
59-
Contracts_Switches := ();
60-
case Contracts_Checks is
61-
when "enabled" =>
62-
Contracts_Switches :=
63-
("-gnata"); -- Enable assertions and contracts
64-
when others => null;
65-
end case;
66-
67-
Build_Switches := ();
68-
case Build_Mode is
69-
when "release" =>
70-
Build_Switches := ("-O2", -- Optimization
71-
"-march=native",
72-
"-fomit-frame-pointer",
73-
"-ffunction-sections",
74-
"-flto",
75-
"-gnatn"); -- Enable inlining
76-
when "debug" =>
77-
Build_Switches := ("-g", -- Debug info
78-
"-Og"); -- No optimization
79-
when "coverage" =>
80-
Build_Switches := ("-O0", "-march=native", "-fprofile-arcs", "-ftest-coverage");
81-
when "profiling" =>
82-
Build_Switches := ("-g", "-pg");
83-
end case;
84-
85-
package Compiler is
86-
for Default_Switches ("Ada") use
87-
Compile_Checks_Switches &
88-
Build_Switches &
89-
Runtime_Checks_Switches &
90-
Style_Checks_Switches &
91-
Contracts_Switches &
92-
("-gnatw.X", -- Disable warnings for No_Exception_Propagation
93-
"-gnatQ"); -- Don't quit. Generate ALI and tree files even if illegalities
13+
package Compiler extends JSON_Config.Compiler is
9414
for Local_Configuration_Pragmas use "gnat.adc";
9515
end Compiler;
9616

97-
package Binder is
98-
for Switches ("Ada") use ("-Es"); -- Symbolic traceback
99-
end Binder;
17+
package Binder renames JSON_Config.Binder;
18+
19+
package Prove is
20+
for Proof_Switches ("Ada") use ("--checks-as-errors", "--level=4", "--no-axiom-guard", "--mode=check", "--prover=all", "--cwe", "--pedantic", "-k", "-j0", "--output-header");
21+
end Prove;
10022

10123
end Json;

json/json_config.gpr

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
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;

json/json_pretty_print.gpr

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
with "json_config";
12
with "json";
23

34
project JSON_Pretty_Print is
@@ -15,4 +16,13 @@ project JSON_Pretty_Print is
1516
package Compiler renames JSON.Compiler;
1617
package Binder renames JSON.Binder;
1718

19+
package Linker is
20+
case JSON_Config.Build_Mode is
21+
when "coverage" =>
22+
for Switches ("Ada") use ("-lgcov");
23+
when others =>
24+
null;
25+
end case;
26+
end Linker;
27+
1828
end JSON_Pretty_Print;

tests/json_tests.gpr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
-- See the License for the specific language governing permissions and
1515
-- limitations under the License.
1616

17+
with "../json/json_config";
1718
with "json";
1819
with "aunit";
1920

@@ -37,7 +38,7 @@ project JSON_Tests is
3738
end Compiler;
3839

3940
package Linker is
40-
case JSON.Build_Mode is
41+
case JSON_Config.Build_Mode is
4142
when "coverage" =>
4243
for Switches ("Ada") use ("-lgcov");
4344
when others =>

0 commit comments

Comments
 (0)