Skip to content

Commit b9860dc

Browse files
authored
Deprecate legacy API [AP-643] (#1373)
# Description @swift-nav/devinfra Follow through on legacy API deprecation plan as previously agreed upon. The goals of this PR are: - Keep the legacy API in place but make it much more difficult to access - Any usage of the legacy API must be explicit on behalf of the user - Legacy API no longer implicitly available by including `libsbp/sbp.h` - legacy headers must be explicitly included - All header files in the legacy API generate a compile time message at the point of inclusion warning that they will be removed in version 6 - All symbols in the legacy API are marked with the `deprecated` attribute - All mentions of `v4` (ie, the modern replacement API) removed from headers, source files, etc. Moving forwards there will be no such thing as the "v4" API, there will just be the libsbp API - Shuffle files around in the source and include directories to better reflect the transition from legacy to modern APIs - The correct way to include a package worth of message types is by including (eg) `libsbp/observation.h` - v4 "package" header files (eg `libsbp/v4/observation.h`) are still available but are deprecated. They generate a compile time message warning that they will be removed in version 6 and then include `libsbp/<package>.h` (the new header file) automatically - The end goal of all of this is that there is the libsbp API (previously know as the v4 API), plus a legacy API which is hanging around but very much a second class citizen. - The legacy code is sufficiently separated so that removing it in version 6 should be a fairly trivial task consisting mostly of deleting some source/header files and templates # API compatibility Does this change introduce a API compatibility risk? Nothing significant. The vast majority of symbols are present and have the same meaning as before. Users of the legacy API may find that they need to alter some include directives, but the warnings should be obnoxious enough that they have no excuse for not transitioning to the modern API immediately. The one piece which has changed is the C++ state wrapper (`sbp::State`) which previously was capable of handling both the legacy and modern APIs. This has been broken up so that `sbp::State` now only handles the modern API, and a new class `sbp::LegacyState` inherits from `sbp::State` and adds a coupld of functions to deal with the legacy API. This class is immediately deprecated and marked for deletion in version 6 The modern API is untouched by this PR ## API compatibility plan If the above is "Yes", please detail the compatibility (or migration) plan: All users must transition to the modern API immediately if they haven't already done so. # JIRA Reference https://swift-nav.atlassian.net/browse/AP-643
1 parent cf3f252 commit b9860dc

File tree

1,209 files changed

+10494
-5344
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,209 files changed

+10494
-5344
lines changed

.github/workflows/c.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ jobs:
126126
sudo apt-get -qq install gcc-multilib-mips-linux-gnu gcc-mips-linux-gnu qemu-user g++-mips-linux-gnu
127127
128128
- name: Run big endian tests
129-
run: make test-c-v4
129+
run: make test-c-modern
130130
env:
131131
CC: mips-linux-gnu-gcc
132132
CXX: mips-linux-gnu-g++

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -382,13 +382,13 @@ test-c:
382382
$(MAKE) do-all-tests
383383
$(call announce-end,"Finished running C tests")
384384

385-
test-c-v4:
385+
test-c-modern:
386386
$(call announce-begin,"Running C tests")
387387
cd $(SWIFTNAV_ROOT)/c; \
388388
mkdir -p build/ && cd build/; \
389389
cmake $(CMAKEFLAGS) ../; \
390-
$(MAKE) -j4 test-libsbp-v4 test-libsbp-cpp-v4; \
391-
$(MAKE) do-test-libsbp-v4 do-test-libsbp-cpp-v4
390+
$(MAKE) -j4 test-libsbp test-libsbp-cpp; \
391+
$(MAKE) do-test-libsbp do-test-libsbp-cpp
392392
$(call announce-end,"Finished running C tests")
393393

394394
test-python:

c/BUILD.bazel

+43-37
Original file line numberDiff line numberDiff line change
@@ -15,38 +15,38 @@ swift_c_library(
1515
srcs = [
1616
"src/edc.c",
1717
"src/sbp.c",
18-
"src/v4/string/sbp_string.c",
19-
"src/v4/string/multipart.c",
20-
"src/v4/string/null_terminated.c",
21-
"src/v4/string/double_null_terminated.c",
22-
"src/v4/string/unterminated.c",
18+
"src/string/sbp_string.c",
19+
"src/string/multipart.c",
20+
"src/string/null_terminated.c",
21+
"src/string/double_null_terminated.c",
22+
"src/string/unterminated.c",
2323
# generated files
24-
"src/v4/acquisition.c",
25-
"src/v4/bootload.c",
26-
"src/v4/ext_events.c",
27-
"src/v4/file_io.c",
28-
"src/v4/flash.c",
29-
"src/v4/gnss.c",
30-
"src/v4/imu.c",
31-
"src/v4/integrity.c",
32-
"src/v4/linux.c",
33-
"src/v4/logging.c",
34-
"src/v4/mag.c",
35-
"src/v4/navigation.c",
36-
"src/v4/ndb.c",
37-
"src/v4/observation.c",
38-
"src/v4/orientation.c",
39-
"src/v4/piksi.c",
40-
"src/v4/sbas.c",
41-
"src/v4/settings.c",
42-
"src/v4/signing.c",
43-
"src/v4/solution_meta.c",
44-
"src/v4/ssr.c",
45-
"src/v4/system.c",
46-
"src/v4/telemetry.c",
47-
"src/v4/tracking.c",
48-
"src/v4/user.c",
49-
"src/v4/vehicle.c",
24+
"src/acquisition.c",
25+
"src/bootload.c",
26+
"src/ext_events.c",
27+
"src/file_io.c",
28+
"src/flash.c",
29+
"src/gnss.c",
30+
"src/imu.c",
31+
"src/integrity.c",
32+
"src/linux.c",
33+
"src/logging.c",
34+
"src/mag.c",
35+
"src/navigation.c",
36+
"src/ndb.c",
37+
"src/observation.c",
38+
"src/orientation.c",
39+
"src/piksi.c",
40+
"src/sbas.c",
41+
"src/settings.c",
42+
"src/signing.c",
43+
"src/solution_meta.c",
44+
"src/ssr.c",
45+
"src/system.c",
46+
"src/telemetry.c",
47+
"src/tracking.c",
48+
"src/user.c",
49+
"src/vehicle.c",
5050
],
5151
hdrs = SBP_INCLUDE + SBP_INCLUDE_INTERNAL,
5252
copts = [
@@ -80,24 +80,27 @@ swift_cc_test(
8080
includes = [
8181
"include/libsbp",
8282
],
83+
copts = [
84+
"-Wno-deprecated-declarations",
85+
],
8386
type = UNIT,
8487
deps = [
8588
":sbp",
8689
"@check",
8790
],
8891
)
8992

90-
SBP_V4_C_SOURCES = glob(["test/auto*.c"])
93+
SBP_C_SOURCES = glob(["test/auto*.c"])
9194

9295
swift_cc_test(
93-
name = "sbp-v4-test",
96+
name = "sbp-test",
9497
srcs = [
9598
"test/check_main.c",
9699
"test/check_edc.c",
97100
"test/check_sbp.c",
98101
"test/check_bitfield_macros.c",
99102
"test/check_suites.h",
100-
] + SBP_V4_C_SOURCES,
103+
] + SBP_C_SOURCES,
101104
includes = ["include/libsbp"],
102105
type = UNIT,
103106
deps = [
@@ -106,11 +109,11 @@ swift_cc_test(
106109
],
107110
)
108111

109-
SBP_CPP_V4_C_SOURCES = glob(["test/cpp/auto*.cc"])
112+
SBP_CPP_C_SOURCES = glob(["test/cpp/auto*.cc"])
110113

111114
swift_cc_test(
112-
name = "sbp-cpp-v4-test",
113-
srcs = SBP_CPP_V4_C_SOURCES,
115+
name = "sbp-cpp-test",
116+
srcs = SBP_CPP_C_SOURCES,
114117
type = UNIT,
115118
deps = [
116119
":sbp",
@@ -146,6 +149,9 @@ swift_cc_test(
146149
data = [
147150
"test/legacy/cpp/sbp_data/gnss_data.sbp",
148151
],
152+
copts = [
153+
"-Wno-deprecated-declarations",
154+
],
149155
type = UNIT,
150156
deps = [
151157
":sbp",

c/examples/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ option(BUILD_EXAMPLES "" OFF)
33
if(BUILD_EXAMPLES)
44
add_custom_target(examples)
55
add_subdirectory(legacy)
6-
add_subdirectory(v4)
6+
add_subdirectory(libsbp)
77
endif()

c/examples/legacy/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
foreach(target example cpp_example tcp_example tcp_2sigma_example)
22
add_subdirectory(${target})
3-
add_dependencies(examples libsbp_${target})
4-
endforeach()
3+
add_dependencies(examples libsbp_legacy_${target})
4+
endforeach()

c/examples/legacy/cpp_example/CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 2.8.9)
2-
project(libsbp_cpp_example)
2+
project(libsbp_legacy_cpp_example)
33

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

@@ -11,5 +11,5 @@ find_package(PkgConfig)
1111
link_directories("/usr/local/lib/")
1212
include_directories("/usr/local/include/")
1313

14-
add_executable(libsbp_cpp_example cpp_example.cc)
15-
target_link_libraries(libsbp_cpp_example sbp)
14+
add_executable(libsbp_legacy_cpp_example cpp_example.cc)
15+
target_link_libraries(libsbp_legacy_cpp_example sbp)

c/examples/legacy/cpp_example/cpp_example.cc

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <iostream>
22
#include <fstream>
33

4-
#include <libsbp/cpp/state.h>
4+
#include <libsbp/legacy/cpp/legacy_state.h>
55
#include <libsbp/legacy/cpp/payload_handler.h>
66
#include <libsbp/legacy/cpp/frame_handler.h>
77

@@ -36,7 +36,7 @@ class SbpFileReader : public sbp::IReader {
3636

3737
class ECEFHandler : private sbp::PayloadHandler<msg_gps_time_t, msg_pos_ecef_t> {
3838
public:
39-
ECEFHandler(sbp::State *state) : sbp::PayloadHandler<msg_gps_time_t, msg_pos_ecef_t>(state) {
39+
ECEFHandler(sbp::LegacyState *state) : sbp::PayloadHandler<msg_gps_time_t, msg_pos_ecef_t>(state) {
4040
}
4141

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

5656
class LLHFrameHandler : private sbp::FrameHandler<msg_gps_time_t, msg_pos_llh_t> {
5757
public:
58-
LLHFrameHandler(sbp::State *state) : sbp::FrameHandler<msg_gps_time_t, msg_pos_llh_t>(state) {
58+
LLHFrameHandler(sbp::LegacyState *state) : sbp::FrameHandler<msg_gps_time_t, msg_pos_llh_t>(state) {
5959
}
6060

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

7575
class EverythingHandler : private sbp::AllFrameHandler {
7676
public:
77-
EverythingHandler(sbp::State *state) : sbp::AllFrameHandler(state) {
77+
EverythingHandler(sbp::LegacyState *state) : sbp::AllFrameHandler(state) {
7878
}
7979

8080
void handle_sbp_frame(uint16_t sender_id, uint16_t msg_type,
@@ -102,7 +102,7 @@ int main(int argc, char **argv)
102102
exit(EXIT_FAILURE);
103103
}
104104

105-
sbp::State s;
105+
sbp::LegacyState s;
106106
ECEFHandler ecef_handler(&s);
107107
LLHFrameHandler llh_handler(&s);
108108
EverythingHandler everything_handler(&s);
+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
cmake_minimum_required(VERSION 2.8.9)
2-
project(libsbp_example)
2+
project(libsbp_legacy_example)
33

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

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

8-
add_executable(libsbp_example example.c)
8+
add_executable(libsbp_legacy_example example.c)
99

1010
find_package(PkgConfig)
1111
pkg_check_modules(LIBSERIALPORT libserialport)
@@ -15,4 +15,4 @@ include_directories(${LIBSERIALPORT_INCLUDE_DIRS})
1515
link_directories("/usr/local/lib/")
1616
include_directories("/usr/local/include/")
1717

18-
target_link_libraries(libsbp_example serialport sbp)
18+
target_link_libraries(libsbp_legacy_example serialport sbp)

c/examples/legacy/example/example.c

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <libsbp/sbp.h>
99
#include <libsbp/legacy/system.h>
10+
#include <libsbp/legacy/compat.h>
1011

1112
char *serial_port_name = NULL;
1213
struct sp_port *piksi_port = NULL;
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
cmake_minimum_required(VERSION 2.8.9)
2-
project(libsbp_tcp_2sigma_example)
2+
project(libsbp_legacy_tcp_2sigma_example)
33

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

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

8-
add_executable(libsbp_tcp_2sigma_example tcp_2sigma_example.cc)
8+
add_executable(libsbp_legacy_tcp_2sigma_example tcp_2sigma_example.cc)
99

1010
find_package(PkgConfig)
1111
find_package(Eigen3)
@@ -15,10 +15,10 @@ option(SHOW_PLOT "" OFF)
1515
link_directories("/usr/local/lib/")
1616
include_directories("/usr/local/include/")
1717

18-
target_link_libraries(libsbp_tcp_2sigma_example sbp)
18+
target_link_libraries(libsbp_legacy_tcp_2sigma_example sbp)
1919

2020
if (SHOW_PLOT)
2121
find_package(OpenCV)
2222
set(CMAKE_CXX_FLAGS "-DSHOW_PLOT ${CMAKE_CXX_FLAGS}")
23-
target_link_libraries(libsbp_tcp_2sigma_example opencv_core opencv_imgproc opencv_highgui)
23+
target_link_libraries(libsbp_legacy_tcp_2sigma_example opencv_core opencv_imgproc opencv_highgui)
2424
endif()

c/examples/legacy/tcp_2sigma_example/tcp_2sigma_example.cc

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
#include <libsbp/sbp.h>
4343
#include <libsbp/legacy/navigation.h>
44+
#include <libsbp/legacy/compat.h>
4445

4546
// width and height of the plot window in pixels
4647
#define SIZE_PIXELS 300
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
cmake_minimum_required(VERSION 2.8.9)
2-
project(libsbp_tcp_example)
2+
project(libsbp_legacy_tcp_example)
33

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

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

8-
add_executable(libsbp_tcp_example tcp_example.c)
8+
add_executable(libsbp_legacy_tcp_example tcp_example.c)
99

1010
find_package(PkgConfig)
1111

1212
link_directories("/usr/local/lib/")
1313
include_directories("/usr/local/include/")
1414

15-
target_link_libraries(libsbp_tcp_example sbp)
15+
target_link_libraries(libsbp_legacy_tcp_example sbp)

c/examples/legacy/tcp_example/tcp_example.c

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <libsbp/sbp.h>
99
#include <libsbp/legacy/system.h>
10+
#include <libsbp/legacy/compat.h>
1011

1112
char *tcp_ip_addr = NULL;
1213
char *tcp_ip_port = NULL;

c/examples/libsbp/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
foreach(target example cpp_example cpp_traits_example tcp_example tcp_2sigma_example)
2+
add_subdirectory(${target})
3+
add_dependencies(examples libsbp_${target})
4+
endforeach()

c/examples/v4/cpp_example/CMakeLists.txt renamed to c/examples/libsbp/cpp_example/CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 2.8.9)
2-
project(libsbp_v4_cpp_example)
2+
project(libsbp_cpp_example)
33

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

@@ -11,5 +11,5 @@ find_package(PkgConfig)
1111
link_directories("/usr/local/lib/")
1212
include_directories("/usr/local/include/")
1313

14-
add_executable(libsbp_v4_cpp_example cpp_example.cc)
15-
target_link_libraries(libsbp_v4_cpp_example sbp)
14+
add_executable(libsbp_cpp_example cpp_example.cc)
15+
target_link_libraries(libsbp_cpp_example sbp)

c/examples/v4/cpp_traits_example/CMakeLists.txt renamed to c/examples/libsbp/cpp_traits_example/CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 2.8.9)
2-
project(libsbp_v4_cpp_traits_example)
2+
project(libsbp_cpp_traits_example)
33

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

@@ -11,5 +11,5 @@ find_package(PkgConfig)
1111
link_directories("/usr/local/lib/")
1212
include_directories("/usr/local/include/")
1313

14-
add_executable(libsbp_v4_cpp_traits_example cpp_example.cc)
15-
target_link_libraries(libsbp_v4_cpp_traits_example sbp)
14+
add_executable(libsbp_cpp_traits_example cpp_example.cc)
15+
target_link_libraries(libsbp_cpp_traits_example sbp)

0 commit comments

Comments
 (0)