bundle-mac

 1#!/usr/bin/env bash
 2
 3set -euo pipefail
 4source script/lib/blob-store.sh
 5
 6build_flag="--release"
 7target_dir="release"
 8open_result=false
 9local_arch=false
10local_install=false
11bundle_name=""
12
13
14# Function for displaying help info
15help_info() {
16  echo "
17Usage: ${0##*/} [options] [bundle_name]
18Build the application bundle for macOS.
19
20Options:
21  -d    Compile in debug mode
22  -l    Compile for local architecture only.
23  -o    Open dir with the resulting DMG or launch the app itself in local mode.
24  -i    Install the resulting DMG into /Applications in local mode. Noop without -l.
25  -h    Display this help and exit.
26  "
27}
28
29build_args=""
30while getopts 'dloih' flag
31do
32    case "${flag}" in
33        o) open_result=true
34           build_args="${build_args} -o"
35           ;;
36        d)
37            export CARGO_INCREMENTAL=true
38            export CARGO_BUNDLE_SKIP_BUILD=true
39            build_flag="";
40            target_dir="debug"
41            build_args="${build_args} -d"
42            ;;
43        l)
44            export CARGO_INCREMENTAL=true
45            export CARGO_BUNDLE_SKIP_BUILD=true
46            local_arch=true
47            local_only=true
48            build_args="${build_args} -l"
49            ;;
50        i) local_install=true;;
51        h)
52           help_info
53           exit 0
54           ;;
55    esac
56done
57
58shift $((OPTIND-1))
59
60if [[ $# -gt 0 ]]; then
61    if [ "$1" ]; then
62        bundle_name=$1
63    fi
64fi
65
66script/build-mac $build_args
67if [ "$local_only" = true ]; then
68    script/notarize-mac $bundle_name
69else
70    script/notarize-mac $bundle_name
71fi