Skip to content

Commit a07e79f

Browse files
committed
rename ndt to nsc, do not use common api PCH for the tool, update cmake/scripts/nbl/projectTargetName.cmake bug with unsetting a variable
1 parent 7a39c38 commit a07e79f

File tree

14 files changed

+95
-17
lines changed

14 files changed

+95
-17
lines changed

cmake/common.cmake

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ set(_NBL_CPACK_PACKAGE_RELATIVE_ENTRY_ "$<$<NOT:$<STREQUAL:$<CONFIG>,Release>>:$
2121
# Macro creating project for an executable
2222
# 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)
2323
# Created because of common cmake code for examples and tools
24-
macro(nbl_create_executable_project _EXTRA_SOURCES _EXTRA_OPTIONS _EXTRA_INCLUDES _EXTRA_LIBS _PCH_TARGET) # TODO remove _PCH_TARGET
25-
set(_NBL_PROJECT_DIRECTORY_ "${CMAKE_CURRENT_SOURCE_DIR}")
24+
macro(nbl_create_executable_project _EXTRA_SOURCES _EXTRA_OPTIONS _EXTRA_INCLUDES _EXTRA_LIBS)
25+
get_filename_component(_NBL_PROJECT_DIRECTORY_ "${CMAKE_CURRENT_SOURCE_DIR}" ABSOLUTE)
2626
include("scripts/nbl/projectTargetName") # sets EXECUTABLE_NAME
2727

2828
if(MSVC)
@@ -61,13 +61,17 @@ macro(nbl_create_executable_project _EXTRA_SOURCES _EXTRA_OPTIONS _EXTRA_INCLUDE
6161
if("${EXECUTABLE_NAME}" STREQUAL commonpch)
6262
add_dependencies(${EXECUTABLE_NAME} Nabla)
6363
else()
64-
if(NOT TARGET ${NBL_EXECUTABLE_COMMON_API_TARGET})
65-
message(FATAL_ERROR "Internal error, NBL_EXECUTABLE_COMMON_API_TARGET target must be defined!")
64+
string(FIND "${_NBL_PROJECT_DIRECTORY_}" "${NBL_ROOT_PATH}/examples_tests" _NBL_FOUND_)
65+
66+
if(NOT "${_NBL_FOUND_}" STREQUAL "-1") # the call was made for a target defined in examples_tests, request common api PCH
67+
if(NOT TARGET ${NBL_EXECUTABLE_COMMON_API_TARGET})
68+
message(FATAL_ERROR "Internal error, NBL_EXECUTABLE_COMMON_API_TARGET target must be defined to create an example target!")
69+
endif()
70+
71+
add_dependencies(${EXECUTABLE_NAME} ${NBL_EXECUTABLE_COMMON_API_TARGET})
72+
target_link_libraries(${EXECUTABLE_NAME} PUBLIC ${NBL_EXECUTABLE_COMMON_API_TARGET})
73+
target_precompile_headers("${EXECUTABLE_NAME}" REUSE_FROM "${NBL_EXECUTABLE_COMMON_API_TARGET}")
6674
endif()
67-
68-
add_dependencies(${EXECUTABLE_NAME} ${NBL_EXECUTABLE_COMMON_API_TARGET})
69-
target_link_libraries(${EXECUTABLE_NAME} PUBLIC ${NBL_EXECUTABLE_COMMON_API_TARGET})
70-
target_precompile_headers("${EXECUTABLE_NAME}" REUSE_FROM "${NBL_EXECUTABLE_COMMON_API_TARGET}")
7175
endif()
7276

7377
target_include_directories(${EXECUTABLE_NAME}

cmake/scripts/nbl/projectTargetName.cmake

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,4 @@ string(MAKE_C_IDENTIFIER ${EXECUTABLE_NAME} EXECUTABLE_NAME)
2727

2828
if(DEFINED CI)
2929
execute_process(COMMAND "${CMAKE_COMMAND}" -E echo "${EXECUTABLE_NAME}") # pipe example target name to stdout
30-
endif()
31-
32-
unset(_NBL_PROJECT_DIRECTORY_)
30+
endif()

tools/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
add_subdirectory(ndt)
1+
add_subdirectory(nsc)

tools/ndt/CMakeLists.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

tools/nsc/.profiles/0.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"cmake" :
3+
{
4+
"buildModes" : [],
5+
"configurations" : [ "Release", "Debug", "RelWithDebInfo" ],
6+
"requiredOptions" : []
7+
},
8+
"enableParallelBuild" : true,
9+
"input" :
10+
{
11+
"data" :
12+
[
13+
{
14+
"command" : "../bin/nsc.exe",
15+
"dependencies" : []
16+
}
17+
],
18+
"dependencies" : []
19+
},
20+
"isExecuted" : true,
21+
"profile" :
22+
{
23+
"backend" : "vulkan",
24+
"buildModes" : [],
25+
"gpuArchitectures" : [],
26+
"platform" : "windows",
27+
"runConfiguration" : "Release"
28+
},
29+
"scriptPath" : "../test/test.py",
30+
"threadsPerBuildProcess" : 2
31+
}

tools/nsc/.vscode/launch.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "nsc test module",
6+
"type": "python",
7+
"request": "launch",
8+
"module": "nsc",
9+
"justMyCode": true,
10+
"cwd": "${workspaceFolder}/../",
11+
}
12+
]
13+
}

tools/nsc/.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"python.analysis.extraPaths": [
3+
"../../tests/src"
4+
]
5+
}

tools/nsc/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
set(NBL_EXTRA_SOURCES
2+
# TODO: Cypi list extra sources if you need
3+
)
4+
5+
nbl_create_executable_project("${NBL_EXTRA_SOURCES}" "" "" "")
File renamed without changes.

tools/nsc/__main__.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright (C) 2023 - DevSH Graphics Programming Sp. z O.O.
2+
3+
# "nsc" target's test script, creates python environment for accessing
4+
# Nabla Python Framework module and runs the target's testing interface implementation
5+
6+
# Example of usage
7+
# 1) python3 -m <reference to this module>
8+
# - runs all profiles found, goes through all batches found in a profile being processed
9+
# 2) python3 -m <reference to this module> <profile path/index> [OPTIONAL] <batch index/range of batches> ... [OPTIONAL] <batch index/range of batches>
10+
# - 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)
11+
12+
import sys, os
13+
14+
testModulePath = os.path.dirname(__file__)
15+
nblPythonFrameworkModulePath = os.path.abspath(os.path.join(testModulePath, "../../tests/src"))
16+
17+
sys.path.append(nblPythonFrameworkModulePath) # relative path to Nabla's Python Framework module, relocatable
18+
19+
profile_count = sum(map(lambda arg: arg=="-c", sys.argv))
20+
profile_path = os.path.join(testModulePath, ".profiles")
21+
profile_args = list(map(lambda filename: os.path.join(profile_path, filename),\
22+
filter(lambda file: file.endswith(".json"), os.listdir(profile_path))))\
23+
if profile_count==0 else None
24+
repository_path = os.path.abspath(os.path.join(testModulePath, "../../"))
25+
26+
from .test.test import main
27+
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.

0 commit comments

Comments
 (0)