scilab: change swig options, new option -gatewayxml, remove -internalmodule

This commit is contained in:
Simon Marchetto 2014-10-17 17:33:27 +02:00
commit 32c76be163
2 changed files with 36 additions and 28 deletions

View file

@ -286,8 +286,8 @@ The following table lists the Scilab specific command line options in addition t
</tr> </tr>
<tr> <tr>
<td>-internalmodule &lt;gateway id&gt;</td> <td>-gatewayxml &lt;gateway_id&gt;</td>
<td>Generate an internal module with the given &lt;gateway id&gt;</td> <td>Generate the gateway XML with the given &lt;gateway_id&gt;</td>
</tr> </tr>
<tr> <tr>

View file

@ -26,7 +26,7 @@ Scilab options (available with -scilab)\n\
-addsources <files> - Add comma separated source files <files>\n\ -addsources <files> - Add comma separated source files <files>\n\
-buildflags <file> - Use the Scilab script <file> to set build flags\n\ -buildflags <file> - Use the Scilab script <file> to set build flags\n\
-buildverbositylevel <level> - Set the build verbosity <level> (default 0)\n\ -buildverbositylevel <level> - Set the build verbosity <level> (default 0)\n\
-internalmodule <gateway id> - Generate internal module files with the given <gateway id>\n\ -gatewayxml <gateway_id> - Generate gateway xml with the given <gateway_id>\n\
-nobuilder - Do not generate builder script\n\ -nobuilder - Do not generate builder script\n\
-outputlibrary <name> - Set name of the output library to <name>\n\n"; -outputlibrary <name> - Set name of the output library to <name>\n\n";
@ -41,6 +41,7 @@ protected:
String *variablesCode; String *variablesCode;
bool generateBuilder;
File *builderFile; File *builderFile;
String *builderCode; String *builderCode;
int builderFunctionCount; int builderFunctionCount;
@ -52,19 +53,17 @@ protected:
String *verboseBuildLevel; String *verboseBuildLevel;
String *buildFlagsScript; String *buildFlagsScript;
File *gatewayXMLFile; bool createGatewayGenerator;
String *gatewayXML;
File *gatewayGeneratorFile; File *gatewayGeneratorFile;
String *gatewayGeneratorCode; String *gatewayGeneratorCode;
bool createGatewayXML;
File *gatewayXMLFile;
String *gatewayXML;
String *gatewayID; String *gatewayID;
int primitiveID; int primitiveID;
String *libraryName; String *libraryName;
bool generateBuilder;
bool internalModule;
public: public:
/* ------------------------------------------------------------------------ /* ------------------------------------------------------------------------
@ -85,7 +84,8 @@ public:
gatewayGeneratorFile = NULL; gatewayGeneratorFile = NULL;
libraryName = NULL; libraryName = NULL;
generateBuilder = true; generateBuilder = true;
internalModule = false; createGatewayGenerator = false;
createGatewayXML = false;
/* Manage command line arguments */ /* Manage command line arguments */
for (int argIndex = 1; argIndex < argc; argIndex++) { for (int argIndex = 1; argIndex < argc; argIndex++) {
@ -125,10 +125,9 @@ public:
} else if (strcmp(argv[argIndex], "-nobuilder") == 0) { } else if (strcmp(argv[argIndex], "-nobuilder") == 0) {
Swig_mark_arg(argIndex); Swig_mark_arg(argIndex);
generateBuilder = false; generateBuilder = false;
} else if (strcmp(argv[argIndex], "-internalmodule") == 0) { } else if (strcmp(argv[argIndex], "-gatewayxml") == 0) {
Swig_mark_arg(argIndex); Swig_mark_arg(argIndex);
generateBuilder = false; createGatewayXML = true;
internalModule = true;
gatewayID = NewString(argv[argIndex + 1]); gatewayID = NewString(argv[argIndex + 1]);
Swig_mark_arg(argIndex + 1); Swig_mark_arg(argIndex + 1);
} else if (strcmp(argv[argIndex], "-outputlibrary") == 0) { } else if (strcmp(argv[argIndex], "-outputlibrary") == 0) {
@ -196,16 +195,22 @@ public:
/* Output module initialization code */ /* Output module initialization code */
Swig_banner(beginSection); Swig_banner(beginSection);
// Add builder header code // Create builder file if required
if (generateBuilder) { if (generateBuilder) {
createBuilderFile(); createBuilderFile();
startBuilderCode(outputFilename); startBuilderCode(outputFilename);
} }
// In the case of internal module, create gateway gateway XML and generation script
if (internalModule) { // Create gateway generator script if required
createGatewayXMLFile(moduleName); if (createGatewayGenerator) {
createGatewayGeneratorFile(); createGatewayGeneratorFile();
} }
// Create gateway XML if required
if (createGatewayXML) {
createGatewayXMLFile(moduleName);
}
// Module initialization function // Module initialization function
String *moduleInitFunctionName = NewString(""); String *moduleInitFunctionName = NewString("");
Printf(moduleInitFunctionName, "%s_Init", moduleName); Printf(moduleInitFunctionName, "%s_Init", moduleName);
@ -252,12 +257,15 @@ public:
Dump(variablesCode, beginSection); Dump(variablesCode, beginSection);
Wrapper_pretty_print(initSection, beginSection); Wrapper_pretty_print(initSection, beginSection);
// In the case of internal module, terminate and save gateway XML and generation script // Save gateway generator script
if (internalModule) { if (createGatewayGenerator) {
saveGatewayXMLFile();
saveGatewayGeneratorFile(moduleName); saveGatewayGeneratorFile(moduleName);
} }
if (createGatewayXML) {
saveGatewayXMLFile();
}
/* Cleanup files */ /* Cleanup files */
Delete(runtimeSection); Delete(runtimeSection);
Delete(headerSection); Delete(headerSection);
@ -988,6 +996,7 @@ public:
* ----------------------------------------------------------------------- */ * ----------------------------------------------------------------------- */
void saveGatewayGeneratorFile(String *moduleName) { void saveGatewayGeneratorFile(String *moduleName) {
Printf(gatewayGeneratorCode, "];\n"); Printf(gatewayGeneratorCode, "];\n");
Printv(gatewayGeneratorFile, gatewayGeneratorCode, NIL); Printv(gatewayGeneratorFile, gatewayGeneratorCode, NIL);
String *gatewayGenerateCommand = NewStringf("ilib_gen_gateway('gw_%s.c', table);\n", moduleName); String *gatewayGenerateCommand = NewStringf("ilib_gen_gateway('gw_%s.c', table);\n", moduleName);
@ -1005,15 +1014,14 @@ public:
addFunctionInScriptTable(scilabFunctionName, wrapperFunctionName, builderCode); addFunctionInScriptTable(scilabFunctionName, wrapperFunctionName, builderCode);
} }
if (internalModule) { if (createGatewayGenerator) {
if (gatewayGeneratorFile) {
addFunctionInScriptTable(scilabFunctionName, wrapperFunctionName, gatewayGeneratorCode); addFunctionInScriptTable(scilabFunctionName, wrapperFunctionName, gatewayGeneratorCode);
} }
if (gatewayXMLFile) { if (gatewayXMLFile) {
Printf(gatewayXML, "<PRIMITIVE gatewayId=\"%s\" primitiveId=\"%d\" primitiveName=\"%s\"/>\n", gatewayID, primitiveID++, scilabFunctionName); Printf(gatewayXML, "<PRIMITIVE gatewayId=\"%s\" primitiveId=\"%d\" primitiveName=\"%s\"/>\n", gatewayID, primitiveID++, scilabFunctionName);
} }
} }
}
/* ----------------------------------------------------------------------- /* -----------------------------------------------------------------------
* addFunctionInScriptTable() * addFunctionInScriptTable()