简体   繁体   English

使用Rust Cargo进行构建的不同目标名称

[英]Different target names using Rust Cargo for build

Is there a way to set different target names for development and release configurations using Cargo for building? 有没有办法使用Cargo进行构建,为开发和发布配置设置不同的目标名称? For example, rustlibd.a and rustlib.a? 例如,rustlibd.a和rustlib.a?

No. Debug vs release information is controlled by a profile . 否。调试与发布信息由配置文件控制。 You can see all the profile-related manifest keys in the source code . 您可以在源代码中查看所有与配置文件相关的清单键 The only related one I see is rustc_options . 我看到的唯一相关的是rustc_options Running the build in verbose mode, you can see how cargo calls rustc: 以详细模式运行构建,您可以看到货物如何调用rustc:

$ cargo build --verbose
   Compiling namez v0.1.0 (file:///private/tmp/namez)
     Running `rustc --crate-name namez src/lib.rs --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=5444c772a04e08f3 -C extra-filename=-5444c772a04e08f3 --out-dir /private/tmp/namez/target/debug/deps -L dependency=/private/tmp/namez/target/debug/deps`
    Finished dev [unoptimized + debuginfo] target(s) in 0.45 secs

Unfortunately, changing --crate-name does not have the effect you'd like. 不幸的是,更改--crate-name没有你想要的效果。


Instead, I'd point out that you already have a different filename, you just have to look broader: 相反,我会指出你已经有了不同的文件名,你只需要看起来更广泛:

target/debug/libname.a
target/release/libname.a

The debug and release files are in different directories. 调试和发布文件位于不同的目录中。 Whatever you were going to do to move separately named libraries would have to deal with the debug and release directories anyway . 不管你打算做移动单独命名的图书馆将不得不应对debugrelease 反正目录。 Just update your script: 只需更新您的脚本:

mv target/debug/libname.a libnamed.a
mv target/release/libname.a libname.a

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM