Skip to content

Commit

Permalink
rename ndt to nsc, do not use common api PCH for the tool, update cma…
Browse files Browse the repository at this point in the history
…ke/scripts/nbl/projectTargetName.cmake bug with unsetting a variable
  • Loading branch information
AnastaZIuk committed Jan 18, 2024
1 parent 7a39c38 commit a07e79f
Show file tree
Hide file tree
Showing 14 changed files with 95 additions and 17 deletions.
20 changes: 12 additions & 8 deletions cmake/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ set(_NBL_CPACK_PACKAGE_RELATIVE_ENTRY_ "$<$<NOT:$<STREQUAL:$<CONFIG>,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)
Expand Down Expand Up @@ -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}
Expand Down
4 changes: 1 addition & 3 deletions cmake/scripts/nbl/projectTargetName.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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_)
endif()
2 changes: 1 addition & 1 deletion tools/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
add_subdirectory(ndt)
add_subdirectory(nsc)
5 changes: 0 additions & 5 deletions tools/ndt/CMakeLists.txt

This file was deleted.

31 changes: 31 additions & 0 deletions tools/nsc/.profiles/0.json
Original file line number Diff line number Diff line change
@@ -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
}
13 changes: 13 additions & 0 deletions tools/nsc/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "nsc test module",
"type": "python",
"request": "launch",
"module": "nsc",
"justMyCode": true,
"cwd": "${workspaceFolder}/../",
}
]
}
5 changes: 5 additions & 0 deletions tools/nsc/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"python.analysis.extraPaths": [
"../../tests/src"
]
}
5 changes: 5 additions & 0 deletions tools/nsc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set(NBL_EXTRA_SOURCES
# TODO: Cypi list extra sources if you need
)

nbl_create_executable_project("${NBL_EXTRA_SOURCES}" "" "" "")
File renamed without changes.
27 changes: 27 additions & 0 deletions tools/nsc/__main__.py
Original file line number Diff line number Diff line change
@@ -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 <reference to this module>
# - runs all profiles found, goes through all batches found in a profile being processed
# 2) python3 -m <reference to this module> <profile path/index> [OPTIONAL] <batch index/range of batches> ... [OPTIONAL] <batch index/range of batches>
# - 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit a07e79f

Please sign in to comment.