Pārlūkot izejas kodu

Updated objfw (#2334)

* Updated objfw

* Add additional configs

* Fix configure flags

* Also allow mingw

* All config options

* MacOS should always use the system runtime,
and make seluid24 default faulse

* Add warning

* Use explicit with

* Fix typo

* Clean up description

* Add more options for tls

* Update xmake.lua

* Update xmake.lua

* Update xmake.lua

* Update xmake.lua

* Update ubuntu.yml

* Update ubuntu.yml

* Update xmake.lua

* Add files for both objective C and C++

* Seperate flags properly

* wrong spelling, should be mxx

* remove -local

* Update xmake.lua

---------

Co-authored-by: ruki <[email protected]>
Amrit Bhogal 2 gadi atpakaļ
vecāks
revīzija
837b305392
2 mainītis faili ar 78 papildinājumiem un 12 dzēšanām
  1. 1 7
      .github/workflows/ubuntu.yml
  2. 77 5
      packages/o/objfw/xmake.lua

+ 1 - 7
.github/workflows/ubuntu.yml

@@ -29,13 +29,7 @@ jobs:
         run: |
           # TODO we will remove it later
           sudo apt-get update
-          sudo apt-get install -y libgl1-mesa-dev libglu1-mesa-dev p7zip
-          sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 60
-          sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 60
-          sudo update-alternatives --install /usr/bin/cpp cpp /usr/bin/cpp-9 60
-          sudo update-alternatives --set g++ /usr/bin/g++-9
-          sudo update-alternatives --set gcc /usr/bin/gcc-9
-          sudo update-alternatives --set cpp /usr/bin/cpp-9
+          sudo apt-get install -y libgl1-mesa-dev libglu1-mesa-dev p7zip gobjc gcc g++
 
       - name: Tests
         run: |

+ 77 - 5
packages/o/objfw/xmake.lua

@@ -1,24 +1,96 @@
 package("objfw")
     set_homepage("https://objfw.nil.im")
-    set_description("[Official Mirror] A portable framework for the Objective-C language.")
+    set_description("Portable framework for the Objective-C language.")
 
     add_urls("https://github.com/ObjFW/ObjFW.git")
     add_versions("2023.03.18", "86cec7d17dd323407f30fc5947e0e92cc307e869")
 
-    add_deps("autoconf", "automake", "libtool")
+    if is_host("linux", "macosx") then
+        add_deps("autoconf", "automake", "libtool")
+    end
 
     if is_plat("macosx") then
         add_syslinks("objc")
         add_frameworks("CoreFoundation")
     end
 
+    add_configs("tls", { description = "Enable TLS support.", default = false, values = { true, false, "openssl", "gnutls", "securetransport" } })
+    add_configs("rpath", { description = "Enable rpath.", default = true, type = "boolean" })
+    add_configs("runtime", { description = "Use the included runtime, not recommended for macOS!", default = not is_plat("macosx"), type = "boolean" })
+    add_configs("seluid24", { description = "Use 24 bit instead of 16 bit for selector UIDs.", default = false, type = "boolean" })
+    add_configs("unicode_tables", { description = "Enable Unicode tables.", default = true, type = "boolean" })
+
+    add_configs("codepage_437", { description = "Enable codepage 437 support.", default = true, type = "boolean" })
+    add_configs("codepage_850", { description = "Enable codepage 850 support.", default = true, type = "boolean" })
+    add_configs("codepage-858", { description = "Enable codepage 858 support.", default = true, type = "boolean" })
+    add_configs("iso_8859_2", { description = "Enable ISO-8859-2 support.", default = true, type = "boolean" })
+    add_configs("iso_8859_3", { description = "Enable ISO-8859-3 support.", default = true, type = "boolean" })
+    add_configs("iso_8859_15", { description = "Enable ISO-8859-15 support.", default = true, type = "boolean" })
+    add_configs("koi8_r", { description = "Enable KOI8-R support.", default = true, type = "boolean" })
+    add_configs("koi8_u", { description = "Enable KOI8-U support.", default = true, type = "boolean" })
+    add_configs("mac_roman", { description = "Enable Mac Roman encoding support.", default = true, type = "boolean" })
+    add_configs("windows_1251", { description = "Enable windows 1251 support.", default = true, type = "boolean" })
+    add_configs("windows_1252", { description = "Enable windows 1252 support.", default = true, type = "boolean" })
+
+    add_configs("threads", { description = "Enable threads.", default = true, type = "boolean" })
+    add_configs("compiler_tls", { description = "Enable compiler thread local storage (TLS).", default = true, type = "boolean" })
+    add_configs("files", { description = "Enable files.", default = true, type = "boolean" })
+    add_configs("sockets", { description = "Enable sockets.", default = true, type = "boolean" })
+
+    add_configs("arc", { description = "Enable Automatic Reference Counting (ARC) support.", default = true, type = "boolean" })
+
+    on_load(function (package)
+        local tls = package:config("tls")
+        if type(tls) == "boolean" then
+            if tls then
+                package:add("deps", "openssl")
+            end
+        elseif tls then
+            if tls == "openssl" then
+                package:add("deps", "openssl")
+            else
+                raise("no package %s for objfw!", tls)
+            end
+        end
+    end)
+
     on_install("linux", "macosx", function (package)
-        local configs = {"--without-tls"}
-        table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
-        if package:debug() then
+        local configs = {}
+        local tls = package:config("tls")
+        if type(tls) == "boolean" then
+            tls = tls and "yes" or "no"
+        end
+        table.insert(configs, "--enable-tls=" .. tls)
+        if package:is_debug() then
             table.insert(configs, "--enable-debug")
         end
+        table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
+        table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes"))
+        for name, enabled in pairs(package:configs()) do
+            if not package:extraconf("configs", name, "builtin") then
+                name = name:gsub("_", "-")
+                if enabled then
+                    table.insert(configs, "--enable-" .. name)
+                else
+                    table.insert(configs, "--disable-" .. name)
+                end
+            end
+        end
         import("package.tools.autoconf").install(package, configs)
+
+        local mflags = {}
+        local mxxflags = {}
+        local ldflags = {}
+        local objfwcfg = path.join(package:installdir("bin"), "objfw-config")
+        local mflags_str = os.iorunv(objfwcfg, {"--cflags", "--cppflags", "--objcflags", (package:config("arc") and "--arc" or "")})
+        local mxxflags_str = os.iorunv(objfwcfg, {"--cxxflags", "--cppflags", "--objcflags", (package:config("arc") and "--arc" or "")})
+        local ldflags_str = os.iorunv(objfwcfg, {"--ldflags"})
+        table.join2(mflags, mflags_str:split("%s+"))
+        table.join2(mxxflags, mxxflags_str:split("%s+"))
+        table.join2(ldflags, ldflags_str:split("%s+"))
+        package:add("mflags", mflags)
+        package:add("mxxflags", mxxflags)
+        package:add("ldflags", ldflags)
     end)
 
     on_test(function (package)