-
Notifications
You must be signed in to change notification settings - Fork 15.3k
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
Add support for outputting dependency manifest files, used by ninja and make #178
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.
@TeBoring to take a look. We got internal feature requests for this as well. Need to find a solution that works both for internal users and opensource users. |
I don't quite understand what exactly do you want. |
output_filename = output_filename.substr(2); | ||
} | ||
ss << output_filename << ": "; | ||
for (set<const FileDescriptor*>::const_iterator it = already_seen.begin(); it != already_seen.end(); ++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.
Should it iterate on file_set.file()?
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.
Yes this should be file_set. Originally I was calling GetSourceLocation, which is a private member of FileDescriptor.
The makefile depency file output contents is
you can separate lines for readability with a \ character followed by a newline character For examples, you can generate this file for a number of situations with gcc with the flags "-MMD -MF test.d". |
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. |
Could you sign the cla first? Thanks |
Internally, our need is a little bit different. We don't give protoc the name for manifest file. protoc will generated a .d file for each input file, which records dependencies of just that single input file. |
Sounds good. Out of interest, which directory do you output the files to On 3 February 2015 at 13:55, Paul Yang notifications@github.com wrote:
|
If you just have -m, it will generate file in the same directory as the input file.
|
We have many users who have read-only access to some source directories. We're not intending to use the -m multi-file option, but you may want to consider making the multi-output directory explicit. Depfile syntax : The output path should match the format expected by the build system, which will only be visible via the command line. If it's specified as relative on the cmdline, the output path needs to be relative. If it's specified as absolute on the cmdline it needs to be absolute in the depfile. It's the same for the input files. |
Some files are not input files, but they are included by other input files. On Tuesday, February 3, 2015, Richard Geary notifications@github.com
|
The most general solution would be to provide an option to the user. The option would specify a root path for depfile paths, and all paths under the root would be output as relative paths. If the option was not specified, the paths would be absolute. I realize I've just proposed adding several new command line options to protoc; some projects resist command line option bloat, some seem to embrace it (eg. "man gcc"!). If I had to choose, I'd say use absolute paths always since it's unambiguous. |
I prefer to use absolute path always. On Tuesday, February 3, 2015, Richard Geary notifications@github.com
|
…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
We just found the feature you implemented is enough for internal use. So instead, I want to clean up this pull request. I sent another pull request: #193 to clean the code. |
Signed the CLA, Tower Research Capital |
@rgeary1 Could you add your email (the one associated with this pull request) to tower-research-google-open-source-contributors@googlegroups.com |
CLAs look good, thanks! |
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 : . 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.