Browse Source

add qwindowkit (#3892)

* add qwindowkit

* add deps

* add qt6gui to qwindowkit

* update qtbase

* fix arch

* use 1.1 version

* use submodules

* add logs

* fix test

* fix qmsetup

* remove dir

* fix qmsetup

---------

Co-authored-by: star9029 <[email protected]>
ruki 1 year ago
parent
commit
f8f29a122b
3 changed files with 97 additions and 3 deletions
  1. 21 0
      packages/q/qmsetup/xmake.lua
  2. 35 3
      packages/q/qtbase/xmake.lua
  3. 41 0
      packages/q/qwindowkit/xmake.lua

+ 21 - 0
packages/q/qmsetup/xmake.lua

@@ -0,0 +1,21 @@
+package("qmsetup")
+    set_homepage("https://github.com/stdware/qmsetup")
+    set_description("CMake Modules and Basic Libraries for C/C++ projects.")
+    set_license("MIT")
+
+    add_urls("https://github.com/stdware/qmsetup.git")
+    add_versions("2024.04.23", "0b95afa778b99d9e9de772006555309b74ed32f4")
+
+    add_deps("cmake")
+
+    on_install(function (package)
+        local configs = {}
+        table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
+        table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
+        import("package.tools.cmake").install(package, configs)
+        package:addenv("PATH", "bin")
+    end)
+
+    on_test(function (package)
+        assert(package:has_cxxincludes("qmsetup/qmsetup_global.h"))
+    end)

+ 35 - 3
packages/q/qtbase/xmake.lua

@@ -147,7 +147,7 @@ package("qtbase")
         -- special case for cross-compilation since we need binaries we can run on the host
         -- special case for cross-compilation since we need binaries we can run on the host
         if package:is_cross() then
         if package:is_cross() then
             local runhost
             local runhost
-            if is_host("windows") or package:is_plat("mingw") then
+            if is_host("windows") then
                 runhost = "windows"
                 runhost = "windows"
             elseif is_host("linux") then
             elseif is_host("linux") then
                 runhost = "linux"
                 runhost = "linux"
@@ -157,8 +157,40 @@ package("qtbase")
                 raise("unhandled host " .. os.host())
                 raise("unhandled host " .. os.host())
             end
             end
 
 
+            local hostarch
+            if is_host("windows") then
+                local winarch
+                if os.arch():find("64", 1, true) then
+                    winarch = "64"
+                else
+                    winarch = "32"
+                end
+
+                local compiler_version
+                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 os.arch() == "x64" then
+                    compiler_version = compiler_version .. "_64"
+                elseif os.arch() == "arm64" then
+                    compiler_version = compiler_version .. "_arm64"
+                end
+                hostarch = "win" .. winarch .. "_" .. compiler_version
+            elseif is_host("linux") then
+                hostarch = "gcc_64"
+            elseif is_host("macosx") then
+                hostarch = "clang_64"
+            end
+
             -- download qtbase to bin_host folder
             -- download qtbase to bin_host folder
-            os.vrunv("aqt", {"install-qt", "-O", path.join(installdir, "bin_host"), runhost, "desktop", versionstr, "--archives", "qtbase"})
+            os.vrunv("aqt", {"install-qt", "-O", path.join(installdir, "bin_host"),
+                runhost, "desktop", versionstr, hostarch})
 
 
             -- add symbolic links for useful tools
             -- add symbolic links for useful tools
             local tool_folders = {}
             local tool_folders = {}
@@ -183,7 +215,7 @@ package("qtbase")
             end
             end
 
 
             for folder, tools in pairs(tool_folders) do
             for folder, tools in pairs(tool_folders) do
-                for _, file in pairs(os.files(path.join(installdir, "bin_host", versionstr, "*", folder, "*"))) do
+                for _, file in ipairs(os.files(path.join(installdir, "bin_host", versionstr, "*", folder, "*"))) do
                     local filename = path.filename(file)
                     local filename = path.filename(file)
                     if tools[filename] then
                     if tools[filename] then
                         local targetpath = path.join(installdir, folder, filename)
                         local targetpath = path.join(installdir, folder, filename)

+ 41 - 0
packages/q/qwindowkit/xmake.lua

@@ -0,0 +1,41 @@
+package("qwindowkit")
+    set_homepage("https://github.com/stdware/qwindowkit")
+    set_description("Cross-platform frameless window framework for Qt. Support Windows, macOS, Linux.")
+    set_license("Apache-2.0")
+
+    add_urls("https://github.com/stdware/qwindowkit/archive/refs/tags/$(version).tar.gz",
+             "https://github.com/stdware/qwindowkit.git")
+
+    add_versions("1.1", "a0102ee4c4fdd08ce35c29a5b9a27384005028b2ab6094f61e467c35917b8c5e")
+
+    add_deps("cmake")
+    add_deps("qmsetup")
+    add_deps("qt6gui")
+    if is_plat("linux") then
+        add_deps("fontconfig", "libxkbcommon")
+    end
+
+    add_includedirs("include/QWindowKit")
+
+    on_install("windows|x64", "linux|x86_64", "macosx|x86_64", function (package)
+        local configs = {}
+        table.insert(configs, "-Dqmsetup_DIR=" .. package:dep("qmsetup"):installdir("lib"))
+        table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
+        table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
+        import("package.tools.cmake").install(package, configs)
+    end)
+
+    on_test(function (package)
+        local cxflags
+        if package:is_plat("windows") then
+            cxflags = {"/Zc:__cplusplus", "/permissive-"}
+        else
+            cxflags = "-fPIC"
+        end
+        assert(package:check_cxxsnippets({test = [[
+            #include <QWKWidgets/widgetwindowagent.h>
+            void test() {
+                QWK::WidgetWindowAgent(nullptr);
+            }
+        ]]}, {configs = {languages = "c++17", cxflags = cxflags}}))
+    end)