diff options
| author | ruki <[email protected]> | 2023-03-16 22:51:43 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-03-16 22:51:43 +0800 |
| commit | 472ec86bf11cbeca78b71d1bc2d8112b5da03e09 (patch) | |
| tree | b406d5a28871f0661414606c779c4299077deb0e | |
| parent | 49314f129111b1c8cfa6c3972afa5c5491cf8964 (diff) | |
add find_tclsh
| -rw-r--r-- | xmake/core/package/package.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/detect/tools/find_tclsh.lua | 50 |
2 files changed, 52 insertions, 0 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index a7171c1d1..f279950d0 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -1507,10 +1507,12 @@ function _instance:_fetch_tool(opt) end end else + print("find_tool", self:name()) fetchinfo = self:find_tool(self:name(), {require_version = opt.require_version, cachekey = "fetch_package_xmake", norun = true, -- we need not run it to check for xmake/packages, @see https://github.com/xmake-io/xmake-repo/issues/66 force = opt.force}) + print("fetchinfo", fetchinfo) -- may be toolset, not single tool if not fetchinfo then diff --git a/xmake/modules/detect/tools/find_tclsh.lua b/xmake/modules/detect/tools/find_tclsh.lua new file mode 100644 index 000000000..4a3364372 --- /dev/null +++ b/xmake/modules/detect/tools/find_tclsh.lua @@ -0,0 +1,50 @@ +--!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_tclsh.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find tclsh +-- +-- @param opt the argument options, e.g. {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local tclsh = find_tclsh() +-- local tclsh, version = find_tclsh({program = "tclsh", version = true}) +-- +-- @endcode +-- +function main(opt) + opt = opt or {} + opt.check = opt.check or function (program) + local infile = os.tmpfile() + local outfile = os.tmpfile() + io.writefile(infile, "puts hello\n") + local outdata = os.iorunv(program, {infile}) + assert(outdata == "hello\n") + os.rm(infile) + os.rm(outfile) + end + return find_program(opt.program or "tclsh", opt) +end |
