Fix switch build

This commit is contained in:
Benau 2022-03-17 13:52:46 +08:00
parent f01959de8b
commit 38a553513c
4 changed files with 16 additions and 6 deletions

View File

@ -1465,7 +1465,7 @@ void CompileAndLinkShaderFiles(glslang::TWorklist& Worklist)
ShaderCompUnit compUnit(FindLanguage("stdin"));
std::istreambuf_iterator<char> begin(std::cin), end;
std::string tempString(begin, end);
char* fileText = strdup(tempString.c_str());
char* fileText = __Strdup(tempString.c_str());
std::string fileName = "stdin";
compUnit.addString(fileName, fileText);
compUnits.push_back(compUnit);
@ -1721,7 +1721,7 @@ void CompileFile(const char* fileName, ShHandle compiler)
if ((Options & EOptionStdin) != 0) {
std::istreambuf_iterator<char> begin(std::cin), end;
std::string tempString(begin, end);
shaderString = strdup(tempString.c_str());
shaderString = __Strdup(tempString.c_str());
} else {
shaderString = ReadFileData(fileName);
}

View File

@ -33,7 +33,7 @@
if(WIN32)
add_subdirectory(OSDependent/Windows)
elseif(UNIX OR "${CMAKE_SYSTEM_NAME}" STREQUAL "Fuchsia")
elseif(UNIX OR "${CMAKE_SYSTEM_NAME}" STREQUAL "Fuchsia" OR "${CMAKE_SYSTEM_NAME}" STREQUAL "NintendoSwitch")
add_subdirectory(OSDependent/Unix)
else()
message("unknown platform")

View File

@ -46,6 +46,7 @@
#endif
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <map>
#include <set>
@ -98,9 +99,15 @@ std::string to_string(const T& val) {
}
#endif
#if defined(_MSC_VER)
#define strdup _strdup
#endif
inline char* __Strdup(const char* s)
{
size_t slen = strlen(s);
char* result = (char*)malloc(slen + 1);
if (result == NULL)
return NULL;
memcpy(result, s, slen + 1);
return result;
}
/* windows only pragma */
#ifdef _MSC_VER

View File

@ -39,6 +39,9 @@ option(SPIRV_ALLOW_TIMERS "Allow timers via clock_gettime on supported platforms
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
add_definitions(-DSPIRV_LINUX)
set(SPIRV_TIMER_ENABLED ${SPIRV_ALLOW_TIMERS})
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "NintendoSwitch")
# STK addition treat it as linux, SPIRV_LINUX is used in source/print.cpp:17 only
add_definitions(-DSPIRV_LINUX)
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Emscripten")
add_definitions(-DSPIRV_EMSCRIPTEN)
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Windows")