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

Add buildsupport code

parents
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
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
Version".
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
version:
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
document.
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
document.
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
Version.
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
Library.
GCCVERSION := $(shell gcc -v 2>&1 | grep ada | wc -l)
UNAME := $(shell uname)
VERSION=0.1
exec = buildsupport
sources = $(wildcard ada/*.ad? c/*.c include/*.h)
all: checkVersion $(exec)
checkVersion:
#ifeq ($(UNAME),Linux)
# @if [ $(GCCVERSION) -ne 1 ] ; then echo gcc must point to GNAT... check your PATH ; exit 1 ; fi
#endif
$(exec): $(sources)
ifeq ($(UNAME), Linux)
@echo "package buildsupport_version is" > ada/buildsupport_version.ads.new
@echo -n "buildsupport_release : constant string := \"" >> ada/buildsupport_version.ads.new
@svnversion -n . >> ada/buildsupport_version.ads.new
@echo "\";" >> ada/buildsupport_version.ads.new
@echo -n "end buildsupport_version;" >> ada/buildsupport_version.ads.new
@if [ ! -f "ada/buildsupport_version.ads" ] ; then \
mv ada/buildsupport_version.ads.new ada/buildsupport_version.ads; \
else \
MD1=`cat ada/buildsupport_version.ads | md5sum` ; \
MD2=`cat ada/buildsupport_version.ads.new | md5sum` ; \
if [ "$$MD1" != "$$MD2" ] ; then \
mv ada/buildsupport_version.ads.new ada/buildsupport_version.ads ; \
else \
rm ada/buildsupport_version.ads.new ; \
fi ; \
fi
endif
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)
install:
cp buildsupport `ocarina-config --prefix`/bin/
cp misc/driveGnuPlotsStreams.pl `ocarina-config --prefix`/bin/
clean:
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/driveGnuPlotsStreams.pl tmp/buildsupport-$(VERSION)/misc/driveGnuPlotsStreams.pl
( 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/
$(MAKE)
cp -f buildsupport tmp/buildsupport-`uname -m`-$(VERSION)/bin
cp -f misc/driveGnuPlotsStreams.pl 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.
This diff is collapsed.
-- *************************** buildsupport **************************** --
-- (c) 2015 European Space Agency - maxime.perrotin@esa.int
-- LGPL license, see LICENSE file
-- Set of helper functions for buildsupport
with Ocarina;
with Types;
use Ocarina;
package Buildsupport_Utils is
use Types;
procedure Banner;
procedure Usage;
procedure Exit_On_Error (Error : Boolean; Reason : String);
type Synchronism is (Sync, Async);
procedure Init;
type Supported_RCM_Operation_Kind is (Unprotected_Operation,
Protected_Operation,
Variator_Operation,
Modifier_Operation,
Cyclic_Operation,
Sporadic_Operation,
Unknown_Operation);
function Get_RCM_Operation_Kind
(E : Node_Id)
return Supported_RCM_Operation_Kind;
function Get_RCM_Operation (E : Node_Id) return Node_Id;
function Get_RCM_Period (D : Node_Id) return Unsigned_Long_Long;
function Get_APLC_Binding (E : Node_Id) return List_Id;
type Supported_ASN1_Encoding is (Default, Native, UPER, ACN);
function Get_ASN1_Encoding (E : Node_Id) return Supported_ASN1_Encoding;
type Supported_ASN1_Basic_Type is (ASN1_Sequence,
ASN1_SequenceOf,
ASN1_Enumerated,
ASN1_Set,
ASN1_SetOf,
ASN1_Integer,
ASN1_Boolean,
ASN1_Real,
ASN1_OctetString,
ASN1_Choice,
ASN1_String,
ASN1_Unknown);
function Get_ASN1_Basic_Type (E : Node_Id) return Supported_ASN1_Basic_Type;
function Get_Ada_Package_Name (D : Node_Id) return Name_Id;
function Get_Ellidiss_Tool_Version (D : Node_Id) return Name_Id;
function Get_Interface_Name (D : Node_Id) return Name_Id;
function Get_ASN1_Module_Name (D : Node_Id) return String;
end Buildsupport_Utils;
This diff is collapsed.
with "ocarina";
project BuildSupport is
for Source_Dirs use ("ada", "c", "include");
for Object_Dir use "tmpBuild";
for Exec_Dir use ".";
for Main use ("buildsupport.adb");
for Languages use ("Ada", "C");
for Source_Files use ("c_backend.c", "sdl_gateway.c", "my_types.h",
"build_sdl_glue.c", "imported_routines.ads", "buildsupport.adb",
"buildsupport_utils.ads", "buildsupport_utils.adb",
"simulink_gateway.c");
package Builder is
for Default_Switches ("ada") use ("-m");
end Builder;
package binder is
for default_switches ("Ada") use ("-E", "-t", "-static");
end binder;
package Compiler is
for Default_Switches ("Ada") use
("-g",
"-gnat05",
"-gnatf",
"-gnaty",
-- "-gnatwa",
"-gnatoa",
"-gnatg",
"-fstack-check");
for Default_Switches ("C") use ("-g");
end Compiler;
end BuildSupport;
/* Buildsupport is (c) 2008-2015 European Space Agency
* contact: maxime.perrotin@esa.int
* License is LGPL, check LICENSE file */
/*
* AADL Concurrency view "Unparser"
* Generate an interface view AADL file containing the results of the vertical transformation
*
*/
/* TODO : (1) add deadlines
(2) add correct WCET
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <assert.h>
#include <stdbool.h>
#include "my_types.h"
#include "practical_functions.h"
#include "c_ast_construction.h"
void AADL_CV_Unparser ()
{
System *ast = get_system_ast ();
FILE *aadl = NULL;
int x0 = -200,
x1 = 0,
y0 = 200,
y1 = 0,
max_y1 = 0;
Interface_list *all_interfaces = NULL;
create_file (OUTPUT_PATH, "Concurrency-View.aadl", &aadl);
assert (NULL != aadl);
/* AADL file preamble */
fprintf (aadl, "-- TASTE - Warning: This is NOT the real Concurrency view --\n");
fprintf (aadl, "-- This file was automatically generated and should remain read-only\n");
fprintf (aadl, "-- Open it with TASTE-IV\n");
fprintf (aadl, "-- The only intended use of this file is visualization - not processing.\n");
fprintf (aadl, "\npackage generated_cv::IV::ConcurrencyView\n");
fprintf (aadl, "public\n");
fprintf (aadl, "with dataview; \nwith exportedComponent::FV;\nwith taste;\n\n");
/* Insert a comment in the AADL file for graphical display */
fprintf (aadl, " --{ interfaceview obj6480 10 10\n");
fprintf (aadl, " --TASTE-generated concurrency view\n");
fprintf (aadl, " --For visualization purposes.\n");
fprintf (aadl, " --}\n\n");
fprintf (aadl, " system exportedComponent\n end exportedComponent;\n\n");
fprintf (aadl, " system implementation exportedComponent.others\n subcomponents\n");
/* Declare each subsystem */
FOREACH (fv, FV, ast->functions, {
fprintf (aadl, "\t%s : system interfaceview::IV::%s%s.others;\n",
fv->name,
thread_runtime == fv->runtime_nature ? "THREAD_" : "PASSIVE_",
fv->name);
});
/* Declare all system-level connections */
fprintf (aadl, " connections\n");
FOREACH (fv, FV, ast->functions, {
char *fv_name = NULL;
fv_name = make_string ("%s%s",
thread_runtime == fv->runtime_nature ? "THREAD_" : "PASSIVE_",
fv->name);
FOREACH (interface, Interface, fv->interfaces, {
if (RI == interface->direction) {
FV *distant_fv = NULL;
char *distant_fv_name = NULL;
FOREACH (function, FV, ast->functions, {
if (!strcmp (function->name, interface->distant_fv))
distant_fv = function;
});
if (NULL != distant_fv) {
distant_fv_name = make_string ("%s%s",
thread_runtime == distant_fv->runtime_nature ? "THREAD_" : "PASSIVE_",
distant_fv->name);
fprintf (aadl, "\t%s_%s : subprogram access %s.%s -> %s.%s;\n",
RCM_KIND(interface),
interface->distant_name,
distant_fv_name,
interface->distant_name,
fv_name,
interface->name);
free (distant_fv_name);
}
}
});
free (fv_name);
})
fprintf (aadl, " end exportedComponent.others;\n\n");
/* Define each individual subsystem and its implementation */
FOREACH (fv, FV, ast->functions, {
char *fv_name = NULL;
int nb_pi = 0;
int nb_ri = 0;
int if_x = 0;
int if_y_pi = 0;
int if_y_ri = 0;
/* Compute size and coordinated of subsystems */
FOREACH (interface, Interface, fv->interfaces, {
if (PI == interface->direction) nb_pi ++;
else nb_ri ++;
});
if (nb_ri > nb_pi) nb_pi = nb_ri;
x0 += 400;
if (x0 > 2200) {
x0 = 200;
y0 = 200 + max_y1 + 100;
}
x1 = x0 + 250;
y1 = y0 + (nb_pi*45);
if (y1 > max_y1) max_y1 = y1;
fv_name = make_string ("%s%s",
thread_runtime == fv->runtime_nature ? "THREAD_" : "PASSIVE_",
fv->name);
fprintf (aadl, " system %s\n features\n",
fv_name);
if_y_pi = y0 - 30;
if_y_ri = y0 - 30;
FOREACH (interface, Interface, fv->interfaces, {
int if_y = 0;
if (PI == interface->direction) {
if_x = x0;
if_y_pi = if_y_pi + 45;
if_y = if_y_pi;
}
else {
if_x = x1;
if_y_ri = if_y_ri + 45;
if_y = if_y_ri;
}
ADD_TO_SET (Interface, all_interfaces, interface);
fprintf (aadl, "\t%s : %s subprogram access exportedComponent::fv::%s.others\n",
interface->name,
PI == interface->direction ? "provides" : "requires",
NULL != interface->distant_name ?
interface->distant_name:interface->name);
fprintf (aadl, "\t { taste::Coordinates => \"%d %d %d %d\";\n",
if_x,
if_y,
if_x,
if_y);
fprintf (aadl, "\t taste::RCMoperationKind => %s;\n",
RCM_KIND(interface));
fprintf (aadl, "\t taste::RCMperiod => %lld;",
interface->period);
fprintf (aadl, "};\n");
/* TODO add deadline */
});
fprintf (aadl, " properties\n\tsource_language => C;\n");
fprintf (aadl, "\ttaste::coordinates => \"%d %d %d %d\";\n",
x0,
y0,
x1,
y1);
fprintf (aadl, "\ttaste::instance_name => \"%s\";\n",
fv->name);
fprintf (aadl, " end %s;\n\n",
fv_name);
/* Then the system implementation */
fprintf (aadl, " system implementation %s.others\n",
fv_name);
fprintf (aadl, " subcomponents\n");
FOREACH (interface, Interface, fv->interfaces, {
fprintf (aadl, "\t%s_impl : subprogram exportedComponent::FV::%s.others\n",
interface->name,
NULL != interface->distant_name ? interface->distant_name : interface->name);
fprintf (aadl, "\t { compute_execution_time => 0ms..0ms;};\n");
});
fprintf (aadl, " connections\n");
FOREACH (interface, Interface, fv->interfaces, {
fprintf (aadl, "\tsubprogram access %s_impl -> %s;\n",
interface->name,
interface->name);
});
fprintf (aadl, " end %s.others;\n\n",
fv_name);
free (fv_name);
});
fprintf (aadl, "properties\n");
fprintf (aadl, " taste::coordinates => \"0 0 2970 2100\";\n\n");
fprintf (aadl, "end generated_cv::IV;\n\n");
/* Functional view */
fprintf (aadl, "package exportedComponent::FV\npublic\n");
fprintf (aadl, "with dataview;\nwith taste;\n\n");
FOREACH (interface, Interface, all_interfaces, {
fprintf (aadl, " subprogram %s\n end %s;\n\n",
NULL != interface->distant_name ? interface->distant_name : interface->name,
NULL != interface->distant_name ? interface->distant_name : interface->name);
});
fprintf (aadl, "end exportedComponent::FV;\n");
close_file (&aadl);
}
This diff is collapsed.
/* Buildsupport is (c) 2008-2015 European Space Agency
* contact: maxime.perrotin@esa.int
* License is LGPL, check LICENSE file */
/*
* Call 'asn2dataModel.py' tool to complete the generation
* of function skeleton with the data types transformed
* from ASN.1 to the target language (C, Ada, RTDS, etc.).
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <assert.h>
#include <stdbool.h>
#include <errno.h>
#include "my_types.h"
#include "practical_functions.h"
#include "c_ast_construction.h"
void Print_ASN1_Filename(ASN1_Filename * f)
{
printf("%s", f);
}
void Call_asn2dataModel(FV * fv)
{
//bool hasparam = false;
char *command = NULL;
char *dataviewpath = NULL;
int ret = 0;
/* There is no A mapper for VHDL/SystemC/GUI */
if (vhdl == fv->language || system_c == fv->language
|| gui == fv->language)
return;
/* check if there is at least one parameter in one interface */
// Removed - generate data types in any case so that user code
// can have local variables...
//FOREACH(i, Interface, fv->interfaces, {
// if (NULL != i->in || NULL != i->out) hasparam = true;}
//);
//if (false == hasparam)
// return;
dataviewpath = make_string("%s/%s", OUTPUT_PATH, fv->name);
/*
* In case of "native" languages, place the result in a subdirectory
* called "dataview", so that the code is not mixed up with user code
*/
if (c == fv->language
|| cpp == fv->language
|| qgenada == fv->language
|| qgenc == fv->language
|| ada == fv->language || blackbox_device == fv->language) {
build_string(&dataviewpath, "/dataview", strlen("/dataview"));
}
ret = mkdir(dataviewpath, 0700);
if (-1 == ret) {
switch (errno) {
case EEXIST:
break;
default:
ERROR("Error creating directory %s\n", dataviewpath);
add_error();
return;
break;
}
}
char *dataview_uniq = getASN1DataView();
char *dataview_path = getDataViewPath();
if (!file_exists(dataview_path, dataview_uniq)) {
printf
("[Information] %s/%s not found. Checking for dataview-uniq.asn\n",
dataview_path, dataview_uniq);
free(dataview_uniq);
dataview_uniq = make_string("dataview-uniq.asn");
}
if (!file_exists(dataview_path, dataview_uniq)) {
ERROR("** Error: %s/%s not found\n", dataview_path, dataview_uniq);
exit(-1);
}
command = make_string("asn2dataModel.py -o %s -to%s %s/%s",
dataviewpath,
LANGUAGE(fv), dataview_path, dataview_uniq);
free(dataview_uniq);
free(dataview_path);
if (system(command)) {
ERROR
("** Error: Check this command line and make sure all files are valid:\n%s\n", command);
exit(-1);
}
free(command);
free(dataviewpath);
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.