Skip to content

Deprecate legacy API [AP-643] #1373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/c.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ jobs:
sudo apt-get -qq install gcc-multilib-mips-linux-gnu gcc-mips-linux-gnu qemu-user g++-mips-linux-gnu

- name: Run big endian tests
run: make test-c-v4
run: make test-c-modern
env:
CC: mips-linux-gnu-gcc
CXX: mips-linux-gnu-g++
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -382,13 +382,13 @@ test-c:
$(MAKE) do-all-tests
$(call announce-end,"Finished running C tests")

test-c-v4:
test-c-modern:
$(call announce-begin,"Running C tests")
cd $(SWIFTNAV_ROOT)/c; \
mkdir -p build/ && cd build/; \
cmake $(CMAKEFLAGS) ../; \
$(MAKE) -j4 test-libsbp-v4 test-libsbp-cpp-v4; \
$(MAKE) do-test-libsbp-v4 do-test-libsbp-cpp-v4
$(MAKE) -j4 test-libsbp test-libsbp-cpp; \
$(MAKE) do-test-libsbp do-test-libsbp-cpp
$(call announce-end,"Finished running C tests")

test-python:
Expand Down
80 changes: 43 additions & 37 deletions c/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,38 @@ swift_c_library(
srcs = [
"src/edc.c",
"src/sbp.c",
"src/v4/string/sbp_string.c",
"src/v4/string/multipart.c",
"src/v4/string/null_terminated.c",
"src/v4/string/double_null_terminated.c",
"src/v4/string/unterminated.c",
"src/string/sbp_string.c",
"src/string/multipart.c",
"src/string/null_terminated.c",
"src/string/double_null_terminated.c",
"src/string/unterminated.c",
# generated files
"src/v4/acquisition.c",
"src/v4/bootload.c",
"src/v4/ext_events.c",
"src/v4/file_io.c",
"src/v4/flash.c",
"src/v4/gnss.c",
"src/v4/imu.c",
"src/v4/integrity.c",
"src/v4/linux.c",
"src/v4/logging.c",
"src/v4/mag.c",
"src/v4/navigation.c",
"src/v4/ndb.c",
"src/v4/observation.c",
"src/v4/orientation.c",
"src/v4/piksi.c",
"src/v4/sbas.c",
"src/v4/settings.c",
"src/v4/signing.c",
"src/v4/solution_meta.c",
"src/v4/ssr.c",
"src/v4/system.c",
"src/v4/telemetry.c",
"src/v4/tracking.c",
"src/v4/user.c",
"src/v4/vehicle.c",
"src/acquisition.c",
"src/bootload.c",
"src/ext_events.c",
"src/file_io.c",
"src/flash.c",
"src/gnss.c",
"src/imu.c",
"src/integrity.c",
"src/linux.c",
"src/logging.c",
"src/mag.c",
"src/navigation.c",
"src/ndb.c",
"src/observation.c",
"src/orientation.c",
"src/piksi.c",
"src/sbas.c",
"src/settings.c",
"src/signing.c",
"src/solution_meta.c",
"src/ssr.c",
"src/system.c",
"src/telemetry.c",
"src/tracking.c",
"src/user.c",
"src/vehicle.c",
],
hdrs = SBP_INCLUDE + SBP_INCLUDE_INTERNAL,
copts = [
Expand Down Expand Up @@ -80,24 +80,27 @@ swift_cc_test(
includes = [
"include/libsbp",
],
copts = [
"-Wno-deprecated-declarations",
],
type = UNIT,
deps = [
":sbp",
"@check",
],
)

SBP_V4_C_SOURCES = glob(["test/auto*.c"])
SBP_C_SOURCES = glob(["test/auto*.c"])

swift_cc_test(
name = "sbp-v4-test",
name = "sbp-test",
srcs = [
"test/check_main.c",
"test/check_edc.c",
"test/check_sbp.c",
"test/check_bitfield_macros.c",
"test/check_suites.h",
] + SBP_V4_C_SOURCES,
] + SBP_C_SOURCES,
includes = ["include/libsbp"],
type = UNIT,
deps = [
Expand All @@ -106,11 +109,11 @@ swift_cc_test(
],
)

SBP_CPP_V4_C_SOURCES = glob(["test/cpp/auto*.cc"])
SBP_CPP_C_SOURCES = glob(["test/cpp/auto*.cc"])

swift_cc_test(
name = "sbp-cpp-v4-test",
srcs = SBP_CPP_V4_C_SOURCES,
name = "sbp-cpp-test",
srcs = SBP_CPP_C_SOURCES,
type = UNIT,
deps = [
":sbp",
Expand Down Expand Up @@ -146,6 +149,9 @@ swift_cc_test(
data = [
"test/legacy/cpp/sbp_data/gnss_data.sbp",
],
copts = [
"-Wno-deprecated-declarations",
],
type = UNIT,
deps = [
":sbp",
Expand Down
2 changes: 1 addition & 1 deletion c/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ option(BUILD_EXAMPLES "" OFF)
if(BUILD_EXAMPLES)
add_custom_target(examples)
add_subdirectory(legacy)
add_subdirectory(v4)
add_subdirectory(libsbp)
endif()
4 changes: 2 additions & 2 deletions c/examples/legacy/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
foreach(target example cpp_example tcp_example tcp_2sigma_example)
add_subdirectory(${target})
add_dependencies(examples libsbp_${target})
endforeach()
add_dependencies(examples libsbp_legacy_${target})
endforeach()
6 changes: 3 additions & 3 deletions c/examples/legacy/cpp_example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 2.8.9)
project(libsbp_cpp_example)
project(libsbp_legacy_cpp_example)

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")

Expand All @@ -11,5 +11,5 @@ find_package(PkgConfig)
link_directories("/usr/local/lib/")
include_directories("/usr/local/include/")

add_executable(libsbp_cpp_example cpp_example.cc)
target_link_libraries(libsbp_cpp_example sbp)
add_executable(libsbp_legacy_cpp_example cpp_example.cc)
target_link_libraries(libsbp_legacy_cpp_example sbp)
10 changes: 5 additions & 5 deletions c/examples/legacy/cpp_example/cpp_example.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <iostream>
#include <fstream>

#include <libsbp/cpp/state.h>
#include <libsbp/legacy/cpp/legacy_state.h>
#include <libsbp/legacy/cpp/payload_handler.h>
#include <libsbp/legacy/cpp/frame_handler.h>

Expand Down Expand Up @@ -36,7 +36,7 @@ class SbpFileReader : public sbp::IReader {

class ECEFHandler : private sbp::PayloadHandler<msg_gps_time_t, msg_pos_ecef_t> {
public:
ECEFHandler(sbp::State *state) : sbp::PayloadHandler<msg_gps_time_t, msg_pos_ecef_t>(state) {
ECEFHandler(sbp::LegacyState *state) : sbp::PayloadHandler<msg_gps_time_t, msg_pos_ecef_t>(state) {
}

void handle_sbp_msg(uint16_t sender_id, uint8_t message_length, const msg_gps_time_t& msg) {
Expand All @@ -55,7 +55,7 @@ class ECEFHandler : private sbp::PayloadHandler<msg_gps_time_t, msg_pos_ecef_t>

class LLHFrameHandler : private sbp::FrameHandler<msg_gps_time_t, msg_pos_llh_t> {
public:
LLHFrameHandler(sbp::State *state) : sbp::FrameHandler<msg_gps_time_t, msg_pos_llh_t>(state) {
LLHFrameHandler(sbp::LegacyState *state) : sbp::FrameHandler<msg_gps_time_t, msg_pos_llh_t>(state) {
}

void handle_sbp_frame(uint16_t sender_id, uint16_t msg_type,
Expand All @@ -74,7 +74,7 @@ class LLHFrameHandler : private sbp::FrameHandler<msg_gps_time_t, msg_pos_llh_t>

class EverythingHandler : private sbp::AllFrameHandler {
public:
EverythingHandler(sbp::State *state) : sbp::AllFrameHandler(state) {
EverythingHandler(sbp::LegacyState *state) : sbp::AllFrameHandler(state) {
}

void handle_sbp_frame(uint16_t sender_id, uint16_t msg_type,
Expand Down Expand Up @@ -102,7 +102,7 @@ int main(int argc, char **argv)
exit(EXIT_FAILURE);
}

sbp::State s;
sbp::LegacyState s;
ECEFHandler ecef_handler(&s);
LLHFrameHandler llh_handler(&s);
EverythingHandler everything_handler(&s);
Expand Down
6 changes: 3 additions & 3 deletions c/examples/legacy/example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
cmake_minimum_required(VERSION 2.8.9)
project(libsbp_example)
project(libsbp_legacy_example)

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")

set(CMAKE_C_FLAGS "-Wall -Werror -Wno-error=deprecated-declarations -std=gnu99")

add_executable(libsbp_example example.c)
add_executable(libsbp_legacy_example example.c)

find_package(PkgConfig)
pkg_check_modules(LIBSERIALPORT libserialport)
Expand All @@ -15,4 +15,4 @@ include_directories(${LIBSERIALPORT_INCLUDE_DIRS})
link_directories("/usr/local/lib/")
include_directories("/usr/local/include/")

target_link_libraries(libsbp_example serialport sbp)
target_link_libraries(libsbp_legacy_example serialport sbp)
1 change: 1 addition & 0 deletions c/examples/legacy/example/example.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <libsbp/sbp.h>
#include <libsbp/legacy/system.h>
#include <libsbp/legacy/compat.h>

char *serial_port_name = NULL;
struct sp_port *piksi_port = NULL;
Expand Down
8 changes: 4 additions & 4 deletions c/examples/legacy/tcp_2sigma_example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
cmake_minimum_required(VERSION 2.8.9)
project(libsbp_tcp_2sigma_example)
project(libsbp_legacy_tcp_2sigma_example)

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")

set(CMAKE_CXX_FLAGS "-Wall -Wextra -Werror -Wno-error=deprecated-declarations -std=c++14")

add_executable(libsbp_tcp_2sigma_example tcp_2sigma_example.cc)
add_executable(libsbp_legacy_tcp_2sigma_example tcp_2sigma_example.cc)

find_package(PkgConfig)
find_package(Eigen3)
Expand All @@ -15,10 +15,10 @@ option(SHOW_PLOT "" OFF)
link_directories("/usr/local/lib/")
include_directories("/usr/local/include/")

target_link_libraries(libsbp_tcp_2sigma_example sbp)
target_link_libraries(libsbp_legacy_tcp_2sigma_example sbp)

if (SHOW_PLOT)
find_package(OpenCV)
set(CMAKE_CXX_FLAGS "-DSHOW_PLOT ${CMAKE_CXX_FLAGS}")
target_link_libraries(libsbp_tcp_2sigma_example opencv_core opencv_imgproc opencv_highgui)
target_link_libraries(libsbp_legacy_tcp_2sigma_example opencv_core opencv_imgproc opencv_highgui)
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

#include <libsbp/sbp.h>
#include <libsbp/legacy/navigation.h>
#include <libsbp/legacy/compat.h>

// width and height of the plot window in pixels
#define SIZE_PIXELS 300
Expand Down
6 changes: 3 additions & 3 deletions c/examples/legacy/tcp_example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
cmake_minimum_required(VERSION 2.8.9)
project(libsbp_tcp_example)
project(libsbp_legacy_tcp_example)

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")

set(CMAKE_C_FLAGS "-Wall -Wextra -Wno-strict-prototypes -Werror -Wno-error=deprecated-declarations -std=gnu99 ${CMAKE_C_FLAGS}")

add_executable(libsbp_tcp_example tcp_example.c)
add_executable(libsbp_legacy_tcp_example tcp_example.c)

find_package(PkgConfig)

link_directories("/usr/local/lib/")
include_directories("/usr/local/include/")

target_link_libraries(libsbp_tcp_example sbp)
target_link_libraries(libsbp_legacy_tcp_example sbp)
1 change: 1 addition & 0 deletions c/examples/legacy/tcp_example/tcp_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <libsbp/sbp.h>
#include <libsbp/legacy/system.h>
#include <libsbp/legacy/compat.h>

char *tcp_ip_addr = NULL;
char *tcp_ip_port = NULL;
Expand Down
4 changes: 4 additions & 0 deletions c/examples/libsbp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
foreach(target example cpp_example cpp_traits_example tcp_example tcp_2sigma_example)
add_subdirectory(${target})
add_dependencies(examples libsbp_${target})
endforeach()
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 2.8.9)
project(libsbp_v4_cpp_example)
project(libsbp_cpp_example)

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")

Expand All @@ -11,5 +11,5 @@ find_package(PkgConfig)
link_directories("/usr/local/lib/")
include_directories("/usr/local/include/")

add_executable(libsbp_v4_cpp_example cpp_example.cc)
target_link_libraries(libsbp_v4_cpp_example sbp)
add_executable(libsbp_cpp_example cpp_example.cc)
target_link_libraries(libsbp_cpp_example sbp)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 2.8.9)
project(libsbp_v4_cpp_traits_example)
project(libsbp_cpp_traits_example)

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")

Expand All @@ -11,5 +11,5 @@ find_package(PkgConfig)
link_directories("/usr/local/lib/")
include_directories("/usr/local/include/")

add_executable(libsbp_v4_cpp_traits_example cpp_example.cc)
target_link_libraries(libsbp_v4_cpp_traits_example sbp)
add_executable(libsbp_cpp_traits_example cpp_example.cc)
target_link_libraries(libsbp_cpp_traits_example sbp)
Loading