Skip to content

--message-format=json should indicate which produced files are executables #5426

@matklad

Description

@matklad

Currently --message-format=json just dumps the list of files that was produced when compiling a project. Cargo doesn't have too much knowledge about what exactly is produced for which target and crate type, but it should indicate at least which artifact is an executable binary. This is important for IDEs, which at the moment have to implement ugly work-arounds to separate actual binaries from debuginfo, for example (see vadimcn/codelldb#104).

Some pointers to code:

  • a struct representing JSON messages:
    pub struct Artifact<'a> {
  • the place where we actually print the info:
    if json_messages {
    machine_message::emit(&machine_message::Artifact {
    package_id: &package_id,
    target: &target,
    profile: &profile,
    features,
    filenames: destinations,
    fresh,
    });
    }
  • a struct which knows where the binaries are:
    /// An array of all tests created during this compilation.
    pub tests: Vec<(Package, TargetKind, String, PathBuf)>,
    /// An array of all binaries created.
    pub binaries: Vec<PathBuf>,

I think we could perhaps add an executable: Option<PathBuf> field to the CompilerArtifact?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions