source: orange/install-scripts/mac/build-osx-app.sh @ 11635:9c1270f157c0

Revision 11635:9c1270f157c0, 4.1 KB checked in by Ales Erjavec <ales.erjavec@…>, 9 months ago (diff)

Added a build-osx-app.sh script.

  • Property exe set to *
Line 
1#!/bin/bash -e
2# Build an OSX Applicaiton (.app) for Orange Canvas
3#
4# Example:
5#
6#     $ build-osx-app.sh $HOME/Applications/Orange.app
7#
8
9function print_usage() {
10    echo 'build-osx-app.sh [-i] [--template] Orange.app
11
12Build an Orange Canvas OSX application bundle (Orange.app).
13
14NOTE: this script should be run from the source root directory.
15
16Options:
17
18    --template TEMPLATE_URL  Path or url to an application template as build
19                             by "build-osx-app-template.sh. If not provided
20                             a default one will be downloaded.
21    -i --inplace             The provided target application path is already
22                             a template into which Orange should be installed
23                             (this flag cannot be combined with --template).
24    -h --help                Print this help'
25}
26
27while [[ ${1:0:1} = "-" ]]; do
28    case $1 in
29        --template)
30            TEMPLATE_URL=$2
31            shift 2;
32            ;;
33        -i|--inplace)
34            INPLACE=1
35            shift 1
36            ;;
37        -h|--help)
38            print_usage
39            exit 0
40            ;;
41        -*)
42            echo "Unknown argument $1"
43            print_usage
44            exit 1
45            ;;
46    esac
47done
48
49# extended glob expansion / fail on filename expansion
50shopt -s extglob failglob
51
52
53APP=${1:-dist/Orange.app}
54
55if [[ $INPLACE ]]; then
56    if [[ $TEMPLATE_URL ]]; then
57        echo "--inplace and --template can not be combined"
58        print_usage
59        exit 1
60    fi
61
62    if [[ -e $APP && ! -d $APP ]]; then
63        echo "$APP exists and is not a directory"
64        print_usage
65        exit 1
66    fi
67fi
68
69TEMPLATE_URL=${TEMPLATE_URL:-"http://orange.biolab.si/download/bundle-templates/Orange.app.tar.gz"}
70
71SCHEMA_REGEX='^(https?|ftp|local)://.*'
72
73if [[ ! $INPLACE ]]; then
74    BUILD_DIR=$(mktemp -d -t orange-build)
75
76    echo "Retrieving a template from $TEMPLATE_URL"
77    # check for a url schema
78    if [[ $TEMPLATE_URL =~ $SCHEMA_REGEX ]]; then
79        curl --fail --silent "$TEMPLATE_URL" | tar -xf -C "$BUILD_DIR"
80        TEMPLATE=( $BUILD_DIR/*.app )
81
82    elif [[ -d $TEMPLATE_URL ]]; then
83        cp -a $TEMPLATE_URL $BUILD_DIR
84        TEMPLATE=$BUILD_DIR/$(basename "$TEMPLATE_URL")
85
86    elif [[ -e $TEMPLATE_URL ]]; then
87        # Assumed to be an archive
88        tar -xf "$TEMPLATE_URL" -C "$BUILD_DIR"
89        TEMPLATE=( $BUILD_DIR/*.app )
90    else
91        echo "Invalid --template $TEMPLATE_URL"
92        exit 1
93    fi
94else
95    TEMPLATE=$APP
96fi
97echo "Building application in $TEMPLATE"
98
99PYTHON=$TEMPLATE/Contents/MacOS/python
100PIP=$TEMPLATE/Contents/MacOS/pip
101
102PREFIX=$("$PYTHON" -c'import sys; print sys.prefix')
103
104echo "Building Orange"
105echo "==============="
106"$PYTHON" setup.py build
107
108echo "Building orangeqt extension"
109echo "==========================="
110
111FDIR=$TEMPLATE/Contents/Frameworks
112# to find moc executable in the app bundle
113EXTRA_PATH=$PREFIX/bin:$TEMPLATE/Contents/Resources/Qt4/bin
114# for the compiler to find Qt's headers and frameworks
115EXTRA_CXXFLAGS="-F$FDIR -I$FDIR/QtCore.framework/Headers -I$FDIR/QtGui.framework/Headers"
116EXTRA_LDFLAGS="-F$FDIR -framework QtCore -framework QtGui"
117
118(
119    PATH=$EXTRA_PATH:$PATH
120    CXXFLAGS=${EXTRA_CXXFLAGS}${CXXFLAGS:+:$CXXFLAGS}
121    LDFLAGS=${EXTRA_LDFLAGS}:${LDFLAGS:+:$LDFLAGS}
122    "$PYTHON" setup.py build_pyqt_ext
123)
124
125echo "Installing Orange"
126echo "================="
127
128"$PYTHON" setup.py install
129
130cat <<-'EOF' > "$TEMPLATE"/Contents/MacOS/Orange
131    #!/bin/bash
132
133    DIRNAME=$(dirname "$0")
134    source "$DIRNAME"/ENV
135
136    # LaunchServices passes the Carbon process identifier to the application with
137    # -psn parameter - we do not want it
138    if [[ $1 == -psn_* ]]; then
139        shift 1
140    fi
141
142    exec -a "$0" "$DIRNAME"/PythonAppStart -m Orange.OrangeCanvas.main "$@"
143EOF
144
145chmod +x "$TEMPLATE"/Contents/MacOS/Orange
146
147
148echo "Installing add ons"
149echo "=================="
150
151"$PIP" install hg+https://bitbucket.org/biolab/orange-bioinformatics
152"$PIP" install hg+https://bitbucket.org/biolab/orange-text
153
154
155if [[ ! $INPLACE ]]; then
156    echo "Moving the application to $APP"
157    if [[ -e $APP ]]; then
158        rm -rf "$APP"
159    fi
160
161    mv "$TEMPLATE" "$APP"
162fi
Note: See TracBrowser for help on using the repository browser.