|
| 1 | +package("foxglove-sdk") |
| 2 | + set_homepage("https://github.com/foxglove/foxglove-sdk") |
| 3 | + set_description("SDK for connecting live robotics and embodied AI data to Foxglove") |
| 4 | + set_license("MIT") |
| 5 | + |
| 6 | + add_configs("remote_access", {description = "Enable Foxglove Remote Access.", default = false, type = "boolean"}) |
| 7 | + |
| 8 | + add_deps("cmake") |
| 9 | + set_policy("package.precompiled", false) |
| 10 | + |
| 11 | + if is_plat("linux") and is_arch("x86_64") then |
| 12 | + set_urls("https://github.com/foxglove/foxglove-sdk/releases/download/sdk/v$(version)/foxglove-v$(version)-cpp-x86_64-unknown-linux-gnu.zip") |
| 13 | + add_versions("0.25.2", "ac001974aa0e3ac5b8159bcd698007c0661715c4a0201c99353e8a8dfe03bd44") |
| 14 | + elseif is_plat("linux") and is_arch("arm64") then |
| 15 | + set_urls("https://github.com/foxglove/foxglove-sdk/releases/download/sdk/v$(version)/foxglove-v$(version)-cpp-aarch64-unknown-linux-gnu.zip") |
| 16 | + add_versions("0.25.2", "72d403cc2ee90e84bd803c08e7dcaa2ddf5175d381f9668b595357a9445c39b6") |
| 17 | + elseif is_plat("macosx") and is_arch("x86_64") then |
| 18 | + set_urls("https://github.com/foxglove/foxglove-sdk/releases/download/sdk/v$(version)/foxglove-v$(version)-cpp-x86_64-apple-darwin.zip") |
| 19 | + add_versions("0.25.2", "3ef620496dde842bc35201f87c33cf94e3b3b2b5b5fb8f057ad64bcf0b12238b") |
| 20 | + elseif is_plat("macosx") and is_arch("arm64") then |
| 21 | + set_urls("https://github.com/foxglove/foxglove-sdk/releases/download/sdk/v$(version)/foxglove-v$(version)-cpp-aarch64-apple-darwin.zip") |
| 22 | + add_versions("0.25.2", "8839bde7c4e1142e7cbbf57756d87d2e36a683fad6fb32cbc240038d6e781ad8") |
| 23 | + elseif is_plat("windows") and is_arch("x64") then |
| 24 | + set_urls("https://github.com/foxglove/foxglove-sdk/releases/download/sdk/v$(version)/foxglove-v$(version)-cpp-x86_64-pc-windows-msvc.zip") |
| 25 | + add_versions("0.25.2", "02b27c7ecb5a0124eebb6e925586a45487d56da708d0088dedb770007fb4a849") |
| 26 | + elseif is_plat("windows") and is_arch("arm64") then |
| 27 | + set_urls("https://github.com/foxglove/foxglove-sdk/releases/download/sdk/v$(version)/foxglove-v$(version)-cpp-aarch64-pc-windows-msvc.zip") |
| 28 | + add_versions("0.25.2", "d0688eb49aea912035225a5077a5fce7f2300bc05b2bdabf637016d418063f8a") |
| 29 | + end |
| 30 | + |
| 31 | + if on_check then |
| 32 | + on_check(function (package) |
| 33 | + assert(package:is_plat("linux", "macosx", "windows"), "foxglove-sdk only supports Linux, macOS, and Windows") |
| 34 | + if package:is_plat("windows") then |
| 35 | + assert(package:is_arch("x64", "arm64"), "foxglove-sdk only supports x64 and arm64 on Windows") |
| 36 | + else |
| 37 | + assert(package:is_arch("x86_64", "arm64"), "foxglove-sdk only supports x86_64 and arm64 on this platform") |
| 38 | + end |
| 39 | + assert(not package:config("remote_access") or package:config("shared"), "foxglove-sdk remote_access requires shared=true") |
| 40 | + end) |
| 41 | + end |
| 42 | + |
| 43 | + on_load(function (package) |
| 44 | + package:add("links", "foxglove_cpp") |
| 45 | + if package:config("remote_access") then |
| 46 | + package:add("defines", "FOXGLOVE_REMOTE_ACCESS") |
| 47 | + elseif not package:config("shared") then |
| 48 | + package:add("links", "foxglove") |
| 49 | + if package:is_plat("windows") then |
| 50 | + package:add("syslinks", "ntdll", "bcrypt", "schannel", "crypt32", "ncrypt") |
| 51 | + elseif package:is_plat("macosx") then |
| 52 | + package:add("frameworks", "IOKit", "Security", "CoreFoundation") |
| 53 | + else |
| 54 | + package:add("syslinks", "pthread", "dl", "m") |
| 55 | + end |
| 56 | + end |
| 57 | + if package:is_plat("windows") and package:config("shared") then |
| 58 | + package:addenv("PATH", "bin") |
| 59 | + end |
| 60 | + end) |
| 61 | + |
| 62 | + on_install("linux", "macosx", "windows", function (package) |
| 63 | + local source_root = os.isdir("foxglove") and "foxglove" or "." |
| 64 | + os.cp(path.join(package:scriptdir(), "port", "cmakelists.txt"), path.join(source_root, "CMakeLists.txt")) |
| 65 | + os.cd(source_root) |
| 66 | + |
| 67 | + local configs = { |
| 68 | + "-DFOXGLOVE_WRAPPER_SHARED=" .. (package:config("shared") and "ON" or "OFF"), |
| 69 | + "-DFOXGLOVE_REMOTE_ACCESS=" .. (package:config("remote_access") and "ON" or "OFF") |
| 70 | + } |
| 71 | + import("package.tools.cmake").install(package, configs) |
| 72 | + end) |
| 73 | + |
| 74 | + on_test(function (package) |
| 75 | + assert(package:check_cxxsnippets({test = [[ |
| 76 | + #include <foxglove/websocket.hpp> |
| 77 | + #include <utility> |
| 78 | + void test() { |
| 79 | + foxglove::WebSocketServerOptions options; |
| 80 | + auto server = foxglove::WebSocketServer::create(std::move(options)); |
| 81 | + } |
| 82 | + ]]}, {configs = {languages = "c++17"}})) |
| 83 | + end) |
0 commit comments