diff options
| author | Odd Stranne <odd@mullvad.net> | 2018-06-25 11:10:16 +0200 |
|---|---|---|
| committer | Odd Stranne <odd@mullvad.net> | 2018-06-25 11:10:16 +0200 |
| commit | 1d70f24f6a7fcb10d9ced9592a279ec8ee3c1592 (patch) | |
| tree | cb51ee931f2751ea7d372b79317c395da63e3a7e | |
| parent | f68e205b870a20933bf306b407bc86d08d5a6820 (diff) | |
| parent | 516b0aefa684b97ddb6bb53c64ee2c9e08aa4634 (diff) | |
| download | mullvadvpn-1d70f24f6a7fcb10d9ced9592a279ec8ee3c1592.tar.xz mullvadvpn-1d70f24f6a7fcb10d9ced9592a279ec8ee3c1592.zip | |
Merge branch 'overhaul-build-scripts'
| -rwxr-xr-x | build.sh | 83 |
1 files changed, 60 insertions, 23 deletions
@@ -2,58 +2,91 @@ # This script is used to build, and sign a release artifact. See `README.md` for instructions on # how to just build a development/testing version. +# +# Invoke the script with --dev-build in order to skip checks, cleaning and signing. -set -eu +################################################################################ +# Platform specific configuration. +################################################################################ + +case "$(uname -s)" in + Linux*) + # config + ;; + Darwin*) + export MACOSX_DEPLOYMENT_TARGET="10.7" + ;; + MINGW*) + # config + ;; +esac + +################################################################################ +# Verify and configure environment. +################################################################################ -REQUIRED_RUSTC_VERSION="rustc 1.26.0 (a77568041 2018-05-07)" RUSTC_VERSION=`rustc +stable --version` -if [[ $RUSTC_VERSION != $REQUIRED_RUSTC_VERSION ]]; then - echo "You are running the wrong Rust compiler version." - echo "You are running $RUSTC_VERSION, but this project requires $REQUIRED_RUSTC_VERSION" - echo "for release builds." - exit 1 -fi -if [[ "${1:-""}" != "--allow-dirty" ]]; then +if [[ "${1:-""}" != "--dev-build" ]]; then + + REQUIRED_RUSTC_VERSION="rustc 1.26.2 (594fb253c 2018-06-01)" + + if [[ $RUSTC_VERSION != $REQUIRED_RUSTC_VERSION ]]; then + echo "You are running the wrong Rust compiler version." + echo "You are running $RUSTC_VERSION, but this project requires $REQUIRED_RUSTC_VERSION" + echo "for release builds." + exit 1 + fi + if [[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]]; then echo "Dirty working directory!" echo "You should only build releases in clean working directories in order to make it" echo "easier to reproduce the same build." - echo "" - echo "Use --allow-dirty to skip this check. Never do this for official releases." exit 1 fi -fi -if [[ "$(uname -s)" = "Darwin" ]]; then - export MACOSX_DEPLOYMENT_TARGET="10.7" - - # if CSC_LINK is set, then we do signing - if [[ ! -z ${CSC_LINK-} ]]; then - echo "Building with macOS signing activated. Using certificate at $CSC_LINK" + if [[ ("$(uname -s)" == "Darwin") || ("$(uname -s)" == "MINGW"*) ]]; then + echo "Configuring environment for signing of binaries" + if [[ -z ${CSC_LINK-} ]]; then + echo "The variable CSC_LINK is not set. It needs to point to a file containing the" + echo "private key used for signing of binaries." + exit 1 + fi if [[ -z ${CSC_KEY_PASSWORD-} ]]; then read -sp "CSC_KEY_PASSWORD = " CSC_KEY_PASSWORD echo "" export CSC_KEY_PASSWORD fi + # MacOs: This needs to be set to 'true' to activate signing, even when CSC_LINK is set. export CSC_IDENTITY_AUTO_DISCOVERY=true else - echo "!! CSC_LINK not set. This build will not be signed !!" unset CSC_LINK CSC_KEY_PASSWORD export CSC_IDENTITY_AUTO_DISCOVERY=false fi + + cargo +stable clean + +else + echo "!! Development build. Not for general distribution !!" + unset CSC_LINK CSC_KEY_PASSWORD + export CSC_IDENTITY_AUTO_DISCOVERY=false fi -# Remove binaries. To make sure it is rebuilt with the stable toolchain and the latest changes. -cargo +stable clean +################################################################################ +# Compile and link all binaries. +################################################################################ if [[ "$(uname -s)" == "MINGW"* ]]; then - ./build_winfw.sh + ./build_windows_libraries.sh $1 fi -echo "Compiling mullvad-daemon in release mode with $RUSTC_VERSION..." +echo "Building Rust code in release mode using $RUSTC_VERSION..." cargo +stable build --release +################################################################################ +# Other work to prepare the release. +################################################################################ + # Only strip binaries on platforms other than Windows. if [[ "$(uname -s)" != "MINGW"* ]]; then binaries=( @@ -73,6 +106,10 @@ echo "Updating relay list..." echo "Installing JavaScript dependencies..." yarn install +################################################################################ +# Package release. +################################################################################ + echo "Packing final release artifact..." case "$(uname -s)" in Linux*) yarn pack:linux;; |
