deployqtHelper_mac.sh 4.34 KB
Newer Older
1
#!/bin/bash
2
[ $# -lt 5 ] && echo "Usage: $(basename $0) <app folder> <qt translations folder> <qt plugin folder> <qt quick imports folder> <qt quick 2 imports folder>" && exit 2
Eike Ziller's avatar
Eike Ziller committed
3
4
[ $(uname -s) != "Darwin" ] && echo "Run this script on Mac OS X" && exit 2;

5
6
echo "Deploying Qt"

7
8
# collect designer plugins
designerDestDir="$1/Contents/PlugIns/designer"
9
10
11
12
13
14
15
if [ ! -d "$designerDestDir" ]; then
    echo "- Copying designer plugins"
    mkdir -p "$designerDestDir"
    for plugin in "$3"/designer/*.dylib; do
        cp "$plugin" "$designerDestDir"/ || exit 1
    done
fi
16

17
18
19
# copy Qt Quick 1 imports
importsDir="$1/Contents/Imports/qtquick1"
if [ -d "$4" ]; then
20
21
22
23
24
    if [ ! -d "$importsDir" ]; then
        echo "- Copying Qt Quick 1 imports"
        mkdir -p "$importsDir"
        cp -R "$4"/ "$importsDir"/
    fi
25
26
27
28
29
fi

# copy Qt Quick 2 imports
imports2Dir="$1/Contents/Imports/qtquick2"
if [ -d "$5" ]; then
30
31
32
33
34
    if [ ! -d "$imports2Dir" ]; then
        echo "- Copying Qt Quick 2 imports"
        mkdir -p "$imports2Dir"
        cp -R "$5"/ "$imports2Dir"/
    fi
35
36
fi

37
# copy qt creator qt.conf
38
39
40
41
if [ ! -f "$1/Contents/Resources/qt.conf" ]; then
    echo "- Copying qt.conf"
    cp -f "$(dirname "${BASH_SOURCE[0]}")/../dist/installer/mac/qt.conf" "$1/Contents/Resources/qt.conf" || exit 1
fi
Eike Ziller's avatar
Eike Ziller committed
42

43
# copy ios tools' qt.conf
44
45
46
47
if [ ! -f "$1/Contents/Resources/ios/qt.conf" ]; then
    echo "- Copying ios/qt.conf"
    cp -f "$(dirname "${BASH_SOURCE[0]}")/../dist/installer/mac/ios_qt.conf" "$1/Contents/Resources/ios/qt.conf" || exit 1
fi
48

Eike Ziller's avatar
Eike Ziller committed
49
# copy Qt translations
50
51
52
53
54
# check for known existing translation to avoid copying multiple times
if [ ! -f "$1/Contents/Resources/translations/qt_de.qm" ]; then
    echo "- Copying Qt translations"
    cp "$2"/*.qm "$1/Contents/Resources/translations/" || exit 1
fi
Eike Ziller's avatar
Eike Ziller committed
55
56
57

# copy libclang if needed
if [ $LLVM_INSTALL_DIR ]; then
58
    if [ "$LLVM_INSTALL_DIR"/lib/libclang.dylib -nt "$1/Contents/PlugIns"/libclang.dylib ]; then
59
        echo "- Copying libclang"
Eike Ziller's avatar
Eike Ziller committed
60
61
62
        mkdir -p "$1/Contents/Frameworks" || exit 1
        # use recursive copy to make it copy symlinks as symlinks
        cp -Rf "$LLVM_INSTALL_DIR"/lib/libclang.*dylib "$1/Contents/Frameworks/" || exit 1
63
        cp -Rf "$LLVM_INSTALL_DIR"/lib/clang "$1/Contents/Resources/cplusplus/" || exit 1
64
65
66
67
68
69
        clangsource="$LLVM_INSTALL_DIR"/bin/clang
        clanglinktarget="$(readlink "$clangsource")"
        cp -Rf "$clangsource" "$1/Contents/Resources/" || exit 1
        if [ $clanglinktarget ]; then
            cp -Rf "$(dirname "$clangsource")/$clanglinktarget" "$1/Contents/Resources/$clanglinktarget" || exit 1
        fi
70
    fi
71
    _CLANG_CODEMODEL_LIB="$1/Contents/PlugIns/libClangCodeModel_debug.dylib"
Eike Ziller's avatar
Eike Ziller committed
72
    if [ ! -f "$_CLANG_CODEMODEL_LIB" ]; then
73
        _CLANG_CODEMODEL_LIB="$1/Contents/PlugIns/libClangCodeModel.dylib"
Eike Ziller's avatar
Eike Ziller committed
74
    fi
75
    # this will just fail when run a second time on libClangCodeModel
76
    xcrun install_name_tool -delete_rpath "$LLVM_INSTALL_DIR/lib" "$_CLANG_CODEMODEL_LIB" || true
Eike Ziller's avatar
Eike Ziller committed
77
78
    xcrun install_name_tool -add_rpath "@loader_path/../Frameworks" "$_CLANG_CODEMODEL_LIB" || true
    clangbackendArgument="-executable=$1/Contents/Resources/clangbackend"
Eike Ziller's avatar
Eike Ziller committed
79
80
fi

81
82
#### macdeployqt

83
if [ ! -d "$1/Contents/Frameworks/QtCore.framework" ]; then
84

85
86
87
88
    qmlpuppetapp="$1/Contents/MacOS/qmlpuppet"
    if [ -f "$qmlpuppetapp" ]; then
        qmlpuppetArgument="-executable=$qmlpuppetapp"
    fi
89

90
91
92
93
94
    qml2puppetapp="$1/Contents/MacOS/qml2puppet"
    if [ -f "$qml2puppetapp" ]; then
        qml2puppetArgument="-executable=$qml2puppetapp"
    fi

95
96
    qbsapp="$1/Contents/MacOS/qbs"

97
98
99
    echo "- Running macdeployqt ($(which macdeployqt))"

    macdeployqt "$1" \
100
101
102
103
104
        "-executable=$1/Contents/Resources/qtpromaker" \
        "-executable=$1/Contents/Resources/sdktool" \
        "-executable=$1/Contents/Resources/ios/iostool" \
        "-executable=$1/Contents/Resources/ios/iossim" \
        "-executable=$1/Contents/Resources/ios/iossim_1_8_2" \
Eike Ziller's avatar
Eike Ziller committed
105
106
        "-executable=$1/Contents/Resources/buildoutputparser" \
        "-executable=$1/Contents/Resources/cpaster" \
107
108
109
110
111
112
113
        "-executable=$qbsapp" \
        "-executable=$qbsapp-config" \
        "-executable=$qbsapp-config-ui" \
        "-executable=$qbsapp-qmltypes" \
        "-executable=$qbsapp-setup-android" \
        "-executable=$qbsapp-setup-qt" \
        "-executable=$qbsapp-setup-toolchains" \
Eike Ziller's avatar
Eike Ziller committed
114
        "$qmlpuppetArgument" "$qml2puppetArgument" "$clangbackendArgument" || exit 1
115

116
fi