-
Notifications
You must be signed in to change notification settings - Fork 15.4k
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
Implement a feature to generate a dependency file #193
Conversation
…nd make Use --manifest-file=somefile.d to output the dependency manifest. This file will contain a list of files which were read by protoc as part of creating the output files. It doesn't include the plugin inputs if plugins are used, that could be a later extension. The manifest file is in the format <output file>: <input files>. The manifest file format only allows you to specify one output file, which isn't a problem as it's used to detect input changes in order to detect when to rerun the protoc command. The output file used in the manifest is the manifest filename itself; to use this in ninja you should declare the manifest file as the first output as well as the depfile input.
…he flag "--dependency_manifest_out=FILE", protoc will write dependencies of input proto files into FILE. In FILE, the format will be <full path to FILE>: <full path to 1st proto>\\\n <full path to 2nd proto> ... This cl is based on protocolbuffers#178
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project, in which case you'll need to sign a Contributor License Agreement (CLA) at https://cla.developers.google.com/. If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check the information on your CLA or see this help article on setting the email on your git commits. Once you've done that, please reply here to let us know. If you signed the CLA as a corporation, please let us know the company's name. |
I have signed CLA |
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. |
@rgeary1 to review |
@@ -1012,6 +1019,22 @@ CommandLineInterface::InterpretArgument(const string& name, | |||
} | |||
descriptor_set_name_ = value; | |||
|
|||
} else if (name == "--dependency_out") { | |||
if (!dependency_manifest_name_.empty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make var name (dependency_manifest_name_) match argument name somewhat (dependency_out_name_?)
ExpectNoErrors(); | ||
|
||
ExpectFileContent("manifest", | ||
"$tmpdir/manifest: $tmpdir/foo.proto\\\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
normally the file would be:
<outputfile1>; <outputfile2>; ... : <dependency1>; \\
<dependency2>; \\
<dependency3>; \\
...
where for a main.c of:
#include "main.h"
int main() {
return 0;
}
cc -MMD main.c
you are going to get:
main.o: main.c main.h
our code is not going to set <outputfile> correctly. I would expect for the cpp compiler that we would actually generate
foo.pb.cc foo.pb.h: foo.proto
Thoughts? I think the current code will actually work for my needs, but it is certainly not a correct solution as far as I can tell.
I'm working from "http://make.mad-scientist.net/papers/advanced-auto-dependency-generation/".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
foo.pb.cc foo.pb.h: foo.proto
It looks good. However, protoc doesn't know generated file is named foo.pb.cc and foo.pb.h
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If code generator/plugin can tell protoc the path of its generated files, protoc can make it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Wed, Feb 4, 2015 at 2:33 PM, dmaclach notifications@github.com wrote:
In src/google/protobuf/compiler/command_line_interface_unittest.cc
#193 (comment):
- "syntax = "proto2";\n"
- "message Foo {}\n");
- CreateTempFile("bar.proto",
- "syntax = "proto2";\n"
- "import "foo.proto";\n"
- "message Bar {\n"
- " optional Foo foo = 1;\n"
- "}\n");
- Run("protocol_compiler --dependency_out=$tmpdir/manifest "
"--test_out=$tmpdir --proto_path=$tmpdir bar.proto");
- ExpectNoErrors();
- ExpectFileContent("manifest",
"$tmpdir/manifest: $tmpdir/foo.proto\\n"
normally the file would be:
... :
...where for a main.c of:
#include "main.h"int main() {
return 0;
}cc -MMD main.c
you are going to get:
main.o: main.c main.h
our code is not going to set correctly. I would expect for the cpp
compiler that we would actually generatefoo.pb.cc foo.pb.h : foo.proto
Thoughts? I think the current code will actually work for my needs, but it
is certainly not a correct solution as far as I can tell.Protoc has one difference from gcc: protoc can generate different set of
files for different languages, where as gcc is tied to C/C++. This means
the output of protoc varies from language. And sometimes it's may not be
tied with any language at all. For example, users may just want to find all
imports of a certain .proto file and build a protodb for them. For this
reason I think it's better to avoid any language specific files in the
generated dependency file and make it a general purpose dependency file
that could be used for any language.
I'm working from "
http://make.mad-scientist.net/papers/advanced-auto-dependency-generation/
".—
Reply to this email directly or view it on GitHub
https://github.com/google/protobuf/pull/193/files#r24126637.
If the spec includes support for multiple output files in the depfile and it's supported by make, then I suspect this is a ninja implementation issue. I'll email the ninja mailing list to find out their reasons. |
@rgeary1, how's the CLA going? |
Still working on it. I've asked our legal team for an ETA. On 19 February 2015 at 04:11, Paul Yang notifications@github.com wrote:
|
Signed the CLA, Tower Research Capital |
We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm. |
All CLAs should have been signed. |
Implement a feature to generate a dependency file
Implement a feature to generate a dependency file
By giving protoc the flag
"--dependency_out=FILE", protoc will write dependencies of input proto files into FILE. In FILE, the format will be: ^output_file_path: input1_path\n input2_path$
Whether path is relative or absolute will be based on the input on command line.
This cl is based on google#178