Skip to content

Commit 7a726b4

Browse files
authored
Merge pull request #109 from godunko/master
Add option to use `No_Elaboration_Code_All` pragma.
2 parents ab0b7af + 576884b commit 7a726b4

File tree

4 files changed

+58
-27
lines changed

4 files changed

+58
-27
lines changed

src/ada_gen.adb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,7 @@ package body Ada_Gen is
11161116
G_Empty_Line := True;
11171117

11181118
if Spec.Preelaborated then
1119-
if not SVD2Ada_Utils.In_Runtime then
1119+
if not SVD2Ada_Utils.No_Elaboration_Code_All then
11201120
-- When part of the runtime, we need the more strict
11211121
-- No_Elaboration_Code_All
11221122
Ada.Text_IO.Put_Line
@@ -1172,7 +1172,7 @@ package body Ada_Gen is
11721172
if Spec.Preelaborated then
11731173
Ada.Text_IO.Put_Line
11741174
(F, " pragma Preelaborate;");
1175-
if SVD2Ada_Utils.In_Runtime then
1175+
if SVD2Ada_Utils.No_Elaboration_Code_All then
11761176
Ada.Text_IO.Put_Line
11771177
(F, " pragma No_Elaboration_Code_All;");
11781178
end if;

src/svd2ada.adb

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
-- --
33
-- SVD Binding Generator --
44
-- --
5-
-- Copyright (C) 2015-2020, AdaCore --
5+
-- Copyright (C) 2015-2024, AdaCore --
66
-- --
77
-- SVD2Ada is free software; you can redistribute it and/or modify it --
88
-- under terms of the GNU General Public License as published by the Free --
@@ -67,21 +67,22 @@ procedure SVD2Ada is
6767
Executable_Location);
6868

6969
-- The generated Device
70-
Device : Descriptors.Device.Device_T;
71-
SVD_File_Name : Unbounded_String;
70+
Device : Descriptors.Device.Device_T;
71+
SVD_File_Name : Unbounded_String;
7272

7373
-- Command line parser and switches/arguments
74-
Cmd_Line_Cfg : GNAT.Command_Line.Command_Line_Configuration;
75-
Root_Pkg_Name : aliased GNAT.Strings.String_Access;
76-
Output_Dir : aliased GNAT.Strings.String_Access;
77-
Base_Types_Pkg : aliased GNAT.Strings.String_Access;
78-
Gen_Booleans : aliased Boolean := False;
79-
Gen_UInt_Always : aliased Boolean := False;
80-
No_UInt_Subtype : aliased Boolean := False;
81-
No_Arrays : aliased Boolean := False;
82-
No_Defaults : aliased Boolean := False;
83-
No_VFA_On_Types : aliased Boolean := False;
84-
Gen_IRQ_Support : aliased Boolean := False;
74+
Cmd_Line_Cfg : GNAT.Command_Line.Command_Line_Configuration;
75+
Root_Pkg_Name : aliased GNAT.Strings.String_Access;
76+
Output_Dir : aliased GNAT.Strings.String_Access;
77+
Base_Types_Pkg : aliased GNAT.Strings.String_Access;
78+
Gen_Booleans : aliased Boolean := False;
79+
Gen_UInt_Always : aliased Boolean := False;
80+
No_UInt_Subtype : aliased Boolean := False;
81+
No_Arrays : aliased Boolean := False;
82+
No_Defaults : aliased Boolean := False;
83+
No_VFA_On_Types : aliased Boolean := False;
84+
Gen_IRQ_Support : aliased Boolean := False;
85+
No_Elab_Code_All : aliased Boolean := False;
8586

8687
use type GNAT.Strings.String_Access;
8788

@@ -177,6 +178,12 @@ procedure SVD2Ada is
177178
-- register record type when those fields are
178179
-- themselves represented as register types
179180
Value => True);
181+
Define_Switch
182+
(Cmd_Line_Cfg,
183+
Output => No_Elab_Code_All'Access,
184+
Long_Switch => "--no-elaboration-code-all",
185+
Help => "use pragma No_Elaboration_Code_All",
186+
Value => True);
180187
end Configure_Command_Line;
181188

182189
------------------------
@@ -202,6 +209,7 @@ procedure SVD2Ada is
202209
Set_No_Defaults (No_Defaults);
203210
Set_No_UInt_Subtype (No_UInt_Subtype);
204211
Set_No_VFA_On_Reg_Types (No_VFA_On_Types);
212+
Set_No_Elaboration_Code_All (No_Elab_Code_All);
205213

206214
if Base_Types_Pkg.all /= "" then
207215
Set_Base_Types_Package (Base_Types_Pkg.all);

src/svd2ada_utils.adb

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
-- --
33
-- SVD Binding Generator --
44
-- --
5-
-- Copyright (C) 2015-200, AdaCore --
5+
-- Copyright (C) 2015-2004, AdaCore --
66
-- --
77
-- SVD2Ada is free software; you can redistribute it and/or modify it --
88
-- under terms of the GNU General Public License as published by the Free --
@@ -25,15 +25,16 @@ with GNAT.OS_Lib; use GNAT.OS_Lib;
2525

2626
package body SVD2Ada_Utils is
2727

28-
G_Use_Boolean : Boolean := False;
29-
G_Types_Pkg : Unbounded_String := Null_Unbounded_String;
30-
G_Root_Pkg : Unbounded_String := Null_Unbounded_String;
31-
G_Use_UInt : Boolean := False;
32-
G_Gen_Arrays : Boolean := True;
33-
G_No_VFA_On_Reg_Types : Boolean := False;
34-
G_Gen_IRQ_Support : Boolean := False;
35-
G_Gen_UInt_Subtype : Boolean := True;
36-
G_Gen_Fields_Default : Boolean := True;
28+
G_Use_Boolean : Boolean := False;
29+
G_Types_Pkg : Unbounded_String := Null_Unbounded_String;
30+
G_Root_Pkg : Unbounded_String := Null_Unbounded_String;
31+
G_Use_UInt : Boolean := False;
32+
G_Gen_Arrays : Boolean := True;
33+
G_No_VFA_On_Reg_Types : Boolean := False;
34+
G_Gen_IRQ_Support : Boolean := False;
35+
G_Gen_UInt_Subtype : Boolean := True;
36+
G_Gen_Fields_Default : Boolean := True;
37+
G_No_Elaboration_Code_All : Boolean := False;
3738

3839
function Installation_Dir (Exec_with_Path : String) return String;
3940
-- Exec_with_Path is the executable name preceeded by the absolute or
@@ -383,4 +384,22 @@ package body SVD2Ada_Utils is
383384
or else Word = "with"
384385
or else Word = "xor");
385386

387+
-----------------------------
388+
-- No_Elaboration_Code_All --
389+
-----------------------------
390+
391+
function No_Elaboration_Code_All return Boolean is
392+
begin
393+
return In_Runtime or G_No_Elaboration_Code_All;
394+
end No_Elaboration_Code_All;
395+
396+
---------------------------------
397+
-- Set_No_Elaboration_Code_All --
398+
---------------------------------
399+
400+
procedure Set_No_Elaboration_Code_All (Value : Boolean) is
401+
begin
402+
G_No_Elaboration_Code_All := Value;
403+
end Set_No_Elaboration_Code_All;
404+
386405
end SVD2Ada_Utils;

src/svd2ada_utils.ads

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
-- --
33
-- SVD Binding Generator --
44
-- --
5-
-- Copyright (C) 2015-2020, AdaCore --
5+
-- Copyright (C) 2015-2024, AdaCore --
66
-- --
77
-- SVD2Ada is free software; you can redistribute it and/or modify it --
88
-- under terms of the GNU General Public License as published by the Free --
@@ -49,6 +49,10 @@ package SVD2Ada_Utils is
4949

5050
function In_Runtime return Boolean;
5151

52+
function No_Elaboration_Code_All return Boolean;
53+
54+
procedure Set_No_Elaboration_Code_All (Value : Boolean);
55+
5256
procedure Set_No_VFA_On_Reg_Types (Value : Boolean);
5357

5458
function No_VFA_On_Reg_Types return Boolean;

0 commit comments

Comments
 (0)