-
-
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.
- Loading branch information
1 parent
cd37d87
commit 2261851
Showing
1 changed file
with
43 additions
and
19 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 |
---|---|---|
@@ -1,32 +1,56 @@ | ||
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. Also support C, C#, Java, Python, Node.js, Electron etc.") | ||
set_license("GNU Lesser General Public License v3.0") | ||
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") | ||
-- add_urls("https://codeload.github.com/itas109/CSerialPort/zip/refs/tags/$(version)") | ||
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") | ||
|
||
on_install("windows", "linux", function (package) | ||
local configs = {} | ||
table.insert(configs, "-DCSERIALPORT_BUILD_EXAMPLES=" .. "OFF") | ||
on_install(function (package) | ||
-- remove clang-tidy | ||
io.replace("CMakeLists.txt", "if(MSVC)", "if(0)", {plain = true}) | ||
|
||
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) | ||
|
||
end) | ||
|
||
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=[[ | ||
#include "CSerialPort/SerialPort.h" | ||
int main(int argc, char** argv) { | ||
itas109::CSerialPort serialPort; | ||
return 0; | ||
} | ||
]] | ||
}), {configs = {languages = "c++11"}}) | ||
end) | ||
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) |