소스 검색

serial: add package (#2379)

* serial: add package

* serial: fix windows and macosx

* serial: disable plat

* serial: enable mingw
star9029 2 년 전
부모
커밋
14024811d0
1개의 변경된 파일59개의 추가작업 그리고 0개의 파일을 삭제
  1. 59 0
      packages/s/serial/xmake.lua

+ 59 - 0
packages/s/serial/xmake.lua

@@ -0,0 +1,59 @@
+package("serial")
+    set_homepage("http://wjwwood.github.io/serial")
+    set_description("Cross-platform, Serial Port library written in C++")
+    set_license("MIT")
+
+    add_urls("https://github.com/wjwwood/serial.git")
+    add_versions("2022.3.9", "69e0372cf0d3796e84ce9a09aff1d74496f68720")
+
+    if is_plat("windows", "mingw") then
+        add_syslinks("advapi32", "setupapi")
+    elseif is_plat("linux") then
+        add_syslinks("rt", "pthread")
+    elseif is_plat("macosx") then
+        add_frameworks("IOKit", "Foundation")
+    end
+
+    on_install("windows", "linux", "macosx", "mingw", "cross", "wasm", function (package)
+        local configs = {}
+        io.writefile("xmake.lua", [[
+            add_rules("mode.debug", "mode.release")
+            target("serial")
+                set_kind("$(kind)")
+                add_files("src/serial.cc")
+                add_includedirs("include")
+                add_headerfiles("include/(serial/*.h)")
+                if is_plat("windows", "mingw") then
+                    add_files("src/impl/win.cc")
+                    add_files("src/impl/list_ports/list_ports_win.cc")
+                    add_syslinks("advapi32", "setupapi")
+                    if is_plat("windows") and is_kind("shared") then
+                        add_rules("utils.symbols.export_all", {export_classes = true})
+                    end
+                else
+                    add_files("src/impl/unix.cc")
+                    if is_plat("macosx") then
+                        add_files("src/impl/list_ports/list_ports_osx.cc")
+                        add_frameworks("IOKit", "Foundation")
+                    else
+                        add_files("src/impl/list_ports/list_ports_linux.cc")
+                        if is_plat("linux") then
+                            add_syslinks("rt", "pthread")
+                        end
+                    end
+                end
+        ]])
+        if package:config("shared") then
+            configs.kind = "shared"
+        end
+        import("package.tools.xmake").install(package, configs)
+    end)
+
+    on_test(function (package)
+        assert(package:check_cxxsnippets({test = [[
+            #include <serial/serial.h>
+            void test() {
+                serial::list_ports();
+            }
+        ]]}))
+    end)