-
-
Notifications
You must be signed in to change notification settings - Fork 398
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add cserialport lib * Update xmake.lua * Update xmake.lua --------- Co-authored-by: star9029 <[email protected]>
- Loading branch information
1 parent
588080a
commit de97c7e
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package("cserialport") | ||
set_homepage("https://github.com/itas109/CSerialPort") | ||
set_description("CSerialPort is a lightweight cross-platform serial port library based on C++, which can easy to read and write serial port on multiple operating system.") | ||
set_license("LGPL-3.0") | ||
|
||
add_urls("https://github.com/itas109/CSerialPort/archive/refs/tags/$(version).tar.gz", | ||
"https://github.com/itas109/CSerialPort.git") | ||
|
||
add_versions("v4.3.1", "376f41866be65ddfed91f3d0fea91aaaf5ca7e645f9b9cfcdaa0a9182a0bb3ac") | ||
|
||
add_configs("c_api", {description = "Build C API", default = false, type = "boolean"}) | ||
|
||
if is_plat("windows", "mingw") then | ||
add_syslinks("advapi32") | ||
elseif is_plat("linux", "bsd") then | ||
add_syslinks("pthread") | ||
elseif is_plat("macosx") then | ||
add_frameworks("Foundation", "IOKit") | ||
end | ||
|
||
add_deps("cmake") | ||
|
||
if on_check then | ||
on_check("windows", function (package) | ||
import("core.base.semver") | ||
|
||
if package:is_arch("arm.*") then | ||
local vs_toolset = package:toolchain("msvc"):config("vs_toolset") | ||
assert(vs_toolset and semver.new(vs_toolset):minor() >= 30, "package(cserialport/arm): need vs_toolset >= v143") | ||
end | ||
end) | ||
end | ||
|
||
on_install("!cross and !iphoneos and !android", function (package) | ||
local configs = {"-DCSERIALPORT_BUILD_EXAMPLES=OFF"} | ||
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) | ||
|
||
if package:config("c_api") then | ||
io.replace("bindings/c/cserialport.h", "#define C_DLL_EXPORT __declspec(dllexport)", "#define C_DLL_EXPORT", {plain = true}) | ||
io.writefile("xmake.lua", [[ | ||
add_rules("mode.debug", "mode.release") | ||
target("cserialport-c") | ||
set_kind("static") | ||
add_files("bindings/c/cserialport.cpp") | ||
add_headerfiles("bindings/c/cserialport.h") | ||
add_includedirs("include") | ||
]]) | ||
import("package.tools.xmake").install(package) | ||
end | ||
end) | ||
|
||
on_test(function (package) | ||
assert(package:check_cxxsnippets({test = [[ | ||
void test() { | ||
itas109::CSerialPort serialPort; | ||
} | ||
]]}, {configs = {languages = "c++11"}, includes = "CSerialPort/SerialPort.h"})) | ||
|
||
if package:config("c_api") then | ||
assert(package:has_cfuncs("CSerialPortInit", {includes = "cserialport.h"})) | ||
end | ||
end) |