-
Notifications
You must be signed in to change notification settings - Fork 57
Bazel updates for Harmonic #397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
4795e34
Harmonic bazel
mjcarroll cf54236
Fix RE and install path
mjcarroll 4fc843f
Fix up generate script
mjcarroll f7db1e1
Minimize diff
mjcarroll 8881d33
Fix arg
mjcarroll 554b57c
Revert all changes to gz_msgs_generate
mjcarroll 35d48cd
Clean up harmonic implementation
mjcarroll 6338d74
Add a "lite" factory variant
mjcarroll 5138cc5
Add lint support
mjcarroll 4e73795
Generate command line files
mjcarroll b4ac4da
Allow dynamic factory to load from descriptor files
mjcarroll 4a840f8
Lint
mjcarroll 155304a
Remove dead code
mjcarroll 8e1d0db
Add iostream header
mjcarroll f02ed90
Change data deps
mjcarroll 0ebc366
Lint
mjcarroll 8d03c23
Needs .string() on Windows
mjcarroll 4ed4226
add docs
mjcarroll e55e4e3
IWYU
mjcarroll a6fab0c
Move generated file location
mjcarroll 3df1f83
Merge branch 'mjcarroll/port/9_to_10' into mjcarroll/bazel_harmonic
mjcarroll dbb7688
Add descriptors test
mjcarroll 42ff5a2
Merge branch 'gz-msgs10' into mjcarroll/bazel_harmonic
mjcarroll 317d704
Differentiate message names
mjcarroll 1c36fed
Address reviewer comments
mjcarroll bb61343
Merge branch 'gz-msgs10' into mjcarroll/bazel_harmonic
mjcarroll File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,116 @@ | ||
| /* | ||
| * Copyright 2016 Open Source Robotics Foundation | ||
| * | ||
| * 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 <algorithm> | ||
| #include <filesystem> | ||
| #include <iostream> | ||
| #include <fstream> | ||
| #include <map> | ||
| #include <memory> | ||
| #include <sstream> | ||
| #include <string> | ||
| #include <utility> | ||
| #include <vector> | ||
|
|
||
| #ifdef _MSC_VER | ||
| #pragma warning(push) | ||
| #pragma warning(disable: 4100 4512 4127 4068 4244 4267 4251 4146) | ||
| #endif | ||
|
|
||
| #include <google/protobuf/descriptor.h> | ||
| #include <google/protobuf/compiler/code_generator.h> | ||
| #include <google/protobuf/io/printer.h> | ||
| #include <google/protobuf/io/zero_copy_stream.h> | ||
| #include <google/protobuf/descriptor.pb.h> | ||
|
|
||
| #ifdef _MSC_VER | ||
| #pragma warning(pop) | ||
| #endif | ||
|
|
||
| #include "Generator.hh" | ||
|
|
||
| namespace google::protobuf::compiler::cpp { | ||
|
|
||
| ///////////////////////////////////////////////// | ||
| Generator::Generator(const std::string &/*_name*/) | ||
| { | ||
| } | ||
|
|
||
| ///////////////////////////////////////////////// | ||
| Generator::~Generator() = default; | ||
|
|
||
| ///////////////////////////////////////////////// | ||
| bool Generator::Generate(const FileDescriptor *_file, | ||
| const std::string &/*_parameter*/, | ||
| OutputDirectory *_generatorContext, | ||
| std::string * /*_error*/) const | ||
| { | ||
| std::string delim = ".proto"; | ||
| auto headerFilename = _file->name(); | ||
| auto sourceFilename = _file->name(); | ||
|
|
||
| { | ||
| auto pos = headerFilename.rfind(delim); | ||
| headerFilename.replace(pos, delim.size(), ".pb.h"); | ||
| } | ||
| { | ||
| auto pos = sourceFilename.rfind(delim); | ||
| sourceFilename.replace(pos, delim.size(), ".pb.h"); | ||
| } | ||
|
|
||
| { | ||
| auto *output = _generatorContext->OpenForInsert(headerFilename, "includes"); | ||
| auto printer = io::Printer(output, '$'); | ||
| printer.Print("#include <memory>\n", "name", "includes"); | ||
| } | ||
|
|
||
| { | ||
| auto *output = _generatorContext->OpenForInsert( | ||
| headerFilename, "namespace_scope"); | ||
| auto printer = io::Printer(output, '$'); | ||
|
|
||
| for (auto i = 0; i < _file->message_type_count(); ++i) | ||
| { | ||
| const auto *desc = _file->message_type(i); | ||
| std::string ptrTypes; | ||
|
|
||
| // Define std::unique_ptr types for our messages | ||
| ptrTypes += "typedef std::unique_ptr<" | ||
| + desc->name() + "> " | ||
| + desc->name() + "UniquePtr;\n"; | ||
|
|
||
| // Define const std::unique_ptr types for our messages | ||
| ptrTypes += "typedef std::unique_ptr<const " | ||
| + desc->name() + "> Const" | ||
| + desc->name() + "UniquePtr;\n"; | ||
|
|
||
| // Define std::shared_ptr types for our messages | ||
| ptrTypes += "typedef std::shared_ptr<" | ||
| + desc->name() + "> " | ||
| + desc->name() + "SharedPtr;\n"; | ||
|
|
||
| // Define const std::shared_ptr types for our messages | ||
| ptrTypes += "typedef std::shared_ptr<const " | ||
| + desc->name() + "> Const" | ||
| + desc->name() + "SharedPtr;\n"; | ||
|
|
||
| printer.PrintRaw(ptrTypes.c_str()); | ||
| } | ||
| } | ||
| return true; | ||
| } | ||
| } // namespace google::protobuf::compiler::cpp |
This file contains hidden or 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,57 @@ | ||
| /* | ||
| * Copyright (C) 2016 Open Source Robotics Foundation | ||
| * | ||
| * 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 GZ_MSGS_GENERATOR_HH_ | ||
| #define GZ_MSGS_GENERATOR_HH_ | ||
|
|
||
| #include <google/protobuf/compiler/code_generator.h> | ||
| #include <string> | ||
|
|
||
| namespace google { | ||
| namespace protobuf { | ||
| namespace compiler { | ||
| namespace cpp { | ||
| /// \cond | ||
| /// \brief Google protobuf message generator for igntion::msgs | ||
mjcarroll marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| class Generator : public CodeGenerator | ||
| { | ||
| /// \brief Constructor | ||
| /// \param[in] _name Name value (currently unused) | ||
| public: explicit Generator(const std::string &_name); | ||
|
|
||
| /// \brief Destructor | ||
| public: virtual ~Generator(); | ||
|
|
||
| /// \brief Generate a message. | ||
| /// \param[in] _file File descriptor of the message. | ||
| /// \param[in] _parameter Unused string value | ||
| /// \param[in] _generatorContext Output directory. | ||
| /// \param[in] _error Unused string value | ||
| /// \return true if successful, otherwise sets _error and returns false | ||
| public: virtual bool Generate(const FileDescriptor *_file, | ||
| const std::string &_parameter, | ||
| OutputDirectory *_generatorContext, | ||
| std::string *_error) const; | ||
|
|
||
| // private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Generator); | ||
mjcarroll marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }; | ||
| /// \endcond | ||
| } | ||
| } | ||
| } | ||
| } | ||
| #endif | ||
This file contains hidden or 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,42 @@ | ||
| /* | ||
| * Copyright (C) 2016 Open Source Robotics Foundation | ||
| * | ||
| * 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. | ||
| * | ||
| */ | ||
|
|
||
| #ifdef _MSC_VER | ||
| #pragma warning(push) | ||
| #pragma warning(disable: 4251) | ||
| #endif | ||
|
|
||
| #include <google/protobuf/compiler/plugin.h> | ||
|
|
||
| #ifdef _MSC_VER | ||
| #pragma warning(pop) | ||
| #endif | ||
|
|
||
| #include "Generator.hh" | ||
|
|
||
| int main(int _argc, char *_argv[]) | ||
| { | ||
| #ifdef _MSC_VER | ||
| // Don't print a silly message or stick a modal dialog box in my face, | ||
| // please. | ||
| _set_abort_behavior(0, ~0); | ||
| #endif // !_MSC_VER | ||
|
|
||
| google::protobuf::compiler::cpp::Generator | ||
| generator("gz-msgs-plugin"); | ||
| return google::protobuf::compiler::PluginMain(_argc, _argv, &generator); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.