【问题标题】:How to specify the output file name of a library via the command line?如何通过命令行指定库的输出文件名?
【发布时间】:2020-08-11 21:03:20
【问题描述】:

如何通过命令行为库动态指定输出文件名?

# something like this
cargo build --output-file-name "my_lib.so" # or .*dylib

通过 Cargo.toml 或 .cargo/config 对我不起作用。

有可能吗?

【问题讨论】:

  • 构建后重命名文件?你可能可以用cargo rustcRUSTFLAGS 做一些事情,但我不确定这是否值得。

标签: rust rust-cargo


【解决方案1】:

编辑:

请参阅以下内容:https://doc.rust-lang.org/cargo/reference/cargo-targets.html#configuring-a-target,这可能有助于您指定最终 .so 的名称


以下参数控制rustc中的输出文件名

https://doc.rust-lang.org/rustc/command-line-arguments.html#-o-filename-of-the-output

正如Steve Marnach 提到的,您可以通过here 描述的几种方式将标志传递给rustc

或者,您可以使用Philipp Oppermann's cargo-post 工具创建一个构建后脚本并将其设置为重命名输出库。

【讨论】:

    猜你喜欢
    • 2018-10-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-28
    相关资源
    最近更新 更多