Skip to content

Commit

Permalink
verilator: fix flex
Browse files Browse the repository at this point in the history
  • Loading branch information
star-hengxing committed Nov 6, 2024
1 parent 16f012a commit a644cd4
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions packages/v/verilator/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,8 @@ package("verilator")

on_load(function (package)
if not package:is_precompiled() then
if package:is_plat("windows") then
package:add("deps", "winflexbison", {kind = "library"})
else
package:add("deps", "flex", {kind = "library"})
package:add("deps", "bison")
end
package:add("deps", "flex", {kind = "library"})
package:add("deps", "bison")
package:add("deps", "python 3.x", {kind = "binary"})
end
package:mark_as_pathenv("VERILATOR_ROOT")
Expand All @@ -29,16 +25,31 @@ package("verilator")
import("package.tools.cmake")

io.replace("src/CMakeLists.txt", "MSVC_RUNTIME_LIBRARY MultiThreaded$<IF:$<CONFIG:Release>,,DebugDLL>", "", {plain = true})
if is_subhost("msys") then
io.replace("CMakeLists.txt", "if(WIN32)", "if(0)", {plain = true})
end

local configs = {"-DOBJCACHE_ENABLED=OFF", "-DDEBUG_AND_RELEASE_AND_COVERAGE=OFF"}
local configs = {
"-DOBJCACHE_ENABLED=OFF",
"-DDEBUG_AND_RELEASE_AND_COVERAGE=OFF",
"-DCMAKE_CXX_STANDARD=20",
}
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
if package:is_plat("windows") then
table.insert(configs, "-DCMAKE_COMPILE_PDB_OUTPUT_DIRECTORY=''")
end

local opt = {}
opt.envs = cmake.buildenvs(package)
if package:is_plat("windows") then
table.insert(configs, "-DCMAKE_COMPILE_PDB_OUTPUT_DIRECTORY=''")
opt.envs.WIN_FLEX_BISON = package:dep("winflexbison"):installdir("include")
if is_host("windows") then
local winflexbison = package:dep("winflexbison")
if winflexbison then
opt.envs.WIN_FLEX_BISON = winflexbison:installdir("include")
else
local flex = package:dep("flex")
table.insert(configs, "-DFLEX_INCLUDE_DIR=" .. flex:installdir("include"))
end
end
cmake.install(package, configs, opt)

Expand All @@ -56,5 +67,7 @@ package("verilator")
end)

on_test(function (package)
os.vrun("verilator --version")
if not package:is_cross() then
os.vrun("verilator --version")
end
end)

0 comments on commit a644cd4

Please sign in to comment.