Skip to content

Always set the OUT_DIR environment variable #9084

@JOOpdenhoevel

Description

@JOOpdenhoevel

Describe the problem you are trying to solve
I want to create a procedural attribute macro that analyzes a function signature and exports this information into a file. This file will be used later by another program, so it's definitely needed. However, the environment variable OUT_DIR isn't always set, which would tell me a good spot to write the file to. If the crate that uses the macro has a build script, OUT_DIR is set, but if it doesn't have a build script, OUT_DIR isn't set. Therefore, I would need to tell my users to always have a build script so that the macro works. This does not work well when there are many users of that macro.

Describe the solution you'd like
My requested solution is simple: Always set the OUT_DIR environment variable to a valid output directory, if the built crate has a build script or not.

Notes
One point against this is that OUT_DIR might collide with other uses of the variable, or that the name OUT_DIR isn't a good name for that in general. However, this would be a whole other discussion since it is already set for and used by build scripts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions