mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 18:45:54 -05:00
shaderc: Added command line argument for setting preprocessor defines. Issue #662.
This commit is contained in:
parent
beb8eea2fe
commit
6d80ef7835
1 changed files with 17 additions and 0 deletions
|
@ -4,6 +4,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "shaderc.h"
|
#include "shaderc.h"
|
||||||
|
#include <bx/tokenizecmd.h>
|
||||||
|
|
||||||
bool g_verbose = false;
|
bool g_verbose = false;
|
||||||
|
|
||||||
|
@ -662,6 +663,7 @@ void help(const char* _error = NULL)
|
||||||
" osx\n"
|
" osx\n"
|
||||||
" windows\n"
|
" windows\n"
|
||||||
" --preprocess Preprocess only.\n"
|
" --preprocess Preprocess only.\n"
|
||||||
|
" --define <defines> Add defines to preprocessor (semicolon separated).\n"
|
||||||
" --raw Do not process shader. No preprocessor, and no glsl-optimizer (GLSL only).\n"
|
" --raw Do not process shader. No preprocessor, and no glsl-optimizer (GLSL only).\n"
|
||||||
" --type <type> Shader type (vertex, fragment)\n"
|
" --type <type> Shader type (vertex, fragment)\n"
|
||||||
" --varyingdef <file path> Path to varying.def.sc file.\n"
|
" --varyingdef <file path> Path to varying.def.sc file.\n"
|
||||||
|
@ -807,6 +809,21 @@ int main(int _argc, const char* _argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* defines = cmdLine.findOption("define");
|
||||||
|
while (NULL != defines
|
||||||
|
&& '\0' != *defines)
|
||||||
|
{
|
||||||
|
defines = bx::strws(defines);
|
||||||
|
const char* eol = strchr(defines, ';');
|
||||||
|
if (NULL == eol)
|
||||||
|
{
|
||||||
|
eol = defines + strlen(defines);
|
||||||
|
}
|
||||||
|
std::string define(defines, eol);
|
||||||
|
preprocessor.setDefine(define.c_str());
|
||||||
|
defines = ';' == *eol ? eol+1 : eol;
|
||||||
|
}
|
||||||
|
|
||||||
preprocessor.setDefaultDefine("BX_PLATFORM_ANDROID");
|
preprocessor.setDefaultDefine("BX_PLATFORM_ANDROID");
|
||||||
preprocessor.setDefaultDefine("BX_PLATFORM_EMSCRIPTEN");
|
preprocessor.setDefaultDefine("BX_PLATFORM_EMSCRIPTEN");
|
||||||
preprocessor.setDefaultDefine("BX_PLATFORM_IOS");
|
preprocessor.setDefaultDefine("BX_PLATFORM_IOS");
|
||||||
|
|
Loading…
Reference in a new issue