10 export PATH
="$PATH:$HOME/.cargo/bin"
11 curl https
://sh.rustup.rs
-sSf | sh
-s -- -y --default-toolchain=$1
14 # Add provided target to current Rust toolchain if it is not already
15 # the default or installed.
17 if ! rustup target list |
grep -E "$1 \((default|installed)\)"
24 apt-get
-qq -y install zip
28 mingw_i686_install
() {
29 curl https
://static.rust-lang.org
/dist
/rust-mingw-nightly-i686-pc-windows-gnu.
tar.gz \
31 /tmp
/rust-mingw-nightly-i686-pc-windows-gnu
/install.sh
--prefix=`rustc --print sysroot`
34 # Configure rustc target for cross compilation. Provided with a build
35 # target, this will determine which linker to use for cross compilation.
40 aarch64-unknown-linux-gnu
)
41 prefix
=aarch64-linux-gnu
43 arm
*-unknown-linux-gnueabihf)
44 prefix
=arm-linux-gnueabihf
46 arm-unknown-linux-gnueabi
)
47 prefix
=arm-linux-gnueabi
49 mipsel-unknown-linux-musl
)
50 prefix
=mipsel-openwrt-linux
52 x86_64-pc-windows-gnu
)
53 prefix
=x86_64-w64-mingw32
56 prefix
=i686-w64-mingw32
64 cat >~
/.cargo
/config
<<EOF
66 linker = "$prefix-gcc"
72 # Build current crate for given target and print file type information.
73 # If the second argument is set, a release build will be made.
84 if [ "$mode" == "release" ]
89 cargo build
--target $1 $modeflag
91 file $
(get_binary
$1 $mode)
94 # Run current crate's tests if the current system supports it.
96 if echo "$1" |
grep -E "(i686|x86_64)-unknown-linux-(gnu|musl)|darwin"
98 cargo
test --target $1
102 # Returns relative path to binary
103 # based on build target and type ("release"/"debug").
106 if [[ "$1" =~
"windows" ]]
110 echo "target/$1/$2/geckodriver$ext"
113 # Create a compressed archive of the binary
114 # for the given given git tag, build target, and build type.
117 bin
=$
(get_binary
$2 $4)
120 if [[ "$2" =~
"windows" ]]
122 filename
="geckodriver-$1-$3.zip"
123 zip "$filename" geckodriver.exe
126 filename
="geckodriver-$1-$3.tar.gz"
127 tar zcvf
"$filename" geckodriver
130 if [ ! -z "$DOCKER_IMAGE" ]
132 chown
"$USER_ID:$GROUP_ID" "$filename"
137 TOOLCHAIN
=${TOOLCHAIN:=stable}
139 if [ ! -z "$DOCKER_IMAGE" ]
144 rustup_install
$TOOLCHAIN
146 rustup_target_add
$TARGET
148 # custom mingw component required
149 # when compiling on 32-bit windows
150 # see https://github.com/mozilla/geckodriver/pull/138#issuecomment-232139097
151 if [[ $TARGET == "i686-pc-windows-gnu" ]]
160 # when something is tagged,
161 # also create a release build and package it
162 if [ ! -z "$TRAVIS_TAG" ]
164 cargo_build
$TARGET 1
165 package_binary
$TRAVIS_TAG $TARGET $NAME "release"