Skip to content
This repository was archived by the owner on Jul 9, 2023. It is now read-only.
This repository was archived by the owner on Jul 9, 2023. It is now read-only.

A library+tool to get all source files for a crate #38

@jsgf

Description

@jsgf

It would he useful to have a library which can produce a list of all source files used to build a crate. Currently this can be done with rustc --emit dep-info, but that requires a full build, including all dependencies to have already been built. I'm thinking of a tool which can be applied in isolation to any top-level source file, much like rustfmt can be.

Given a top-level module source file, it should find:

  • the top level module (given)
  • all other module sources
  • all included files (whether they're Rust source or not)

It should also have the option to take a set of cfg options so that the list of files can be limited to conditionally compiled code. But it should also have an option to emit all files, regardless of conditions.

For more general use, each file should also have associated with it whether its 1) a Rust module, 2) included Rust code, 3) included binary/text.

I can think of two awkward cases:

  1. a procedural macro generates an include! variant or a mod name; reference which would be missed without running the procmacro
  2. a path isn't a string literal, but composed by concatenation with env vars or other macros

I'm OK with leaving those out for now (the latter could be a best-effort representation, or just a warning that there's an unrepresentable name).

This would be useful as both a library and a CLI tool wrapping the library. The CLI tool should have the option to emit plaintext and json for easy scripting integration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions