move build to build3 to avoid naming conflict with Bullet 2.x
fix build error in BasicGpuDemo Thanks to joen66 for the report here: https://github.com/erwincoumans/bullet3/issues/5
This commit is contained in:
79
build3/stringifyKernel.lua
Normal file
79
build3/stringifyKernel.lua
Normal file
@@ -0,0 +1,79 @@
|
||||
|
||||
|
||||
function stringifyKernel(filenameIn, filenameOut, kernelMethod)
|
||||
local BUFSIZE = 1024*1024 -- 1MB
|
||||
local f = io.open(filenameIn,"r");
|
||||
local fw = io.open(filenameOut,"w");
|
||||
fw:write("//this file is autogenerated using stringify.bat (premake --stringify) in the build folder of this project\n")
|
||||
fw:write("static const char* " .. kernelMethod .. "= \\\n")
|
||||
local cc, lc, wc = 0, 0, 0 -- char, line, and word counts
|
||||
while true do
|
||||
local lines, rest = f:read(BUFSIZE, "*line")
|
||||
if not lines then break end
|
||||
|
||||
local i = 0
|
||||
local startpos = 0
|
||||
local slen = string.len(lines)
|
||||
local endpos = 0
|
||||
while true do
|
||||
i = string.find(lines, "\n", i+1) -- find 'next' newline
|
||||
if i == nil then
|
||||
endpos = slen
|
||||
else
|
||||
endpos = i
|
||||
end
|
||||
oneline = string.sub(lines,startpos,endpos)
|
||||
oneline = string.gsub(oneline,"\n","")
|
||||
oneline = string.gsub(oneline,"\"","\\\"");
|
||||
oneline = '\"' .. oneline .. '\\n\"'
|
||||
oneline = string.gsub(oneline,"\\\\n","")
|
||||
oneline = oneline .. "\n"
|
||||
--print(oneline)
|
||||
fw:write(oneline)
|
||||
if i == nil then break end
|
||||
startpos = i+1
|
||||
end
|
||||
|
||||
if rest then lines = lines .. rest .. '\n' end
|
||||
cc = cc + string.len(lines)
|
||||
-- count words in the chunk
|
||||
local _,t = string.gsub(lines, "%S+", "")
|
||||
wc = wc + t
|
||||
-- count newlines in the chunk
|
||||
_,t = string.gsub(lines, "\n", "\n")
|
||||
lc = lc + t
|
||||
end
|
||||
--print("stringified " .. filenameIn .. " into " .. filenameOut .. " processed " .. lc .. " lines")
|
||||
print(filenameIn .. " (" .. lc .. " lines)")
|
||||
|
||||
f:close()
|
||||
fw:write(";\n")
|
||||
fw:close()
|
||||
end
|
||||
|
||||
newoption {
|
||||
trigger = "kernelfile",
|
||||
value = "kernelpath",
|
||||
description = "full path to the kernel source input file"
|
||||
}
|
||||
|
||||
newoption {
|
||||
trigger = "headerfile",
|
||||
value = "path",
|
||||
description = "full path to the header output file"
|
||||
}
|
||||
|
||||
newoption {
|
||||
trigger = "stringname",
|
||||
value = "var",
|
||||
description = "name of the kernel string variable"
|
||||
}
|
||||
|
||||
newaction {
|
||||
trigger = "stringify",
|
||||
description = "stringify kernels source code into strings",
|
||||
execute = function ()
|
||||
stringifyKernel( _OPTIONS["kernelfile"] , _OPTIONS["headerfile"], _OPTIONS["stringname"])
|
||||
|
||||
end
|
||||
}
|
||||
Reference in New Issue
Block a user