Skip to content

Commit

Permalink
plugingenerator: Use pdk naming instead of sdk.
Browse files Browse the repository at this point in the history
Signed-off-by: andreidanila1 <[email protected]>
  • Loading branch information
andreidanila1 committed Aug 20, 2024
1 parent 8629515 commit 6ddecd8
Show file tree
Hide file tree
Showing 9 changed files with 131 additions and 131 deletions.
2 changes: 1 addition & 1 deletion tools/plugingenerator/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk":{
"pdk":{
"enable": true,
"deps_path": "",
"project_path": ""
Expand Down
162 changes: 81 additions & 81 deletions tools/plugingenerator/plugin_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

filesGenerated = []
directoriesGenerated = []
sdkSupport = generatorOptions["sdk"]["enable"]
pdkSupport = generatorOptions["pdk"]["enable"]
pluginDirName = generatorOptions["plugin"]["dir_name"]
pluginName = generatorOptions["plugin"]["plugin_name"]
pluginDisplayName = generatorOptions["plugin"]["plugin_display_name"]
Expand All @@ -55,19 +55,19 @@
print("Starting file generation:")

pluginsPath = os.path.join(pathToScopy, "plugins")
if sdkSupport:
sdkPath = generatorOptions["sdk"]["project_path"]
if not sdkPath:
sdkPath = os.path.join(pathToScopy, "ScopySDK")
if pdkSupport:
pdkPath = generatorOptions["pdk"]["project_path"]
if not pdkPath:
pdkPath = os.path.join(pathToScopy, "ScopyPDK")
else:
sdkPath = os.path.join(sdkPath, "ScopySDK")
pdkPath = os.path.join(pdkPath, "ScopyPDK")
try:
os.mkdir(sdkPath, mode)
directoriesGenerated.append(sdkPath)
os.mkdir(pdkPath, mode)
directoriesGenerated.append(pdkPath)
except FileExistsError:
print(sdkPath + " directory already exists!")
print(pdkPath + " directory already exists!")

pluginsPath = os.path.join(sdkPath, "plugin")
pluginsPath = os.path.join(pdkPath, "plugin")
try:
os.mkdir(pluginsPath, mode)
directoriesGenerated.append(pluginsPath)
Expand Down Expand Up @@ -120,106 +120,106 @@
else:
print(pluginSrcConfigPath + " file already exists!")

####################################################### sdk ##################################################
if sdkSupport:
sdkCmakeFuncFilePath = os.path.join(sdkPath, "SdkSupport.cmake")
if not os.path.exists(sdkCmakeFuncFilePath):
sdkCmakeFuncTemplate = Template(
filename="templates/sdk/sdk_cmake_func_template.mako"
####################################################### pdk ##################################################
if pdkSupport:
pdkCmakeFuncFilePath = os.path.join(pdkPath, "PdkSupport.cmake")
if not os.path.exists(pdkCmakeFuncFilePath):
pdkCmakeFuncTemplate = Template(
filename="templates/pdk/pdk_cmake_func_template.mako"
)
sdkCmakeFuncContent = sdkCmakeFuncTemplate.render()
sdkCmakeFuncFile = open(sdkCmakeFuncFilePath, "w")
sdkCmakeFuncFile.write(sdkCmakeFuncContent)
sdkCmakeFuncFile.close()
filesGenerated.append(sdkCmakeFuncFilePath)
pdkCmakeFuncContent = pdkCmakeFuncTemplate.render()
pdkCmakeFuncFile = open(pdkCmakeFuncFilePath, "w")
pdkCmakeFuncFile.write(pdkCmakeFuncContent)
pdkCmakeFuncFile.close()
filesGenerated.append(pdkCmakeFuncFilePath)
else:
print(sdkCmakeFuncFilePath + " file already exists!")
print(pdkCmakeFuncFilePath + " file already exists!")

sdkCmakeFilePath = os.path.join(sdkPath, "CMakeLists.txt")
if not os.path.exists(sdkCmakeFilePath):
sdkCmakeTemplate = Template(
filename="templates/sdk/sdk_cmake_template.mako"
pdkCmakeFilePath = os.path.join(pdkPath, "CMakeLists.txt")
if not os.path.exists(pdkCmakeFilePath):
pdkCmakeTemplate = Template(
filename="templates/pdk/pdk_cmake_template.mako"
)
sdkCmakeContent = sdkCmakeTemplate.render(
deps_path=generatorOptions["sdk"]["deps_path"],
pdkCmakeContent = pdkCmakeTemplate.render(
deps_path=generatorOptions["pdk"]["deps_path"],
plugin_dir=pluginDirName,
plugin_name=pluginName
)
sdkCmakeFile = open(sdkCmakeFilePath, "w")
sdkCmakeFile.write(sdkCmakeContent)
sdkCmakeFile.close()
filesGenerated.append(sdkCmakeFilePath)
pdkCmakeFile = open(pdkCmakeFilePath, "w")
pdkCmakeFile.write(pdkCmakeContent)
pdkCmakeFile.close()
filesGenerated.append(pdkCmakeFilePath)
else:
print(sdkCmakeFilePath + " file already exists!")
print(pdkCmakeFilePath + " file already exists!")

sdkIncludePath = os.path.join(sdkPath, "include")
pdkIncludePath = os.path.join(pdkPath, "include")
try:
os.mkdir(sdkIncludePath, mode)
directoriesGenerated.append(sdkIncludePath)
os.mkdir(pdkIncludePath, mode)
directoriesGenerated.append(pdkIncludePath)
except FileExistsError:
print(sdkIncludePath + " directory already exists!")
print(pdkIncludePath + " directory already exists!")

sdkHeaderFilePath = os.path.join(sdkIncludePath, "sdkwindow.h")
if not os.path.exists(sdkHeaderFilePath):
sdkHeaderTemplate = Template(
filename="templates/sdk/sdk_header_template.mako"
pdkHeaderFilePath = os.path.join(pdkIncludePath, "pdkwindow.h")
if not os.path.exists(pdkHeaderFilePath):
pdkHeaderTemplate = Template(
filename="templates/pdk/pdk_header_template.mako"
)
sdkHeaderContent = sdkHeaderTemplate.render()
sdkHeaderFile = open(sdkHeaderFilePath, "w")
sdkHeaderFile.write(sdkHeaderContent)
sdkHeaderFile.close()
filesGenerated.append(sdkHeaderFilePath)
pdkHeaderContent = pdkHeaderTemplate.render()
pdkHeaderFile = open(pdkHeaderFilePath, "w")
pdkHeaderFile.write(pdkHeaderContent)
pdkHeaderFile.close()
filesGenerated.append(pdkHeaderFilePath)
else:
print(sdkHeaderFilePath + " file already exists!")
print(pdkHeaderFilePath + " file already exists!")

sdkCmakeInFilePath = os.path.join(sdkIncludePath, "sdk-util_config.h.cmakein")
if not os.path.exists(sdkCmakeInFilePath):
sdkCmakeInTemplate = Template(
filename="templates/sdk/sdk_cmakein_template.mako"
pdkCmakeInFilePath = os.path.join(pdkIncludePath, "pdk-util_config.h.cmakein")
if not os.path.exists(pdkCmakeInFilePath):
pdkCmakeInTemplate = Template(
filename="templates/pdk/pdk_cmakein_template.mako"
)
sdkCmakeInTemplate = sdkCmakeInTemplate.render()
sdkCmakeInFile = open(sdkCmakeInFilePath, "w")
sdkCmakeInFile.write(sdkCmakeInTemplate)
sdkCmakeInFile.close()
filesGenerated.append(sdkCmakeInFilePath)
pdkCmakeInTemplate = pdkCmakeInTemplate.render()
pdkCmakeInFile = open(pdkCmakeInFilePath, "w")
pdkCmakeInFile.write(pdkCmakeInTemplate)
pdkCmakeInFile.close()
filesGenerated.append(pdkCmakeInFilePath)
else:
print(sdkCmakeInFilePath + " file already exists!")
print(pdkCmakeInFilePath + " file already exists!")

sdkSrcPath = os.path.join(sdkPath, "src")
pdkSrcPath = os.path.join(pdkPath, "src")
try:
os.mkdir(sdkSrcPath, mode)
directoriesGenerated.append(sdkSrcPath)
os.mkdir(pdkSrcPath, mode)
directoriesGenerated.append(pdkSrcPath)
except FileExistsError:
print(sdkSrcPath + " directory already exists!")
print(pdkSrcPath + " directory already exists!")

sdkSrcFilePath = os.path.join(sdkSrcPath, "main.cpp")
if not os.path.exists(sdkSrcFilePath):
sdkSrcTemplate = Template(
filename="templates/sdk/sdk_src_template.mako"
pdkSrcFilePath = os.path.join(pdkSrcPath, "main.cpp")
if not os.path.exists(pdkSrcFilePath):
pdkSrcTemplate = Template(
filename="templates/pdk/pdk_src_template.mako"
)
sdkSrcContent = sdkSrcTemplate.render()
sdkSrcFile = open(sdkSrcFilePath, "w")
sdkSrcFile.write(sdkSrcContent)
sdkSrcFile.close()
filesGenerated.append(sdkSrcFilePath)
pdkSrcContent = pdkSrcTemplate.render()
pdkSrcFile = open(pdkSrcFilePath, "w")
pdkSrcFile.write(pdkSrcContent)
pdkSrcFile.close()
filesGenerated.append(pdkSrcFilePath)

sdkResPath = os.path.join(sdkPath, "res")
pdkResPath = os.path.join(pdkPath, "res")
try:
os.mkdir(sdkResPath, mode)
directoriesGenerated.append(sdkResPath)
os.mkdir(pdkResPath, mode)
directoriesGenerated.append(pdkResPath)
except FileExistsError:
print(sdkResPath + " directory already exists!")
shutil.copy(pathToScopy+"/gui/res/stylesheets/default.qss",sdkResPath)
sdkResQrc = os.path.join(sdkResPath, "resources.qrc")
if not os.path.exists(sdkResQrc):
resFile = open(sdkResQrc, "w")
print(pdkResPath + " directory already exists!")
shutil.copy(pathToScopy+"/gui/res/stylesheets/default.qss",pdkResPath)
pdkResQrc = os.path.join(pdkResPath, "resources.qrc")
if not os.path.exists(pdkResQrc):
resFile = open(pdkResQrc, "w")
resFile.write("<RCC>\n")
resFile.write(" <qresource prefix=\"/\">\n")
resFile.write(" <file>default.qss</file>\n")
resFile.write(" </qresource>\n")
resFile.write("</RCC>")
resFile.close()
filesGenerated.append(sdkResQrc)
filesGenerated.append(pdkResQrc)

##################################################### Include ################################################
includePath = os.path.join(newPluginPath, "include")
Expand Down Expand Up @@ -294,7 +294,7 @@
+ str(generatorOptions["test"]["cmake_min_required"])
+ ")\n\n"
)
if not sdkSupport:
if not pdkSupport:
if generatorOptions["test"]["tst_pluginloader"]:
testCmakeFile.write("include(ScopyTest)\n\nsetup_scopy_tests(pluginloader)")
filesGenerated.append(testCmakePath)
Expand Down Expand Up @@ -344,7 +344,7 @@
cmakeTemplate = Template(filename="templates/cmakelists_template.mako")

cmakeContent = cmakeTemplate.render(
sdk_en=sdkSupport,
pdk_en=pdkSupport,
scopy_module=pluginName,
plugin_display_name=pluginDisplayName,
plugin_description=pluginDecription, config=generatorOptions["cmakelists"]
Expand Down
8 changes: 4 additions & 4 deletions tools/plugingenerator/templates/cmakelists_template.mako
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ target_include_directories(${"${PROJECT_NAME}"} INTERFACE ${"${CMAKE_CURRENT_SOU
target_include_directories(${"${PROJECT_NAME}"} PRIVATE ${"${CMAKE_CURRENT_SOURCE_DIR}"}/include/${"${SCOPY_MODULE}"})

% if oot_en:
target_include_directories(${"${PROJECT_NAME}"} PRIVATE ${"${SDK_DEPS_INCLUDE}"})
target_include_directories(${"${PROJECT_NAME}"} PRIVATE ${"${PDK_DEPS_INCLUDE}"})

include(${"${CMAKE_SOURCE_DIR}"}/SdkSupport.cmake)
inlcude_dirs(${"${SDK_DEPS_INCLUDE}"})
include(${"${CMAKE_SOURCE_DIR}"}/PdkSupport.cmake)
inlcude_dirs(${"${PDK_DEPS_INCLUDE}"})

target_link_libraries(${"${PROJECT_NAME}"} PUBLIC Qt::Widgets Qt::Core)

link_libs(${"${SDK_DEPS_LIB}"})
link_libs(${"${PDK_DEPS_LIB}"})

% else:
target_include_directories(${"${PROJECT_NAME}"} PUBLIC scopy-pluginbase scopy-gui)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.9)

# Project name
set(TARGET_NAME "ScopySDK")
set(TARGET_NAME "ScopyPDK")

project(${"${TARGET_NAME}"} VERSION 0.0.1 DESCRIPTION "Project Description")

Expand All @@ -11,22 +11,22 @@ set(CMAKE_AUTOMOC ON)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(SDK_DEPS_PATH ${deps_path})
if(NOT DEFINED SDK_DEPS_PATH)
message(FATAL_ERROR "SDK_DEPS_PATH is required!")
set(PDK_DEPS_PATH ${deps_path})
if(NOT DEFINED PDK_DEPS_PATH)
message(FATAL_ERROR "PDK_DEPS_PATH is required!")
else()
if(NOT EXISTS ${"${SDK_DEPS_PATH}"})
message(FATAL_ERROR "The path=" \"${"${SDK_DEPS_PATH}"}\" " to the dependencies doesn't exist!")
if(NOT EXISTS ${"${PDK_DEPS_PATH}"})
message(FATAL_ERROR "The path=" \"${"${PDK_DEPS_PATH}"}\" " to the dependencies doesn't exist!")
endif()
endif()
set(SDK_DEPS_INCLUDE ${"${SDK_DEPS_PATH}"}/usr/local/include)
if(NOT EXISTS ${"${SDK_DEPS_INCLUDE}"})
message(FATAL_ERROR "The path=" \"${"${SDK_DEPS_INCLUDE}"}\" " to the headers doesn't exist!")
set(PDK_DEPS_INCLUDE ${"${PDK_DEPS_PATH}"}/usr/local/include)
if(NOT EXISTS ${"${PDK_DEPS_INCLUDE}"})
message(FATAL_ERROR "The path=" \"${"${PDK_DEPS_INCLUDE}"}\" " to the headers doesn't exist!")
endif()

set(SDK_DEPS_LIB ${"${SDK_DEPS_PATH}"}/usr/local/lib)
if(NOT EXISTS ${"${SDK_DEPS_LIB}"})
message(FATAL_ERROR "The path=" \"${"${SDK_DEPS_LIB}"}\" " to the libraries doesn't exist!")
set(PDK_DEPS_LIB ${"${PDK_DEPS_PATH}"}/usr/local/lib)
if(NOT EXISTS ${"${PDK_DEPS_LIB}"})
message(FATAL_ERROR "The path=" \"${"${PDK_DEPS_LIB}"}\" " to the libraries doesn't exist!")
endif()

set(PLUGIN_INSTALL_PATH ${"${CMAKE_CURRENT_BINARY_DIR}"}/plugin/${plugin_dir}/libscopy-${plugin_name}.so)
Expand All @@ -37,9 +37,9 @@ find_package(Qt${"${QT_VERSION_MAJOR}"} REQUIRED COMPONENTS Widgets Core)
file(GLOB SRC_LIST src/*.cpp)
file(GLOB HEADER_LIST include/*.h include/*.hpp)

configure_file(include/sdk-util_config.h.cmakein ${"${CMAKE_CURRENT_SOURCE_DIR}"}/include/sdk-util_config.h @ONLY)
configure_file(include/pdk-util_config.h.cmakein ${"${CMAKE_CURRENT_SOURCE_DIR}"}/include/pdk-util_config.h @ONLY)

set(PROJECT_SOURCES ${"${SRC_LIST}"} ${"${HEADER_LIST}"} ${"${CMAKE_CURRENT_SOURCE_DIR}"}/include/sdk-util_config.h)
set(PROJECT_SOURCES ${"${SRC_LIST}"} ${"${HEADER_LIST}"} ${"${CMAKE_CURRENT_SOURCE_DIR}"}/include/pdk-util_config.h)
find_path(IIO_INCLUDE_DIRS iio.h REQUIRED)
find_library(IIO_LIBRARIES NAMES iio libiio REQUIRED)

Expand All @@ -49,17 +49,17 @@ qt_add_resources(PROJ_RES res/resources.qrc)

add_executable(${"${TARGET_NAME}"} ${"${PROJECT_SOURCES}"} ${"${PROJ_RES}"})

include(${"${CMAKE_CURRENT_SOURCE_DIR}"}/SdkSupport.cmake)
include(${"${CMAKE_CURRENT_SOURCE_DIR}"}/PdkSupport.cmake)

target_include_directories(${"${TARGET_NAME}"} PRIVATE ${"${Qt${QT_VERSION_MAJOR}_INCLUDE_DIRS}"})
target_include_directories(${"${TARGET_NAME}"} PRIVATE ${"${CMAKE_SOURCE_DIR}"}/include)
target_include_directories(${"${TARGET_NAME}"} INTERFACE ${"${IIO_INCLUDE_DIRS}"})

target_include_directories(${"${TARGET_NAME}"} PUBLIC ${"${SDK_DEPS_INCLUDE}"} ${"${IIO_INCLUDE_DIRS}"})
target_include_directories(${"${TARGET_NAME}"} PUBLIC ${"${PDK_DEPS_INCLUDE}"} ${"${IIO_INCLUDE_DIRS}"})

inlcude_dirs(${"${SDK_DEPS_INCLUDE}"})
inlcude_dirs(${"${PDK_DEPS_INCLUDE}"})
# Add any extra libs to link also.
link_libs(${"${SDK_DEPS_LIB}"})
link_libs(${"${PDK_DEPS_LIB}"})
target_link_libraries(
${"${TARGET_NAME}"} PRIVATE Qt${"${QT_VERSION_MAJOR}"}::Widgets Qt${"${QT_VERSION_MAJOR}"}::Core ${"${IIO_LIBRARIES}"}
)
6 changes: 6 additions & 0 deletions tools/plugingenerator/templates/pdk/pdk_cmakein_template.mako
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef PDK_UTIL_H_CMAKEIN
#define PDK_UTIL_H_CMAKEIN

#define PLUGIN_INSTALL_PATH "@PLUGIN_INSTALL_PATH@"

#endif // PDK_UTIL_H_CMAKEIN
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
class MainWidget;
class PluginManager;

class SDKWindow : public QMainWindow
class PDKWindow : public QMainWindow
{
Q_OBJECT
public:
SDKWindow(QWidget *parent = nullptr);
~SDKWindow();
PDKWindow(QWidget *parent = nullptr);
~PDKWindow();

public Q_SLOTS:
void onConnect();
Expand Down
Loading

0 comments on commit 6ddecd8

Please sign in to comment.