LoginSignup
4

More than 5 years have passed since last update.

RustのLinux/Windows/macOS向け64bitバイナリをTravis-CIで生成する

Last updated at Posted at 2018-01-22

はじめに

この手の記事も3回目ですが、ようやくTravis-CIだけでLinux/Windows/macOSの64bitバイナリが生成できるようになりました。
Travis-CIのRustサポートも改善されてかなり少ない記述でできるようになっています。

必要なファイル

必要なファイルは.travis.yml.cargo/configの2つです。

.travis.yml

Travis-CIのlanguage: rustrustupも入るようになりました。
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に集約してみました。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4