mozilla/rust — pull request #11155 by SiegeLord (2013-12-27 03:57:10+00:00)
Title: Generate --dep-info earlier in the compillation

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...
~~~