Skip to content

Commit 9afd026

Browse files
hyj0824luadebug
andauthored
Add foxglove-sdk 0.25.2 (#10430)
* Add foxglove-sdk 0.25.2 Add the Foxglove SDK package for Linux, macOS, and Windows on x86_64/arm64 platforms. * Rename CMakeLists.txt to cmakelists.txt * Fix case of CMakeLists.txt in installation script * Add IOKit framework for macOS platform * Add 'ntdll' to Windows syslinks in xmake.lua * Add platform-specific library linking for Windows and macOS * Remove duplicate entries in syslinks and frameworks * Update cmakelists.txt * Update system links and frameworks for platforms * Implement platform-specific linking in CMakeLists Add platform-specific library linking for Windows and macOS. --------- Co-authored-by: Saikari <lin@sz.cn.eu.org>
1 parent 9fc673e commit 9afd026

2 files changed

Lines changed: 140 additions & 0 deletions

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
cmake_minimum_required(VERSION 3.20)
2+
project(foxglove-sdk-xmake LANGUAGES CXX)
3+
4+
include(GNUInstallDirs)
5+
6+
option(FOXGLOVE_WRAPPER_SHARED "Build the C++ wrapper as a shared library" OFF)
7+
option(FOXGLOVE_REMOTE_ACCESS "Enable Foxglove Remote Access" OFF)
8+
9+
if(FOXGLOVE_REMOTE_ACCESS AND NOT FOXGLOVE_WRAPPER_SHARED)
10+
message(FATAL_ERROR "Foxglove Remote Access requires a shared C++ wrapper")
11+
endif()
12+
13+
find_package(foxglove-sdk CONFIG REQUIRED HINTS "${CMAKE_CURRENT_SOURCE_DIR}")
14+
15+
if(FOXGLOVE_WRAPPER_SHARED)
16+
set(_foxglove_wrapper_type SHARED)
17+
else()
18+
set(_foxglove_wrapper_type STATIC)
19+
endif()
20+
21+
foxglove_sdk_add_cpp_library(
22+
foxglove_cpp
23+
TYPE ${_foxglove_wrapper_type}
24+
REMOTE_ACCESS ${FOXGLOVE_REMOTE_ACCESS}
25+
)
26+
27+
if(WIN32)
28+
target_link_libraries(foxglove_cpp PRIVATE ntdll)
29+
endif()
30+
if(APPLE)
31+
find_library(IOKIT_LIBRARY IOKit REQUIRED)
32+
target_link_libraries(foxglove_cpp PRIVATE ${IOKIT_LIBRARY})
33+
endif()
34+
35+
install(
36+
TARGETS foxglove_cpp
37+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
38+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
39+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
40+
)
41+
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
42+
43+
if(NOT FOXGLOVE_WRAPPER_SHARED)
44+
install(
45+
FILES "${CMAKE_CURRENT_SOURCE_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}foxglove${CMAKE_STATIC_LIBRARY_SUFFIX}"
46+
DESTINATION ${CMAKE_INSTALL_LIBDIR}
47+
)
48+
elseif(FOXGLOVE_REMOTE_ACCESS)
49+
if(WIN32)
50+
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/lib/foxglove.dll" DESTINATION ${CMAKE_INSTALL_BINDIR})
51+
else()
52+
install(
53+
FILES "${CMAKE_CURRENT_SOURCE_DIR}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}foxglove${CMAKE_SHARED_LIBRARY_SUFFIX}"
54+
DESTINATION ${CMAKE_INSTALL_LIBDIR}
55+
)
56+
endif()
57+
endif()

packages/f/foxglove-sdk/xmake.lua

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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

Comments
 (0)