-
-
Notifications
You must be signed in to change notification settings - Fork 875
init with find deployqt #6873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
init with find deployqt #6873
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| --!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, Xmake Open Source Community. | ||
| -- | ||
| -- @author ruki | ||
| -- @file find_deployqt.lua | ||
| -- | ||
|
|
||
| -- imports | ||
| import("lib.detect.find_program") | ||
|
|
||
| -- find deployqt | ||
| -- | ||
| -- @param opt the argument options, e.g. {version = true} | ||
| -- | ||
| -- @return program | ||
| -- | ||
| function main(opt) | ||
|
|
||
| -- init options | ||
| opt = opt or {} | ||
| opt.check = opt.check or function (program) | ||
| -- check version to verify the program is working | ||
| if is_host("windows") then | ||
| -- windeployqt --help should return successfully | ||
| os.run("%s --help", program) | ||
| elseif is_host("macosx") then | ||
| -- macdeployqt --help should return successfully | ||
| os.run("%s --help", program) | ||
| else | ||
| -- assume linux, linuxdeployqt --help should return successfully | ||
| os.run("%s --help", program) | ||
| end | ||
| end | ||
|
|
||
| -- define program names for different platforms | ||
| local program_name = opt.program | ||
| if not program_name then | ||
| if is_host("windows") then | ||
| program_name = "windeployqt" | ||
| elseif is_host("macosx") then | ||
| program_name = "macdeployqt" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| else | ||
| -- linux and other unix-like systems | ||
| program_name = "linuxdeployqt" | ||
| end | ||
| end | ||
|
|
||
| -- additional search paths for common Qt installations | ||
| if not opt.paths then | ||
| opt.paths = {} | ||
|
|
||
| if is_host("windows") then | ||
| -- common Qt installation paths on Windows | ||
| table.insert(opt.paths, "C:\\Qt\\*\\bin") | ||
| table.insert(opt.paths, "C:\\Qt\\Tools\\*\\bin") | ||
| table.insert(opt.paths, path.join(os.getenv("QTDIR") or "", "bin")) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When the |
||
| elseif is_host("macosx") then | ||
| -- common Qt installation paths on macOS | ||
| table.insert(opt.paths, "/usr/local/Qt*/*/bin") | ||
| table.insert(opt.paths, "~/Qt/*/bin") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| table.insert(opt.paths, "/opt/Qt*/*/bin") | ||
| table.insert(opt.paths, path.join(os.getenv("QTDIR") or "", "bin")) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the Windows case, when the |
||
| else | ||
| -- common Qt installation paths on Linux | ||
| table.insert(opt.paths, "/usr/lib/qt*/bin") | ||
| table.insert(opt.paths, "/usr/lib64/qt*/bin") | ||
| table.insert(opt.paths, "/opt/qt*/bin") | ||
| table.insert(opt.paths, "/usr/local/qt*/bin") | ||
| table.insert(opt.paths, "~/Qt/*/bin") | ||
| table.insert(opt.paths, path.join(os.getenv("QTDIR") or "", "bin")) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the Windows and macOS cases, when the |
||
| end | ||
| end | ||
|
|
||
| -- find program | ||
| return find_program(program_name, opt) | ||
| end | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
checkfunction doesn't explicitly return a value, so it implicitly returnsnil. This will cause the check to fail for any program found. You should return the result ofos.run. Additionally, theif/elseif/elseblock is redundant because the same command is executed for all platforms. The function can be simplified significantly.