Improve qt5 packages using a template (#1055)
* Improve qt5 packages using a template * Qt: Fix install * Qt: small refactor * Fix kind of qt5lib * Qt: requested changes * Update xmake.lua * Update xmake.lua * Update xmake.lua * Update xmake.lua * Update xmake.lua * Qt: fix qt5lib Co-authored-by: ruki <waruqi@gmail.com>pull/1056/head
parent
8fb1fa8e80
commit
198147e15c
4 changed files with 113 additions and 198 deletions
@ -1,83 +1,28 @@ |
||||
package("qt5core") |
||||
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_versions("5.15.2", "dummy") |
||||
add_versions("5.12.5", "dummy") |
||||
set_base("qt5lib") |
||||
|
||||
on_load(function (package) |
||||
package:add("deps", "qt5base", {debug = package:is_debug(), version = package:version_str()}) |
||||
end) |
||||
|
||||
on_fetch(function (package) |
||||
local qt = package:dep("qt5base"):data("qt") |
||||
if not qt then |
||||
return |
||||
end |
||||
|
||||
local syslinks |
||||
local linkname |
||||
local frameworks |
||||
local includedirs = {qt.includedir} |
||||
if package:is_plat("windows") then |
||||
linkname = "Qt5Core" |
||||
if package:is_debug() then |
||||
linkname = linkname .. "d" |
||||
end |
||||
table.insert(includedirs, path.join(qt.includedir, "QtCore")) |
||||
elseif package:is_plat("android") then |
||||
linkname = "Qt5Core" |
||||
if package:is_arch("x86_64", "x64") then |
||||
linkname = linkname .. "_x86_64" |
||||
elseif package:is_arch("arm64", "arm64-v8a") then |
||||
linkname = linkname .. "_arm64-v8a" |
||||
elseif package:is_arch("armv7", "armeabi-v7a", "armeabi", "armv7-a", "armv5te") then |
||||
linkname = linkname .. "_armeabi-v7a" |
||||
elseif package:is_arch("x86") then |
||||
linkname = linkname .. "_x86" |
||||
end |
||||
syslinks = "z" |
||||
table.insert(includedirs, path.join(qt.includedir, "QtCore")) |
||||
elseif package:is_plat("macosx") then |
||||
table.insert(includedirs, path.join(qt.libdir, "QtCore.framework/Versions/5/Headers")) |
||||
frameworks = "QtCore" |
||||
package:data_set("libname", "Core") |
||||
if package:is_plat("android") then |
||||
package:data_set("syslinks", "z") |
||||
elseif package:is_plat("iphoneos") then |
||||
linkname = "Qt5Core" |
||||
frameworks = {"UIKit", "CoreText", "CoreGraphics", "CoreServices", "CoreFoundation"} |
||||
syslinks = {"qtpcre2", "z"} |
||||
table.insert(includedirs, path.join(qt.includedir, "QtCore")) |
||||
else |
||||
linkname = "Qt5Core" |
||||
table.insert(includedirs, path.join(qt.includedir, "QtCore")) |
||||
package:data_set("frameworks", {"UIKit", "CoreText", "CoreGraphics", "CoreServices", "CoreFoundation"}) |
||||
package:data_set("syslinks", {"qtpcre2", "z"}) |
||||
end |
||||
|
||||
return { |
||||
qtdir = qt, |
||||
version = qt.version, |
||||
includedirs = includedirs, |
||||
links = linkname, |
||||
linkdirs = qt.libdir, |
||||
frameworks = frameworks, |
||||
frameworkdirs = qt.libdir, |
||||
syslinks = syslinks |
||||
} |
||||
end) |
||||
|
||||
on_install("windows", "linux", "macosx", "mingw", "android", "iphoneos", function (package) |
||||
local base = package:dep("qt5base") |
||||
local qt = base:data("qt") |
||||
assert(qt, "qt5base is required") |
||||
package:base():script("load")(package) |
||||
package:set("kind", "library") |
||||
end) |
||||
|
||||
on_test(function (package) |
||||
local cxflags |
||||
if not package:is_plat("windows") then |
||||
cxflags = "-fPIC" |
||||
end |
||||
assert(package:check_cxxsnippets({test = [[ |
||||
int test(int argc, char** argv) { |
||||
QCoreApplication app (argc, argv); |
||||
return app.exec(); |
||||
} |
||||
]]}, {configs = {languages = "c++14", cxflags = not package:is_plat("windows") and "-fPIC" or nil}, includes = {"QCoreApplication"}})) |
||||
]]}, {configs = {languages = "c++14", cxflags = cxflags}, includes = {"QCoreApplication"}})) |
||||
end) |
||||
|
@ -1,81 +1,31 @@ |
||||
package("qt5gui") |
||||
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_versions("5.15.2", "dummy") |
||||
add_versions("5.12.5", "dummy") |
||||
set_base("qt5lib") |
||||
set_kind("library") |
||||
|
||||
on_load(function (package) |
||||
package:add("deps", "qt5base", "qt5core", {debug = package:is_debug(), version = package:version_str()}) |
||||
end) |
||||
|
||||
on_fetch(function (package) |
||||
local qt = package:dep("qt5base"):data("qt") |
||||
if not qt then |
||||
return |
||||
end |
||||
package:add("deps", "qt5core", {debug = package:is_debug(), version = package:version_str()}) |
||||
package:data_set("libname", "Gui") |
||||
|
||||
local linkname |
||||
local syslinks |
||||
local frameworks |
||||
local includedirs = {qt.includedir} |
||||
if package:is_plat("windows") then |
||||
linkname = "Qt5Gui" |
||||
if package:is_debug() then |
||||
linkname = linkname .. "d" |
||||
end |
||||
table.insert(includedirs, path.join(qt.includedir, "QtGui")) |
||||
elseif package:is_plat("android") then |
||||
linkname = "Qt5Gui" |
||||
if package:is_arch("x86_64", "x64") then |
||||
linkname = linkname .. "_x86_64" |
||||
elseif package:is_arch("arm64", "arm64-v8a") then |
||||
linkname = linkname .. "_arm64-v8a" |
||||
elseif package:is_arch("armv7", "armeabi-v7a", "armeabi", "armv7-a", "armv5te") then |
||||
linkname = linkname .. "_armeabi-v7a" |
||||
elseif package:is_arch("x86") then |
||||
linkname = linkname .. "_x86" |
||||
end |
||||
syslinks = "GLESv2" |
||||
table.insert(includedirs, path.join(qt.includedir, "QtGui")) |
||||
elseif package:is_plat("macosx") then |
||||
table.insert(includedirs, path.join(qt.libdir, "QtGui.framework/Versions/5/Headers")) |
||||
frameworks = "QtGui" |
||||
if package:is_plat("android") then |
||||
package:data_set("syslinks", "GLESv2") |
||||
elseif package:is_plat("iphoneos") then |
||||
linkname = {"Qt5Gui", "qtharfbuzz"} |
||||
syslinks = {"qtlibpng", "z"} |
||||
table.insert(includedirs, path.join(qt.includedir, "QtGui")) |
||||
else |
||||
linkname = "Qt5Gui" |
||||
table.insert(includedirs, path.join(qt.includedir, "QtGui")) |
||||
package:data_set("links", "qtharfbuzz") |
||||
package:data_set("syslinks", {"qtlibpng", "z"}) |
||||
end |
||||
|
||||
return { |
||||
qtdir = qt, |
||||
version = qt.version, |
||||
includedirs = includedirs, |
||||
links = linkname, |
||||
linkdirs = qt.libdir, |
||||
frameworks = frameworks, |
||||
frameworkdirs = qt.libdir, |
||||
syslinks = syslinks |
||||
} |
||||
end) |
||||
|
||||
on_install("windows", "linux", "macosx", "mingw", "android", "iphoneos", function (package) |
||||
local qt = package:dep("qt5base"):data("qt") |
||||
assert(qt, "qt5base is required") |
||||
|
||||
package:base():script("load")(package) |
||||
package:set("kind", "library") |
||||
end) |
||||
|
||||
on_test(function (package) |
||||
local cxflags |
||||
if not package:is_plat("windows") then |
||||
cxflags = "-fPIC" |
||||
end |
||||
assert(package:check_cxxsnippets({test = [[ |
||||
int test(int argc, char** argv) { |
||||
QGuiApplication app (argc, argv); |
||||
return app.exec(); |
||||
} |
||||
]]}, {configs = {languages = "c++14", cxflags = not package:is_plat("windows") and "-fPIC" or nil}, includes = {"QGuiApplication"}})) |
||||
]]}, {configs = {languages = "c++14", cxflags = cxflags}, includes = {"QGuiApplication"}})) |
||||
end) |
||||
|
@ -0,0 +1,73 @@ |
||||
package("qt5lib") |
||||
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_versions("5.15.2", "dummy") |
||||
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") |
||||
if not qt then |
||||
return |
||||
end |
||||
|
||||
local libname = assert(package:data("libname"), "this package must not be used directly") |
||||
|
||||
local links = table.wrap(package:data("links")) |
||||
local includedirs = {qt.includedir} |
||||
local linkname |
||||
if package:is_plat("windows") then |
||||
linkname = "Qt5" .. libname |
||||
if package:is_debug() then |
||||
linkname = linkname .. "d" |
||||
end |
||||
table.insert(includedirs, path.join(qt.includedir, "Qt" .. libname)) |
||||
elseif package:is_plat("android") then |
||||
linkname = "Qt5" .. libname |
||||
if package:is_arch("x86_64", "x64") then |
||||
linkname = linkname .. "_x86_64" |
||||
elseif package:is_arch("arm64", "arm64-v8a") then |
||||
linkname = linkname .. "_arm64-v8a" |
||||
elseif package:is_arch("armv7", "armeabi-v7a", "armeabi", "armv7-a", "armv5te") then |
||||
linkname = linkname .. "_armeabi-v7a" |
||||
elseif package:is_arch("x86") then |
||||
linkname = linkname .. "_x86" |
||||
end |
||||
table.insert(includedirs, path.join(qt.includedir, "Qt" .. libname)) |
||||
elseif package:is_plat("macosx") then |
||||
table.insert(includedirs, path.join(qt.libdir, "Qt" .. libname .. ".framework", "Versions", "5", "Headers")) |
||||
frameworks = "Qt" .. libname |
||||
else |
||||
linkname = "Qt5" .. libname |
||||
table.insert(includedirs, path.join(qt.includedir, "Qt" .. libname)) |
||||
end |
||||
|
||||
table.insert(links, 1, linkname) |
||||
|
||||
return { |
||||
qtdir = qt, |
||||
version = qt.version, |
||||
includedirs = includedirs, |
||||
links = links, |
||||
linkdirs = qt.libdir, |
||||
frameworks = package:data("frameworks"), |
||||
frameworkdirs = qt.libdir, |
||||
syslinks = package:data("syslinks") |
||||
} |
||||
end) |
||||
|
||||
on_install("windows", "linux", "macosx", "mingw", "android", "iphoneos", function (package) |
||||
local qt = package:dep("qt5base"):data("qt") |
||||
assert(qt, "qt5base is required") |
||||
end) |
Loading…
Reference in new issue