Skip to content

Commit 1b8c81a

Browse files
authored
RSDK-12498: Fix building against local protos (#537)
1 parent 352f025 commit 1b8c81a

File tree

9 files changed

+64
-58
lines changed

9 files changed

+64
-58
lines changed

buf.lock

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Generated by buf. DO NOT EDIT.
2+
version: v2
3+
deps:
4+
- name: buf.build/googleapis/googleapis
5+
commit: 004180b77378443887d3b55cabc00384
6+
digest: b5:e8f475fe3330f31f5fd86ac689093bcd274e19611a09db91f41d637cb9197881ce89882b94d13a58738e53c91c6e4bae7dc1feba85f590164c975a89e25115dc
7+
- name: buf.build/opentelemetry/opentelemetry
8+
commit: 648a3e2f02e14fe187656ea4ac3befa1
9+
digest: b5:a0514be587ab2e8598f7102dfdaba5e985138b8c041c707e470a9c8b877410ada6e60cf2359352302f08c0504de685379f7f7a085d4699d69a2e6ed7035e78d9
10+
- name: buf.build/viamrobotics/api
11+
commit: 9e59e291a4574eebbf5241b3e004a6bd
12+
digest: b5:8bd880cf71605a19b2a098cf39756cfcb7365328a088e25c38e4c74d26c63b6a16b2b7c71601158a4cc535b937b641e201adef32904795808a5a8f56c11d1a21
13+
- name: buf.build/viamrobotics/goutils
14+
commit: 5fff320e3fab4611aea8180e09bcb5e5
15+
digest: b5:e524fd761245da57e4651fd26e16d1a1ea9f45b5fe43ac63e35070f814e9665e5e06741e30e3c803b4d6c6f5d685a62f705e916089d92f34be7e42ba721e6f7d
Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1-
version: v1
2-
breaking:
3-
use:
4-
- FILE
5-
lint:
6-
use:
7-
- DEFAULT
1+
version: v2
82
deps:
93
- buf.build/googleapis/googleapis
4+
- buf.build/opentelemetry/opentelemetry
105
- buf.build/viamrobotics/api
116
- buf.build/viamrobotics/goutils
12-
- buf.build/opentelemetry/opentelemetry
7+
lint:
8+
use:
9+
- DEFAULT
10+
except:
11+
- FIELD_NOT_REQUIRED
12+
- PACKAGE_NO_IMPORT_CYCLE
13+
disallow_comment_ignores: true
14+
breaking:
15+
use:
16+
- FILE
17+
except:
18+
- EXTENSION_NO_DELETE
19+
- FIELD_SAME_DEFAULT

src/viam/api/CMakeLists.txt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ set(PROTO_GEN_DIR ${CMAKE_CURRENT_SOURCE_DIR})
33

44
if (VIAMCPPSDK_USE_DYNAMIC_PROTOS)
55
# reads in buf.lock and grabs the commit hashes supported by this version of C++ SDK
6-
if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/buf.lock)
6+
if (NOT EXISTS ${PROJECT_SOURCE_DIR}/buf.lock)
77
message(FATAL_ERROR "No `buf.lock` file was found in the src/viam/api directory")
88
endif()
9-
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/buf.lock lockfile)
9+
file(READ ${PROJECT_SOURCE_DIR}/buf.lock lockfile)
1010

1111
string(REGEX MATCH "googleapis[ \t\r\n]*commit: ([A-Za-z0-9_]*)" _ ${lockfile})
1212
set(BUF_GOOGLE_API_SOURCE buf.build/googleapis/googleapis:${CMAKE_MATCH_1})
@@ -42,17 +42,15 @@ if (VIAMCPPSDK_USE_LOCAL_PROTOS)
4242
message(FATAL_ERROR "The VIAMCPPSDK_USE_LOCAL_PROTOS option requires VIAMCPPSDK_USE_DYNAMIC_PROTOS=ON")
4343
endif()
4444

45-
if (NOT EXISTS ${PROJECT_SOURCE_DIR}/../buf.work.yaml)
46-
message(FATAL_ERROR "No `buf.work.yaml` file was found in the parent directory")
47-
endif()
48-
45+
# TODO: I believe it is no longer necessary for the Viam API repo to be a sibling repo of the Viam C++ SDK repo.
46+
# Maybe try to detect the sibling configuration as before, but also allow the option to pass the directory as a CMake arg.
4947
if (NOT EXISTS ${PROJECT_SOURCE_DIR}/../api/proto/viam)
5048
message(FATAL_ERROR "No Viam api repository was found in the parent directory")
5149
endif()
5250

53-
file(RELATIVE_PATH BUF_LOCAL_PROTO_PATH ${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/..)
51+
file(RELATIVE_PATH BUF_LOCAL_PROTO_PATH ${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/../api)
5452
set(BUF_VIAM_API_SOURCE ${BUF_LOCAL_PROTO_PATH})
55-
list(TRANSFORM BUF_PROTO_COMPONENTS PREPEND ${BUF_LOCAL_PROTO_PATH}/api/proto/viam/)
53+
list(TRANSFORM BUF_PROTO_COMPONENTS PREPEND ${BUF_LOCAL_PROTO_PATH}/proto/viam/)
5654
endif()
5755

5856
list(JOIN BUF_PROTO_COMPONENTS , BUF_PROTO_COMPONENTS_JOINED)

src/viam/api/buf.lock

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/viam/api/config/buf.gen.local.yaml.in

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2023 Viam Inc.
1+
# Copyright 2026 Viam Inc.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -12,10 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
version: v1
15+
version: v2
1616
plugins:
17-
- name: cpp
17+
- protoc_builtin: cpp
1818
out: gen/viam/api
19-
- name: cpp-grpc
19+
- local: ${VIAMCPPSDK_GRPC_CPP_PLUGIN}
2020
out: gen/viam/api
21-
path: ${VIAMCPPSDK_GRPC_CPP_PLUGIN}

src/viam/api/config/buf.gen.remote.plugin.yaml.in

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2023 Viam Inc.
1+
# Copyright 2026 Viam Inc.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -12,11 +12,11 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
version: v1
15+
version: v2
1616
managed:
1717
enabled: true
1818
plugins:
19-
- plugin: buf.build/grpc/cpp:v@VIAMCPPSDK_GRPCXX_VERSION@
19+
- remote: buf.build/grpc/cpp:v@VIAMCPPSDK_GRPCXX_VERSION@
2020
out: gen/viam/api
21-
- plugin: buf.build/protocolbuffers/cpp:v@VIAMCPPSDK_PROTOC_VERSION@
21+
- remote: buf.build/protocolbuffers/cpp:v@VIAMCPPSDK_PROTOC_VERSION@
2222
out: gen/viam/api
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Generated by buf. DO NOT EDIT.
2+
version: v2
3+
deps:
4+
- name: buf.build/googleapis/googleapis
5+
commit: 004180b77378443887d3b55cabc00384
6+
digest: b5:e8f475fe3330f31f5fd86ac689093bcd274e19611a09db91f41d637cb9197881ce89882b94d13a58738e53c91c6e4bae7dc1feba85f590164c975a89e25115dc
Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2023 Viam Inc.
1+
# Copyright 2026 Viam Inc.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -12,13 +12,21 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
16-
version: v1
15+
version: v2
16+
modules:
17+
- path: proto
1718
deps:
1819
- buf.build/googleapis/googleapis
19-
breaking:
20-
use:
21-
- FILE
2220
lint:
2321
use:
2422
- DEFAULT
23+
except:
24+
- FIELD_NOT_REQUIRED
25+
- PACKAGE_NO_IMPORT_CYCLE
26+
disallow_comment_ignores: true
27+
breaking:
28+
use:
29+
- FILE
30+
except:
31+
- EXTENSION_NO_DELETE
32+
- FIELD_SAME_DEFAULT

src/viam/examples/modules/complex/proto/buf.lock

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)