lib/adc: Remove unnecessary .options file
The proto options file was only being used to generate a max_count
constant, not to actually encode messages. http://pwrev.dev/236816
removes such constants from fields which are not inline-able in the
first place (such as submessages). This removes the options file and
also ensures that only .pwpb_options extensions are supported moving
forward.
Change-Id: I54fd76c4e2bf34a347858bdaee5b05a155d2e183
Reviewed-on: https://pigweed-review.googlesource.com/c/gonk/+/245612
Reviewed-by: Rob Mohr <mohrr@google.com>
Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com>
Pigweed-Auto-Submit: Alexei Frolov <frolv@google.com>
Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed-service-accounts.iam.gserviceaccount.com>
diff --git a/.gn b/.gn
index 8e044a6..530b90e 100644
--- a/.gn
+++ b/.gn
@@ -18,6 +18,9 @@
# Default gn build virtualenv target.
pw_build_PYTHON_BUILD_VENV = "//:gonk_build_venv"
+ # Don't allow a plain .options file extension for pwpb protos.
+ pw_protobuf_compiler_NO_GENERIC_OPTIONS_FILES = true
+
dir_pw_third_party_freertos = "//third_party/FreeRTOS"
dir_pw_third_party_stm32cube_f7 = "//third_party/stm32cube_f7"
diff --git a/lib/adc/BUILD.gn b/lib/adc/BUILD.gn
index af17a5d..a1c8321 100644
--- a/lib/adc/BUILD.gn
+++ b/lib/adc/BUILD.gn
@@ -23,7 +23,6 @@
pw_proto_library("protos") {
sources = [ "adc_measurement.proto" ]
- inputs = [ "adc_measurement.options" ]
prefix = "gonk_adc"
deps = [ "$dir_pw_protobuf:common_protos" ]
}
diff --git a/lib/adc/adc.cc b/lib/adc/adc.cc
index 8b1f740..16306a1 100644
--- a/lib/adc/adc.cc
+++ b/lib/adc/adc.cc
@@ -401,13 +401,10 @@
return pw::OkStatus();
}
-// Ensure the proto max size is == the expected kMaxStreamingAdcCount
-static_assert(Payload::kAdcMeasurementsMaxSize == kMaxStreamingAdcCount);
-
Status Adc::WriteMeasurementPacket() {
- std::array<std::byte, FramedProto::kMaxEncodedSizeBytes +
- (AdcMeasure::kMaxEncodedSizeBytes *
- Payload::kAdcMeasurementsMaxSize)>
+ std::array<std::byte,
+ FramedProto::kMaxEncodedSizeBytes +
+ (AdcMeasure::kMaxEncodedSizeBytes * kMaxStreamingAdcCount)>
packet_buffer;
FramedProto::MemoryEncoder packet(packet_buffer);
Status status = packet.WriteMagicStart(kFramedProtoMagicConstant);
diff --git a/lib/adc/adc_measurement.options b/lib/adc/adc_measurement.options
deleted file mode 100644
index 344e30d..0000000
--- a/lib/adc/adc_measurement.options
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2022 The Pigweed Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-gonk.adc.Payload.adc_measurements max_count:11
\ No newline at end of file