diff --git a/tools/plugingenerator/config.json b/tools/plugingenerator/config.json index c56727c236..3ba3c4c9ca 100644 --- a/tools/plugingenerator/config.json +++ b/tools/plugingenerator/config.json @@ -2,6 +2,8 @@ "plugin": { "dir_name": "new", "plugin_name": "newplugin", + "plugin_display_name": "newpluginDisplayName", + "plugin_description": "newpluginDescription", "class_name": "NEWPlugin", "cmakelists": true, "namespace": "scopy::newplugin", diff --git a/tools/plugingenerator/plugin_generator.py b/tools/plugingenerator/plugin_generator.py index 0ad8d183ad..7e176c0d54 100644 --- a/tools/plugingenerator/plugin_generator.py +++ b/tools/plugingenerator/plugin_generator.py @@ -51,6 +51,8 @@ directoriesGenerated = [] pluginDirName = generatorOptions["plugin"]["dir_name"] pluginName = generatorOptions["plugin"]["plugin_name"] +pluginDisplayName = generatorOptions["plugin"]["plugin_display_name"] +pluginDecription = generatorOptions["plugin"]["plugin_description"] pluginClassName = generatorOptions["plugin"]["class_name"] pluginExportMacro = "SCOPY_" + pluginName.upper() + "_EXPORT" @@ -216,7 +218,9 @@ cmakeListsPath = os.path.join(newPluginPath, "CMakeLists.txt") cmakeTemplate = Template(filename="templates/cmakelists_template.mako") cmakeContent = cmakeTemplate.render( - scopy_module=pluginName, config=generatorOptions["cmakelists"] + scopy_module=pluginName, + plugin_display_name=pluginDisplayName, + plugin_description=pluginDecription, config=generatorOptions["cmakelists"] ) if not os.path.exists(cmakeListsPath): @@ -226,6 +230,25 @@ filesGenerated.append(cmakeListsPath) else: print(cmakeListsPath + " file already exists!") +########################################### Plugin CMAKE variable configuration file ########################## +if os.path.exists(pluginIncludePath): + cmakeinFilePath = os.path.join(pluginIncludePath, "scopy-" + pluginName + "_config.h.cmakein") + if not os.path.exists(cmakeinFilePath): + cmakeinFileTemplate = Template( + filename="templates/plugin_cmake_config_vars.mako" + ) + cmakeinFileContent = cmakeinFileTemplate.render( + plugin_name=pluginName + ) + + cmakeinFile = open(cmakeinFilePath, "w") + cmakeinFile.write(cmakeinFileContent) + cmakeinFile.close() + filesGenerated.append(cmakeinFilePath) + + else: + print(cmakeinFilePath + " file already exists!") + ##################################################### Plugin ToolList ######################################### toolList = generatorOptions["plugin"]["tools"] @@ -290,8 +313,10 @@ print(gitignorePath + " file already exists!") else: pluginExportPath = "include/"+ pluginName + "/scopy-" + pluginName + "_export.h" + pluginConfigPath = "\ninclude/"+ pluginName + "/scopy-" + pluginName + "_config.h" gitignoreFile = open(gitignorePath, "w") gitignoreFile.write(pluginExportPath) + gitignoreFile.write(pluginConfigPath) gitignoreFile.close() print("Plugin .gitignore file created!") diff --git a/tools/plugingenerator/templates/cmakelists_template.mako b/tools/plugingenerator/templates/cmakelists_template.mako index b0ab99cbb2..96d378591f 100644 --- a/tools/plugingenerator/templates/cmakelists_template.mako +++ b/tools/plugingenerator/templates/cmakelists_template.mako @@ -10,6 +10,9 @@ message(STATUS "building plugin: " ${"${SCOPY_MODULE}"}) project(scopy-${"${SCOPY_MODULE}"} VERSION 0.1 LANGUAGES CXX) +set(PLUGIN_DISPLAY_NAME ${plugin_display_name.upper()}) +set(PLUGIN_DESCRIPTION ${plugin_description.upper()}) + include(GenerateExportHeader) # TODO: split stylesheet/resources and add here TODO: export header files correctly @@ -58,6 +61,11 @@ generate_export_header( ${"${PROJECT_NAME}"} EXPORT_FILE_NAME ${"${CMAKE_CURRENT_SOURCE_DIR}"}/include/${"${SCOPY_MODULE}"}/${"${PROJECT_NAME}"}_export.h ) +configure_file( + include/${"${SCOPY_MODULE}"}/scopy-${"${SCOPY_MODULE}"}_config.h.cmakein + ${"${CMAKE_CURRENT_SOURCE_DIR}"}/include/${"${SCOPY_MODULE}"}/scopy-${"${SCOPY_MODULE}"}_config.h @ONLY +) + target_include_directories(${"${PROJECT_NAME}"} INTERFACE ${"${CMAKE_CURRENT_SOURCE_DIR}"}/include) target_include_directories(${"${PROJECT_NAME}"} PRIVATE ${"${CMAKE_CURRENT_SOURCE_DIR}"}/include/${"${SCOPY_MODULE}"}) @@ -72,6 +80,11 @@ target_link_libraries( scopy-iioutil ) -set(PLUGIN_NAME ${"${PROJECT_NAME}"} PARENT_SCOPE) +if(${"${CMAKE_SYSTEM_NAME}"} MATCHES "Windows") + configureinstallersettings(${"${SCOPY_MODULE}"} ${"${PLUGIN_DESCRIPTION}"} FALSE) +endif() + +set(${scopy_module}_TARGET_NAME ${"${PROJECT_NAME}"} PARENT_SCOPE) + install(TARGETS ${"${PROJECT_NAME}"} RUNTIME DESTINATION ${"${SCOPY_PLUGIN_INSTALL_DIR}"}) \ No newline at end of file diff --git a/tools/plugingenerator/templates/plugin_cmake_config_vars.mako b/tools/plugingenerator/templates/plugin_cmake_config_vars.mako new file mode 100644 index 0000000000..9fa7170396 --- /dev/null +++ b/tools/plugingenerator/templates/plugin_cmake_config_vars.mako @@ -0,0 +1,10 @@ +#ifndef SCOPY_${plugin_name.upper()}_CONFIG_H_CMAKEIN +#define SCOPY_${plugin_name.upper()}_CONFIG_H_CMAKEIN + +#define ${plugin_name.upper()}_PLUGIN_DISPLAY_NAME "@PLUGIN_DISPLAY_NAME@" +#define ${plugin_name.upper()}_PLUGIN_SCOPY_MODULE "@SCOPY_MODULE@" +#define ${plugin_name.upper()}_PLUGIN_DESCRIPTION "@PLUGIN_DESCRIPTION@" + +#cmakedefine ENABLE_SCOPYJS + +#endif // SCOPY_${plugin_name.upper()}_CONFIG_H_CMAKEIN diff --git a/tools/plugingenerator/templates/plugin_src_template.mako b/tools/plugingenerator/templates/plugin_src_template.mako index 0a5101899f..12bbbe9cc8 100644 --- a/tools/plugingenerator/templates/plugin_src_template.mako +++ b/tools/plugingenerator/templates/plugin_src_template.mako @@ -74,7 +74,7 @@ void ${config['class_name']}::loadToolList() void ${config['class_name']}::unload() { /*delete m_infoPage;*/ } -QString ${config['class_name']}::description() { return "Write the plugin description here"; } +QString ${config['class_name']}::description() { return "${config['plugin_description']}"; } bool ${config['class_name']}::onConnect() {