Jelajahi Sumber

add dorkbox/UDT (#4736)

* add dorkbox/UDT

* remove versions

* move variables to outside of on_install and add pthread

* Update xmake.lua

* add mingw try try?

* windows export symbols

* Update xmake.lua

---------

Co-authored-by: star9029 <[email protected]>
Elite-stay 1 tahun lalu
induk
melakukan
d79da8c7fb
1 mengubah file dengan 48 tambahan dan 0 penghapusan
  1. 48 0
      packages/u/udt/xmake.lua

+ 48 - 0
packages/u/udt/xmake.lua

@@ -0,0 +1,48 @@
+package("udt")
+    set_homepage("https://github.com/dorkbox/UDT")
+    set_description("UDP-based Data Transfer Protocol")
+    set_license("Apache-2.0")
+
+    add_urls("https://github.com/dorkbox/UDT/archive/8272c251deb8bfd7289646b7604f1079b59194d0.tar.gz",
+             "https://github.com/dorkbox/UDT.git")
+
+    add_versions("2017.12.03", "af743ffdb2e40225d7375df1a3d6320127b903322af4021460681f1052b7461e")
+
+    if is_plat("windows", "mingw") then
+        add_defines("WINDOWS")
+        add_syslinks("Ws2_32")
+    elseif is_plat("linux", "bsd") then
+        add_syslinks("pthread", "m")
+    end
+
+    on_install("!windows or windows|!x86", function (package)
+        io.writefile("xmake.lua", [[
+            add_rules("mode.debug", "mode.release")
+            target("udt")
+                set_kind("$(kind)")
+                if is_mode("debug") then
+                    add_defines("_DEBUG")
+                end
+                if is_plat("windows") and is_kind("shared") then
+                    add_rules("utils.symbols.export_all", {export_classes = true})
+                end
+                set_languages("cxx11")
+                if is_plat("windows", "mingw") then
+                    add_defines("WINDOWS")
+                    add_syslinks("Ws2_32")
+                elseif is_plat("linux", "bsd") then
+                    add_syslinks("pthread", "m")
+                end
+                add_files("src/*.cpp")
+                add_headerfiles("src/udt.h")
+        ]])
+        import("package.tools.xmake").install(package)
+    end)
+
+    on_test(function (package)
+        assert(package:check_cxxsnippets({test = [[
+            void test() {
+                UDT::startup();
+            }
+        ]]}, {configs = {languages = "c++11"}, includes = "udt.h"}))
+    end)