Commit 97e1393d authored by Maxime Perrotin's avatar Maxime Perrotin

Sync with subversion

parent 82de8cbd
Pipeline #350 skipped
......@@ -42,6 +42,7 @@ endif
# strip $(exec)
install:
$(MAKE)
cp buildsupport `ocarina-config --prefix`/bin/
cp misc/driveGnuPlotsStreams.pl `ocarina-config --prefix`/bin/
......
......@@ -580,7 +580,8 @@ procedure BuildSupport is
if Is_In (Param_I) then
Imported_Routines.C_Add_In_Param
(Get_Name_String
(Name (Identifier (Param_I))),
(Display_Name
(Identifier (Param_I))),
Len_Name,
Get_Name_String
(Get_Type_Source_Name (Asntype)),
......@@ -595,7 +596,8 @@ procedure BuildSupport is
else
Imported_Routines.C_Add_Out_Param
(Get_Name_String
(Name (Identifier (Param_I))),
(Display_Name
(Identifier (Param_I))),
Len_Name,
Get_Name_String
(Get_Type_Source_Name (Asntype)),
......@@ -1172,111 +1174,120 @@ procedure BuildSupport is
end if;
if Get_Category_Of_Component (Tmp_CI) = CC_Process then
declare
Node_Coverage : Boolean := False;
begin
if Is_Defined_Property (Tmp_CI,
"taste_dv_properties::coverageenabled")
then
Node_Coverage := Get_Boolean_Property
(Tmp_CI,
Get_String_Name ("taste_dv_properties::coverageenabled"));
if Node_Coverage then
Put_Line ("Needs Coverage");
else
Put_Line ("Needs No coverage");
end if;
end if;
CPU := Get_Bound_Processor (Tmp_CI);
Set_Str_To_Name_Buffer ("");
CPU_Name := Name
(Identifier
(Parent_Subcomponent (CPU)));
CPU_Platform := Get_Execution_Platform (CPU);
if ATN.Namespace
(Corresponding_Declaration
(CPU)) /= No_Node
then
Set_Str_To_Name_Buffer ("");
Get_Name_String
(ATN.Name
(ATN.Identifier
(ATN.Namespace
(Corresponding_Declaration (CPU)))));
Pkg_Name := Name_Find;
Imported_Routines.C_Add_Package
(Get_Name_String (Pkg_Name),
Get_Name_String (Pkg_Name)'Length);
CPU := Get_Bound_Processor (Tmp_CI);
Set_Str_To_Name_Buffer ("");
Get_Name_String (Pkg_Name);
Add_Str_To_Name_Buffer ("::");
Get_Name_String_And_Append (Name (Identifier (CPU)));
CPU_Classifier := Name_Find;
else
CPU_Classifier := Name (Identifier (CPU));
end if;
CPU_Name := Name
(Identifier
(Parent_Subcomponent (CPU)));
Imported_Routines.C_New_Processor
(Get_Name_String (CPU_Name),
Get_Name_String (CPU_Name)'Length,
Get_Name_String (CPU_Classifier),
Get_Name_String (CPU_Classifier)'Length,
Supported_Execution_Platform'Image (CPU_Platform),
Supported_Execution_Platform'Image (CPU_Platform)'Length);
CPU_Platform := Get_Execution_Platform (CPU);
Imported_Routines.C_New_Process
(Get_Name_String
(ATN.Name
(ATN.Component_Type_Identifier
(Corresponding_Declaration (Tmp_CI)))),
Get_Name_String
(ATN.Name
(ATN.Component_Type_Identifier
(Corresponding_Declaration (Tmp_CI))))'Length,
Get_Name_String (Name (Identifier (Processes))),
Get_Name_String (Name (Identifier (Processes)))'Length,
NodeName, NodeName'Length);
if ATN.Namespace
(Corresponding_Declaration
(CPU)) /= No_Node
then
Processes2 := First_Node (Subcomponents (My_System));
Set_Str_To_Name_Buffer ("");
Get_Name_String
(ATN.Name
(ATN.Identifier
(ATN.Namespace
(Corresponding_Declaration (CPU)))));
Pkg_Name := Name_Find;
Imported_Routines.C_Add_Package
(Get_Name_String (Pkg_Name),
Get_Name_String (Pkg_Name)'Length);
Set_Str_To_Name_Buffer ("");
Get_Name_String (Pkg_Name);
Add_Str_To_Name_Buffer ("::");
Get_Name_String_And_Append (Name (Identifier (CPU)));
CPU_Classifier := Name_Find;
else
CPU_Classifier := Name (Identifier (CPU));
end if;
while Present (Processes2) loop
Tmp_CI2 := Corresponding_Instance (Processes2);
Imported_Routines.C_New_Processor
(Get_Name_String (CPU_Name),
Get_Name_String (CPU_Name)'Length,
Get_Name_String (CPU_Classifier),
Get_Name_String (CPU_Classifier)'Length,
Supported_Execution_Platform'Image (CPU_Platform),
Supported_Execution_Platform'Image (CPU_Platform)'Length);
Imported_Routines.C_New_Process
(Get_Name_String
(ATN.Name
(ATN.Component_Type_Identifier
(Corresponding_Declaration (Tmp_CI)))),
Get_Name_String
(ATN.Name
(ATN.Component_Type_Identifier
(Corresponding_Declaration (Tmp_CI))))'Length,
Get_Name_String (Name (Identifier (Processes))),
Get_Name_String (Name (Identifier (Processes)))'Length,
NodeName, NodeName'Length,
Boolean'Pos (Node_Coverage));
Processes2 := First_Node (Subcomponents (My_System));
while Present (Processes2) loop
Tmp_CI2 := Corresponding_Instance (Processes2);
if Get_Category_Of_Component (Tmp_CI2) = CC_System
and then
Is_Defined_Property
(Tmp_CI2, "taste::aplc_binding")
then
Ref := Get_Reference_Property
(Tmp_CI2, Get_String_Name ("taste::aplc_binding"));
if Get_Category_Of_Component (Tmp_CI2) = CC_System
and then
Is_Defined_Property
(Tmp_CI2, "taste::aplc_binding")
then
Ref := Get_Reference_Property
(Tmp_CI2, Get_String_Name ("taste::aplc_binding"));
if Ref = Tmp_CI then
declare
Bound_APLC_Name : Unbounded_String;
-- constant String :=
-- Get_Name_String
-- (ATN.Name
-- (ATN.Component_Type_Identifier
-- (Corresponding_Declaration (Tmp_CI2))));
-- (Name
-- (Identifier (Processes2)));
-- (Identifier (Tmp_CI2)));
begin
if Ref = Tmp_CI then
declare
Bound_APLC_Name : Unbounded_String;
begin
Bound_APLC_Name := To_Unbounded_String
(Get_Name_String
(ATN.Name
(ATN.Component_Type_Identifier
(Corresponding_Declaration (Tmp_CI2)))));
exception
when System.Assertions.Assert_Failure =>
Put_Line
("Detected DV from TASTE version 1.2");
begin
Bound_APLC_Name := To_Unbounded_String
(Get_Name_String
(Name (Identifier (Processes2))));
end;
(ATN.Name
(ATN.Component_Type_Identifier
(Corresponding_Declaration (Tmp_CI2)))));
exception
when System.Assertions.Assert_Failure =>
Put_Line
("Detected DV from TASTE version 1.2");
Bound_APLC_Name := To_Unbounded_String
(Get_Name_String
(Name (Identifier (Processes2))));
end;
Imported_Routines.C_Add_Binding
(To_String (Bound_APLC_Name),
To_String (Bound_APLC_Name)'Length);
end;
Imported_Routines.C_Add_Binding
(To_String (Bound_APLC_Name),
To_String (Bound_APLC_Name)'Length);
end;
end if;
end if;
end if;
Processes2 := Next_Node (Processes2);
end loop;
Processes2 := Next_Node (Processes2);
end loop;
Imported_Routines.C_End_Process;
Imported_Routines.C_End_Process;
end;
end if;
Processes := Next_Node (Processes);
......
......@@ -34,7 +34,8 @@ package Imported_Routines is
Id : String;
LenId : Integer;
Node_Name : String;
Len_Node : Integer);
Len_Node : Integer;
Coverage : Integer);
procedure C_New_Processor (Name : String;
Name_Len : Integer;
......
This diff is collapsed.
......@@ -73,6 +73,15 @@ int ada_gw_preamble(FV * fv)
FOREACH(i, Interface, fv->interfaces, {
FOREACH(p, Parameter, i->in, ADD_TO_SET(ASN1_Module, modules, p->asn1_module));
FOREACH(p, Parameter, i->out, ADD_TO_SET(ASN1_Module, modules, p->asn1_module));
FOREACH(cp, Context_Parameter, fv->context_parameters, {
if (strcmp (cp->type.name, "Taste-directive") &&
strcmp (cp->type.name, "Simulink-Tunable-Parameter") &&
strcmp (cp->type.name, "Timer")) {
ADD_TO_SET(ASN1_Module,
modules,
asn2underscore(cp->type.module, strlen(cp->type.module)));
}
});
});
FOREACH(m, ASN1_Module, modules, {
......@@ -99,7 +108,7 @@ int ada_gw_preamble(FV * fv)
"\t%s : asn1Scc%s := context_%s.%s_ctxt.%s;\n"
"\tpragma export(C, %s, \"%s_%s\");\n",
cp->name,
cp->type.name,
asn2underscore(cp->type.name, strlen(cp->type.name)),
fv->name,
fv->name,
cp->name,
......
/* Buildsupport is (c) 2008-2015 European Space Agency
/* Buildsupport is (c) 2008-2016 European Space Agency
* contact: maxime.perrotin@esa.int
* License is LGPL, check LICENSE file */
/* build_c_skeletons.c
......@@ -6,6 +6,7 @@
this program generates empty C functions respecting the interfaces defined
in the interface view. it provides functions to invoke RI.
updated 10/06/2016: properly align params and use FOREACH
updated 20/04/2009 to disable in case "-onlycv" flag is set
updated 8/10/2009 to rename the user_code.h/c to FV_name.h/c like in the Ada backend
*/
......@@ -58,7 +59,7 @@ void c_gw_preamble(FV * fv)
/* b. user_code.c preamble (if applicable) */
if (NULL != user_code_c) {
fprintf(user_code_c,
"/* Functions to be filled by the user (never overwritten by buildsupport tool) */\n\n");
"/* User code: This file will not be overwritten by TASTE. */\n\n");
fprintf(user_code_c, "#include \"%s.h\"\n\n", fv->name);
......@@ -92,12 +93,14 @@ int Init_C_GW_Backend(FV * fv, bool generateC)
strlen(fv->system_ast->context->output));
}
build_string(&path, fv->name, strlen(fv->name));
build_string(&filename, fv->name, strlen(fv->name));
build_string(&filename, ".h", strlen(".h"));
create_file(path, filename, &user_code_h);
create_file(path, filename, &user_code_h);
filename[strlen(filename) - 1] = 'c'; /* change from .h to .c */
if (cpp == fv->language) {
build_string(&filename, "c", 1); /* change from .c to .cc */
}
if (!file_exists(path, filename) && true == generateC)
create_file(path, filename, &user_code_c);
......@@ -131,79 +134,92 @@ void close_c_gw_files()
*/
void add_PI_to_C_gw(Interface * i)
{
Parameter_list *tmp;
if (NULL == user_code_h)
return;
fprintf(user_code_h, "void %s_PI_%s(", i->parent_fv->name, i->name);
if (NULL != user_code_c)
fprintf(user_code_c, "void %s_PI_%s(", i->parent_fv->name,
i->name);
char *signature = make_string("void %s_PI_%s(",
i->parent_fv->name,
i->name);
tmp = i->in;
size_t sig_len = strlen(signature);
char *sep = make_string(",\n%*s", sig_len, "");
bool comma = false;
while (NULL != tmp) {
fprintf(user_code_h, "%sconst asn1Scc%s *",
(tmp != i->in) ? ", " : "", tmp->value->type);
if (NULL != user_code_c)
fprintf(user_code_c, "%sconst asn1Scc%s *IN_%s",
(tmp != i->in) ? ", " : "",
tmp->value->type, tmp->value->name);
tmp = tmp->next;
}
fprintf(user_code_h, "%s", signature);
tmp = i->out;
while (NULL != tmp) {
fprintf(user_code_h, "%sasn1Scc%s *",
(tmp != i->out
|| (tmp == i->out
&& NULL != i->in)) ? ", " : "", tmp->value->type);
if (NULL != user_code_c)
fprintf(user_code_c, "%sasn1Scc%s *OUT_%s",
(tmp != i->out
|| (tmp == i->out
&& NULL != i->in)) ? ", " : "", tmp->value->type,
tmp->value->name);
tmp = tmp->next;
if (NULL != user_code_c) {
fprintf(user_code_c, "%s", signature);
}
FOREACH (p, Parameter, i->in, {
char *sort = make_string("%sconst asn1Scc%s *",
comma? sep: "",
p->type);
fprintf(user_code_h, "%s", sort);
if(NULL != user_code_c) {
fprintf(user_code_c, "%sIN_%s",
sort,
p->name);
}
free(sort);
comma = true;
});
FOREACH (p, Parameter, i->out, {
char *sort = make_string("%sasn1Scc%s *",
comma? sep: "",
p->type);
fprintf(user_code_h, "%s", sort);
if(NULL != user_code_c) {
fprintf(user_code_c, "%sOUT_%s",
sort,
p->name);
}
free(sort);
comma = true;
});
fprintf(user_code_h, ");\n\n");
if (NULL != user_code_c)
fprintf(user_code_c, ")\n{\n /* Write your code here! */\n}\n\n");
free(signature);
free(sep);
}
/* Declaration of the RI in user_code.h */
void add_RI_to_C_gw(Interface * i)
{
Parameter_list *tmp;
if (NULL == user_code_h)
return;
fprintf(user_code_h, "extern void %s_RI_%s(", i->parent_fv->name,
i->name);
char *signature = make_string("extern void %s_RI_%s(",
i->parent_fv->name,
i->name);
tmp = i->in;
size_t sig_len = strlen(signature);
char *sep = make_string(",\n%*s", sig_len, "");
bool comma = false;
while (NULL != tmp) {
fprintf(user_code_h, "%sconst asn1Scc%s *",
(tmp != i->in) ? ", " : "", tmp->value->type);
tmp = tmp->next;
}
fprintf(user_code_h, "%s", signature);
tmp = i->out;
FOREACH (p, Parameter, i->in, {
fprintf(user_code_h, "%sconst asn1Scc%s *",
comma? sep: "",
p->type);
comma = true;
});
while (NULL != tmp) {
fprintf(user_code_h, "%sasn1Scc%s *",
(tmp != i->out
|| (tmp == i->out
&& NULL != i->in)) ? ", " : "", tmp->value->type);
tmp = tmp->next;
}
FOREACH (p, Parameter, i->out, {
fprintf(user_code_h,"%sconst asn1Scc%s *",
comma? sep: "",
p->type);
comma = true;
});
fprintf(user_code_h, ");\n\n");
free(signature);
free(sep);
}
/* Add timer declarations to the C code skeletons */
......
/* Buildsupport is (c) 2008-2015 European Space Agency
/* Buildsupport is (c) 2008-2016 European Space Agency
* contact: maxime.perrotin@esa.int
* License is LGPL, check LICENSE file */
/* build_script.c
this backend generates parts of the build_sample.sh script that are project-specific.
this backend generates the build script that generates the binary files
1st version 20 may 2009
......@@ -105,20 +105,34 @@ void Create_script()
fprintf (script, "SKELS=\"%s\"\n\n", OUTPUT_PATH);
fprintf (script, "# Update the data view with local paths\n"
"taste-update-data-view\n\n");
/* OpenGEODE-specific: call code generator on the fly */
FOREACH (fv, FV, get_system_ast()->functions, {
if (sdl == fv->language) {
fprintf(script,
"# Generate code for OpenGEODE function %s\n"
"cd \"$SKELS\"/%s && "
"opengeode --toAda %s.pr system_structure.pr "
"&& cd $OLDPWD\n\n",
fv->name, fv->name, fv->name);
}
});
/* Remove old zip files and create fresh new ones from user code */
fprintf (script, "cd \"$SKELS\"\n");
FOREACH (fv, FV, get_system_ast()->functions, {
//if (sdl != fv->language PUT BACK WHEN OPENGEODE FULLY SUPPORTED
if (vhdl != fv->language
&& gui != fv->language
&& rtds != fv->language
&& NULL == fv->zipfile) {
fprintf (script, "rm -f %s.zip\n", fv->name);
fprintf (script, "zip %s %s/*\n", fv->name, fv->name);
fprintf (script,
"cd \"$SKELS\" && rm -f %s.zip && "
"zip %s %s/* && cd $OLDPWD\n\n",
fv->name, fv->name, fv->name);
}
})
fprintf (script, "cd \"$OLDPWD\"\n\n");
fprintf (script, "[ ! -z \"$CLEANUP\" ] && rm -rf binary\n\n");
......@@ -215,11 +229,21 @@ void Create_script()
}
})
/* If node is configured with code coverage flag, set the option */
FOREACH (process, Process, get_system_ast()->processes, {
if (true == process->coverage) {
fprintf(script,
" \\\n\t--nodeOptions %s@gcov=on",
process->name);
}
});
/* Let user add custom orchestrator flags */
fprintf (script, " \\\n\t$ORCHESTRATOR_OPTIONS\n");
close_file(&script);
if (chmod ("build-script.sh", S_IRWXG | S_IRWXO | S_IRWXU)) {
fprintf (stderr, "Warning: Unable to change mode of build-script.sh to make it executable\n");
fprintf (stderr, "Warning: Unable to change mode of build-script.sh to make it executable\n");
}
}
......
......@@ -8,8 +8,6 @@
*/
#define ID "$Id$"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......@@ -319,7 +317,7 @@ void Set_Context_Variable (char *name, size_t len1, char *type, size_t len2,
{
Context_Parameter *cp = NULL;
unsigned int i = 0;
cp = (Context_Parameter *) malloc (sizeof (Context_Parameter));
assert (NULL != cp);
......@@ -334,7 +332,7 @@ void Set_Context_Variable (char *name, size_t len1, char *type, size_t len2,
/* First check the validity of the ASN.1 module name */
if (!strncmp (mod, "nomodule", len4)) {
ERROR ("** Error: The dataview you are using was generated using an old version\n");
ERROR (" of the toolchain. You must update it by calling asn2aadlPlus.py <file.asn>.\n");
ERROR (" of the toolchain. You must update it by calling taste-update-data-view\n");
exit (-1);
}
/* Temporary for the SMP2 support until version of taste-IV withtout obj suffixes */
......@@ -503,7 +501,8 @@ void New_Process(char *procname,
char *procid,
size_t lenid,
char *node,
size_t lennode)
size_t lennode,
bool coverage)
{
Create_Process(&process);
......@@ -520,6 +519,7 @@ void New_Process(char *procname,
old_cpu_name);
//free(old_cpu_name);
}
process->coverage = coverage;
}
}
......@@ -907,7 +907,7 @@ void Add_RI(char *ri, size_t length,
RI);
}
/* add an IN parameter to the list */
/* add an IN parameter to the list (name respects the case) */
void Add_In_Param(char *name, size_t l1,
char *type, size_t l2,
char *module, size_t l3,
......@@ -917,8 +917,14 @@ void Add_In_Param(char *name, size_t l1,
Create_Parameter(&parameter);
assert (NULL != parameter && NULL != interface);
char *param_name = name;
build_string(&(parameter->name), name, l1);
if (0 == system_ast->context->keep_case) {
// user does not want to keep case of the parameters
param_name = string_to_lower(name);
}
build_string(&(parameter->name), param_name, l1);
build_string(&(parameter->type), type, l2);
build_string(&(parameter->asn1_module), module, l3);
build_string(&(parameter->asn1_filename), filename, l4);
......@@ -938,8 +944,14 @@ void Add_Out_Param(char *name, size_t l1,
Create_Parameter(&parameter);
assert (NULL != parameter && NULL != interface);
char *param_name = name;
if (0 == system_ast->context->keep_case) {
// user does not want to keep case of the parameters
param_name = string_to_lower(name);
}
build_string(&(parameter->name), name, l1);
build_string(&(parameter->name), param_name, l1);
build_string(&(parameter->type), type, l2);
build_string(&(parameter->asn1_module), module, l3);
build_string(&(parameter->asn1_filename), filename, l4);
......
......@@ -21,8 +21,6 @@
static FILE *h = NULL, *cfile = NULL;
extern void Check_If_A_Calling_Thread_Has_No_Async_RI(FV *, int *);
/* Adds header to files */
void c_wrappers_preamble(FV * fv)
{
......@@ -224,10 +222,10 @@ void add_sync_PI_to_c_wrappers(Interface * i)
fprintf(h, "----------------------------------------------------*/\n");
fprintf(h, "void sync_%s_%s(int", i->parent_fv->name, i->name);
FOREACH(p, Parameter, i->in, {
(void) p; fprintf(h, ", void *, int");});
(void) p; fprintf(h, ", void *, size_t");});
FOREACH(p, Parameter, i->out, {
(void) p; fprintf(h, ", void *, int *");});
(void) p; fprintf(h, ", void *, size_t *");});
fprintf(h, ");\n\n");
......@@ -241,11 +239,11 @@ void add_sync_PI_to_c_wrappers(Interface * i)
fprintf(cfile, "void sync_%s_%s(int calling_thread",
i->parent_fv->name, i->name);
FOREACH(p, Parameter, i->in, {