diff --git a/tools/shaderc/shaderc.cpp b/tools/shaderc/shaderc.cpp index 4b6c7ec0..9c3c9849 100644 --- a/tools/shaderc/shaderc.cpp +++ b/tools/shaderc/shaderc.cpp @@ -4,6 +4,7 @@ */ #include "shaderc.h" +#include bool g_verbose = false; @@ -662,6 +663,7 @@ void help(const char* _error = NULL) " osx\n" " windows\n" " --preprocess Preprocess only.\n" + " --define Add defines to preprocessor (semicolon separated).\n" " --raw Do not process shader. No preprocessor, and no glsl-optimizer (GLSL only).\n" " --type Shader type (vertex, fragment)\n" " --varyingdef 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_EMSCRIPTEN"); preprocessor.setDefaultDefine("BX_PLATFORM_IOS");