Commit e0a2fe6f authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Merge branch 'master' of https://gitrepos.estec.esa.int/taste/buildsupport into crazyflie

parents 970bc7de abe758a2
......@@ -1467,6 +1467,7 @@ procedure BuildSupport is
IV_Root : Node_Id;
AST : Complete_Interface_View;
pragma Unreferenced (AST);
begin
Banner;
......@@ -1483,11 +1484,11 @@ begin
Get_String_Name ("interfaceview.others");
IV_Root := Root_System (Instantiate_Model (Root => Interface_Root));
AST := AADL_to_Ada_IV (IV_Root);
for each of AST.Flat_Functions loop
Put_Line ("AST: " & To_String (Each.Prefix.Value_Or (US ("")))
& " " & To_String (Each.Name));
end loop;
-- AST := AADL_to_Ada_IV (IV_Root);
-- for each of AST.Flat_Functions loop
-- Put_Line ("AST: " & To_String (Each.Prefix.Value_Or (US ("")))
-- & " " & To_String (Each.Name));
-- end loop;
Process_Interface_View (IV_Root);
-- (Root_System (Instantiate_Model (Root => Interface_Root)));
......
with "ocarina";
with "templates_parser"; -- from libtemplates-parser11.10.1-dev
-- with "templates_parser"; -- from libtemplates-parser11.10.1-dev
project BuildSupport is
......
......@@ -80,7 +80,7 @@ void Call_asn2dataModel(FV * fv)
if (!file_exists(dataview_path, dataview_uniq)) {
printf
("[Information] %s/%s not found. Checking for dataview-uniq.asn\n",
("[INFO] %s/%s not found. Checking for dataview-uniq.asn\n",
dataview_path, dataview_uniq);
free(dataview_uniq);
dataview_uniq = make_string("dataview-uniq.asn");
......
/* Buildsupport is (c) 2008-2015 European Space Agency
/* Buildsupport is (c) 2008-2017 European Space Agency
* contact: maxime.perrotin@esa.int
* License is LGPL, check LICENSE file */
/* build_ada_skeletons.c
......@@ -6,23 +6,8 @@
this program generates empty Ada functions respecting the interfaces defined
in the interface view. it provides functions to invoke RI.
Note on the use of the Ada skeletons:
Generated functions for PI are called by C code with parameters passed as
pointers. In Ada, pointers are expressed using the "access" keyword instead
of "in" or "out". To access the variable values, the ".all" postfix can be
used. And to declare a variable for which an access is necessary, the type
must be "aliased". Complete example:
procedure Compute (my_input: access asn1sccT_SEQUENCE) is -- Provided interface
my_output: aliased T_INTEGER; -- Parameter of a Required Interface
begin
my_output := my_input.all.x + my_input.all.y;
required_interface (my_output'access); -- Call Required Interface
end Compute;
Copyright 2014-2015 IB Krates <info@krates.ee>
QGenc code generator integration
*/
#include <stdio.h>
......@@ -105,8 +90,8 @@ int ada_gw_preamble(FV * fv)
strcmp (cp->type.name, "Timer")) {
fprintf(ads,
"\t%s : asn1Scc%s := context_%s.%s_ctxt.%s;\n"
"\tpragma export(C, %s, \"%s_%s\");\n",
" %s : asn1Scc%s := context_%s.%s_ctxt.%s;\n"
" pragma Export(C, %s, \"%s_%s\");\n",
cp->name,
asn2underscore(cp->type.name, strlen(cp->type.name)),
fv->name,
......@@ -180,7 +165,7 @@ int Init_Ada_GW_Backend(FV * fv)
create_file(path, filename, &adb);
assert(NULL != adb);
} else
INFO ("** Information: User code not overwritten for function %s\n",
INFO ("[INFO] User code not overwritten for function %s\n",
fv->name);
free(path);
......@@ -231,10 +216,10 @@ void add_PI_to_Ada_gw(Interface * i)
return;
fprintf(ads,
"\t---------------------------------------------------------\n"
"\t-- Provided interface \"%s\"\n"
"\t---------------------------------------------------------\n"
"\tprocedure %s",
" -- ---------------------------------------------------- --\n"
" -- Provided interface \"%s\"\n"
" -- ---------------------------------------------------- --\n"
" procedure %s",
i->name,
i->name);
......@@ -255,15 +240,15 @@ void add_PI_to_Ada_gw(Interface * i)
}
fprintf(ads, ";\n");
fprintf(ads, "\tpragma export(C, %s, \"%s_PI_%s\");\n\n", i->name,
fprintf(ads, " pragma Export(C, %s, \"%s_PI_%s\");\n\n", i->name,
i->parent_fv->name, i->name);
if (NULL != adb) {
fprintf(adb,
"\t---------------------------------------------------------\n"
"\t-- Provided interface \"%s\"\n"
"\t---------------------------------------------------------\n"
"\tprocedure %s",
" -- ------------------------------------------------ --\n"
" -- Provided interface \"%s\"\n"
" -- ------------------------------------------------ --\n"
" procedure %s",
i->name,
i->name);
}
......@@ -276,12 +261,12 @@ void add_PI_to_Ada_gw(Interface * i)
if (NULL != adb) {
fprintf(adb,
" is\n\tpragma suppress (all_checks);"
"\n\tbegin\n\n");
" is\n pragma Suppress (All_Checks);"
"\n begin\n\n");
fprintf(adb,
"\t\tnull;"
" -- Replace \"null\" with your own code!\n\n\tend %s;\n\n",
" null;"
" -- Replace \"null\" with your own code!\n\n end %s;\n\n",
i->name);
}
......@@ -300,10 +285,10 @@ void add_RI_to_Ada_gw(Interface * i)
return;
fprintf(ads,
"\t---------------------------------------------------------\n"
"\t-- Required interface \"%s\"\n"
"\t---------------------------------------------------------\n"
"\tprocedure %s",
" -- --------------------------------------------------- --\n"
" -- Required interface \"%s\"\n"
" -- --------------------------------------------------- --\n"
" procedure %s",
i->name,
i->name);
......@@ -324,20 +309,17 @@ void add_RI_to_Ada_gw(Interface * i)
fprintf(ads, ";\n");
fprintf(ads, "\tpragma import(C, %s, \"%s_RI_%s\");\n", i->name,
fprintf(ads, " pragma Import(C, %s, \"%s_RI_%s\");\n", i->name,
i->parent_fv->name, i->name);
fprintf(ads, "\tprocedure RI%s", i->name);
fprintf(ads, " procedure RI%s", i->name);
if (NULL != ada_params) {
fprintf(ads, "(%s)", ada_params);
}
fprintf(ads, " renames %s;\n\n", i->name);
free(ada_params);
ada_params = NULL;
}
/* Add timer declarations to the Ada code skeletons */
......@@ -345,23 +327,23 @@ void Ada_Add_timers (FV *fv)
{
if (NULL != fv->timer_list) {
fprintf (ads,
"\t---------------------------------------------------------\n"
"\t-- Timers management --\n"
"\t---------------------------------------------------------\n"
" -- ------------------------------------------------ --\n"
" -- Timers management --\n"
" -- ------------------------------------------------ --\n"
"\n\n");
}
FOREACH(timer, String, fv->timer_list, {
fprintf(ads,
"\t-- This function is called when the timer \"%s\" expires\n"
"\tprocedure %s;\n"
"\tpragma export(C, %s, \"%s_PI_%s\");\n\n"
"\t-- Call this function to set (enable) the timer\n"
"\t-- Value is in milliseconds, and must be a multiple of 100\n"
"\tprocedure SET_%s(val: access asn1sccT_UInt32);\n\n"
"\tpragma import(C, SET_%s, \"%s_RI_SET_%s\");\n\n"
"\t-- Call this function to reset (disable) the timer\n"
"\tprocedure RESET_%s;\n\n"
"\tpragma import(C, RESET_%s, \"%s_RI_RESET_%s\");\n\n",
" -- This function is called when the timer \"%s\" expires\n"
" procedure %s;\n"
" pragma Export(C, %s, \"%s_PI_%s\");\n\n"
" -- Call this function to set (enable) the timer\n"
" -- Value is in milliseconds, and must be a multiple of 100\n"
" procedure Set_%s(val: access asn1sccT_UInt32);\n\n"
" pragma Import(C, Set_%s, \"%s_RI_SET_%s\");\n\n"
" -- Call this function to reset (disable) the timer\n"
" procedure Reset_%s;\n\n"
" pragma Import(C, Reset_%s, \"%s_RI_RESET_%s\");\n\n",
timer,
timer,
timer,
......@@ -377,11 +359,11 @@ void Ada_Add_timers (FV *fv)
timer);
if (NULL != adb) {
fprintf(adb,
"\t-- This function is called when the timer \"%s\" expires \n"
"\tprocedure %s is\n"
"\tbegin\n"
"\t null; -- Replace \"null\" with your own code!\n"
"\tend;\n\n",
" -- This function is called when the timer \"%s\" expires \n"
" procedure %s is\n"
" begin\n"
" null; -- Replace \"null\" with your own code!\n"
" end;\n\n",
timer,
timer);
}
......@@ -412,9 +394,9 @@ void GW_Ada_Backend(FV * fv)
* input queue of the process before executing continuous signals */
if(get_context()->polyorb_hi_c) {
fprintf(ads,
"\t-- TASTE API to check if the input queue is empty\n"
"\tprocedure check_queue(res: access asn1SccT_Boolean);\n"
"\tpragma import(C, check_queue, \"%s_RI_check_queue\");\n",
" -- TASTE API to check if the input queue is empty\n"
" procedure Check_Queue(res: access asn1SccT_Boolean);\n"
" pragma Import(C, Check_Queue, \"%s_RI_check_queue\");\n",
fv->name);
}
......
......@@ -41,9 +41,12 @@ void c_preamble(FV * fv)
fprintf(vm_if_h, "#ifndef VM_IF_%s\n", fv->name);
fprintf(vm_if_h, "#define VM_IF_%s\n\n", fv->name);
fprintf(vm_if_h, "#ifdef __unix__\n");
fprintf(vm_if, "#include <stdlib.h>\n" "#include <stdio.h>\n");
fprintf(vm_if_h, "#endif\n\n");
fprintf(vm_if, "#ifdef __unix__\n"
" #include <stdlib.h>\n"
" #include <stdio.h>\n"
"#else\n"
" typedef unsigned size_t;\n"
"#endif\n\n");
fprintf(vm_if_h, "#ifdef __cplusplus\n"
"extern \"C\" {\n" "#endif\n\n");
......@@ -61,7 +64,7 @@ void c_preamble(FV * fv)
}
if (hasparam) {
fprintf(vm_if, "#include \"C_ASN1_Types.h\"\n\n");
fprintf(vm_if, "#include \"C_ASN1_Types.h\"\n\n");
fprintf(vm_if_h, "#include \"C_ASN1_Types.h\"\n\n");
}
......@@ -288,7 +291,9 @@ void add_PI_to_c_vm_if(Interface * i)
FOREACH(p, Parameter, i->in, {
fprintf(vm_if,
" if (0 != Decode_%s_%s (&IN_%s, pmy_%s, size_my_%s)) {\n"
" printf(\"\\nError Decoding %s\\n\");\n"
" #ifdef __unix__\n"
" printf(\"\\nError Decoding %s\\n\");\n"
" #endif\n"
" return;\n"
" }\n\n",
BINARY_ENCODING(p),
......@@ -573,8 +578,9 @@ void add_RI_to_c_invoke_ri(Interface * i)
"#ifdef __unix__\n"
" printf (\"** Encoding error in %s_RI_%s!!\\n\");\n"
"#endif\n"
" /* Major error, we must stop the application and let the FDIR/Watchdogs recover */\n"
" exit (-1);\n"
" /* Crash the application due to message loss */\n"
" extern void abort (void);\n"
" abort();\n"
" }\n",
p->name,
BINARY_ENCODING(p),
......
......@@ -49,7 +49,11 @@ void driver_gw_preamble(FV * fv)
"#ifndef __DRIVER_CODE_H_%s__\n#define __DRIVER_CODE_H_%s__\n\n",
fv->name, fv->name);
fprintf(driver_h, "#include <stdlib.h>\n\n");
fprintf(driver_h, "#ifdef __unix__\n"
" #include <stdlib.h>\n"
"#else\n"
" typedef unsigned size_t;\n"
"#endif\n\n");
fprintf(driver_h, "void init_%s();\n\n", fv->name);
......@@ -87,7 +91,7 @@ int Init_Driver_GW_Backend(FV * fv)
if (!file_exists(path, filename))
create_file(path, filename, &driver_c);
else {
ERROR ("** Information: driver code not overwritten\n");
ERROR ("[INFO] driver code not overwritten\n");
driver_c = NULL;
}
......@@ -107,7 +111,7 @@ void close_driver_gw_files()
{
fprintf(driver_h, "\n#endif\n");
close_file(&driver_h);
close_file(&driver_c);
}
......
......@@ -41,11 +41,13 @@ void Create_script()
assert (NULL != script);
fprintf (script, "#!/bin/bash\n\n"
"# This script will build your TASTE system (by default with the C runtime).\n\n"
fprintf (script, "#!/bin/bash -e\n\n"
"# This script will build your TASTE system.\n\n"
"# You should not change this file as it was automatically generated.\n\n"
"# If you need additional preprocessing, create a file named 'user_init_pre.sh'\n"
"# and/or 'user_init_post.sh - They will never get overwritten.'\n\n"
"# If you need additional preprocessing, there are three hook files\n"
"# that you can provide and that are called dring the build:\n"
"# user_init_pre.sh, user_init_post.sh and user_init_last.sh\n"
"# These files will never get overwritten by TASTE.'\n\n"
"# Inside these files you may set some environment variables:\n"
"# C_INCLUDE_PATH=/usr/include/xenomai/analogy/:${C_INCLUDE_PATH}\n"
"# unset USE_POHIC \n\n"
......@@ -125,7 +127,7 @@ void Create_script()
fprintf (script, "if [ -z \"$DEPLOYMENTVIEW\" ]\n"
"then\n"
" DEPLOYMENTVIEW=DeploymentView.aadl\n"
"fi\n\n"
"fi\n\n"
"# Detect models from Ellidiss tools v2, and convert them to 1.3\n"
"grep \"version => \\\"2\" \"$DEPLOYMENTVIEW\" >/dev/null && {\n"
" echo -e \"${INFO} Converting deployment view from V2 to V1.3\"\n"
......@@ -136,8 +138,9 @@ 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");
fprintf (script, "# Check if Dataview references existing files \n"
"taste-extract-asn-from-design.exe -i \"$INTERFACEVIEW\" -j /tmp/dv.asn\n\n");
//"taste-update-data-view\n\n");
/* OpenGEODE-specific: call code generator on the fly */
FOREACH (fv, FV, get_system_ast()->functions, {
......@@ -184,6 +187,11 @@ void Create_script()
"then\n"
" ORCHESTRATOR_OPTIONS+=\" -w ConcurrencyView.pro \"\n"
"fi\n\n"
"if [ -f user_init_post.sh ]\n"
"then\n"
" echo -e \"${INFO} Executing user-defined post-init script\"\n"
" source user_init_post.sh\n"
"fi\n\n"
"if [ ! -z \"$USE_POHIC\" ]\n"
"then\n"
" OUTPUTDIR=binary.c\n"
......@@ -194,13 +202,6 @@ void Create_script()
"else\n"
" OUTPUTDIR=binary\n"
"fi\n\n"
);
fprintf (script, "if [ -f user_init_post.sh ]\n"
"then\n"
" echo -e \"${INFO} Executing user-defined init script\"\n"
" source user_init_post.sh\n"
"fi\n\n"
"cd \"$CWD\" && assert-builder-ocarina.py \\\n"
"\t--fast \\\n"
"\t--debug \\\n");
......@@ -252,7 +253,7 @@ void Create_script()
case qgenc: fprintf (script, "--subQGenC ");
break;
default:
ERROR ("** Error: unsupported language (function %s)\n", fv->name);
ERROR ("[ERROR] Unsupported language (function %s)\n", fv->name);
ERROR (" -> please manually check the build-script.sh file\n");
break;
}
......@@ -289,7 +290,14 @@ void Create_script()
});
/* Let user add custom orchestrator flags */
fprintf (script, " \\\n\t$ORCHESTRATOR_OPTIONS\n");
fprintf (script, " \\\n\t$ORCHESTRATOR_OPTIONS\n\n");
fprintf (script, "if [ -f user_init_last.sh ]\n"
"then\n"
" echo -e \"${INFO} Executing user-defined post-build script\"\n"
" source user_init_last.sh\n"
"fi\n\n");
close_file(&script);
if (chmod ("build-script.sh", S_IRWXG | S_IRWXO | S_IRWXU)) {
......
......@@ -113,9 +113,9 @@ void C_End()
which possibly creates additional functions */
FOREACH(fv, FV, get_system_ast()->functions, {
if (get_context()->gw && NULL != fv->zipfile && !get_context()->glue) {
printf ("[Information] No skeleton is generated for function \"%s\"\n"
" because source code is provided in file \"%s\"\n"
" (as specified in the interface view)\n\n",
printf ("[INFO] No skeleton is generated for function \"%s\"\n"
" because source code is provided in file \"%s\"\n"
" (as specified in the interface view)\n\n",
fv->name,
fv->zipfile
);
......
......@@ -154,7 +154,7 @@ void Process_Context_Parameters(FV *fv)
dataview_path = getDataViewPath();
if (!file_exists (dataview_path, dataview_uniq)) {
ERROR ("[Information] %s/%s not found."
ERROR ("[INFO] %s/%s not found."
" Checking for dataview-uniq.asn\n",
dataview_path, dataview_uniq);
free (dataview_uniq);
......@@ -162,7 +162,7 @@ void Process_Context_Parameters(FV *fv)
}
if (!file_exists (dataview_path, dataview_uniq)) {
ERROR ("** Error: %s/%s not found\n",
ERROR ("[ERROR] %s/%s not found\n",
dataview_path, dataview_uniq);
exit (-1);
}
......@@ -190,7 +190,7 @@ void Process_Context_Parameters(FV *fv)
}
if (!will_fail && system (command)) {
ERROR ("The command failed. Try it yourself "
ERROR ("[ERROR] The command failed. Try it yourself "
"(correct paths, access to files, etc.)\n");
exit (-1);
}
......
......@@ -738,8 +738,8 @@ void Preprocess_FV (FV *fv)
* define as unprotected */
else rcm = unprotected;
/* Create a new FV (thread) if there is more than
* one PI in the function */
if (count_pro+count_unpro+count_thread>1) {
* one PI in the function (unprotected don't count) */
if (count_pro+count_thread>1) {
ProcessArtificial_FV_Creation (i, rcm);
}
}
......@@ -903,16 +903,16 @@ void Add_api(Process *node, FV_list *all_fv)
"#define __AUTO_CODE_H_%s__\n\n"
"#include \"C_ASN1_Types.h\"\n"
"#ifdef __cplusplus\n"
"extern \"C\" {\n"
" extern \"C\" {\n"
"#endif\n\n",
fv->name,
fv->name);
/* Debug mode - Unix platform, when env variable CHECKQ_DEBUG is set */
fprintf (header, "#ifdef __unix__\n"
"#include <stdbool.h>\n"
"#include <stdlib.h>\n"
"static bool debugCheckQ = false;\n"
" #include <stdbool.h>\n"
" #include <stdlib.h>\n"
" static bool debugCheckQ = false;\n"
"#endif\n\n");
fprintf (code, "#ifdef __unix__\n"
......@@ -952,9 +952,9 @@ void Add_api(Process *node, FV_list *all_fv)
" if (__po_hi_gqueue_get_count(%s, %s)) {\n"
" *res = 1;\n"
" #ifdef __unix__\n"
" if (debugCheckQ) {\n"
" printf (\"[DEBUG] Pending message %s in function %s\\n\");\n"
" }\n"
" if (debugCheckQ) {\n"
" printf (\"[DEBUG] Pending message %s in function %s\\n\");\n"
" }\n"
" #endif\n"
" }\n",
string_to_lower(task_id),
......
......@@ -34,19 +34,19 @@ void Create_New_SDL_Structure(FV * fv)
char *dataview_uniq = getASN1DataView();
char *dataview_path = getDataViewPath();
if (!file_exists (dataview_path, dataview_uniq)) {
ERROR ("[Information] %s/%s not found. Checking for dataview-uniq.asn\n", dataview_path, dataview_uniq);
ERROR ("[INFO] %s/%s not found. Checking for dataview-uniq.asn\n", dataview_path, dataview_uniq);
free (dataview_uniq);
dataview_uniq = make_string ("dataview-uniq.asn");
}
char *command = make_string("mono $(which asn1.exe) -customStg $(taste-config --prefix)/share/asn1scc/python.stg:%s/DataView.py -customStgAstVerion 4 %s/%s", path, dataview_path, dataview_uniq);
if (system(command)) {
ERROR ("** Error: Command \"%s\" failed in generation of SDL skeleton\n", command);
ERROR ("[ERROR] Command \"%s\" failed in generation of SDL skeleton\n", command);
}
free(command);
command = make_string("cp \"%s/%s\" %s/", dataview_path, dataview_uniq, path);
if (system(command)) {
ERROR ("** Error: Command \"%s\" failed in generation of SDL skeleton\n", command);
ERROR ("[ERROR] Command \"%s\" failed in generation of SDL skeleton\n", command);
}
free(command);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment