Skip to content

Commit

Permalink
serial: add package (#2379)
Browse files Browse the repository at this point in the history
* serial: add package

* serial: fix windows and macosx

* serial: disable plat

* serial: enable mingw
  • Loading branch information
star-hengxing authored Jul 30, 2023
1 parent 246d2c2 commit 1402481
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions packages/s/serial/xmake.lua
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 1402481

Please sign in to comment.