Skip to content

Commit

Permalink
plugingenerator: update to match new CMAKE variables content
Browse files Browse the repository at this point in the history
Signed-off-by: Ionut Muthi <[email protected]>
  • Loading branch information
IonutMuthi committed Jun 13, 2024
1 parent e5f56ac commit 651f186
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 3 deletions.
2 changes: 2 additions & 0 deletions tools/plugingenerator/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
27 changes: 26 additions & 1 deletion tools/plugingenerator/plugin_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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):
Expand All @@ -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"]
Expand Down Expand Up @@ -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!")

Expand Down
15 changes: 14 additions & 1 deletion tools/plugingenerator/templates/cmakelists_template.mako
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}"})

Expand All @@ -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}"})
10 changes: 10 additions & 0 deletions tools/plugingenerator/templates/plugin_cmake_config_vars.mako
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion tools/plugingenerator/templates/plugin_src_template.mako
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down

0 comments on commit 651f186

Please sign in to comment.