qt: playlist: use item title if available
[vlc.git] / extras / package / macosx / build.sh
1 #!/bin/sh
2 set -e
3
4 info()
5 {
6     local green="\033[1;32m"
7     local normal="\033[0m"
8     echo "[${green}build${normal}] $1"
9 }
10
11 SCRIPTDIR=$(dirname "$0")
12 source "$SCRIPTDIR/env.build.sh" "none"
13
14 SDKROOT=$(xcrun --show-sdk-path)
15 VLCBUILDDIR=""
16
17 CORE_COUNT=`getconf NPROCESSORS_ONLN 2>&1`
18 let JOBS=$CORE_COUNT+1
19
20 usage()
21 {
22 cat << EOF
23 usage: $0 [options]
24
25 Build vlc in the current directory
26
27 OPTIONS:
28    -h            Show some help
29    -q            Be quiet
30    -j            Force number of cores to be used
31    -r            Rebuild everything (tools, contribs, vlc)
32    -c            Recompile contribs from sources
33    -p            Build packages for all artifacts
34    -i <n|u>      Create an installable package (n: nightly, u: unsigned stripped release archive)
35    -k <sdk>      Use the specified sdk (default: $SDKROOT)
36    -a <arch>     Use the specified arch (default: $HOST_ARCH)
37    -C            Use the specified VLC build dir
38    -b <url>      Enable breakpad support and send crash reports to this URL
39    -d            Disable debug mode (on by default)
40 EOF
41
42 }
43
44 spushd()
45 {
46     pushd "$1" > /dev/null
47 }
48
49 spopd()
50 {
51     popd > /dev/null
52 }
53
54 while getopts "qhvrcdpi:k:a:j:C:b:" OPTION
55 do
56      case $OPTION in
57          h)
58              usage
59              exit 1
60              ;;
61          q)
62              set +x
63              QUIET="yes"
64          ;;
65          d)
66              NODEBUG="yes"
67          ;;
68          r)
69              REBUILD="yes"
70          ;;
71          c)
72              CONTRIBFROMSOURCE="yes"
73          ;;
74          p)
75              PACKAGE="yes"
76          ;;
77          i)
78              PACKAGETYPE=$OPTARG
79          ;;
80          a)
81              HOST_ARCH=$OPTARG
82          ;;
83          k)
84              SDKROOT=$OPTARG
85          ;;
86          j)
87              JOBS=$OPTARG
88          ;;
89          C)
90              VLCBUILDDIR=$OPTARG
91          ;;
92          b)
93              BREAKPAD=$OPTARG
94          ;;
95          *)
96              usage
97              exit 1
98          ;;
99      esac
100 done
101 shift $(($OPTIND - 1))
102
103 if [ "x$1" != "x" ]; then
104     usage
105     exit 1
106 fi
107
108 #
109 # Various initialization
110 #
111
112 out="/dev/stdout"
113 if [ "$QUIET" = "yes" ]; then
114     out="/dev/null"
115 fi
116
117 ACTUAL_HOST_ARCH=`get_actual_arch $HOST_ARCH`
118 BUILD_ARCH=`get_buildsystem_arch $BUILD_ARCH`
119
120 info "Building VLC for macOS, architecture ${ACTUAL_HOST_ARCH} on a ${BUILD_ARCH} device"
121
122 BUILD_TRIPLET=$(vlcGetBuildTriplet)
123 HOST_TRIPLET=$(vlcGetHostTriplet)
124 export SDKROOT
125 vlcSetBaseEnvironment
126 vlcroot="$(vlcGetRootDir)"
127
128 # Checking prerequisites
129 info "Checking for python3 ..."
130 python3 --version || { echo "python3 not found. Please install from python.org, or set" \
131         "VLC_PATH environment variable to include python3." \
132         ; exit 1; }
133
134
135 builddir="$(pwd)"
136 info "Building in \"$builddir\""
137
138 #
139 # vlc/extras/tools
140 #
141
142 info "Building building tools"
143 spushd "${vlcroot}/extras/tools"
144 ./bootstrap > $out
145 if [ "$REBUILD" = "yes" ]; then
146     make clean
147     ./bootstrap > $out
148 fi
149 make > $out
150 spopd
151
152 #
153 # vlc/contribs
154 #
155
156 vlcSetSymbolEnvironment
157 vlcSetContribEnvironment "$MINIMAL_OSX_VERSION"
158
159 info "Building contribs"
160 spushd "${vlcroot}/contrib"
161
162 if [ "$REBUILD" = "yes" ]; then
163     rm -rf contrib-$HOST_TRIPLET
164     rm -rf $HOST_TRIPLET
165 fi
166 mkdir -p contrib-$HOST_TRIPLET && cd contrib-$HOST_TRIPLET
167 ../bootstrap --build=$BUILD_TRIPLET --host=$HOST_TRIPLET > $out
168
169 if [ "$CONTRIBFROMSOURCE" = "yes" ]; then
170     make list
171     make fetch
172     make -j$JOBS .gettext
173     make -j$JOBS -k || make -j1
174
175     if [ "$PACKAGE" = "yes" ]; then
176         make package
177     fi
178
179 else
180 if [ ! -e "../$HOST_TRIPLET" ]; then
181     if [ -n "$VLC_PREBUILT_CONTRIBS_URL" ]; then
182         make prebuilt PREBUILT_URL="$VLC_PREBUILT_CONTRIBS_URL"
183         make .luac
184     else
185         make prebuilt
186         make .luac
187     fi
188 fi
189 fi
190 spopd
191
192
193 vlcUnsetContribEnvironment
194 vlcSetLibVLCEnvironment
195
196 #
197 # vlc/bootstrap
198 #
199
200 info "Bootstrap-ing configure"
201 spushd "${vlcroot}"
202 if ! [ -e "${vlcroot}/configure" ]; then
203     ${vlcroot}/bootstrap > $out
204 fi
205 spopd
206
207
208 if [ ! -z "$VLCBUILDDIR" ];then
209     mkdir -p $VLCBUILDDIR
210     pushd $VLCBUILDDIR
211 fi
212 #
213 # vlc/configure
214 #
215
216 CONFIGFLAGS=""
217 if [ ! -z "$BREAKPAD" ]; then
218      CONFIGFLAGS="$CONFIGFLAGS --with-breakpad=$BREAKPAD"
219 fi
220 if [ "$NODEBUG" = "yes" ]; then
221      CONFIGFLAGS="$CONFIGFLAGS --disable-debug"
222 fi
223
224 if [ "${vlcroot}/configure" -nt Makefile ]; then
225
226   ${vlcroot}/extras/package/macosx/configure.sh \
227       --build=$BUILD_TRIPLET \
228       --host=$HOST_TRIPLET \
229       --with-macosx-version-min=$MINIMAL_OSX_VERSION \
230       --with-macosx-sdk=$SDKROOT \
231       $CONFIGFLAGS \
232       $VLC_CONFIGURE_ARGS > $out
233 fi
234
235 #
236 # make
237 #
238
239 if [ "$REBUILD" = "yes" ]; then
240     info "Running make clean"
241     make clean
242 fi
243
244 info "Running make -j$JOBS"
245 make -j$JOBS
246
247 info "Preparing VLC.app"
248 make VLC.app
249
250 if [ "$PACKAGETYPE" = "u" ]; then
251     info "Copying app with debug symbols into VLC-debug.app and stripping"
252     rm -rf VLC-debug.app
253     cp -Rp VLC.app VLC-debug.app
254
255     # Workaround for breakpad symbol parsing:
256     # Symbols must be uploaded for libvlc(core).dylib, not libvlc(core).x.dylib
257     (cd VLC-debug.app/Contents/MacOS/lib/ && rm libvlccore.dylib && mv libvlccore.*.dylib libvlccore.dylib)
258     (cd VLC-debug.app/Contents/MacOS/lib/ && rm libvlc.dylib && mv libvlc.*.dylib libvlc.dylib)
259
260     find VLC.app/ -name "*.dylib" -exec strip -x {} \;
261     find VLC.app/ -type f -name "VLC" -exec strip -x {} \;
262     find VLC.app/ -type f -name "Sparkle" -exec strip -x {} \;
263     find VLC.app/ -type f -name "Growl" -exec strip -x {} \;
264     find VLC.app/ -type f -name "Breakpad" -exec strip -x {} \;
265
266     if [ "$BUILD_TRIPLET" = "$HOST_TRIPLET" ]; then
267         bin/vlc-cache-gen VLC.app/Contents/MacOS/plugins
268     fi
269
270     info "Building VLC release archive"
271     make package-macosx-release
272     make package-macosx-sdk
273
274     shasum -a 512 vlc-*-release.zip
275     shasum -a 512 vlc-macos-sdk-*.tar.gz
276
277 elif [ "$PACKAGETYPE" = "n" -o "$PACKAGE" = "yes" ]; then
278     info "Building VLC dmg package"
279     make package-macosx
280     make package-macosx-sdk
281 fi
282
283 if [ ! -z "$VLCBUILDDIR" ]; then
284     popd
285 fi