summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-01-11 00:53:55 +0800
committerruki <[email protected]>2023-01-11 00:53:55 +0800
commitf75c8f8efd93e6b7616a38a582cf1c51b6652e3a (patch)
treeb831cafcb710b63edaa6aa7780790bae1a70a6ec
parent50133fca9a6f5f3919227146e98b08794d84d932 (diff)
add find iverilog
-rw-r--r--xmake/modules/detect/tools/find_iverilog.lua62
1 files changed, 62 insertions, 0 deletions
diff --git a/xmake/modules/detect/tools/find_iverilog.lua b/xmake/modules/detect/tools/find_iverilog.lua
new file mode 100644
index 000000000..85ac740f2
--- /dev/null
+++ b/xmake/modules/detect/tools/find_iverilog.lua
@@ -0,0 +1,62 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file find_iverilog.lua
+--
+
+-- imports
+import("lib.detect.find_program")
+import("lib.detect.find_programver")
+
+-- find iverilog
+--
+-- @param opt the argument options, e.g. {version = true}
+--
+-- @return program, version
+--
+-- @code
+--
+-- local iverilog = find_iverilog()
+--
+-- @endcode
+--
+function main(opt)
+
+ -- init options
+ opt = opt or {}
+ opt.check = opt.check or "-V"
+ opt.command = opt.command or "-V"
+
+ -- find it from some logical drives paths
+ if is_host("windows") then
+ opt.paths = opt.paths or {}
+ for _, logical_drive in ipairs(winos.logical_drives()) do
+ table.insert(opt.paths, path.join(logical_drive, "iverilog", "bin"))
+ end
+ end
+
+ -- find program
+ local program = find_program(opt.program or "iverilog", opt)
+
+ -- find program version
+ local version = nil
+ if program and opt and opt.version then
+ version = find_programver(program, opt)
+ end
+ return program, version
+end
+