summaryrefslogtreecommitdiff
path: root/xmake/rules/verilator/xmake.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2024-05-05 21:20:01 +0800
committerruki <[email protected]>2024-05-05 21:21:16 +0800
commitba1f9f4eaa90aa786a714f8f8da6f0e95a6a6327 (patch)
tree7f77b353f03a8a6ffca7fc389af9d645a8562bc6 /xmake/rules/verilator/xmake.lua
parent382b22c3d6ec529bf085aaa7498c39dd83758e69 (diff)
Support Verilator target build to static library #5060
Diffstat (limited to 'xmake/rules/verilator/xmake.lua')
-rw-r--r--xmake/rules/verilator/xmake.lua28
1 files changed, 28 insertions, 0 deletions
diff --git a/xmake/rules/verilator/xmake.lua b/xmake/rules/verilator/xmake.lua
index 4272ed91f..76d213096 100644
--- a/xmake/rules/verilator/xmake.lua
+++ b/xmake/rules/verilator/xmake.lua
@@ -20,6 +20,7 @@
-- @see https://github.com/xmake-io/xmake/issues/3257
rule("verilator.binary")
+ add_deps("c++")
set_extensions(".v", ".sv")
on_load(function (target)
target:set("kind", "binary")
@@ -45,3 +46,30 @@ rule("verilator.binary")
import("verilator").buildcmd_cppfiles(target, batchcmds, sourcebatch, opt)
end)
+rule("verilator.static")
+ add_deps("c++")
+ set_extensions(".v", ".sv")
+ on_load(function (target)
+ target:set("kind", "static")
+ end)
+
+ on_config(function (target)
+ 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})
+
+ before_buildcmd_files(function(target, batchcmds, sourcebatch, opt)
+ import("verilator").buildcmd_vfiles(target, batchcmds, sourcebatch, opt)
+ end)
+
+ on_buildcmd_files(function (target, batchcmds, sourcebatch, opt)
+ import("verilator").buildcmd_cppfiles(target, batchcmds, sourcebatch, opt)
+ end)
+