ocarina-backends-po_hi_ada.adb 23.6 KB
Newer Older
1 2 3 4 5 6 7 8
------------------------------------------------------------------------------
--                                                                          --
--                           OCARINA COMPONENTS                             --
--                                                                          --
--           O C A R I N A . B A C K E N D S . P O _ H I _ A D A            --
--                                                                          --
--                                 B o d y                                  --
--                                                                          --
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
--    Copyright (C) 2008-2009 Telecom ParisTech, 2010-2015 ESA & ISAE.      --
--                                                                          --
-- Ocarina  is free software; you can redistribute it and/or modify under   --
-- terms of the  GNU General Public License as published  by the Free Soft- --
-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
-- sion. Ocarina is distributed in the hope that it will be useful, but     --
-- WITHOUT ANY WARRANTY; without even the implied warranty of               --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     --
--                                                                          --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception,   --
-- version 3.1, as published by the Free Software Foundation.               --
--                                                                          --
-- You should have received a copy of the GNU General Public License and    --
-- a copy of the GCC Runtime Library Exception along with this program;     --
-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
-- <http://www.gnu.org/licenses/>.                                          --
26
--                                                                          --
jhugues's avatar
jhugues committed
27 28
--                 Ocarina is maintained by the TASTE project               --
--                      (taste-users@lists.tuxfamily.org)                   --
29 30 31 32
--                                                                          --
------------------------------------------------------------------------------

with GNAT.OS_Lib;
33
with Ocarina.Output;
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
with Utils;

with Ocarina.Instances;
with Ocarina.Backends.Ada_Tree.Generator;
with Ocarina.Backends.Expander;
with Ocarina.Backends.Messages;
with Ocarina.Backends.Properties;
with Ocarina.Backends.PO_HI_Ada.Runtime;
with Ocarina.Backends.PO_HI_Ada.Naming;
with Ocarina.Backends.PO_HI_Ada.Marshallers;
with Ocarina.Backends.PO_HI_Ada.Deployment;
with Ocarina.Backends.PO_HI_Ada.Activity;
with Ocarina.Backends.PO_HI_Ada.Subprograms;
with Ocarina.Backends.PO_HI_Ada.Transport;
with Ocarina.Backends.PO_HI_Ada.Types;
with Ocarina.Backends.PO_HI_Ada.Main;
50
with Ocarina.Backends.ASN1;
51 52 53 54 55 56

with Ocarina.Backends.Utils;
with Ocarina.Backends.Build_Utils;
with Ocarina.Backends.Execution_Utils;
with Ocarina.Backends.Execution_Tests;

57
with Ocarina.Namet; use Ocarina.Namet;
58 59 60 61

package body Ocarina.Backends.PO_HI_Ada is

   use GNAT.OS_Lib;
62
   use Ocarina.Output;
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
   use Ocarina.Instances;
   use Ocarina.Backends.Ada_Tree.Generator;
   use Ocarina.Backends.Expander;
   use Ocarina.Backends.Messages;
   use Ocarina.Backends.PO_HI_Ada.Runtime;
   use Ocarina.Backends.Utils;
   use Ocarina.Backends.Properties;
   use Ocarina.Backends.Build_Utils;
   use Ocarina.Backends.Execution_Utils;
   use Ocarina.Backends.Execution_Tests;

   procedure Visit_Architecture_Instance (E : Node_Id);
   --  Most top level visitor routine. E is the root of the AADL
   --  instance tree. The procedure does a traversal for each
   --  compilation unit to be generated.

   procedure PolyORB_HI_Ada_Makefile
80 81 82
     (Appli_Name              : Name_Id;
      Node_Name               : Name_Id;
      Execution_Platform      : Supported_Execution_Platform := Platform_None;
83
      Execution_Platform_Name : Name_Id;
84 85
      USER_CFLAGS             : Name_Id;
      USER_LDFLAGS            : Name_Id;
86 87 88 89 90 91 92 93 94 95 96 97
      Transport_API           : Supported_Transport_APIs;
      Ada_Sources             : Name_Tables.Instance;
      Asn_Sources             : Name_Tables.Instance;
      C_Sources               : Name_Tables.Instance;
      C_Libraries             : Name_Tables.Instance;
      User_Source_Dirs        : Name_Tables.Instance;
      Use_Transport           : Boolean;
      Use_Simulink            : Boolean;
      Simulink_Directory      : Name_Id;
      Simulink_Node           : Name_Id;
      Use_Scade               : Boolean;
      Scade_Directory         : Name_Id);
98 99 100 101 102 103 104 105 106

   --  Generate the part of the Makefile that is specific to the
   --  corresponding code generator.

   procedure PolyORB_HI_Ada_Ada_Project_File
     (Appli_Name         : Name_Id;
      Node_Name          : Name_Id;
      Is_Server          : Boolean;
      Execution_Platform : Supported_Execution_Platform;
107
      Ada_Runtime        : Name_Id;
108 109 110 111 112 113 114
      Transport_API      : Supported_Transport_APIs;
      Spec_Names         : Name_Tables.Instance;
      Custom_Spec_Names  : Name_Tables.Instance;
      Body_Names         : Name_Tables.Instance;
      Custom_Body_Names  : Name_Tables.Instance;
      User_Source_Dirs   : Name_Tables.Instance);

115 116 117 118 119 120 121 122 123 124 125
   --------------------------
   --  Set_ASN1_Deployment --
   --------------------------

   Generate_ASN1_Deployment : Boolean := False;

   procedure Set_ASN1_Deployment (Use_It : Boolean) is
   begin
      Generate_ASN1_Deployment := Use_It;
   end Set_ASN1_Deployment;

126 127 128 129 130
   -----------------------------
   -- PolyORB_HI_Ada_Makefile --
   -----------------------------

   procedure PolyORB_HI_Ada_Makefile
131 132 133
     (Appli_Name              : Name_Id;
      Node_Name               : Name_Id;
      Execution_Platform      : Supported_Execution_Platform := Platform_None;
134
      Execution_Platform_Name : Name_Id;
135 136
      USER_CFLAGS             : Name_Id;
      USER_LDFLAGS            : Name_Id;
137 138 139 140 141 142 143 144 145 146 147 148
      Transport_API           : Supported_Transport_APIs;
      Ada_Sources             : Name_Tables.Instance;
      Asn_Sources             : Name_Tables.Instance;
      C_Sources               : Name_Tables.Instance;
      C_Libraries             : Name_Tables.Instance;
      User_Source_Dirs        : Name_Tables.Instance;
      Use_Transport           : Boolean;
      Use_Simulink            : Boolean;
      Simulink_Directory      : Name_Id;
      Simulink_Node           : Name_Id;
      Use_Scade               : Boolean;
      Scade_Directory         : Name_Id)
149
   is
150 151 152 153 154 155 156 157 158 159 160 161 162
      pragma Unreferenced
        (Appli_Name,
         Transport_API,
         Execution_Platform_Name,
         Ada_Sources,
         C_Libraries,
         User_Source_Dirs,
         Use_Transport,
         Use_Scade,
         Scade_Directory,
         Use_Simulink,
         Simulink_Directory,
         Simulink_Node);
163 164 165 166 167 168 169 170 171 172 173 174

      Target_Prefix : String_Access := Getenv ("TARGET_PREFIX");
      Target        : String_Access;

   begin
      --  Determine the compiler that will be used. If the
      --  user did specify the target prefix by mean of the
      --  environment variable "TARGET_PREFIX" then we use
      --  its value. Otherwise, we use the default compiler
      --  name.

      case Execution_Platform is
175 176 177 178 179
         when Platform_Native |
           Platform_LINUX32   |
           Platform_LINUX64   |
           Platform_WIN32     |
           Platform_None      =>
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
            Change_If_Empty (String_Ptr (Target_Prefix), "");
            Target := new String'("NATIVE");

         when Platform_LEON_ORK =>
            Change_If_Empty (String_Ptr (Target_Prefix), "sparc-elf-");
            Target := new String'("LEON_ORK");

         when Platform_LEON_GNAT =>
            Change_If_Empty (String_Ptr (Target_Prefix), "leon-elf-");
            Target := new String'("LEON_GNAT");

         when Platform_ERC32_ORK =>
            Change_If_Empty (String_Ptr (Target_Prefix), "erc32-elf-");
            Target := new String'("ERC32");

         when Platform_MARTE_OS =>
            Change_If_Empty (String_Ptr (Target_Prefix), "m");
            Target := new String'("MARTEOS");

199 200 201 202
         when Platform_GNAT_Runtime =>
            Change_If_Empty (String_Ptr (Target_Prefix), "arm-eabi-");
            Target := new String'("GNAT_Runtime");

203
         when Platform_LEON_RTEMS | Platform_LEON_RTEMS_POSIX =>
204
            --   Nothing to do: a special makefile is used for RTEMS
205 206 207
            null;

         when others =>
208 209
            raise Program_Error
              with "Unsupported platform: " & Execution_Platform'Img;
210 211
      end case;

212
      if Execution_Platform /= Platform_LEON_RTEMS
213
        and then Execution_Platform /= Platform_LEON_RTEMS_POSIX
214
      then
215 216
         Write_Line ("GNATMAKE = " & Target_Prefix.all & "gnatmake");
         Write_Line ("GNAT = " & Target_Prefix.all & "gnat");
yoogx's avatar
yoogx committed
217
         Write_Line ("CC = " & Target_Prefix.all & "gcc");
218 219 220 221 222 223
         Write_Line ("TARGET = " & Target.all);
         Write_Line ("BUILD = Debug");
         Write_Line ("CGCTRL = No");
         Free (Target_Prefix);
         Free (Target);

224 225 226 227 228 229 230
         Write_Str ("USER_CFLAGS =");
         Write_Name (USER_CFLAGS);
         Write_Eol;
         Write_Str ("USER_LDFLAGS =");
         Write_Name (USER_LDFLAGS);
         Write_Eol;

231 232 233 234 235
         --  Project file

         Write_Str ("PROJECT_FILE = ");
         Write_Name (Node_Name);
         Write_Line (".gpr");
236 237 238 239 240 241 242
         Write_Str ("ASN_SOURCES=");

         if Generate_ASN1_Deployment then
            Write_Str ("../../asn1_deployment.asn ");
         end if;

         if Length (Asn_Sources) > 0 then
243
            for J in Name_Tables.First .. Name_Tables.Last (Asn_Sources) loop
244 245 246 247 248 249
               Write_Str ("");
               Write_Name (Asn_Sources.Table (J));
               exit when J = Name_Tables.Last (Asn_Sources);
               Write_Space;
            end loop;
         end if;
250 251 252 253 254 255
         Write_Eol;

         --  The 'all' target

         Write_Str ("all:");

256 257 258 259 260 261
         --  First, process ASN.1 files

         if Length (Asn_Sources) > 0 then
            Write_Str (" generate-asn1-files");
         end if;

262 263 264 265 266 267 268 269 270 271
         --  If there are C files to be compiled, add a dependency on
         --  these files

         if Length (C_Sources) > 0 then
            Write_Str (" compile-c-files");
         end if;

         Write_Eol;

         Write_Char (ASCII.HT);
272 273 274 275 276 277 278
         Write_Line
           ("ADA_PROJECT_PATH=" &
            Standard.Utils.Quoted
              (Get_Runtime_Path ("polyorb-hi-ada") &
               Path_Separator &
               "$$ADA_PROJECT_PATH") &
            " \");
279
         Write_Char (ASCII.HT);
280 281 282
         Write_Str
           ("  $(GNATMAKE) -x -P$(PROJECT_FILE) -XTARGET=$(TARGET)" &
            " -XBUILD=$(BUILD) -XCGCTRL=$(CGCTRL) ${USER_CFLAGS}");
283 284 285 286

         --  If there are C source or C libraries, there will be more
         --  options.

287 288 289
         Write_Str
           (" -largs $(EXTERNAL_OBJECTS) ${C_OBJECTS} ${USER_LDFLAGS}");

290 291
         Write_Eol;

292 293 294 295
         --  Use gnateliim to determine which portion of code is
         --  unused and recompile the application with Eliminate
         --  pragmas. Note: gnatelim is available in GNAT GPL/Pro,
         --  but not GCC
296

297 298 299 300 301 302 303 304 305 306 307 308 309 310 311
         Write_Eol;
         Write_Line ("elim:");
         Write_Char (ASCII.HT);
         Write_Line
           ("ADA_PROJECT_PATH=" &
            Standard.Utils.Quoted
              (Get_Runtime_Path ("polyorb-hi-ada") &
               Path_Separator &
               "$$ADA_PROJECT_PATH") &
            " \");
         Write_Char (ASCII.HT);
         Write_Str ("  $(GNAT) elim -P$(PROJECT_FILE) ");
         Write_Name (Node_Name);
         Write_Str (" > local.adc");
         Write_Eol;
312

313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328
         Write_Char (ASCII.HT);
         Write_Line
           ("ADA_PROJECT_PATH=" &
            Standard.Utils.Quoted
              (Get_Runtime_Path ("polyorb-hi-ada") &
               Path_Separator &
               "$$ADA_PROJECT_PATH") &
            " \");
         Write_Char (ASCII.HT);
         Write_Str
           ("  $(GNATMAKE) -f -P$(PROJECT_FILE) -XTARGET=$(TARGET)" &
              " -XBUILD=$(BUILD) -XCGCTRL=$(CGCTRL)" &
              " -cargs -gnatec=local.adc");

         --  If there are C source or C libraries, there will be more
         --  options.
329

330 331 332
         Write_Str
           (" -largs $(EXTERNAL_OBJECTS) ${C_OBJECTS} ${USER_LDFLAGS}");
         Write_Eol;
333 334 335 336 337 338

      else
         Write_Str ("PROGRAM = ");
         Write_Name (Node_Name);
         Write_Eol;
         Write_Eol;
339 340 341 342
         Write_Line
           ("include " &
            Get_Runtime_Path ("polyorb-hi-ada") &
            "/make/Makefile.rtems_ada");
343 344
         Write_Eol;
         Write_Line
345 346 347
           ("rtems_init.o: " &
            Get_Runtime_Path ("polyorb-hi-ada") &
            "/make/rtems_init.c $(FILESYSTEM_SRCS) $(NETWORK_HFILE) ");
348 349 350
         Write_Char (ASCII.HT);
         Write_Str ("$(CC) $(CFLAGS) -I. $(CPU_CFLAGS) -c $<");
      end if;
351 352 353 354 355

      Write_Eol;
      Write_Line ("generate-asn1-files: $(ASN_SOURCES)");
      Write_Char (ASCII.HT);
      Write_Line (" asn1.exe -Ada -uPER $(ASN_SOURCES)");
356 357 358 359 360 361 362 363 364 365 366
   end PolyORB_HI_Ada_Makefile;

   -------------------------------------
   -- PolyORB_HI_Ada_Ada_Project_File --
   -------------------------------------

   procedure PolyORB_HI_Ada_Ada_Project_File
     (Appli_Name         : Name_Id;
      Node_Name          : Name_Id;
      Is_Server          : Boolean;
      Execution_Platform : Supported_Execution_Platform;
367
      Ada_Runtime        : Name_Id;
368 369 370 371 372 373 374 375 376 377
      Transport_API      : Supported_Transport_APIs;
      Spec_Names         : Name_Tables.Instance;
      Custom_Spec_Names  : Name_Tables.Instance;
      Body_Names         : Name_Tables.Instance;
      Custom_Body_Names  : Name_Tables.Instance;
      User_Source_Dirs   : Name_Tables.Instance)
   is
      pragma Unreferenced (Appli_Name, Is_Server);

   begin
378 379 380 381 382 383
      if Ada_Runtime /= No_Name then
         Write_Str ("with """);
         Write_Name (Ada_Runtime);
         Write_Line (""";");
      end if;

384 385 386 387 388
      Write_Line
        ("with """ &
         Get_Runtime_Path ("polyorb-hi-ada") &
         Directory_Separator &
         "polyorb_hi"";");
389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415

      Write_Eol;

      Write_Str ("project ");
      Write_Name (Node_Name);
      Write_Line (" is");
      Increment_Indentation;

      --  The source directory list

      Write_Indentation;
      Write_Line ("for Source_Dirs use");
      Increment_Indentation;

      Write_Indentation (-1);
      Write_Line ("(""."",");

      --  Get the PolyORB-HI/Ada runtime source directory

      Write_Indentation;
      Write_Str ("""" & Get_Runtime_Path ("polyorb-hi-ada") & """");

      --  The user provided source dirs

      if Length (User_Source_Dirs) > 0 then
         Write_Line (",");

416
         for J in Name_Tables.First .. Name_Tables.Last (User_Source_Dirs) loop
417 418 419 420 421 422 423 424 425 426 427
            Write_Indentation;
            Write_Char ('"');
            Write_Name (User_Source_Dirs.Table (J));
            Write_Char ('"');

            exit when J = Name_Tables.Last (User_Source_Dirs);

            Write_Line (",");
         end loop;
      end if;

428
      Write_Line
yoogx's avatar
yoogx committed
429 430 431 432 433
        (") & external_as_list(""" &
         "ADA_INCLUDE_PATH" &
         """, """ &
         ":" &
         """);");
434 435 436 437 438 439 440 441 442 443 444

      Decrement_Indentation;

      --  The main subprogram name

      Write_Eol;
      Write_Indentation;
      Write_Str ("for Main use (""");
      Write_Name (Node_Name);
      Write_Line (".adb"");");

445 446 447 448 449 450 451 452
      if Ada_Runtime /= No_Name then
         Write_Eol;
         Write_Indentation;
         Write_Str ("for Runtime (""Ada"") use ");
         Write_Name (Ada_Runtime);
         Write_Line ("'Runtime (""Ada"");");
      end if;

453 454 455 456 457 458 459 460 461 462 463 464 465
      --  The custom file names

      Write_Eol;
      Write_Indentation;
      Write_Line ("package Naming is");
      Increment_Indentation;

      Write_Eol;
      Write_Indentation;
      Write_Line ("--  Custom middleware file names");
      Write_Eol;

      case Execution_Platform is
466
         when Platform_LEON_ORK | Platform_LEON_GNAT | Platform_ERC32_ORK =>
467 468
            Write_Indentation;
            Write_Line
469 470
              ("for Body (""PolyORB_HI.Output_Low_Level"")" &
               " use ""polyorb_hi-output_low_level_leon.adb"";");
471

472 473 474 475 476 477
         when Platform_GNAT_Runtime =>
            Write_Indentation;
            Write_Line
              ("for Body (""PolyORB_HI.Output_Low_Level"")" &
               " use ""polyorb_hi-output_low_level_gnatruntime.adb"";");

478 479 480
         when others =>
            Write_Indentation;
            Write_Line
481 482
              ("for Body (""PolyORB_HI.Output_Low_Level"")" &
               " use ""polyorb_hi-output_low_level_native.adb"";");
483 484 485 486 487 488
      end case;

      case Transport_API is
         when Transport_BSD_Sockets =>
            Write_Indentation;
            Write_Line
489 490
              ("for Body (""PolyORB_HI.Transport_Low_Level"")" &
               " use ""polyorb_hi-transport_low_level_sockets.adb"";");
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551

         when Transport_SpaceWire =>
            raise Program_Error;

         when Transport_None =>
            --  This means the application is monolithic
            null;

         when Transport_User =>
            --  Code to be supplied by the user
            null;
      end case;

      if Length (Spec_Names) > 0 then
         Write_Eol;
         Write_Indentation;
         Write_Line ("--  Custom user spec names");
         Write_Eol;

         for J in Name_Tables.First .. Name_Tables.Last (Spec_Names) loop
            Write_Indentation;
            Write_Str ("for Specification (""");
            Write_Name (Spec_Names.Table (J));
            Write_Str (""") use """);
            Write_Name (Custom_Spec_Names.Table (J));
            Write_Line (""";");
         end loop;
      end if;

      if Length (Body_Names) > 0 then
         Write_Eol;
         Write_Indentation;
         Write_Line ("--  Custom user body names");
         Write_Eol;

         for J in Name_Tables.First .. Name_Tables.Last (Body_Names) loop
            Write_Indentation;
            Write_Str ("for Body (""");
            Write_Name (Body_Names.Table (J));
            Write_Str (""") use """);
            Write_Name (Custom_Body_Names.Table (J));
            Write_Line (""";");
         end loop;
      end if;

      Write_Eol;
      Decrement_Indentation;
      Write_Indentation;
      Write_Line ("end Naming;");
      Write_Eol;

      Write_Indentation;
      Write_Line ("package Compiler renames PolyORB_HI.Compiler;");
      Write_Indentation;
      Write_Line ("package Builder renames PolyORB_HI.Builder;");
      Write_Indentation;
      Write_Line ("package Binder renames PolyORB_HI.Binder;");
      Write_Indentation;
      Write_Line ("package Linker renames PolyORB_HI.Linker;");
      Write_Indentation;
      Write_Line ("package Check renames PolyORB_HI.Check;");
552 553
      Write_Indentation;
      Write_Line ("package Prove renames PolyORB_HI.Prove;");
554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569
      Write_Eol;

      Decrement_Indentation;
      Write_Str ("end ");
      Write_Name (Node_Name);
      Write_Line (";");
   end PolyORB_HI_Ada_Ada_Project_File;

   --------------
   -- Generate --
   --------------

   procedure Generate (AADL_Root : Node_Id) is
      Instance_Root : Node_Id;
      Success       : Boolean := True;

570 571 572
      procedure Generate_PolyORB_HI_Ada_Makefile is new Build_Utils.Makefiles
        .Generate
        (PolyORB_HI_Ada_Makefile);
573

574 575 576
      procedure Generate_PolyORB_HI_Ada_Ada_Project_File is new Build_Utils
        .Ada_Project_Files
        .Generate
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615
        (PolyORB_HI_Ada_Ada_Project_File);

   begin
      --  Instantiate the AADL tree

      Instance_Root := Instantiate_Model (AADL_Root);

      --  Expand the AADL instance

      Expand (Instance_Root);

      Visit_Architecture_Instance (Instance_Root);

      --  Abort if the construction of the Ada tree failed

      if No (Ada_Root) then
         Display_Error ("Code generation failed", Fatal => True);
      end if;

      --  At this point, we have a valid Ada tree, we can begin the
      --  Ada source file generation.

      --  Enter the output directory

      Enter_Directory (Generated_Sources_Directory);

      if not Remove_Generated_Sources then
         --  Create the source files

         Ada_Tree.Generator.Generate (Ada_Root);

         --  Generate the Makefiles

         Generate_PolyORB_HI_Ada_Makefile (Instance_Root);

         --  Generate the Ada project files

         Generate_PolyORB_HI_Ada_Ada_Project_File (Instance_Root);

616 617 618 619 620 621 622 623 624 625
         --  If we have to generate the ASN1 deployment file, then
         --  we enter the directory that contains the generated
         --  code and invoke directly the ASN1 generator with the
         --  instance root. It should automatically create an .asn1
         --  file that contains deployment/messages informations.

         if Generate_ASN1_Deployment then
            ASN1.Generate (Instance_Root);
         end if;

626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648
         --  If the user requested to build the applications then we
         --  build it.

         if Compile_Generated_Sources then
            Build_Utils.Makefiles.Build (Instance_Root);
         end if;

      else
         Build_Utils.Makefiles.Clean (Instance_Root);
      end if;

      --  If the user requested to test the applications then we
      --  test it.

      if Do_Regression_Test or else Do_Coverage_Test then
         --  Execution_Utils package initialization

         Execution_Utils.Init;
         Execution_Utils.Visit (Instance_Root);

         Execution_Tests.Init;

         if Do_Regression_Test then
649 650 651 652 653
            Success :=
              Execute_Regression_Test
                (Scenario_Dir.all,
                 Ref_Map,
                 Integer (Timeout))
654 655 656 657 658 659 660 661 662 663 664 665 666
              and then Success;

            if not Create_Referencial then
               Write_Eol;
               if Success then
                  Write_Line ("--- All regression tests PASSED ---");
               else
                  Write_Line ("--- Regression tests FAILED ---");
               end if;
            end if;
         end if;

         if Do_Coverage_Test then
667 668
            Success :=
              Execute_Coverage_Test (Integer (Timeout)) and then Success;
669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734

         end if;

         --  Free memory

         Execution_Utils.Reset;
         Execution_Tests.Reset;
         Free (Scenario_Dir);

         --  Exit if one of the tests failed

         if not Success then
            OS_Exit (1);
         end if;
      end if;

      --  Leave the output directory

      Leave_Directory;
   end Generate;

   ----------
   -- Init --
   ----------

   procedure Init is
   begin
      --  Registration of the generator

      Register_Backend ("polyorb_hi_ada", Generate'Access, PolyORB_HI_Ada);

      --  Initialize some units

      Ocarina.Backends.PO_HI_Ada.Runtime.Initialize;
   end Init;

   -----------
   -- Reset --
   -----------

   procedure Reset is
   begin
      Ocarina.Backends.PO_HI_Ada.Runtime.Reset;
   end Reset;

   ---------------------------------
   -- Visit_Architecture_Instance --
   ---------------------------------

   procedure Visit_Architecture_Instance (E : Node_Id) is
   begin
      --  Create the specs subtrees

      Deployment.Package_Spec.Visit (E);
      Naming.Package_Spec.Visit (E);
      Types.Package_Spec.Visit (E);
      Subprograms.Package_Spec.Visit (E);
      Activity.Package_Spec.Visit (E);
      Transport.Package_Spec.Visit (E);
      Marshallers.Package_Spec.Visit (E);

      --  Create the bodies subtrees

      Types.Package_Body.Visit (E);
      Subprograms.Package_Body.Visit (E);
      Transport.Package_Body.Visit (E);
yoogx's avatar
yoogx committed
735
      Activity.Package_Body.Visit (E);
736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751
      Marshallers.Package_Body.Visit (E);

      --  The main subprogram

      Main.Subprogram_Body.Visit (E);

      --  The makefiles

      Build_Utils.Makefiles.Visit (E);

      --  The Ada project files

      Build_Utils.Ada_Project_Files.Visit (E);
   end Visit_Architecture_Instance;

end Ocarina.Backends.PO_HI_Ada;