|
|
|
// Protocol Buffers - Google's data interchange format
|
|
|
|
// Copyright 2023 Google LLC. All rights reserved.
|
|
|
|
//
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file or at
|
|
|
|
// https://developers.google.com/open-source/licenses/bsd
|
|
|
|
|
|
|
|
// IWYU pragma: private, include "upb/reflection/def.h"
|
|
|
|
|
|
|
|
// Declarations common to all public def types.
|
|
|
|
|
|
|
|
#ifndef UPB_REFLECTION_COMMON_H_
|
|
|
|
#define UPB_REFLECTION_COMMON_H_
|
|
|
|
|
Fixed layering check violations once and for all in upb bootstrapping.
Our bootstrapping setup compiles multiple versions of the generated code for `descriptor.proto` and `plugin.proto`, one for each stage of the bootstrap. For source files (`.c`), we can always select the correct version of the file in the BUILD rules, but for header files we need to make sure the correct stage's file is always selected via `#include`.
Previously we used `cc_library(includes=[])` to make it appear as though our bootstrapped headers had the same names as the "real" headers. This allowed a lot of the code to be agnostic to whether a bootstrap header was being used, which simplified things because we did not have to change the code performing the `#include`.
Unfortunately, due to build system limitations, this sometimes led to the incorrect header getting included. This should not have been possible, because we had a clean BUILD graph that should have removed all ambiguity about which header should be available. But in non-sandboxed builds, the compiler was able to find headers that were not actually in `deps=[]`, and worse it preferred those headers over the headers that actually were in `deps=[]`. This led to unintended results and errors about layering check violations.
This CL fixes the problem by removing all use of `includes=[]`. We now spell a full pathname to all bootstrap headers, so this class of errors is no longer possible. Unfortunately this adds some complexity, as we have to hard-code these full paths in several places.
A nice improvement in this CL is that `bootstrap_upb_proto_library()` can now only be used for bootstrapping; it only exposes the `descriptor_bootstrap.h` / `plugin_bootstrap.h` files. Anyone wanting to use the normal `net/proto2/proto/descriptor.upb.h` file should depend on `//net/proto2/proto:descriptor_upb_c_proto` target instead.
PiperOrigin-RevId: 664953196
3 months ago
|
|
|
#include "upb/reflection/descriptor_bootstrap.h" // IWYU pragma: export
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
kUpb_Syntax_Proto2 = 2,
|
|
|
|
kUpb_Syntax_Proto3 = 3,
|
|
|
|
kUpb_Syntax_Editions = 99
|
|
|
|
} upb_Syntax;
|
|
|
|
|
|
|
|
// Forward declarations for circular references.
|
|
|
|
typedef struct upb_DefPool upb_DefPool;
|
|
|
|
typedef struct upb_EnumDef upb_EnumDef;
|
|
|
|
typedef struct upb_EnumReservedRange upb_EnumReservedRange;
|
|
|
|
typedef struct upb_EnumValueDef upb_EnumValueDef;
|
|
|
|
typedef struct upb_ExtensionRange upb_ExtensionRange;
|
|
|
|
typedef struct upb_FieldDef upb_FieldDef;
|
|
|
|
typedef struct upb_FileDef upb_FileDef;
|
|
|
|
typedef struct upb_MessageDef upb_MessageDef;
|
|
|
|
typedef struct upb_MessageReservedRange upb_MessageReservedRange;
|
|
|
|
typedef struct upb_MethodDef upb_MethodDef;
|
|
|
|
typedef struct upb_OneofDef upb_OneofDef;
|
|
|
|
typedef struct upb_ServiceDef upb_ServiceDef;
|
|
|
|
|
|
|
|
// EVERYTHING BELOW THIS LINE IS INTERNAL - DO NOT USE /////////////////////////
|
|
|
|
|
|
|
|
typedef struct upb_DefBuilder upb_DefBuilder;
|
|
|
|
|
|
|
|
#endif /* UPB_REFLECTION_COMMON_H_ */
|