2016-11-16 40 views
8

由Cargo創建的默認文件樹允許並行編譯釋放和調試版本,因爲它們位於其自己的目錄中;分別爲target/releasetarget/debug它允許與Rust穩定和夜間通道並行編譯代碼有多困難?

它也難以並行編譯stable/nightly-compiler。例如使用目錄

  • target/debug/stable
  • target/debug/nightly

我知道它可以與監獄/容器來完成,但我希望的一個較爲貨物上下的解決方案。

回答

12

Is it possible to deactivate file locking in cargo?解釋,你可以設置環境變量CARGO_TARGET_DIR每個通道你有興趣:

$ CARGO_TARGET_DIR=$PWD/stable rustup run stable cargo build 
    Compiling many v0.1.0 (file:///private/tmp/many) 
    Finished debug [unoptimized + debuginfo] target(s) in 0.89 secs 
$ CARGO_TARGET_DIR=$PWD/nightly rustup run nightly cargo build 
    Compiling many v0.1.0 (file:///private/tmp/many) 
    Finished debug [unoptimized + debuginfo] target(s) in 0.62 secs 
$ ./stable/debug/many 
Hello, world! 
$ ./nightly/debug/many 
Hello, world! 
+0

正是我所期待的! – PureW

+2

@PureW不值得一個完整的答案,但我有['test-matrix.py'](https://github.com/DanielKeep/rust-script-toolbox/blob/master/test-matrix.py)腳本這對於(簡單)Travis CI配置是這樣做的。 –