Try to fix sanitizer CI
This commit is contained in:
parent
95742b6ba3
commit
ca0ab34f32
|
|
@ -21,7 +21,6 @@ jobs:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-20.04]
|
os: [ubuntu-20.04]
|
||||||
arch: [x86_64]
|
arch: [x86_64]
|
||||||
mode: [asan]
|
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
if: "!contains(github.event.head_commit.message, 'ci skip')"
|
if: "!contains(github.event.head_commit.message, 'ci skip')"
|
||||||
|
|
@ -76,7 +75,11 @@ jobs:
|
||||||
|
|
||||||
# Setup compilation mode and install project dependencies
|
# Setup compilation mode and install project dependencies
|
||||||
- name: Configure xmake and install dependencies
|
- name: Configure xmake and install dependencies
|
||||||
run: xmake config --shadernodes=y --tests=y --arch=${{ matrix.arch }} --mode=${{ matrix.mode }} --toolchain=hfuzz-clang --verbose --yes
|
run: xmake config --shadernodes=y --tests=y --arch=${{ matrix.arch }} --mode=fuzz --verbose --yes
|
||||||
|
|
||||||
|
# Configure xmake with honggfuzz to build the engine
|
||||||
|
- name: Configure xmake with honggfuzz
|
||||||
|
run: xmake config --shadernodes=y --tests=y --arch=${{ matrix.arch }} --mode=fuzz --verbose --toolchain=hfuzz-clang
|
||||||
|
|
||||||
# Build the engine
|
# Build the engine
|
||||||
- name: Build Nazara
|
- name: Build Nazara
|
||||||
|
|
|
||||||
96
xmake.lua
96
xmake.lua
|
|
@ -124,21 +124,25 @@ add_rules("mode.asan", "mode.debug", "mode.releasedbg")
|
||||||
add_rules("plugin.vsxmake.autoupdate")
|
add_rules("plugin.vsxmake.autoupdate")
|
||||||
add_rules("build_rendererplugins")
|
add_rules("build_rendererplugins")
|
||||||
|
|
||||||
if is_plat("windows") then
|
|
||||||
set_allowedmodes("debug", "releasedbg", "asan")
|
|
||||||
else
|
|
||||||
set_allowedmodes("debug", "releasedbg", "asan", "coverage")
|
|
||||||
add_rules("mode.coverage")
|
|
||||||
end
|
|
||||||
|
|
||||||
set_allowedplats("windows", "mingw", "linux", "macosx")
|
set_allowedplats("windows", "mingw", "linux", "macosx")
|
||||||
set_allowedarchs("windows|x64", "mingw|x86_64", "linux|x86_64", "macosx|x86_64")
|
set_allowedarchs("windows|x64", "mingw|x86_64", "linux|x86_64", "macosx|x86_64")
|
||||||
set_defaultmode("debug")
|
set_defaultmode("debug")
|
||||||
|
|
||||||
|
if is_plat("windows") then
|
||||||
|
set_allowedmodes("debug", "releasedbg", "asan")
|
||||||
|
else
|
||||||
|
set_allowedmodes("debug", "releasedbg", "asan", "coverage", "fuzz")
|
||||||
|
add_rules("mode.coverage")
|
||||||
|
add_rules("mode.fuzz")
|
||||||
|
end
|
||||||
|
|
||||||
if is_mode("debug") then
|
if is_mode("debug") then
|
||||||
add_rules("debug_suffix")
|
add_rules("debug_suffix")
|
||||||
elseif is_mode("asan") then
|
elseif is_mode("asan") then
|
||||||
set_optimize("none") -- by default xmake will optimize asan builds
|
set_optimize("none") -- by default xmake will optimize asan builds
|
||||||
|
elseif is_mode("fuzz") then
|
||||||
|
-- we don't want packages to require compilation with fuzz toolchain
|
||||||
|
set_policy("package.inherit_external_configs", false)
|
||||||
elseif is_mode("coverage") then
|
elseif is_mode("coverage") then
|
||||||
if not is_plat("windows") then
|
if not is_plat("windows") then
|
||||||
add_links("gcov")
|
add_links("gcov")
|
||||||
|
|
@ -242,81 +246,3 @@ includes("tools/xmake.lua")
|
||||||
includes("tests/xmake.lua")
|
includes("tests/xmake.lua")
|
||||||
includes("plugins/*/xmake.lua")
|
includes("plugins/*/xmake.lua")
|
||||||
includes("examples/*/xmake.lua")
|
includes("examples/*/xmake.lua")
|
||||||
|
|
||||||
-- Adds -d as a debug suffix
|
|
||||||
rule("debug_suffix")
|
|
||||||
on_load(function (target)
|
|
||||||
if target:kind() ~= "binary" then
|
|
||||||
target:set("basename", target:basename() .. "-d")
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Builds renderer plugins if linked to NazaraRenderer
|
|
||||||
rule("build_rendererplugins")
|
|
||||||
on_load(function (target)
|
|
||||||
local deps = table.wrap(target:get("deps"))
|
|
||||||
|
|
||||||
if target:kind() == "binary" and (table.contains(deps, "NazaraRenderer") or table.contains(deps, "NazaraGraphics")) then
|
|
||||||
for name, _ in pairs(modules) do
|
|
||||||
local depName = "Nazara" .. name
|
|
||||||
if name:match("^.+Renderer$") and not table.contains(deps, depName) then -- don't overwrite dependency
|
|
||||||
target:add("deps", depName, {inherit = false})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Turns resources into includables headers
|
|
||||||
rule("embed_resources")
|
|
||||||
before_build(function (target, opt)
|
|
||||||
import("core.base.option")
|
|
||||||
if xmake.version():ge("2.5.9") then
|
|
||||||
import("utils.progress")
|
|
||||||
elseif not import("utils.progress", { try = true }) then
|
|
||||||
import("private.utils.progress")
|
|
||||||
end
|
|
||||||
|
|
||||||
local function GenerateEmbedHeader(filepath, targetpath)
|
|
||||||
local bufferSize = 1024 * 1024
|
|
||||||
|
|
||||||
progress.show(opt.progress, "${color.build.object}embedding %s", filepath)
|
|
||||||
|
|
||||||
local resource = assert(io.open(filepath, "rb"))
|
|
||||||
local targetFile = assert(io.open(targetpath, "w+"))
|
|
||||||
|
|
||||||
local resourceSize = resource:size()
|
|
||||||
|
|
||||||
local remainingSize = resourceSize
|
|
||||||
local headerSize = 0
|
|
||||||
|
|
||||||
while remainingSize > 0 do
|
|
||||||
local readSize = math.min(remainingSize, bufferSize)
|
|
||||||
local data = resource:read(readSize)
|
|
||||||
remainingSize = remainingSize - readSize
|
|
||||||
|
|
||||||
local headerContentTable = {}
|
|
||||||
for i = 1, #data do
|
|
||||||
table.insert(headerContentTable, string.format("%d,", data:byte(i)))
|
|
||||||
end
|
|
||||||
local content = table.concat(headerContentTable)
|
|
||||||
|
|
||||||
headerSize = headerSize + #content
|
|
||||||
|
|
||||||
targetFile:write(content)
|
|
||||||
end
|
|
||||||
|
|
||||||
resource:close()
|
|
||||||
targetFile:close()
|
|
||||||
end
|
|
||||||
|
|
||||||
for _, sourcebatch in pairs(target:sourcebatches()) do
|
|
||||||
if sourcebatch.rulename == "embed_resources" then
|
|
||||||
for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
|
|
||||||
local targetpath = sourcefile .. ".h"
|
|
||||||
if option.get("rebuild") or os.mtime(sourcefile) >= os.mtime(targetpath) then
|
|
||||||
GenerateEmbedHeader(sourcefile, targetpath)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
-- Adds -d as a debug suffix
|
||||||
|
rule("debug_suffix")
|
||||||
|
on_load(function (target)
|
||||||
|
if target:kind() ~= "binary" then
|
||||||
|
target:set("basename", target:basename() .. "-d")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
-- Turns resources into includables headers
|
||||||
|
rule("embed_resources")
|
||||||
|
before_build(function (target, opt)
|
||||||
|
import("core.base.option")
|
||||||
|
if xmake.version():ge("2.5.9") then
|
||||||
|
import("utils.progress")
|
||||||
|
elseif not import("utils.progress", { try = true }) then
|
||||||
|
import("private.utils.progress")
|
||||||
|
end
|
||||||
|
|
||||||
|
local function GenerateEmbedHeader(filepath, targetpath)
|
||||||
|
local bufferSize = 1024 * 1024
|
||||||
|
|
||||||
|
progress.show(opt.progress, "${color.build.object}embedding %s", filepath)
|
||||||
|
|
||||||
|
local resource = assert(io.open(filepath, "rb"))
|
||||||
|
local targetFile = assert(io.open(targetpath, "w+"))
|
||||||
|
|
||||||
|
local resourceSize = resource:size()
|
||||||
|
|
||||||
|
local remainingSize = resourceSize
|
||||||
|
local headerSize = 0
|
||||||
|
|
||||||
|
while remainingSize > 0 do
|
||||||
|
local readSize = math.min(remainingSize, bufferSize)
|
||||||
|
local data = resource:read(readSize)
|
||||||
|
remainingSize = remainingSize - readSize
|
||||||
|
|
||||||
|
local headerContentTable = {}
|
||||||
|
for i = 1, #data do
|
||||||
|
table.insert(headerContentTable, string.format("%d,", data:byte(i)))
|
||||||
|
end
|
||||||
|
local content = table.concat(headerContentTable)
|
||||||
|
|
||||||
|
headerSize = headerSize + #content
|
||||||
|
|
||||||
|
targetFile:write(content)
|
||||||
|
end
|
||||||
|
|
||||||
|
resource:close()
|
||||||
|
targetFile:close()
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, sourcebatch in pairs(target:sourcebatches()) do
|
||||||
|
if sourcebatch.rulename == "embed_resources" then
|
||||||
|
for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
|
||||||
|
local targetpath = sourcefile .. ".h"
|
||||||
|
if option.get("rebuild") or os.mtime(sourcefile) >= os.mtime(targetpath) then
|
||||||
|
GenerateEmbedHeader(sourcefile, targetpath)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
rule("mode.fuzz")
|
||||||
|
on_config(function (target)
|
||||||
|
if is_mode("fuzz") then
|
||||||
|
target:set("symbols", "debug")
|
||||||
|
|
||||||
|
target:add("cxflags", "-fsanitize=address,fuzzer")
|
||||||
|
target:add("mxflags", "-fsanitize=address,fuzzer")
|
||||||
|
target:add("ldflags", "-fsanitize=address,fuzzer")
|
||||||
|
target:add("shflags", "-fsanitize=address,fuzzer")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
-- Builds renderer plugins if linked to NazaraRenderer
|
||||||
|
rule("build_rendererplugins")
|
||||||
|
on_load(function (target)
|
||||||
|
local deps = table.wrap(target:get("deps"))
|
||||||
|
|
||||||
|
if target:kind() == "binary" and (table.contains(deps, "NazaraRenderer") or table.contains(deps, "NazaraGraphics")) then
|
||||||
|
for name, _ in pairs(modules) do
|
||||||
|
local depName = "Nazara" .. name
|
||||||
|
if name:match("^.+Renderer$") and not table.contains(deps, depName) then -- don't overwrite dependency
|
||||||
|
target:add("deps", depName, {inherit = false})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
@ -15,11 +15,6 @@ toolchain("hfuzz-clang")
|
||||||
set_toolset("mxx", "hfuzz-clang++")
|
set_toolset("mxx", "hfuzz-clang++")
|
||||||
set_toolset("as", "hfuzz-clang")
|
set_toolset("as", "hfuzz-clang")
|
||||||
|
|
||||||
add_cxflags("-fsanitize=fuzzer-no-link")
|
|
||||||
add_ldflags("-fsanitize=fuzzer-no-link")
|
|
||||||
add_shflags("-fsanitize=fuzzer-no-link")
|
|
||||||
add_arflags("-fsanitize=fuzzer-no-link")
|
|
||||||
|
|
||||||
on_check(function (toolchain)
|
on_check(function (toolchain)
|
||||||
return import("lib.detect.find_tool")("hfuzz-clang")
|
return import("lib.detect.find_tool")("hfuzz-clang")
|
||||||
end)
|
end)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue