はじめに
この手の記事も3回目ですが、ようやくTravis-CIだけでLinux/Windows/macOSの64bitバイナリが生成できるようになりました。
Travis-CIのRustサポートも改善されてかなり少ない記述でできるようになっています。
必要なファイル
必要なファイルは.travis.yml
と.cargo/config
の2つです。
.travis.yml
Travis-CIのlanguage: rust
でrustup
も入るようになりました。
before_script
で追加するのはrustup target add
とwindows用のリンカとしてmingwのgccのみでOKです。
language: rust
os:
- linux
- osx
before_script:
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then rustup target add x86_64-unknown-linux-musl; fi
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then rustup target add x86_64-pc-windows-gnu; fi
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then sudo apt-get -qq update; fi
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then sudo apt-get -qq install binutils-mingw-w64-x86-64 g++-mingw-w64-x86-64; fi
script:
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then cargo build --release --target=x86_64-unknown-linux-musl; fi
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then cargo build --release --target=x86_64-pc-windows-gnu; fi
- if [[ $TRAVIS_OS_NAME == "osx" ]]; then cargo build --release --target=x86_64-apple-darwin; fi
.cargo/config
特定のターゲットに対してcargo
が使うリンカを指定します。
[target.x86_64-pc-windows-gnu]
linker = "x86_64-w64-mingw32-gcc"
32bitビルドについて
前回までは32bitビルドも入れていたのですが、今回改めて試したところ32bitのwindowsだけうまくいきませんでした。
とはいえそろそろ32bitサポートは切ってもいいのではないかと思い64bit限定でTravis-CIに集約してみました。