summaryrefslogtreecommitdiff
path: root/xmake/rules/iverilog/xmake.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2023-01-12 00:50:06 +0800
committerruki <[email protected]>2023-01-13 20:50:56 +0800
commit6b830187bc5feb14a2390aa20e448137a71dd012 (patch)
tree9f6b7ddafd64f177ffbfd9c9186f2ee687142127 /xmake/rules/iverilog/xmake.lua
parent195b23ef65bb65db80d8ba321162636f0357f2f7 (diff)
improve iverilog rule
Diffstat (limited to 'xmake/rules/iverilog/xmake.lua')
-rw-r--r--xmake/rules/iverilog/xmake.lua35
1 files changed, 14 insertions, 21 deletions
diff --git a/xmake/rules/iverilog/xmake.lua b/xmake/rules/iverilog/xmake.lua
index 5e19469e1..955c8f762 100644
--- a/xmake/rules/iverilog/xmake.lua
+++ b/xmake/rules/iverilog/xmake.lua
@@ -18,47 +18,40 @@
-- @file xmake.lua
--
-rule("iverilog.wave")
+rule("iverilog.binary")
set_extensions(".v", ".vhd")
on_load(function (target)
target:set("kind", "binary")
if not target:get("extension") then
- target:set("extension", ".vcd")
+ target:set("extension", ".vvp")
end
end)
on_buildcmd_files(function(target, batchcmds, sourcebatch, opt)
+ end)
+
+ on_linkcmd(function (target, batchcmds, opt)
local toolchain = assert(target:toolchain("iverilog"), 'we need set_toolchains("iverilog") in target("%s")', target:name())
local iverilog = assert(toolchain:config("iverilog"), "iverilog not found!")
-- compile wave file
local targetfile = target:targetfile()
local targetdir = path.directory(targetfile)
- local vvpfile = path.join(targetdir, path.basename(targetfile) .. ".vvp")
- local argv = {"-o", vvpfile}
+ local argv = {"-o", targetfile}
+ local sourcebatch = target:sourcebatches()["iverilog.binary"]
local sourcefiles = sourcebatch.sourcefiles
- for _, sourcefile in ipairs(sourcefiles) do
- batchcmds:show_progress(opt.progress, "${color.build.object}compiling.iverilog %s", path.filename(sourcefile))
- table.insert(argv, path(sourcefile))
- batchcmds:add_depfiles(sourcefile)
- end
+ table.join2(argv, sourcefiles)
+ batchcmds:show_progress(opt.progress, "${color.build.target}linking.iverilog %s", path.filename(targetfile))
batchcmds:mkdir(targetdir)
batchcmds:vrunv(iverilog, argv)
- batchcmds:set_depmtime(os.mtime(vvpfile))
- batchcmds:set_depcache(target:dependfile(vvpfile))
+ batchcmds:add_depfiles(sourcefiles)
+ batchcmds:set_depmtime(os.mtime(targetfile))
+ batchcmds:set_depcache(target:dependfile(targetfile))
end)
- on_linkcmd(function (target, batchcmds, opt)
+ on_run(function (target)
local toolchain = assert(target:toolchain("iverilog"), 'we need set_toolchains("iverilog") in target("%s")', target:name())
local vvp = assert(toolchain:config("vvp"), "vvp not found!")
- -- generate wave.lxt
- local targetfile = target:targetfile()
- local targetdir = path.directory(targetfile)
- local vvpfile = path.join(targetdir, path.basename(targetfile) .. ".vvp")
- batchcmds:show_progress(opt.progress, "${color.build.target}linking.iverilog %s", path.filename(targetfile))
- batchcmds:vrunv(vvp, {"-n", vvpfile, "-lxt2"})
- batchcmds:add_depfiles(vvpfile)
- batchcmds:set_depmtime(os.mtime(targetfile))
- batchcmds:set_depcache(target:dependfile(targetfile))
+ os.execv(vvp, {"-n", target:targetfile(), "-lxt2"})
end)