diff --git a/qrenderdoc/Code/pyrenderdoc/pyrenderdoc_stub.cpp b/qrenderdoc/Code/pyrenderdoc/pyrenderdoc_stub.cpp index b0abefd18..2d9bd2c7d 100644 --- a/qrenderdoc/Code/pyrenderdoc/pyrenderdoc_stub.cpp +++ b/qrenderdoc/Code/pyrenderdoc/pyrenderdoc_stub.cpp @@ -72,4 +72,9 @@ extern "C" void ProcessDecRefQueue() { } +extern "C" RENDERDOC_EXPORT_API int _rd_python_minor_version() +{ + return PY_MINOR_VERSION; +} + REPLAY_PROGRAM_MARKER() diff --git a/renderdoc/api/replay/renderdoc_replay.h b/renderdoc/api/replay/renderdoc_replay.h index 5e6dfef85..19d3e8ddf 100644 --- a/renderdoc/api/replay/renderdoc_replay.h +++ b/renderdoc/api/replay/renderdoc_replay.h @@ -2444,8 +2444,7 @@ extern "C" RENDERDOC_API int RENDERDOC_CC RENDERDOC_RunUnitTests(const rdcstr &c const rdcarray &args); DOCUMENT("INTERNAL: Run functional tests."); -extern "C" RENDERDOC_API int RENDERDOC_CC RENDERDOC_RunFunctionalTests(int pythonMinorVersion, - const rdcarray &args); +extern "C" RENDERDOC_API int RENDERDOC_CC RENDERDOC_RunFunctionalTests(const rdcarray &args); #endif #if !defined(SWIG) diff --git a/renderdoc/replay/entry_points.cpp b/renderdoc/replay/entry_points.cpp index 10ee2fe90..5a1be8eb9 100644 --- a/renderdoc/replay/entry_points.cpp +++ b/renderdoc/replay/entry_points.cpp @@ -891,8 +891,7 @@ static void TestPrintMsg(const rdcstr &msg) OSUtility::WriteOutput(OSUtility::Output_StdErr, msg.c_str()); } -extern "C" RENDERDOC_API int RENDERDOC_CC RENDERDOC_RunFunctionalTests(int pythonMinorVersion, - const rdcarray &args) +extern "C" RENDERDOC_API int RENDERDOC_CC RENDERDOC_RunFunctionalTests(const rdcarray &args) { #if ENABLED(RDOC_WIN32) const char *moduledir = "/pymodules"; @@ -932,6 +931,25 @@ extern "C" RENDERDOC_API int RENDERDOC_CC RENDERDOC_RunFunctionalTests(int pytho return 1; } + void *moduleHandle = Process::LoadModule(moduleFilename); + + int pythonMinorVersion = 0; + + if(moduleHandle) + { + typedef int (*PFN_rd_python_minor_version)(); + + PFN_rd_python_minor_version minor = (PFN_rd_python_minor_version)Process::GetFunctionAddress( + moduleHandle, "_rd_python_minor_version"); + + pythonMinorVersion = minor(); + } + else + { + TestPrintMsg(StringFormat::Fmt("Couldn't load python module at %s\n", moduleFilename.c_str())); + return 1; + } + // if we've been built either on windows or on linux from within the project root, going up two // directories from the library will put us at the project root. This is the most common scenario // and we don't add handling for locating the script elsewhere as in that case the user can run it diff --git a/renderdoccmd/CMakeLists.txt b/renderdoccmd/CMakeLists.txt index a0e2e0bb3..7f181469e 100644 --- a/renderdoccmd/CMakeLists.txt +++ b/renderdoccmd/CMakeLists.txt @@ -7,9 +7,9 @@ set(includes PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty ${CMAKE_SOURCE_DIR}/re set(libraries PRIVATE renderdoc) if(PythonLibs_FOUND) - add_definitions(-DPYTHON_VERSION_MINOR=${PYTHON_VERSION_MINOR}) + add_definitions(-DPYTHON_AVAILALBE=1) else() - add_definitions(-DPYTHON_VERSION_MINOR=0) + add_definitions(-DPYTHON_AVAILALBE=0) endif() if(APPLE) diff --git a/renderdoccmd/renderdoccmd.cpp b/renderdoccmd/renderdoccmd.cpp index c43ff67e5..a65cbb0aa 100644 --- a/renderdoccmd/renderdoccmd.cpp +++ b/renderdoccmd/renderdoccmd.cpp @@ -846,7 +846,7 @@ public: virtual void AddOptions(cmdline::parser &parser) { parser.set_footer( -#if PYTHON_VERSION_MINOR > 0 +#if PYTHON_AVAILABLE == 1 "" #else "" @@ -876,7 +876,7 @@ public: rest.erase(rest.begin()); if(mode != "unit" -#if PYTHON_VERSION_MINOR > 0 +#if PYTHON_AVAILABLE == 1 && mode != "functional" #endif ) @@ -898,9 +898,9 @@ public: { if(mode == "unit") return RENDERDOC_RunUnitTests("renderdoccmd test unit", args); -#if PYTHON_VERSION_MINOR > 0 +#if PYTHON_AVAILABLE == 1 else if(mode == "functional") - return RENDERDOC_RunFunctionalTests(PYTHON_VERSION_MINOR, args); + return RENDERDOC_RunFunctionalTests(args); #endif std::cerr << "Unsupported test frame work '" << mode << "'" << std::endl << std::endl; diff --git a/renderdoccmd/renderdoccmd.vcxproj b/renderdoccmd/renderdoccmd.vcxproj index 687d990e8..dd8d6650d 100644 --- a/renderdoccmd/renderdoccmd.vcxproj +++ b/renderdoccmd/renderdoccmd.vcxproj @@ -102,7 +102,7 @@ Level3 Disabled - WIN32;_CRT_SECURE_NO_WARNINGS;RENDERDOC_PLATFORM_WIN32;NDEBUG;_CONSOLE;PYTHON_VERSION_MINOR=6;%(PreprocessorDefinitions) + WIN32;_CRT_SECURE_NO_WARNINGS;RENDERDOC_PLATFORM_WIN32;NDEBUG;_CONSOLE;PYTHON_AVAILABLE=1;%(PreprocessorDefinitions) $(SolutionDir)renderdocshim\;$(SolutionDir)renderdoc\api\;$(SolutionDir)renderdoc\api\replay;$(SolutionDir)renderdoccmd\3rdparty\;$(SolutionDir)renderdoc\3rdparty\ MultiThreadedDLL true @@ -124,7 +124,7 @@ Level3 Disabled - WIN32;_CRT_SECURE_NO_WARNINGS;WIN64;RENDERDOC_PLATFORM_WIN32;NDEBUG;_CONSOLE;PYTHON_VERSION_MINOR=6;%(PreprocessorDefinitions) + WIN32;_CRT_SECURE_NO_WARNINGS;WIN64;RENDERDOC_PLATFORM_WIN32;NDEBUG;_CONSOLE;PYTHON_AVAILABLE=1;%(PreprocessorDefinitions) $(SolutionDir)renderdocshim\;$(SolutionDir)renderdoc\api\;$(SolutionDir)renderdoc\api\replay;$(SolutionDir)renderdoccmd\3rdparty\;$(SolutionDir)renderdoc\3rdparty\ MultiThreadedDLL true @@ -147,7 +147,7 @@ MaxSpeed true true - WIN32;_CRT_SECURE_NO_WARNINGS;RENDERDOC_PLATFORM_WIN32;NDEBUG;RELEASE;_CONSOLE;PYTHON_VERSION_MINOR=6;%(PreprocessorDefinitions) + WIN32;_CRT_SECURE_NO_WARNINGS;RENDERDOC_PLATFORM_WIN32;NDEBUG;RELEASE;_CONSOLE;PYTHON_AVAILABLE=1;%(PreprocessorDefinitions) $(SolutionDir)renderdocshim\;$(SolutionDir)renderdoc\api\;$(SolutionDir)renderdoc\api\replay;$(SolutionDir)renderdoccmd\3rdparty\;$(SolutionDir)renderdoc\3rdparty\ true @@ -170,7 +170,7 @@ MaxSpeed true true - WIN32;_CRT_SECURE_NO_WARNINGS;WIN64;RENDERDOC_PLATFORM_WIN32;NDEBUG;RELEASE;_CONSOLE;PYTHON_VERSION_MINOR=6;%(PreprocessorDefinitions) + WIN32;_CRT_SECURE_NO_WARNINGS;WIN64;RENDERDOC_PLATFORM_WIN32;NDEBUG;RELEASE;_CONSOLE;PYTHON_AVAILABLE=1;%(PreprocessorDefinitions) $(SolutionDir)renderdocshim\;$(SolutionDir)renderdoc\api\;$(SolutionDir)renderdoc\api\replay;$(SolutionDir)renderdoccmd\3rdparty\;$(SolutionDir)renderdoc\3rdparty\ true