Skip to content

Commit 4695f3b

Browse files
committed
init with find deployqt
1 parent 4481279 commit 4695f3b

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
--!A cross-platform build utility based on Lua
2+
--
3+
-- Licensed under the Apache License, Version 2.0 (the "License");
4+
-- you may not use this file except in compliance with the License.
5+
-- You may obtain a copy of the License at
6+
--
7+
-- http://www.apache.org/licenses/LICENSE-2.0
8+
--
9+
-- Unless required by applicable law or agreed to in writing, software
10+
-- distributed under the License is distributed on an "AS IS" BASIS,
11+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
-- See the License for the specific language governing permissions and
13+
-- limitations under the License.
14+
--
15+
-- Copyright (C) 2015-present, Xmake Open Source Community.
16+
--
17+
-- @author ruki
18+
-- @file find_deployqt.lua
19+
--
20+
21+
-- imports
22+
import("lib.detect.find_program")
23+
24+
-- find deployqt
25+
--
26+
-- @param opt the argument options, e.g. {version = true}
27+
--
28+
-- @return program
29+
--
30+
function main(opt)
31+
32+
-- init options
33+
opt = opt or {}
34+
opt.check = opt.check or function (program)
35+
-- check version to verify the program is working
36+
if is_host("windows") then
37+
-- windeployqt --help should return successfully
38+
os.run("%s --help", program)
39+
elseif is_host("macosx") then
40+
-- macdeployqt --help should return successfully
41+
os.run("%s --help", program)
42+
else
43+
-- assume linux, linuxdeployqt --help should return successfully
44+
os.run("%s --help", program)
45+
end
46+
end
47+
48+
-- define program names for different platforms
49+
local program_name = opt.program
50+
if not program_name then
51+
if is_host("windows") then
52+
program_name = "windeployqt"
53+
elseif is_host("macosx") then
54+
program_name = "macdeployqt"
55+
else
56+
-- linux and other unix-like systems
57+
program_name = "linuxdeployqt"
58+
end
59+
end
60+
61+
-- additional search paths for common Qt installations
62+
if not opt.paths then
63+
opt.paths = {}
64+
65+
if is_host("windows") then
66+
-- common Qt installation paths on Windows
67+
table.insert(opt.paths, "C:\\Qt\\*\\bin")
68+
table.insert(opt.paths, "C:\\Qt\\Tools\\*\\bin")
69+
table.insert(opt.paths, path.join(os.getenv("QTDIR") or "", "bin"))
70+
elseif is_host("macosx") then
71+
-- common Qt installation paths on macOS
72+
table.insert(opt.paths, "/usr/local/Qt*/*/bin")
73+
table.insert(opt.paths, "~/Qt/*/bin")
74+
table.insert(opt.paths, "/opt/Qt*/*/bin")
75+
table.insert(opt.paths, path.join(os.getenv("QTDIR") or "", "bin"))
76+
else
77+
-- common Qt installation paths on Linux
78+
table.insert(opt.paths, "/usr/lib/qt*/bin")
79+
table.insert(opt.paths, "/usr/lib64/qt*/bin")
80+
table.insert(opt.paths, "/opt/qt*/bin")
81+
table.insert(opt.paths, "/usr/local/qt*/bin")
82+
table.insert(opt.paths, "~/Qt/*/bin")
83+
table.insert(opt.paths, path.join(os.getenv("QTDIR") or "", "bin"))
84+
end
85+
end
86+
87+
-- find program
88+
return find_program(program_name, opt)
89+
end

0 commit comments

Comments
 (0)