Skip to content
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

Generate --dep-info earlier in the compillation #11155

Merged
merged 2 commits into from
Dec 31, 2013

Conversation

SiegeLord
Copy link
Contributor

The --dep-info command line option allows a nice way to generate make-style dependencies, but it currently does so alongside building of the output binary. This isn't a problem for make, as it mixes dependency graph generation and actual building, but it is problematic for other tools (e.g. CMake) which keep them separate.

To play more nicely with those tools, I've moved the --dep-info output from phase 6 (linking) up to after phase 2 (expansion of macros). Also, since there was no prior option to do so, I added a command line switch (--no-analysis) to stop compilation just before phase 3 (type-checking) which speeds this up even further.

Here's the beginning of a CMake function which is enabled by this change:

function(get_rust_deps root_file out_var)
    execute_process(COMMAND rustc ${RUSTC_FLAGS} --no-analysis --dep-info "${CMAKE_BINARY_DIR}/.deps" "${root_file}")

    # Read and parse the dependency information
    file(READ "${CMAKE_BINARY_DIR}/.deps" crate_deps)
    file(REMOVE "${CMAKE_BINARY_DIR}/.deps")
    # parsing follows...

@emberian
Copy link
Member

Ohh this is a nice PR. <3 me some cmake.

@metajack
Copy link
Contributor

Just a small note, CMake must do this fine because it uses the same method that GCC does right? Or does it pass GCC arguments that skip all the compilation phases too?

@SiegeLord
Copy link
Contributor Author

I believe CMake uses a custom dependency scanner for C/C++.

@metajack
Copy link
Contributor

Ah. Ninja uses -MMD I think, so I guess I assumed everyone did. The CMake stuff I wrote computed the crate hash itself since I did it before --crate-file-name existed.

@SiegeLord
Copy link
Contributor Author

I played around with this change some more in the context of CMake and I managed to create a demonstration project here: https://github.com/SiegeLord/RustCMake. Another use of this change that I highlight there is to grab dependencies for rustdoc... although that could be an argument for adding --dep-info to rustdoc.

bors added a commit that referenced this pull request Dec 31, 2013
The `--dep-info` command line option allows a nice way to generate make-style dependencies, but it currently does so alongside building of the output binary. This isn't a problem for make, as it mixes dependency graph generation and actual building, but it is problematic for other tools (e.g. CMake) which keep them separate.

To play more nicely with those tools, I've moved the --dep-info output from phase 6 (linking) up to after phase 2 (expansion of macros). Also, since there was no prior option to do so, I added a command line switch (`--no-analysis`) to stop compilation just before phase 3 (type-checking) which speeds this up even further.

Here's the beginning of a CMake function which is enabled by this change:

~~~cmake
function(get_rust_deps root_file out_var)
	execute_process(COMMAND rustc ${RUSTC_FLAGS} --no-analysis --dep-info "${CMAKE_BINARY_DIR}/.deps" "${root_file}")
	
	# Read and parse the dependency information
	file(READ "${CMAKE_BINARY_DIR}/.deps" crate_deps)
	file(REMOVE "${CMAKE_BINARY_DIR}/.deps")
	# parsing follows...
~~~
@bors bors closed this Dec 31, 2013
@bors bors merged commit cbe8c61 into rust-lang:master Dec 31, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants