Commit 141d694b authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Add buildsupport code

Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
GCCVERSION := $(shell gcc -v 2>&1 | grep ada | wc -l)
UNAME := $(shell uname)
exec = buildsupport
sources = $(wildcard ada/*.ad? c/*.c include/*.h)
all: checkVersion $(exec)
#ifeq ($(UNAME),Linux)
# @if [ $(GCCVERSION) -ne 1 ] ; then echo gcc must point to GNAT... check your PATH ; exit 1 ; fi
$(exec): $(sources)
ifeq ($(UNAME), Linux)
@echo "package buildsupport_version is" > ada/
@echo -n "buildsupport_release : constant string := \"" >> ada/
@svnversion -n . >> ada/
@echo "\";" >> ada/
@echo -n "end buildsupport_version;" >> ada/
@if [ ! -f "ada/" ] ; then \
mv ada/ ada/; \
else \
MD1=`cat ada/ | md5sum` ; \
MD2=`cat ada/ | md5sum` ; \
if [ "$$MD1" != "$$MD2" ] ; then \
mv ada/ ada/ ; \
else \
rm ada/ ; \
fi ; \
mkdir -p tmpBuild
# We have to compile in C99 to support "long long" integers, as imposed by the "aadlinteger" type
# -Wall -Werror -Wextra -Wconversion -Wno-deprecated -Winit-self -Wsign-conversion -Wredundant-decls -Wvla -Wshadow -Wctor-dtor-privacy -Wnon-virtual-dtor -Woverloaded-virtual -Wlogical-op -Wmissing-include-dirs -Winit-self -Wpointer-arith -Wcast-qual -Wcast-align -Wold-style-cast -Wno-error=old-style-cast -Wsign-promo -Wundef
#clang -c -Wall -Werror -Iinclude c/*.c
gcc -c -W -g3 -g -Wall -Werror -Wextra -Werror=format-security -Wconversion -Wno-deprecated -Winit-self -Wsign-conversion -Wredundant-decls -Wvla -Wshadow -Wlogical-op -Wmissing-include-dirs -Winit-self -Wpointer-arith -Wcast-qual -Wcast-align -Wno-error=old-style-cast -Wundef -std=c99 -pedantic -Iinclude c/*.c
mv *.o tmpBuild/
ADA_PROJECT_PATH=`ocarina-config --prefix`/lib/gnat:$$ADA_PROJECT_PATH $(gnatpath)gnatmake -x -g $(exec) -p -P buildsupport.gpr -XBUILD="debug"
# strip $(exec)
cp buildsupport `ocarina-config --prefix`/bin/
cp misc/ `ocarina-config --prefix`/bin/
rm -rf tmpBuild
rm -f $(exec)
rm -f *~
release: clean
rm -rf tmp/ release/
mkdir release/
mkdir -p tmp/buildsupport-$(VERSION)
mkdir -p tmp/buildsupport-$(VERSION)/c
mkdir -p tmp/buildsupport-$(VERSION)/ada
mkdir -p tmp/buildsupport-$(VERSION)/include
mkdir -p tmp/buildsupport-$(VERSION)/misc
cp -f c/*.c tmp/buildsupport-$(VERSION)/c/
cp -f ada/*.ads tmp/buildsupport-$(VERSION)/ada/
cp -f ada/*.adb tmp/buildsupport-$(VERSION)/ada/
cp -f include/*.h tmp/buildsupport-$(VERSION)/include/
cp -f Makefile tmp/buildsupport-$(VERSION)/
cp -f buildsupport.gpr tmp/buildsupport-$(VERSION)/
cp -f misc/ tmp/buildsupport-$(VERSION)/misc/
( cd tmp && tar cvvfz buildsupport-$(VERSION).tar.gz buildsupport-$(VERSION) )
mv tmp/buildsupport-$(VERSION).tar.gz release/
mkdir -p tmp/buildsupport-`uname -m`-$(VERSION)/bin
mkdir -p tmp/buildsupport-`uname -m`-$(VERSION)/misc/
cp -f buildsupport tmp/buildsupport-`uname -m`-$(VERSION)/bin
cp -f misc/ tmp/buildsupport-`uname -m`-$(VERSION)/misc/
( cd tmp && tar cvvfz buildsupport-`uname -m`-$(VERSION).tgz buildsupport-`uname -m`-$(VERSION)/)
( cp -f tmp/buildsupport-`uname -m`-$(VERSION).tgz release/)
rm -rf tmp/
.PHONY: release
buildsupport is a low-level TASTE command, responsible for the generation of skeletons and some glue code.
License: LGPL (see LICENSE file)
Copyright (c) 2008-2015 European Space Agency
This diff is collapsed.
-- *************************** buildsupport **************************** --
-- (c) 2015 European Space Agency -
-- LGPL license, see LICENSE file
with Ada.Text_IO;
with GNAT.OS_Lib;
-- with Imported_Routines;
with Namet;
with Ocarina.Configuration;
with Ocarina.Instances.Queries;
with Ocarina.ME_AADL.AADL_Instances.Nodes;
with Ocarina.ME_AADL.AADL_Instances.Nutils;
with Ada.Characters.Latin_1;
package body Buildsupport_Utils is
use Ada.Text_IO;
use GNAT.OS_Lib;
use Namet;
use Ocarina.Instances.Queries;
use Ocarina.ME_AADL.AADL_Instances.Nodes;
use Ocarina.ME_AADL.AADL_Instances.Nutils;
use Ada.Characters.Latin_1;
-- Banner --
procedure Banner is
The_Banner : constant String :=
"buildsupport - contact: or "
& " "
& "Based on Ocarina: " & Ocarina.Configuration.Ocarina_Version
& " (" & Ocarina.Configuration.Ocarina_SVN_Revision & ")";
Put_Line (The_Banner);
end Banner;
-- Usage --
procedure Usage is
("Usage: buildsupport <options> otherfiles");
("Where <options> are:");
Put ("-l, --glue" & HT & HT & HT & HT);
Put_Line ("Generate glue code");
Put ("-w, --gw" & HT & HT & HT & HT);
Put_Line ("Generate code skeletons");
Put ("-j, --keep-case" & HT & HT & HT & HT);
Put_Line ("Respect the case for interface names");
Put ("-o, --output <outputDir>" & HT & HT);
Put_Line ("Root directory for the output files");
Put ("-i, --interfaceview <i_view.aadl>" & HT);
Put_Line ("The interface view in AADL");
Put ("-c, --deploymentview <d_view.aadl>" & HT);
Put_Line ("The deployment view in AADL");
Put ("-d, --dataview <dataview.aadl>" & HT & HT);
Put_Line ("The data view in AADL");
Put ("-t, --test" & HT & HT & HT & HT);
Put_Line ("Dump model information");
Put ("-g, --debug" & HT & HT & HT & HT);
Put_Line ("Generate runtime debug output");
Put ("-s, --stack <stack-value>" & HT & HT);
Put_Line ("Set the size of the stack in kbytes (default 100)");
Put ("-v, --version" & HT & HT & HT & HT);
Put_Line ("Display buildsupport version number");
Put ("-p, --polyorb-hi-c" & HT & HT & HT);
Put_Line ("Interface glue code with PolyORB-HI-C");
Put ("otherfiles" & HT & HT & HT & HT);
Put_Line ("Any other aadl file you want to parse");
Put_Line ("For example, this command will generate your application"
& " skeletons:");
Put_Line ("buildsupport -i InterfaceView.aadl -d DataView.aadl"
& " -o code --gw --keep-case");
end Usage;
-- Exit_On_Error --
procedure Exit_On_Error (Error : Boolean; Reason : String) is
if Error then
Put_Line (Reason);
-- Imported_Routines.C_End;
OS_Exit (1);
end if;
end Exit_On_Error;
-- Get_RCM_Operation_Kind --
RCM_Operation_Kind : Name_Id;
Unprotected_Name : Name_Id;
Protected_Name : Name_Id;
Variator_Name : Name_Id;
Modifier_Name : Name_Id;
Cyclic_Name : Name_Id;
Sporadic_Name : Name_Id;
function Get_RCM_Operation_Kind
(E : Node_Id) return Supported_RCM_Operation_Kind
RCM_Operation_Kind_N : Name_Id;
if Is_Defined_Enumeration_Property (E, RCM_Operation_Kind) then
:= Get_Enumeration_Property (E, RCM_Operation_Kind);
if RCM_Operation_Kind_N = Unprotected_Name then
return Unprotected_Operation;
elsif RCM_Operation_Kind_N = Protected_Name then
return Protected_Operation;
elsif RCM_Operation_Kind_N = Variator_Name then
return Variator_Operation;
elsif RCM_Operation_Kind_N = Modifier_Name then
return Modifier_Operation;
elsif RCM_Operation_Kind_N = Cyclic_Name then
return Cyclic_Operation;
elsif RCM_Operation_Kind_N = Sporadic_Name then
return Sporadic_Operation;
end if;
end if;
return Unknown_Operation;
end Get_RCM_Operation_Kind;
-- Get_RCM_Operation --
RCM_Operation : Name_Id;
function Get_RCM_Operation (E : Node_Id) return Node_Id is
if Is_Subprogram_Access (E) then
return Corresponding_Instance (E);
if Is_Defined_Property (E, RCM_Operation) then
return Get_Classifier_Property (E, RCM_Operation);
return No_Node;
end if;
end if;
end Get_RCM_Operation;
-- Get_APLC_Binding --
APLC_Binding : Name_Id;
function Get_APLC_Binding (E : Node_Id) return List_Id is
if Is_Defined_Property (E, APLC_Binding) then
return Get_List_Property (E, APLC_Binding);
return No_List;
end if;
end Get_APLC_Binding;
-- Get_RCM_Period --
RCM_Period : Name_Id;
function Get_RCM_Period (D : Node_Id) return Unsigned_Long_Long is
if Is_Defined_Integer_Property (D, RCM_Period) then
return Get_Integer_Property (D, RCM_Period);
return 0;
end if;
end Get_RCM_Period;
-- Get_Ada_Package_Name --
Ada_Package_Name : Name_id;
function Get_Ada_Package_Name (D : Node_Id) return Name_Id is
return Get_String_Property (D, Ada_Package_Name);
end Get_Ada_Package_Name;
-- Get_Ellidiss_Tool_Version --
Ellidiss_Tool_Version : Name_id;
function Get_Ellidiss_Tool_Version (D : Node_Id) return Name_Id is
return Get_String_Property (D, Ellidiss_Tool_Version);
end Get_Ellidiss_Tool_Version;
-- Get_Interface_Name --
Interface_Name : Name_id;
function Get_Interface_Name (D : Node_Id) return Name_Id is
return Get_String_Property (D, Interface_Name);
end Get_Interface_Name;
-- Get ASN.1 Module name --
ASN1_Module : Name_id;
function Get_ASN1_Module_Name (D : Node_Id) return String is
id : Name_Id := No_Name;
if Is_Defined_String_Property (D, ASN1_Module) then
id := Get_String_Property (D, ASN1_Module);
return Get_Name_String (id);
return Get_Name_String (Get_String_Name ("nomodule"));
end if;
end Get_ASN1_Module_Name;
-- Get_ASN1_Encoding --
ASN1_Encoding : Name_Id;
Native_Name : Name_Id;
UPER_Name : Name_Id;
ACN_Name : Name_Id;
function Get_ASN1_Encoding (E : Node_Id) return Supported_ASN1_Encoding is
ASN1_Encoding_N : Name_Id;
if Is_Defined_Enumeration_Property (E, ASN1_Encoding) then
ASN1_Encoding_N := Get_Enumeration_Property (E, ASN1_Encoding);
if ASN1_Encoding_N = Native_Name then
return Native;
elsif ASN1_Encoding_N = UPER_Name then
return UPER;
elsif ASN1_Encoding_N = ACN_Name then
return ACN;
end if;
end if;
Exit_On_Error (True, "ASN1 Encoding not set");
return Default;
end Get_ASN1_Encoding;
-- Get_ASN1_Basic_Type --
ASN1_Basic_Type : Name_Id;
Sequence_Name : Name_Id;
SequenceOf_Name : Name_Id;
Enumerated_Name : Name_Id;
Set_Name : Name_Id;
SetOf_Name : Name_Id;
Integer_Name : Name_Id;
Boolean_Name : Name_Id;
Real_Name : Name_Id;
OctetString_Name : Name_Id;
Choice_Name : Name_Id;
String_Name : Name_Id;
function Get_ASN1_Basic_Type
(E : Node_Id)
return Supported_ASN1_Basic_Type
ASN1_Basic_Type_N : Name_Id;
if Is_Defined_Enumeration_Property (E, ASN1_Basic_Type) then
ASN1_Basic_Type_N := Get_Enumeration_Property (E, ASN1_Basic_Type);
if ASN1_Basic_Type_N = Sequence_Name then
return ASN1_Sequence;
elsif ASN1_Basic_Type_N = SequenceOf_Name then
return ASN1_SequenceOf;
elsif ASN1_Basic_Type_N = Enumerated_Name then
return ASN1_Enumerated;
elsif ASN1_Basic_Type_N = Set_Name then
return ASN1_Set;
elsif ASN1_Basic_Type_N = SetOf_Name then
return ASN1_SetOf;
elsif ASN1_Basic_Type_N = Integer_Name then
return ASN1_Integer;
elsif ASN1_Basic_Type_N = Boolean_Name then
return ASN1_Boolean;
elsif ASN1_Basic_Type_N = Real_Name then
return ASN1_Real;
elsif ASN1_Basic_Type_N = OctetString_Name then
return ASN1_OctetString;
elsif ASN1_Basic_Type_N = Choice_Name then
return ASN1_Choice;
elsif ASN1_Basic_Type_N = String_Name then
return ASN1_String;
raise Program_Error with "Undefined choice "
& Get_Name_String (ASN1_Basic_Type_N);
end if;
end if;
Exit_On_Error (True, "Error: ASN.1 Basic type undefined!");
return ASN1_Unknown;
end Get_ASN1_Basic_Type;
-- Init --
procedure Init is
RCM_Operation_Kind :=
Get_String_Name ("taste::rcmoperationkind");
ASN1_Encoding := Get_String_Name ("taste::encoding");
:= Get_String_Name ("taste::asn1_basic_type");
RCM_Period := Get_String_Name ("taste::rcmperiod");
RCM_Operation := Get_String_Name ("taste::rcmoperation");
APLC_Binding := Get_String_Name ("taste::aplc_binding");
Ellidiss_Tool_Version := Get_String_Name ("taste::version");
Interface_Name := Get_String_Name ("taste::interfacename");
Ada_Package_Name := Get_String_Name ("taste::ada_package_name");
ASN1_Module := Get_String_Name ("deployment::asn1_module_name");
Unprotected_Name := Get_String_Name ("unprotected");
Protected_Name := Get_String_Name ("protected");
Variator_Name := Get_String_Name ("variator");
Modifier_Name := Get_String_Name ("modifier");