Skip to content

Commit 4e99161

Browse files
Merge branch 'slides/217-update_gnat_project_facility' into 'master'
Resolve "Update GNAT Project Facility training for GNAT 24.2" See merge request feng/training/material!297
2 parents 1a019b2 + 610ee21 commit 4e99161

File tree

5 files changed

+92
-77
lines changed

5 files changed

+92
-77
lines changed

courses/gnat_project_facility/010_overview.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,19 @@ Origins and Purposes of Projects
5959

6060
+ Tools (metrics, documentation generator, etc)
6161

62-
+ AdaCore Tools benefit from having knowledge of application structure
62+
+ AdaCore tools benefit from having knowledge of application structure
6363

6464
---------------------------------
6565
Subsystems of Subsystems of ...
6666
---------------------------------
6767

68-
+ Projects support incremental, modular project definition
68+
+ Projects support incremental/modular project definition
6969

7070
+ Projects can import other projects containing needed files
7171
+ Child projects can extend parent projects
7272

7373
+ Inheriting all attributes of parent
74-
+ Can optionally override source files and other attributes
74+
+ Allows override of source files and other attributes
7575

7676
+ Allows structuring of large development efforts into hierarchical subsystems
7777

@@ -112,7 +112,7 @@ Configurable Properties
112112
+ Ada / C / C++ are preconfigured
113113

114114
+ Source file naming conventions
115-
+ et cetera
115+
+ And many more
116116

117117
--------------------------
118118
The Minimal Project File
@@ -129,7 +129,8 @@ Specifying Main Subprogram(s)
129129

130130
+ Optional
131131

132-
+ If not specified in file, must be specified on command-line
132+
+ Some projects do not build an executable
133+
+ If necessary and not specified in file, must be specified on command-line
133134

134135
+ Can have more than one file named
135136
+ A project-level setting

courses/gnat_project_facility/020_building_with_gprbuild.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ GPRbuild Command Line
8888
Common Options Passed To Tools
8989
--------------------------------
9090

91-
* :command:`-cargs options`
91+
:command:`-cargs options`
9292

9393
* Options passed to all compilers
9494
* Example:
@@ -98,7 +98,7 @@ Common Options Passed To Tools
9898
-cargs -g
9999

100100

101-
* :command:`-cargs:<language> options`
101+
:command:`-cargs:<language> options`
102102

103103
* Options passed to compiler for specific language
104104
* Examples:
@@ -109,11 +109,11 @@ Common Options Passed To Tools
109109
-cargs:C -E
110110

111111

112-
* :command:`-bargs options`
112+
:command:`-bargs options`
113113

114114
* Options passed to all binder drivers
115115

116-
* :command:`-bargs:<language> options`
116+
:command:`-bargs:<language> options`
117117

118118
* Options passed to binder driver for specific language
119119
* Examples:
@@ -124,7 +124,7 @@ Common Options Passed To Tools
124124
-bargs:C++ c_compiler_name=ccppc
125125

126126

127-
* :command:`-largs options`
127+
:command:`-largs options`
128128

129129
* Options passed to linker for generating executable
130130

courses/gnat_project_facility/030_project_properties.rst

Lines changed: 43 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ Source Files
173173
Object Directory
174174
------------------
175175

176-
+ Specifies location for compiler-generated files
176+
+ Specifies location for files generated by compiler (or tools)
177177

178-
+ Such as :filename:`.ali` files and object files
178+
+ Such as :filename:`.ali` files and :filename:`.o` files
179179
+ For the project's immediate sources
180180

181181
.. code:: Ada
@@ -187,10 +187,6 @@ Object Directory
187187
188188
+ Only one object directory per project
189189

190-
+ If :ada:`Child` extends project :ada:`Parent` and then building :ada:`Child`
191-
192-
+ For any source that exists only in :ada:`Parent` but has not been compiled, it's object files will appear in the :ada:`Child` object directory
193-
194190
----------------------
195191
Executable Directory
196192
----------------------
@@ -221,34 +217,35 @@ Packages Correspond to Tools
221217

222218
+ Not by users
223219

224-
.. columns::
225-
226-
.. column::
227-
228-
* Analyzer
229-
* Binder
230-
* Builder
231-
* Check
232-
* Clean
233-
* Compiler
234-
* Cross_Reference
235-
* Documentation
236-
* Eliminate
237-
* Finder
238-
* Gnatls
239-
240-
.. column::
241-
242-
* Gnatstub
243-
* IDE
244-
* Install
245-
* Linker
246-
* Metrics
247-
* Naming
248-
* Pretty_Printer
249-
* Remote
250-
* Stack
251-
* Synchronize
220+
.. list-table::
221+
222+
* - Analyzer
223+
- Binder
224+
- Builder
225+
226+
* - Check
227+
- Clean
228+
- Compiler
229+
230+
* - Cross_Reference
231+
- Documentation
232+
- Eliminate
233+
234+
* - Finder
235+
- Gnatls
236+
- Gnatstub
237+
238+
* - IDE
239+
- Install
240+
- Linker
241+
242+
* - Metrics
243+
- Naming
244+
- Pretty_Printer
245+
246+
* - Remote
247+
- Stack
248+
- Synchronize
252249

253250
-----------------------
254251
Setting Tool Switches
@@ -294,8 +291,7 @@ Rationale
294291

295292
+ Third-party libraries
296293
+ Legacy code used different compiler
297-
298-
+ Changing filenames would make tracking changes harder
294+
+ Changing filenames would make tracking changes harder
299295

300296
----------------------------
301297
Source File Naming Schemes
@@ -305,13 +301,12 @@ Source File Naming Schemes
305301

306302
+ Other than GNAT default convention
307303

308-
+ May be applied to all source files in a project
309-
310-
+ Specified in a package named :ada:`Naming`
304+
+ Specified in a package named :ada:`Naming`
311305

312-
+ May be applied to specific files in a project
306+
+ May be applied to all source files in a project
307+
+ May be applied to specific files in a project
313308

314-
+ Individual attribute specifications
309+
+ Individual attribute specifications
315310

316311
-------------------------------------
317312
Foreign Default File Naming Example
@@ -377,11 +372,11 @@ Individual (Arbitrary) File Naming
377372

378373
+ Has distinct attributes for specs and bodies
379374

380-
:ada:`for Spec ("<unit name>") use "<filename>"`
375+
+ Syntax: *for Spec ("<Ada unit name>") use "<filename>";*
381376

382-
:ada:`for Spec ("MyPack.MyChild") use "MMS1AF32.A";`
377+
:ada:`for Spec ("MyPack.MyChild") use "MMS1AF32.A";`
383378

384-
:ada:`for Body ("MyPack.MyChild") use "MMS1AF32.B";`
379+
:ada:`for Body ("MyPack.MyChild") use "MMS1AF32.B";`
385380

386381
======================================
387382
Variables for Conditional Processing
@@ -442,13 +437,13 @@ External and Conditional References
442437

443438
+ Command line switch
444439

445-
:command:`gprbuild -P... -Xname=value ...`
440+
+ Syntax: *gprbuild -P... -Xname=value ...*
446441

447-
.. container:: latex_environment footnotesize
442+
.. container:: latex_environment footnotesize
448443

449-
:command:`gprbuild -P common/build.gpr -Xtarget=test common/main.adb`
444+
:command:`gprbuild -P common/build.gpr -Xtarget=test common/main.adb`
450445

451-
+ **Note:** Command line values override environment variables
446+
.. note:: Command line values override environment variables
452447

453448
----------------------------------------
454449
External/Conditional Reference Example

courses/gnat_project_facility/040_structuring_your_application.rst

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ Project Import Notation
120120
end MyApp;
121121
122122
-----------------------
123-
GPRBuild search paths
123+
GPRbuild search paths
124124
-----------------------
125125

126126
GPR with **relative** paths are searched
@@ -135,9 +135,8 @@ GPR with **relative** paths are searched
135135
* List of directories, separated by PATH-like (``:``, ``;``) separator
136136

137137
+ ``GPR_PROJECT_PATH``
138-
+ ``ADA_PROJECT_PATH`` (deprecated)
139138

140-
- From the current toolchain's install dir
139+
- From the current toolchain's installation directory
141140

142141
* Can be target-specific
143142
* Can be runtime-specific
@@ -223,13 +222,13 @@ Referencing Imported Content
223222
224223
+ Project P uses all the compiler switches in project Foo and adds ``-gnatwa``
225224

226-
+ *Note: in GPR files, "&" can be used to concatenate string lists and string*
225+
.. note:: in GPR files, "&" can be used to concatenate string lists and strings
227226

228227
----------
229228
Renaming
230229
----------
231230

232-
+ Packages can rename (imported) packages
231+
+ Packages can rename imported packages
233232
+ Effect is as if the package is declared locally
234233

235234
+ Much like the Ada language
@@ -257,29 +256,29 @@ Project Source Code Dependencies
257256
with Hmi.Controls;
258257
package body Nav.Engine is
259258
Global_Speed : Speed_T := 0.0;
260-
procedure Increase_Speed (Change : Speed_Delta_T) is
261-
Max_Change : Speed_T := Global_Speed * 0.10;
259+
procedure Increase
260+
(Change : Speed_Delta_T) is
262261
begin
263-
Global_Speed :=
264-
Global_Speed + Speed_T'max (Speed_T (Change),
265-
Max_Change);
266-
Hmi.Controls.Display_Speed (Global_Speed);
267-
end Increase_Speed;
262+
Global_Speed := Global_Speed + Change;
263+
Hmi.Controls.Display (Global_Speed);
264+
end Increase;
268265
end Nav.Engine;
269266
270267
+ In the :ada:`HMI` project
271268

272269
.. code:: Ada
273270
274271
package body Hmi.Controls is
275-
procedure Display_Speed (Speed : Nav.Engine.Speed_T) is
272+
procedure Display
273+
(Speed : Nav.Engine.Speed_T) is
276274
begin
277-
Display_Speed_On_Console (Speed);
278-
end Display_Speed;
279-
procedure Change_Speed (Speed_Change : Nav.Engine.Speed_Delta_T) is
275+
Display_On_Console (Speed);
276+
end Display;
277+
procedure Change
278+
(Speed_Change : Nav.Engine.Speed_Delta_T) is
280279
begin
281-
Nav.Engine.Increase_Speed (Speed_Change);
282-
end Change_Speed;
280+
Nav.Engine.Increase (Speed_Change);
281+
end Change;
283282
end Hmi.Controls;
284283
285284
----------------------
@@ -394,6 +393,26 @@ Extending Projects
394393

395394
+ Hierarchies permitted
396395

396+
-------------------
397+
Project Extension
398+
-------------------
399+
400+
.. code:: Ada
401+
402+
project Child extends "parent.gpr" is
403+
404+
+ New project :ada:`Child` inherits everything from :ada:`Parent`
405+
406+
+ Except whatever new source/properties are specified in :ada:`Child`
407+
408+
+ When compiling project :ada:`Child`
409+
410+
+ Source files in :ada:`Child` get compiled into its object directory
411+
+ For source files in :ada:`Parent` that are not overridden in :ada:`Child`
412+
413+
+ If the source file is compiled into the :ada:`Parent` object directory, that file is considered compiled
414+
+ If the source file is not compiled into the :ada:`Parent` object directory, that file will be compiled into the :ada:`Child` object directory
415+
397416
------------------------------
398417
Limits on Extending Projects
399418
------------------------------

courses/gnat_project_facility/labs/020_building_with_gprbuild.lab.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--------------
2-
Start GPRBuild
2+
Start GPRbuild
33
--------------
44

55
* Open a command shell

0 commit comments

Comments
 (0)