-
Notifications
You must be signed in to change notification settings - Fork 8
/
embedded_files.lua
61 lines (44 loc) · 2.07 KB
/
embedded_files.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
--
-- Copyright 2023 Milos Tosic. All rights reserved.
-- License: http://www.opensource.org/licenses/BSD-2-Clause
--
function shaderConfigure( _config, _projectName, _shaderFiles )
if _shaderFiles == nil then
return
end
local sourcePath = path.getabsolute(RTM_ROOT_DIR .. "src/tools/qt/" .. _projectName .. "/src/") .. "/"
local SHADER_PREBUILD_LUA_PATH = '"' .. RTM_ROOT_DIR .. "build/embedded_shader_prebuild.lua" .. '"'
flatten( _shaderFiles )
local LUAEXE = "lua "
local shaderc = RTM_ROOT_DIR .. "tools/bgfx/shaderc"
if os.is("windows") then
shaderc = RTM_ROOT_DIR .. "tools/bgfx/shaderc.exe"
LUAEXE = "lua.exe "
end
local addedFiles = {}
-- Set up Qt pre-build steps and add the future generated file paths to the pkg
for _,file in ipairs( _shaderFiles ) do
local scFile = stripExtension(file)
local scFileBase = path.getbasename(file)
if scFileBase ~= "varying.def" then
local outFile = path.getabsolute(scFile .. '.bin.h')
local outFileTemp = path.getabsolute(scFile .. '.bin.h.temp')
local shaderType = ""
local includesDirs = " -i " .. RTM_ROOT_DIR .. "3rd/bgfx/src/" .. " -i " .. RTM_ROOT_DIR .. "3rd/bgfx/examples/common/"
local srcFile = path.getabsolute(file)
local dstFile = path.getabsolute(outFile)
-- vertex shader
if string.find(scFileBase, "vs_") ~= nil then
prebuildcommands { LUAEXE .. SHADER_PREBUILD_LUA_PATH .. ' -vs ' .. srcFile .. ' ' .. shaderc .. ' ' .. RTM_ROOT_DIR .. "3rd/bgfx/src/ ".. RTM_ROOT_DIR .. "3rd/bgfx/examples/common/" }
end
if string.find(scFileBase, "fs_") ~= nil then
prebuildcommands { LUAEXE .. SHADER_PREBUILD_LUA_PATH .. ' -fs ' .. srcFile .. ' ' .. shaderc .. ' ' .. RTM_ROOT_DIR .. "3rd/bgfx/src/ ".. RTM_ROOT_DIR .. "3rd/bgfx/examples/common/" }
end
if string.find(scFileBase, "cs_") ~= nil then
prebuildcommands { LUAEXE .. SHADER_PREBUILD_LUA_PATH .. ' -cs ' .. srcFile .. ' ' .. shaderc .. ' ' .. RTM_ROOT_DIR .. "3rd/bgfx/src/ ".. RTM_ROOT_DIR .. "3rd/bgfx/examples/common/" }
end
end
end
configuration {}
return addedFiles
end