From 71ee9fffc0cb570bc1c8c0bf1052bd092f561088 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Sat, 11 Mar 2017 14:22:13 -0800 Subject: [PATCH] Moved glsl-optimizer into separate library. --- scripts/shaderc.lua | 94 +++++++++++++++++++++++++++++++-------------- 1 file changed, 65 insertions(+), 29 deletions(-) diff --git a/scripts/shaderc.lua b/scripts/shaderc.lua index 319062c98..b1727ed59 100644 --- a/scripts/shaderc.lua +++ b/scripts/shaderc.lua @@ -3,6 +3,9 @@ -- License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause -- +local GLSL_OPTIMIZER = path.join(BGFX_DIR, "3rdparty/glsl-optimizer") +local FCPP_DIR = path.join(BGFX_DIR, "3rdparty/fcpp") + project "glslang" kind "StaticLib" @@ -19,6 +22,11 @@ project "glslang" buildoptions { "/wd4005", -- warning C4005: '_CRT_SECURE_NO_WARNINGS': macro redefinition "/wd4100", -- error C4100: 'inclusionDepth' : unreferenced formal parameter + "/wd4127", -- warning C4127: conditional expression is constant + "/wd4456", -- warning C4456: declaration of 'feature' hides previous local declaration + "/wd4457", -- warning C4457: declaration of 'token' hides function parameter + "/wd4458", -- warning C4458: declaration of 'language' hides class member + "/wd4702", -- warning C4702: unreachable code } configuration { "not vs*" } @@ -90,18 +98,51 @@ project "glslang" configuration {} -project "shaderc" - kind "ConsoleApp" - - local GLSL_OPTIMIZER = path.join(BGFX_DIR, "3rdparty/glsl-optimizer") - local FCPP_DIR = path.join(BGFX_DIR, "3rdparty/fcpp") +project "glsl-optimizer" + kind "StaticLib" includedirs { path.join(GLSL_OPTIMIZER, "src"), + path.join(GLSL_OPTIMIZER, "include"), + path.join(GLSL_OPTIMIZER, "src/mesa"), + path.join(GLSL_OPTIMIZER, "src/mapi"), + path.join(GLSL_OPTIMIZER, "src/glsl"), } - links { - "bx", + configuration { "vs*" } + buildoptions { + "/wd4100", -- error C4100: '' : unreferenced formal parameter + "/wd4127", -- warning C4127: conditional expression is constant + "/wd4132", -- warning C4132: 'deleted_key_value': const object should be initialized + "/wd4189", -- warning C4189: 'interface_type': local variable is initialized but not referenced + "/wd4204", -- warning C4204: nonstandard extension used: non-constant aggregate initializer + "/wd4244", -- warning C4244: '=': conversion from 'const flex_int32_t' to 'YY_CHAR', possible loss of data + "/wd4389", -- warning C4389: '!=': signed/unsigned mismatch + "/wd4245", -- warning C4245: 'return': conversion from 'int' to 'unsigned int', signed/unsigned mismatch + "/wd4701", -- warning C4701: potentially uninitialized local variable 'lower' used + "/wd4702", -- warning C4702: unreachable code + "/wd4706", -- warning C4706: assignment within conditional expression + } + + files { + path.join(GLSL_OPTIMIZER, "src/mesa/**.c"), + path.join(GLSL_OPTIMIZER, "src/glsl/**.cpp"), + path.join(GLSL_OPTIMIZER, "src/mesa/**.h"), + path.join(GLSL_OPTIMIZER, "src/glsl/**.c"), + path.join(GLSL_OPTIMIZER, "src/glsl/**.cpp"), + path.join(GLSL_OPTIMIZER, "src/glsl/**.h"), + path.join(GLSL_OPTIMIZER, "src/util/**.c"), + path.join(GLSL_OPTIMIZER, "src/util/**.h"), + } + + removefiles { + path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/glcpp.c"), + path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/tests/**"), + path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/**.l"), + path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/**.y"), + path.join(GLSL_OPTIMIZER, "src/glsl/ir_set_program_inouts.cpp"), + path.join(GLSL_OPTIMIZER, "src/glsl/main.cpp"), + path.join(GLSL_OPTIMIZER, "src/glsl/builtin_stubs.cpp"), } configuration { "Release" } @@ -131,9 +172,6 @@ project "shaderc" "/wd4996" -- warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. } - configuration { "mingw-*" } - targetextension ".exe" - configuration { "mingw* or linux or osx" } buildoptions { "-fno-strict-aliasing", -- glsl-optimizer has bugs if strict aliasing is used. @@ -143,6 +181,22 @@ project "shaderc" "-Wshadow", -- glsl-optimizer is full of -Wshadow warnings ignore it. } + configuration {} + +project "shaderc" + kind "ConsoleApp" + + includedirs { + path.join(GLSL_OPTIMIZER, "include"), + } + + links { + "bx", + } + + configuration { "mingw-*" } + targetextension ".exe" + configuration { "osx" } links { "Cocoa.framework", @@ -199,29 +253,11 @@ project "shaderc" path.join(FCPP_DIR, "cpp5.c"), path.join(FCPP_DIR, "cpp6.c"), path.join(FCPP_DIR, "cpp6.c"), - - path.join(GLSL_OPTIMIZER, "src/mesa/**.c"), - path.join(GLSL_OPTIMIZER, "src/glsl/**.cpp"), - path.join(GLSL_OPTIMIZER, "src/mesa/**.h"), - path.join(GLSL_OPTIMIZER, "src/glsl/**.c"), - path.join(GLSL_OPTIMIZER, "src/glsl/**.cpp"), - path.join(GLSL_OPTIMIZER, "src/glsl/**.h"), - path.join(GLSL_OPTIMIZER, "src/util/**.c"), - path.join(GLSL_OPTIMIZER, "src/util/**.h"), - } - - removefiles { - path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/glcpp.c"), - path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/tests/**"), - path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/**.l"), - path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/**.y"), - path.join(GLSL_OPTIMIZER, "src/glsl/ir_set_program_inouts.cpp"), - path.join(GLSL_OPTIMIZER, "src/glsl/main.cpp"), - path.join(GLSL_OPTIMIZER, "src/glsl/builtin_stubs.cpp"), } links { "glslang", + "glsl-optimizer", } if filesexist(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-ext"), {