Skip to content

Commit

Permalink
move P4RuntimeFormat to new header file
Browse files Browse the repository at this point in the history
Move P4RuntimeFormat definition to a new header file to allow options.h
to include only that header file, and not everything in
p4RuntimeSerializer.h. This prevents needing to pull in the protobuf
includes for any file that uses options.h
  • Loading branch information
grg committed Feb 16, 2024
1 parent 2c02be6 commit 441b614
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
1 change: 1 addition & 0 deletions backends/p4tools/modules/testgen/targets/bmv2/bmv2.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "backends/p4tools/common/compiler/compiler_target.h"
#include "backends/p4tools/common/compiler/midend.h"
#include "backends/p4tools/common/lib/variables.h"
#include "control-plane/p4RuntimeSerializer.h"
#include "frontends/common/options.h"

#include "backends/p4tools/modules/testgen/core/compiler_target.h"
Expand Down
1 change: 1 addition & 0 deletions control-plane/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ set (CONTROLPLANE_HDRS
p4RuntimeArchStandard.h
p4RuntimeSerializer.h
p4RuntimeSymbolTable.h
p4RuntimeTypes.h
typeSpecConverter.h
bfruntime.h
)
Expand Down
4 changes: 1 addition & 3 deletions control-plane/p4RuntimeSerializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ limitations under the License.
#include <unordered_map>

#include "lib/cstring.h"
#include "p4RuntimeTypes.h"

namespace p4 {
namespace config {
Expand All @@ -47,9 +48,6 @@ class CompilerOptions;

namespace P4 {

/// P4Runtime serialization formats.
enum class P4RuntimeFormat { BINARY, JSON, TEXT, TEXT_PROTOBUF };

/// A P4 program's control-plane API, represented in terms of P4Runtime's data
/// structures. Can be inspected or serialized.
struct P4RuntimeAPI {
Expand Down
27 changes: 27 additions & 0 deletions control-plane/p4RuntimeTypes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
Copyright 2024-present Intel Corporation
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
http://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.
*/

#ifndef CONTROL_PLANE_P4RUNTIMETYPES_H_
#define CONTROL_PLANE_P4RUNTIMETYPES_H_

namespace P4 {

/// P4Runtime serialization formats.
enum class P4RuntimeFormat { BINARY, JSON, TEXT, TEXT_PROTOBUF };

} // namespace P4

#endif /* CONTROL_PLANE_P4RUNTIMETYPES_H_ */
2 changes: 1 addition & 1 deletion frontends/common/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ limitations under the License.

#include "parser_options.h"
// for p4::P4RuntimeFormat definition
#include "control-plane/p4RuntimeSerializer.h"
#include "control-plane/p4RuntimeTypes.h"

class CompilerOptions : public ParserOptions {
protected:
Expand Down

0 comments on commit 441b614

Please sign in to comment.