diff options
| author | star9029 <[email protected]> | 2024-11-20 15:11:56 +0800 |
|---|---|---|
| committer | star9029 <[email protected]> | 2024-11-20 15:11:56 +0800 |
| commit | 2b280eed3a311892e4dc1855edd327e46b848ba8 (patch) | |
| tree | 9b0022f5ed996667e177bc36b9621d56855efccf | |
| parent | cefc6b3f0f70508da1f7a64d7d2ad64e45be036c (diff) | |
add wine run support
| -rw-r--r-- | xmake/actions/run/main.lua | 7 | ||||
| -rw-r--r-- | xmake/modules/detect/tools/find_wine.lua | 54 |
2 files changed, 61 insertions, 0 deletions
diff --git a/xmake/actions/run/main.lua b/xmake/actions/run/main.lua index 4f9e44f6a..c11eb2d35 100644 --- a/xmake/actions/run/main.lua +++ b/xmake/actions/run/main.lua @@ -29,6 +29,7 @@ import("devel.debugger") import("async.runjobs") import("private.action.run.runenvs") import("private.service.remote_build.action", {alias = "remote_build_action"}) +import("lib.detect.find_tool") -- run target function _do_run_target(target) @@ -50,6 +51,12 @@ function _do_run_target(target) -- get run arguments local args = table.wrap(option.get("arguments") or target:get("runargs")) + if not is_host("windows") and target:is_plat("windows") then + local wine = assert(find_tool("wine"), "wine not found!") + table.insert(args, 1, targetfile) + targetfile = wine.program + end + -- debugging? if option.get("debug") then debugger.run(targetfile, args, {curdir = rundir, addenvs = addenvs, setenvs = setenvs}) diff --git a/xmake/modules/detect/tools/find_wine.lua b/xmake/modules/detect/tools/find_wine.lua new file mode 100644 index 000000000..05119a88d --- /dev/null +++ b/xmake/modules/detect/tools/find_wine.lua @@ -0,0 +1,54 @@ +--!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_wine.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find wine +-- +-- @param opt the argument options, e.g. {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local wine = find_wine() +-- local wine, version = find_wine({version = true}) +-- +-- @endcode +-- +function main(opt) + -- init options + opt = opt or {} + + -- find program + local program = find_program(opt.program or "wine", opt) + + -- find program version + local version = nil + if program and opt and opt.version then + opt.parse = opt.parse or "wine%-(%d+%.%d+%.%d+)" + version = find_programver(program, opt) + end + + -- ok? + return program, version +end |
