-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement simple annotation bundling
Summary: The standard annotation library is essentially a part of the Thrift compiler toolchain and they have to match each other. Unfortunately this is currently not the case and there exist multiple copies of the annotation library that are rarely updated and cause various issues. Reviewed By: aristidisp Differential Revision: D64916919 fbshipit-source-id: 19d95dced4a5c6e54eaf1164bf24d46b52f38575
- Loading branch information
1 parent
a2f0209
commit d43d589
Showing
4 changed files
with
86 additions
and
2 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
third-party/thrift/src/thrift/annotation/build_annotations.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* 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. | ||
*/ | ||
|
||
#include <fmt/core.h> | ||
#include "thrift/compiler/source_location.h" | ||
|
||
int main() { | ||
// Print the header. | ||
fmt::print( | ||
"// {}generated\n" | ||
"\n" | ||
"#include <thrift/annotation/bundled_annotations.h>\n" | ||
"\n", | ||
'@'); | ||
|
||
// Read the file. | ||
apache::thrift::compiler::source_manager sm; | ||
std::string_view content = sm.get_file("scope.thrift")->text; | ||
content.remove_suffix(1); // Remove trailing NUL. | ||
|
||
// Print the content. | ||
fmt::print( | ||
"namespace apache::thrift::detail {{\n" | ||
"\n" | ||
"const std::string_view bundled_annotations::scope_file_content() {{\n" | ||
" return R\"{0}({1}){0}\";\n" | ||
"}}\n" | ||
"\n" | ||
"}} // namespace apache::thrift::detail\n", | ||
"__FBTHRIFT_TAG__", | ||
content); | ||
} |
25 changes: 25 additions & 0 deletions
25
third-party/thrift/src/thrift/annotation/bundled_annotations.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* 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. | ||
*/ | ||
|
||
#include <string_view> | ||
|
||
namespace apache::thrift::detail { | ||
|
||
struct bundled_annotations { | ||
static const std::string_view scope_file_content(); | ||
}; | ||
|
||
} // namespace apache::thrift::detail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters