gpt4 book ai didi

rust - 如何让 Travis CI 与 Rust 0.12.0 和 Cargo 一起工作?

转载 作者:行者123 更新时间:2023-11-29 08:19:27 27 4
gpt4 key购买 nike

我正在尝试让 Travis CI 构建和测试我的 GitHub 存储库的内容,它与 Rust 0.12.0 和旧版 Cargo 兼容:

rustc 0.12.0 (ba4081a5a 2014-10-07 13:44:41 -0700)
cargo 0.0.1-pre-nightly (861c07f 2014-10-07 23:29:57 +0000)

我在 .travis.yml 中指定了 Rust 0.12.0:

language: rust
rust: 0.12.0
script:
- cargo build --verbose
- cargo test --verbose
- rustdoc --test README.md -L target
- cargo doc

我似乎遇到的问题是 Travis 每晚都会挑选最新的 Cargo: cargo 0.0.1-pre-nightly (fd5d7a9 2014-12-25 04:28:40 +0000)

但是这个较新的版本与 Rust 0.12.0 不兼容,因为它现在使用 --emit=dep-info 而它曾经使用 --dep-info:

--dep-info [FILENAME]
Output dependency info to <filename> after compiling,
in a format suitable for use by Makefiles

这会导致 rustc 调用错误,因为 --emit 的值无效:

Running `rustc src/sqlite3.rs --crate-name sqlite3 --crate-type lib -g -C metadata=1c7080eec8c6f90d -C extra-filename=-1c7080eec8c6f90d --out-dir target/deps --emit=dep-info,link -L target/deps -L target/deps -Awarnings`
...
error: unknown emission type: `dep-info`
...
Could not compile `sqlite3`.

我一直在寻找其他存储库来解决这个问题,但似乎他们要么没有将 Cargo 与 0.12.0(与 Travis 一起使用)一起使用,要么遇到了同样的问题,如下所示:https://travis-ci.org/eliovir/rust-ini

我找不到任何适用于 Travis、rust 0.12.0 和 Cargo 的存储库。如果我可以在某处指定 Cargo 的版本,我将能够解决这个问题,但我未能在 .travis.yml 文件中找到这样做的方法。

当然,随着 Rust 1.0 的出现,如果没有我忽略的明显解决方案,我会等待它 :-)

最佳答案

我同意每晚跟踪可能是最好的选择。如果您依赖的依赖项没有被更新,那么这可能是它们在 1.0 版本中也不会被更新的迹象!

综上所述,Travis 确实允许您在构建之前安装东西。这是完全未经测试的,但你可以做类似的事情

before_script:
- wget https://static.rust-lang.org/dist/rust-0.12.0-x86_64-unknown-linux-gnu.tar.gz
- tar -xvf rust-0.12.0-x86_64-unknown-linux-gnu.tar.gz
- ./rust-0.12.0-x86_64-unknown-linux-gnu/install.sh --prefix /tmp/rust-0.12/
- export PATH=$PATH:$PWD/tmp/rust-0.12/bin
- export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/tmp/rust-0.12/lib

这将下载 Rust 0.12,解压并将其安装在可写的地方(在哪里并不重要)。然后你设置环境变量来指出 Rust 的位置。执行相同操作以下载兼容版本的 Cargo。

如果 Travis 有一个“裸”语言包,那将是最好的。否则,您可以尝试使用 Rust buildpack,或者可能只是其他任何东西(以避免处理多个 rustc 版本)。

关于rust - 如何让 Travis CI 与 Rust 0.12.0 和 Cargo 一起工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27741937/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com