diff options
| author | ruki <[email protected]> | 2023-01-18 22:33:56 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-01-18 22:33:56 +0800 |
| commit | 20f135e26e3597b8cc4fc2061207f94e98a5f006 (patch) | |
| tree | 55fc607d12786a3cd50559b1eb491a7b6dc8d7d6 | |
| parent | 72d7a6249592bed6429c2e62989f9c5eeebe8bb1 (diff) | |
fix verilator for windows
| -rw-r--r-- | xmake/rules/verilator/verilator.lua | 18 | ||||
| -rw-r--r-- | xmake/rules/verilator/xmake.lua | 4 |
2 files changed, 19 insertions, 3 deletions
diff --git a/xmake/rules/verilator/verilator.lua b/xmake/rules/verilator/verilator.lua index 9b8856704..fb7025baa 100644 --- a/xmake/rules/verilator/verilator.lua +++ b/xmake/rules/verilator/verilator.lua @@ -183,8 +183,13 @@ function build_cppfiles(target, batchjobs, sourcebatch, opt) local sourcefiles = sourcebatch.sourcefiles for _, sourcefile in ipairs(sourcefiles) do progress.show(opt.progress or 0, "${color.build.object}compiling.verilog %s", sourcefile) + -- we need use slashes to fix it on windows + -- @see https://github.com/verilator/verilator/issues/3873 + if is_host("windows") then + sourcefile = sourcefile:gsub("\\", "/") + end + table.insert(argv, sourcefile) end - table.join2(argv, sourcefiles) -- generate c++ sourcefiles os.vrunv(verilator, argv, {envs = toolchain:runenvs()}) @@ -229,11 +234,18 @@ function buildcmd_vfiles(target, batchcmds, sourcebatch, opt) local sourcefiles = sourcebatch.sourcefiles for _, sourcefile in ipairs(sourcefiles) do batchcmds:show_progress(opt.progress, "${color.build.object}compiling.verilog %s", sourcefile) + table.insert(argv, path(sourcefile, function (v) + -- we need use slashes to fix it on windows + -- @see https://github.com/verilator/verilator/issues/3873 + if is_host("windows") then + v = v:gsub("\\", "/") + end + return v + end)) end - table.join2(argv, sourcefiles) -- generate c++ sourcefiles - batchcmds:vrunv(verilator, argv) + batchcmds:vrunv(verilator, argv, {envs = toolchain:runenvs()}) batchcmds:add_depfiles(sourcefiles) batchcmds:set_depmtime(os.mtime(cmakefile)) batchcmds:set_depcache(dependfile) diff --git a/xmake/rules/verilator/xmake.lua b/xmake/rules/verilator/xmake.lua index c75972f8d..cc7a24b27 100644 --- a/xmake/rules/verilator/xmake.lua +++ b/xmake/rules/verilator/xmake.lua @@ -29,6 +29,10 @@ rule("verilator.binary") import("verilator").config(target) end) + before_build_files(function (target, sourcebatch) + -- Just to avoid before_buildcmd_files being executed at build time + end) + on_build_files(function (target, batchjobs, sourcebatch, opt) import("verilator").build_cppfiles(target, batchjobs, sourcebatch, opt) end, {batch = true, distcc = true}) |
