From a07e79f0993b8319181a71c0bc0038620b7d14cb Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Thu, 18 Jan 2024 21:32:37 +0100 Subject: [PATCH] rename ndt to nsc, do not use common api PCH for the tool, update cmake/scripts/nbl/projectTargetName.cmake bug with unsetting a variable --- cmake/common.cmake | 20 +++++++----- cmake/scripts/nbl/projectTargetName.cmake | 4 +-- tools/CMakeLists.txt | 2 +- tools/ndt/CMakeLists.txt | 5 --- tools/nsc/.profiles/0.json | 31 +++++++++++++++++++ tools/nsc/.vscode/launch.json | 13 ++++++++ tools/nsc/.vscode/settings.json | 5 +++ tools/nsc/CMakeLists.txt | 5 +++ tools/{ndt => nsc}/__init__.py | 0 tools/nsc/__main__.py | 27 ++++++++++++++++ tools/{ndt => nsc}/config.json.template | 0 tools/{ndt => nsc}/main.cpp | 0 .../test/config/release.json.template | 0 tools/{ndt => nsc}/test/test.py | 0 14 files changed, 95 insertions(+), 17 deletions(-) delete mode 100644 tools/ndt/CMakeLists.txt create mode 100644 tools/nsc/.profiles/0.json create mode 100644 tools/nsc/.vscode/launch.json create mode 100644 tools/nsc/.vscode/settings.json create mode 100644 tools/nsc/CMakeLists.txt rename tools/{ndt => nsc}/__init__.py (100%) create mode 100644 tools/nsc/__main__.py rename tools/{ndt => nsc}/config.json.template (100%) rename tools/{ndt => nsc}/main.cpp (100%) rename tools/{ndt => nsc}/test/config/release.json.template (100%) rename tools/{ndt => nsc}/test/test.py (100%) diff --git a/cmake/common.cmake b/cmake/common.cmake index d8f9ffdb5d..a5d4f92eb5 100755 --- a/cmake/common.cmake +++ b/cmake/common.cmake @@ -21,8 +21,8 @@ set(_NBL_CPACK_PACKAGE_RELATIVE_ENTRY_ "$<$,Release>>:$ # Macro creating project for an executable # Project and target get its name from directory when this macro gets executed (truncating number in the beginning of the name and making all lower case) # Created because of common cmake code for examples and tools -macro(nbl_create_executable_project _EXTRA_SOURCES _EXTRA_OPTIONS _EXTRA_INCLUDES _EXTRA_LIBS _PCH_TARGET) # TODO remove _PCH_TARGET - set(_NBL_PROJECT_DIRECTORY_ "${CMAKE_CURRENT_SOURCE_DIR}") +macro(nbl_create_executable_project _EXTRA_SOURCES _EXTRA_OPTIONS _EXTRA_INCLUDES _EXTRA_LIBS) + get_filename_component(_NBL_PROJECT_DIRECTORY_ "${CMAKE_CURRENT_SOURCE_DIR}" ABSOLUTE) include("scripts/nbl/projectTargetName") # sets EXECUTABLE_NAME if(MSVC) @@ -61,13 +61,17 @@ macro(nbl_create_executable_project _EXTRA_SOURCES _EXTRA_OPTIONS _EXTRA_INCLUDE if("${EXECUTABLE_NAME}" STREQUAL commonpch) add_dependencies(${EXECUTABLE_NAME} Nabla) else() - if(NOT TARGET ${NBL_EXECUTABLE_COMMON_API_TARGET}) - message(FATAL_ERROR "Internal error, NBL_EXECUTABLE_COMMON_API_TARGET target must be defined!") + string(FIND "${_NBL_PROJECT_DIRECTORY_}" "${NBL_ROOT_PATH}/examples_tests" _NBL_FOUND_) + + if(NOT "${_NBL_FOUND_}" STREQUAL "-1") # the call was made for a target defined in examples_tests, request common api PCH + if(NOT TARGET ${NBL_EXECUTABLE_COMMON_API_TARGET}) + message(FATAL_ERROR "Internal error, NBL_EXECUTABLE_COMMON_API_TARGET target must be defined to create an example target!") + endif() + + add_dependencies(${EXECUTABLE_NAME} ${NBL_EXECUTABLE_COMMON_API_TARGET}) + target_link_libraries(${EXECUTABLE_NAME} PUBLIC ${NBL_EXECUTABLE_COMMON_API_TARGET}) + target_precompile_headers("${EXECUTABLE_NAME}" REUSE_FROM "${NBL_EXECUTABLE_COMMON_API_TARGET}") endif() - - add_dependencies(${EXECUTABLE_NAME} ${NBL_EXECUTABLE_COMMON_API_TARGET}) - target_link_libraries(${EXECUTABLE_NAME} PUBLIC ${NBL_EXECUTABLE_COMMON_API_TARGET}) - target_precompile_headers("${EXECUTABLE_NAME}" REUSE_FROM "${NBL_EXECUTABLE_COMMON_API_TARGET}") endif() target_include_directories(${EXECUTABLE_NAME} diff --git a/cmake/scripts/nbl/projectTargetName.cmake b/cmake/scripts/nbl/projectTargetName.cmake index 7e4a177ac5..dd0a504450 100644 --- a/cmake/scripts/nbl/projectTargetName.cmake +++ b/cmake/scripts/nbl/projectTargetName.cmake @@ -27,6 +27,4 @@ string(MAKE_C_IDENTIFIER ${EXECUTABLE_NAME} EXECUTABLE_NAME) if(DEFINED CI) execute_process(COMMAND "${CMAKE_COMMAND}" -E echo "${EXECUTABLE_NAME}") # pipe example target name to stdout -endif() - -unset(_NBL_PROJECT_DIRECTORY_) \ No newline at end of file +endif() \ No newline at end of file diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 45008c281b..f1d6f1bc0c 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1 +1 @@ -add_subdirectory(ndt) \ No newline at end of file +add_subdirectory(nsc) \ No newline at end of file diff --git a/tools/ndt/CMakeLists.txt b/tools/ndt/CMakeLists.txt deleted file mode 100644 index 82112ee147..0000000000 --- a/tools/ndt/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -set(NBL_EXTRA_SOURCES - # TODO: Cypi list extra sources if you need -) - -nbl_create_executable_project("${NBL_EXTRA_SOURCES}" "" "" "" "${NBL_EXECUTABLE_PROJECT_CREATION_PCH_TARGET}") \ No newline at end of file diff --git a/tools/nsc/.profiles/0.json b/tools/nsc/.profiles/0.json new file mode 100644 index 0000000000..2460d56e66 --- /dev/null +++ b/tools/nsc/.profiles/0.json @@ -0,0 +1,31 @@ +{ + "cmake" : + { + "buildModes" : [], + "configurations" : [ "Release", "Debug", "RelWithDebInfo" ], + "requiredOptions" : [] + }, + "enableParallelBuild" : true, + "input" : + { + "data" : + [ + { + "command" : "../bin/nsc.exe", + "dependencies" : [] + } + ], + "dependencies" : [] + }, + "isExecuted" : true, + "profile" : + { + "backend" : "vulkan", + "buildModes" : [], + "gpuArchitectures" : [], + "platform" : "windows", + "runConfiguration" : "Release" + }, + "scriptPath" : "../test/test.py", + "threadsPerBuildProcess" : 2 +} \ No newline at end of file diff --git a/tools/nsc/.vscode/launch.json b/tools/nsc/.vscode/launch.json new file mode 100644 index 0000000000..34dc733b05 --- /dev/null +++ b/tools/nsc/.vscode/launch.json @@ -0,0 +1,13 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "nsc test module", + "type": "python", + "request": "launch", + "module": "nsc", + "justMyCode": true, + "cwd": "${workspaceFolder}/../", + } + ] +} diff --git a/tools/nsc/.vscode/settings.json b/tools/nsc/.vscode/settings.json new file mode 100644 index 0000000000..0a7332f872 --- /dev/null +++ b/tools/nsc/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "python.analysis.extraPaths": [ + "../../tests/src" + ] +} diff --git a/tools/nsc/CMakeLists.txt b/tools/nsc/CMakeLists.txt new file mode 100644 index 0000000000..f72ce3bcfb --- /dev/null +++ b/tools/nsc/CMakeLists.txt @@ -0,0 +1,5 @@ +set(NBL_EXTRA_SOURCES + # TODO: Cypi list extra sources if you need +) + +nbl_create_executable_project("${NBL_EXTRA_SOURCES}" "" "" "") \ No newline at end of file diff --git a/tools/ndt/__init__.py b/tools/nsc/__init__.py similarity index 100% rename from tools/ndt/__init__.py rename to tools/nsc/__init__.py diff --git a/tools/nsc/__main__.py b/tools/nsc/__main__.py new file mode 100644 index 0000000000..043a82f3f5 --- /dev/null +++ b/tools/nsc/__main__.py @@ -0,0 +1,27 @@ +# Copyright (C) 2023 - DevSH Graphics Programming Sp. z O.O. + +# "nsc" target's test script, creates python environment for accessing +# Nabla Python Framework module and runs the target's testing interface implementation + +# Example of usage +# 1) python3 -m +# - runs all profiles found, goes through all batches found in a profile being processed +# 2) python3 -m [OPTIONAL] ... [OPTIONAL] +# - runs given profile, if batch index (or range of batches) is given then it will process only the index of the batch (or the range) + +import sys, os + +testModulePath = os.path.dirname(__file__) +nblPythonFrameworkModulePath = os.path.abspath(os.path.join(testModulePath, "../../tests/src")) + +sys.path.append(nblPythonFrameworkModulePath) # relative path to Nabla's Python Framework module, relocatable + +profile_count = sum(map(lambda arg: arg=="-c", sys.argv)) +profile_path = os.path.join(testModulePath, ".profiles") +profile_args = list(map(lambda filename: os.path.join(profile_path, filename),\ + filter(lambda file: file.endswith(".json"), os.listdir(profile_path))))\ + if profile_count==0 else None +repository_path = os.path.abspath(os.path.join(testModulePath, "../../")) + +from .test.test import main +main(None, profile_args, repository_path, True) # each test target implements its testing interface by overriding common one in Nabla Python Framework module diff --git a/tools/ndt/config.json.template b/tools/nsc/config.json.template similarity index 100% rename from tools/ndt/config.json.template rename to tools/nsc/config.json.template diff --git a/tools/ndt/main.cpp b/tools/nsc/main.cpp similarity index 100% rename from tools/ndt/main.cpp rename to tools/nsc/main.cpp diff --git a/tools/ndt/test/config/release.json.template b/tools/nsc/test/config/release.json.template similarity index 100% rename from tools/ndt/test/config/release.json.template rename to tools/nsc/test/config/release.json.template diff --git a/tools/ndt/test/test.py b/tools/nsc/test/test.py similarity index 100% rename from tools/ndt/test/test.py rename to tools/nsc/test/test.py