Refactor Qt packages to prepare Qt6 (#2252)

* Refactor Qt packages to prepare Qt6

* Update xmake.lua

* update qtbase

* Fix qt5base install

* Fix CI

* Update xmake.lua

* Update xmake.lua

* Try something

* Update xmake.lua
pull/2278/head
Jérôme Leclercq 2 years ago committed by GitHub
parent 2fed8ca552
commit 66799a7bc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 179
      packages/q/qt5base/xmake.lua
  2. 2
      packages/q/qt5core/xmake.lua
  3. 1
      packages/q/qt5gui/xmake.lua
  4. 8
      packages/q/qt5lib/xmake.lua
  5. 1
      packages/q/qt5network/xmake.lua
  6. 1
      packages/q/qt5webview/xmake.lua
  7. 1
      packages/q/qt5widgets/xmake.lua
  8. 232
      packages/q/qtbase/xmake.lua

@ -1,183 +1,10 @@
package("qt5base")
set_kind("phony")
set_homepage("https://www.qt.io")
set_description("Qt is the faster, smarter way to create innovative devices, modern UIs & applications for multiple screens. Cross-platform software development at its best.")
set_license("LGPL-3")
set_base("qtbase")
add_versions("5.15.2", "dummy")
add_versions("5.12.5", "dummy")
add_configs("shared", {description = "Download shared binaries.", default = true, type = "boolean", readonly = true})
add_configs("vs_runtime", {description = "Set vs compiler runtime.", default = "MD", readonly = true})
add_deps("aqt")
on_load(function (package)
package:addenv("PATH", "bin")
end)
on_fetch(function (package, opt)
import("core.base.semver")
import("detect.sdks.find_qt")
local qt = package:data("qt")
if qt then
return qt
end
local sdkdir
if not opt.system then
sdkdir = package:installdir()
end
local qt = find_qt(sdkdir, {force = opt.force})
if not qt then
return
end
local qtversion = semver.new(qt.sdkver)
if not qtversion:satisfies("5.x") then
return
end
qt.version = qt.sdkver
package:data_set("qt", qt)
return qt
end)
on_install("windows|x86", "windows|x64", "linux", "macosx", "mingw", "android", "iphoneos", function (package)
import("core.base.semver")
import("core.project.config")
import("core.tool.toolchain")
local version = package:version()
local versionstr = version:shortstr()
local host
if is_host("windows") or package:is_plat("mingw") then
host = "windows"
elseif is_host("linux") then
host = "linux"
elseif is_host("macosx") then
host = "mac"
else
raise("unhandled host " .. os.host())
end
local target
if package:is_plat("windows", "mingw", "linux", "macosx") then
target = "desktop"
elseif package:is_plat("android") then
target = "android"
elseif package:is_plat("iphoneos") then
target = "ios"
else
raise("unhandled plat " .. package:plat())
end
local arch
if package:is_plat("windows", "mingw") then
local winarch
if package:is_arch("x64", "x86_64") then
winarch = "64"
elseif package:is_arch("x86", "i386") then
winarch = "32"
else
raise("unhandled arch " .. package:targetarch())
end
local compiler_version
if package:is_plat("windows") then
local vs = toolchain.load("msvc"):config("vs")
if tonumber(vs) >= 2019 then
compiler_version = "msvc2019"
elseif vs == "2017" or vs == "2015" then
compiler_version = "msvc" .. vs
else
raise("unhandled msvc version " .. vs)
end
if package:is_arch("x64", "x86_64") then
compiler_version = compiler_version .. "_64"
end
else
local cc = package:tool("cc")
local version = os.iorunv(cc, {"-dumpversion"}):trim()
local mingw_version = semver.new(version)
if mingw_version:ge("8.1") then
compiler_version = "mingw81"
elseif mingw_version:ge("7.3") then
compiler_version = "mingw73"
elseif mingw_version:ge("5.3") then
compiler_version = "mingw53"
else
raise("unhandled mingw version " .. version)
end
end
arch = "win" .. winarch .. "_" .. compiler_version
elseif package:is_plat("linux") then
arch = "gcc_64"
elseif package:is_plat("macosx") then
arch = "clang_64"
elseif package:is_plat("android") then
if version:le("5.13") then
if package:is_arch("x86_64", "x64") then
arch = "android_x86_64"
elseif package:is_arch("arm64", "arm64-v8a") then
arch = "android_arm64_v8a"
elseif package:is_arch("armv7", "armv7-a") then
arch = "android_armv7"
elseif package:is_arch("x86") then
arch = "android_x86"
end
else
arch = "android"
end
end
local installdir = package:installdir()
os.vrunv("aqt", {"install-qt", "-O", installdir, host, target, versionstr, arch})
-- move files to root
os.mv(path.join(installdir, versionstr, "*", "*"), installdir)
os.rmdir(path.join(installdir, versionstr))
-- special case for cross-compilation using MinGW since we need binaries we can run on the host
if package:is_plat("mingw") and not is_host("windows") then
local runhost
if is_host("linux") then
runhost = "linux"
elseif is_host("macosx") then
runhost = "mac"
else
raise("unhandled host " .. os.host())
end
-- download qtbase to bin_host folder
os.vrunv("aqt", {"install-qt", "-O", path.join(installdir, "bin_host"), runhost, "desktop", versionstr, "--archives", "qtbase"})
-- add symbolic links for useful tools
local tools = {
moc = true,
qmake = true,
rcc = true,
uic = true
}
for _, file in pairs(os.files(path.join(installdir, "bin_host", versionstr, "*", "bin", "*"))) do
local filename = path.filename(file)
if (tools[filename]) then
local targetpath = path.join(installdir, "bin", filename)
os.ln(file, path.join(installdir, "bin", filename))
-- some tools like CMake will try to run moc.exe, trick them
os.rm(targetpath .. ".exe")
os.ln(file, path.join(installdir, "bin", filename .. ".exe"))
end
end
end
end)
on_test(function (package)
local qt = assert(package:data("qt"))
os.vrun(path.join(qt.bindir, "moc") .. " -v")
os.vrun(path.join(qt.bindir, "rcc") .. " -v")
on_install("windows|x86", "windows|x64", "linux", "macosx", "mingw", "android", "iphoneos", function (package, opt)
package:base():script("install")(package, opt)
end)

@ -1,5 +1,6 @@
package("qt5core")
set_base("qt5lib")
set_kind("library")
on_load(function (package)
package:data_set("libname", "Core")
@ -11,7 +12,6 @@ package("qt5core")
end
package:base():script("load")(package)
package:set("kind", "library")
end)
on_test(function (package)

@ -14,7 +14,6 @@ package("qt5gui")
end
package:base():script("load")(package)
package:set("kind", "library")
end)
on_test(function (package)

@ -1,4 +1,5 @@
package("qt5lib")
set_kind("template")
set_homepage("https://www.qt.io")
set_description("Qt is the faster, smarter way to create innovative devices, modern UIs & applications for multiple screens. Cross-platform software development at its best.")
set_license("LGPL-3")
@ -10,14 +11,11 @@ package("qt5lib")
add_versions("5.12.5", "dummy")
on_load(function (package)
if package.is_template then
package:set("kind", "template")
end
package:add("deps", "qt5base", {debug = package:is_debug(), version = package:version_str()})
end)
on_fetch(function (package)
local qt = package:dep("qt5base"):data("qt")
local qt = package:dep("qt5base"):fetch()
if not qt then
return
end
@ -74,6 +72,6 @@ package("qt5lib")
end)
on_install("windows|x86", "windows|x64", "linux", "macosx", "mingw", "android", "iphoneos", function (package)
local qt = package:dep("qt5base"):data("qt")
local qt = package:dep("qt5base"):fetch()
assert(qt, "qt5base is required")
end)

@ -19,7 +19,6 @@ package("qt5network")
end
package:base():script("load")(package)
package:set("kind", "library")
end)
on_test(function (package)

@ -7,7 +7,6 @@ package("qt5webview")
package:data_set("libname", "WebView")
package:base():script("load")(package)
package:set("kind", "library")
end)
on_install("windows|x86", "windows|x64", "linux", "macosx", "android", "iphoneos", function (package)

@ -7,7 +7,6 @@ package("qt5widgets")
package:data_set("libname", "Widgets")
package:base():script("load")(package)
package:set("kind", "library")
end)
on_test(function (package)

@ -0,0 +1,232 @@
package("qtbase")
set_kind("template")
set_homepage("https://www.qt.io")
set_description("Qt is the faster, smarter way to create innovative devices, modern UIs & applications for multiple screens. Cross-platform software development at its best.")
set_license("LGPL-3")
add_configs("shared", {description = "Download shared binaries.", default = true, type = "boolean", readonly = true})
add_configs("vs_runtime", {description = "Set vs compiler runtime.", default = "MD", readonly = true})
add_deps("aqt")
on_load(function (package)
package:addenv("PATH", "bin")
end)
on_fetch(function (package, opt)
import("core.base.semver")
import("detect.sdks.find_qt")
local qt = package:data("qt")
if qt then
return qt
end
local sdkdir
if not opt.system then
sdkdir = package:installdir()
end
local qt = find_qt(sdkdir, {force = opt.force})
if not qt then
return
end
local qtversion = semver.new(qt.sdkver)
if not qtversion:ge(package:version()) then
return
end
qt.version = qt.sdkver
package:data_set("qt", qt)
return qt
end)
on_install(function (package)
import("core.base.semver")
import("core.project.config")
import("core.tool.toolchain")
local version = package:version()
local versionstr = version:shortstr()
local host
if is_host("windows") or package:is_plat("mingw") then
host = "windows"
elseif is_host("linux") then
host = "linux"
elseif is_host("macosx") then
host = "mac"
else
raise("unhandled host " .. os.host())
end
local target
if package:is_plat("windows", "mingw", "linux", "macosx") then
target = "desktop"
elseif package:is_plat("android") then
target = "android"
elseif package:is_plat("iphoneos") then
target = "ios"
else
raise("unhandled plat " .. package:plat())
end
local arch
if package:is_plat("windows", "mingw") then
local winarch
if package:is_arch("x64", "x86_64", "arm64") then
winarch = "64"
elseif version:lt("6.0") and package:is_arch("x86", "i386") then -- 32bits support was removed in Qt6
winarch = "32"
else
raise("unhandled arch " .. package:targetarch())
end
local compiler_version
if package:is_plat("windows") then
local vs = toolchain.load("msvc"):config("vs")
if tonumber(vs) >= 2019 or version:ge("6.0") then
compiler_version = "msvc2019"
elseif vs == "2017" or vs == "2015" then
compiler_version = "msvc" .. vs
else
raise("unhandled msvc version " .. vs)
end
if package:is_arch("x64", "x86_64") then
compiler_version = compiler_version .. "_64"
elseif package:is_arch("arm64") then -- arm64 support was added in Qt6.2
compiler_version = compiler_version .. "_arm64"
end
else
local cc = package:tool("cc")
local ccversion = os.iorunv(cc, {"-dumpversion"}):trim()
local mingw_version = semver.new(ccversion)
if version:ge("6.2.2") then
compiler_version = "mingw"
elseif mingw_version:ge("8.1") then
compiler_version = "mingw81"
elseif mingw_version:ge("7.3") then
compiler_version = "mingw73"
elseif mingw_version:ge("5.3") then
compiler_version = "mingw53"
else
raise("unhandled mingw version " .. version)
end
end
arch = "win" .. winarch .. "_" .. compiler_version
elseif package:is_plat("linux") then
arch = "gcc_64"
elseif package:is_plat("macosx") then
arch = "clang_64"
elseif package:is_plat("android") then
if version:le("5.13") or version:ge("6.0") then
if package:is_arch("x86_64", "x64") then
arch = "android_x86_64"
elseif package:is_arch("arm64", "arm64-v8a") then
arch = "android_arm64_v8a"
elseif package:is_arch("armv7", "armv7-a", "armeabi", "armeabi-v7a") then
arch = "android_armv7"
elseif package:is_arch("x86") then
arch = "android_x86"
else
raise("unhandled arch " .. package:targetarch())
end
else
arch = "android"
end
end
local installdir = package:installdir()
os.vrunv("aqt", {"install-qt", "-O", installdir, host, target, versionstr, arch})
-- move files to root
os.mv(path.join(installdir, versionstr, "*", "*"), installdir)
os.rmdir(path.join(installdir, versionstr))
-- special case for cross-compilation since we need binaries we can run on the host
if package:is_plat("mingw") and not is_host("windows") then
local runhost
if is_host("linux") then
runhost = "linux"
elseif is_host("macosx") then
runhost = "mac"
else
raise("unhandled host " .. os.host())
end
-- download qtbase to bin_host folder
os.vrunv("aqt", {"install-qt", "-O", path.join(installdir, "bin_host"), runhost, "desktop", versionstr, "--archives", "qtbase"})
-- add symbolic links for useful tools
local tool_folders = {}
if version:ge("6.0") then
tool_folders.bin = {
qmake = true,
qmake6 = true
}
tool_folders.libexec = {
moc = true,
rcc = true,
uic = true
}
else
tool_folders.bin = {
qmake = true,
moc = true,
rcc = true,
uic = true
}
end
for folder, tools in pairs(tool_folders) do
for _, file in pairs(os.files(path.join(installdir, "bin_host", versionstr, "*", folder, "*"))) do
local filename = path.filename(file)
if tools[filename] then
local targetpath = path.join(installdir, folder, filename)
os.rm(targetpath)
if is_host("windows") then
os.cp(file, targetpath)
else
os.ln(file, targetpath)
end
-- some tools like CMake will try to run moc.exe even on Linux, trick them (ln bin/moc.exe => bin_host/bin/moc)
if package:is_plat("mingw") then
os.rm(targetpath .. ".exe")
if is_host("windows") then
os.cp(file, targetpath .. ".exe")
else
os.ln(file, targetpath .. ".exe")
end
end
end
end
end
end
end)
on_test(function (package)
local qt = assert(package:data("qt"))
local function getbin(name)
if is_host("windows") then
name = name .. ".exe"
end
local exec = path.join(qt.bindir, name)
if not os.isexec(exec) and qt.libexecdir then
exec = path.join(qt.libexecdir, name)
end
if not os.isexec(exec) and qt.libexecdir_host then
exec = path.join(qt.libexecdir_host, name)
end
assert(os.isexec(exec), name .. " not found!")
return exec
end
os.vrun(getbin("qmake") .. " -v")
os.vrun(getbin("moc") .. " -v")
os.vrun(getbin("rcc") .. " -v")
--os.vrun(getbin("uic") .. " -v") -- uic -v seems to hang on CI
end)
Loading…
Cancel
Save