Skip to content

Commit 3edb402

Browse files
committed
Update build scripts
+ Build multiarch version for macOS + Rework of unix build script + Centralize dependencies list + Allow static build with STATIC=1 env variable Signed-off-by: Maxime Gervais <[email protected]>
1 parent bbf1996 commit 3edb402

28 files changed

+709
-325
lines changed

Project/BuildAllFromSource/build

Lines changed: 0 additions & 30 deletions
This file was deleted.

Project/BuildAllFromSource/build.ps1

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# - pkg-config binary in the PATH #
1010
# - Meson binary in the PATH #
1111
# - Ninja binary in the PATH #
12+
# - Git binary in the PATH #
1213
# - Configured WSL2 Linux environment with pkgconf, make and nasm packages installed #
1314
###################################################################################################
1415

@@ -20,12 +21,17 @@ function Cmd-Result {
2021
}
2122

2223
# setup environment
24+
$SCRIPT_DIR=$PSScriptRoot
25+
Push-Location "$SCRIPT_DIR\..\..\.."
26+
$INSTALL_DIR=(Get-Location).Path
27+
Pop-Location
28+
Set-Location $INSTALL_DIR
29+
2330
$ErrorActionPreference="Stop"
2431
$Env:SUBDIR= # Prevent ffmpeg build error
25-
$Env:PKG_CONFIG_PATH="$Pwd\output\lib\pkgconfig"
32+
$Env:PKG_CONFIG_PATH="$INSTALL_DIR\output\lib\pkgconfig"
2633
$FFmpeg_CmdLine=@(
2734
'--toolchain=msvc',
28-
'--prefix=.',
2935
'--enable-shared',
3036
'--disable-static',
3137
'--disable-doc',
@@ -39,14 +45,29 @@ $FFmpeg_CmdLine=@(
3945
'--extra-libs=msvcrt.lib'
4046
)
4147

48+
# get dependencies
49+
Write-Output "Get Dependencies"
50+
Get-Content "$SCRIPT_DIR\dependencies.txt" | ForEach-Object {
51+
$DIR=($_ -Split ':', 2)[0]
52+
$URL=($_ -Split ':', 2)[1]
53+
if (-not (Test-Path "$DIR")) {
54+
New-Item -ItemType Directory -Path "$DIR"
55+
Push-Location "$DIR"
56+
curl.exe -LO "$URL" ; Cmd-Result
57+
tar --extract --strip-components=1 --file="$($URL.Split('/')[-1])" ; Cmd-Result
58+
Remove-Item -Force -Path "$($URL.Split('/')[-1])"
59+
Pop-Location
60+
}
61+
}
62+
4263
# freetype
4364
Write-Output "Build FreeType"
4465
if (Test-Path -Path freetype\build) {
4566
Remove-Item -Recurse -Force -Path freetype\build
4667
}
4768
New-Item -ItemType directory -Name freetype\build
4869
Push-Location -Path freetype\build
49-
meson setup --prefix $Pwd\..\..\output --buildtype=release -Db_vscrt=md -Dbrotli=disabled -Dbzip2=disabled -Dharfbuzz=disabled -Dpng=disabled -Dzlib=internal .. ; Cmd-Result
70+
meson setup --prefix "$INSTALL_DIR\output" --buildtype=release -Db_vscrt=md -Dbrotli=disabled -Dbzip2=disabled -Dharfbuzz=disabled -Dpng=disabled -Dzlib=internal .. ; Cmd-Result
5071
ninja install ; Cmd-Result
5172
Pop-Location
5273

@@ -57,7 +78,7 @@ if (Test-Path -Path harfbuzz\build) {
5778
}
5879
New-Item -ItemType directory -Name harfbuzz\build
5980
Push-Location -Path harfbuzz\build
60-
meson setup --prefix $Pwd\..\..\output --buildtype=release -Db_vscrt=md -Dglib=disabled -Dgobject=disabled -Dcairo=disabled -Dchafa=disabled -Dicu=disabled -Dgraphite=disabled -Dgraphite2=disabled -Dgdi=disabled -Ddirectwrite=disabled -Dcoretext=disabled -Dwasm=disabled -Dtests=disabled -Dintrospection=disabled -Ddocs=disabled -Ddoc_tests=false -Dutilities=disabled .. ; Cmd-Result
81+
meson setup --prefix "$INSTALL_DIR\output" --buildtype=release -Db_vscrt=md -Dglib=disabled -Dgobject=disabled -Dcairo=disabled -Dchafa=disabled -Dicu=disabled -Dgraphite=disabled -Dgraphite2=disabled -Dgdi=disabled -Ddirectwrite=disabled -Dcoretext=disabled -Dwasm=disabled -Dtests=disabled -Dintrospection=disabled -Ddocs=disabled -Ddoc_tests=false -Dutilities=disabled .. ; Cmd-Result
6182
ninja install ; Cmd-Result
6283
Pop-Location
6384

@@ -72,26 +93,27 @@ Pop-Location
7293
# ffmpeg
7394
Write-Output "Build FFmpeg"
7495
Push-Location ffmpeg
75-
if (Test-Path -Path Makefile) {
76-
wsl --shell-type standard -- make clean
77-
}
78-
wsl --shell-type standard -- PKG_CONFIG_PATH=`$PWD/../output/lib/pkgconfig ./configure @FFmpeg_CmdLine ; Cmd-Result
79-
wsl --shell-type standard -- make install ; Cmd-Result
96+
wsl --shell-type standard -- PKG_CONFIG_PATH=`$PWD/../output/lib/pkgconfig ./configure --prefix=`$PWD/../output @FFmpeg_CmdLine ; Cmd-Result
97+
wsl --shell-type standard -- make install ; Cmd-Result
8098
Pop-Location
8199

82-
83100
# qwt
84101
Write-Output "Build Qwt"
85-
Push-Location -Path qwt
86-
$Env:QWT_STATIC=1
102+
if (Test-Path -Path qwt\build) {
103+
Remove-Item -Recurse -Force -Path qwt\build
104+
}
105+
New-Item -ItemType directory -Name qwt\build
106+
Push-Location -Path qwt\build
107+
git -C .. apply "$SCRIPT_DIR\qwt.patch" ; Cmd-Result
87108
$Env:QWT_NO_SVG=1
88109
$Env:QWT_NO_OPENGL=1
89110
$Env:QWT_NO_DESIGNER=1
90-
if (Test-Path -Path Makefile) {
91-
nmake distclean
92-
}
93-
qmake -recursive ; Cmd-Result
94-
nmake Release ; Cmd-Result
111+
$Env:QWT_NO_EXAMPLES=1
112+
$Env:QWT_NO_PLAYGROUND=1
113+
$Env:QWT_NO_TESTS=1
114+
$Env:QWT_INSTALL_PREFIX="$INSTALL_DIR\output"
115+
qmake .. ; Cmd-Result
116+
nmake install ; Cmd-Result
95117
Pop-Location
96118

97119
# qctools
@@ -101,8 +123,13 @@ if (Test-Path -Path qctools\Project\QtCreator\build) {
101123
}
102124
New-Item -ItemType directory -Name qctools\Project\QtCreator\build
103125
Push-Location -Path qctools\Project\QtCreator\build
126+
$Env:QWT_ROOT="$INSTALL_DIR/output"
127+
$Env:FFMPEG="$INSTALL_DIR/output"
104128
qmake QMAKE_CXXFLAGS+=/Zi QMAKE_LFLAGS+=/INCREMENTAL:NO QMAKE_LFLAGS+=/Debug DEFINES+=QT_AVPLAYER_MULTIMEDIA .. ; Cmd-Result
105129
nmake Release ; Cmd-Result
106130
windeployqt qctools-gui/release/QCTools.exe ; Cmd-Result
107131
windeployqt qctools-cli/release/qcli.exe ; Cmd-Result
108132
Pop-Location
133+
134+
Write-Output "QCTools binary is in $INSTALL_DIR/qctools/Project/QtCreator/build/qctools-gui"
135+
Write-Output "qcli binary is in $INSTALL_DIR/qctools/Project/QtCreator/build/qctools-cli"

Project/BuildAllFromSource/build.sh

Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
#! /bin/bash
2+
3+
###################################################################################################
4+
# build.sh - Batch script for building the Unix version of QCTools #
5+
# #
6+
# Script requirements: #
7+
# - qctools_AllInclusive source #
8+
# - Qt bin directory in the PATH #
9+
# - Python3 binary in the PATH #
10+
# - pkg-config binary in the PATH #
11+
# - Meson binary in the PATH #
12+
# - Ninja binary in the PATH #
13+
# - Git binary in the PATH #
14+
# Environment: #
15+
# - MULTIARCH: Compile for arm64 and x86_64 into the same binary (macOS) #
16+
###################################################################################################
17+
# setup environment
18+
set -e
19+
20+
if qmake --version >/dev/null 2>&1 ; then
21+
BINQMAKE=qmake
22+
elif qmake-qt6 --version >/dev/null 2>&1 ; then
23+
BINQMAKE=qmake-qt6
24+
elif qmake6 --version >/dev/null 2>&1 ; then
25+
BINQMAKE=qmake6
26+
else
27+
echo qmake not found
28+
exit 1
29+
fi
30+
31+
SCRIPT_DIR=$(cd $(dirname "$0") && pwd)
32+
INSTALL_DIR=$(cd $(dirname "$0") && cd ../../.. && pwd)
33+
cd "$INSTALL_DIR"
34+
35+
FFMPEG_CONFIGURE_OPTS=(
36+
--enable-gpl
37+
--enable-version3
38+
--disable-doc
39+
--disable-debug
40+
--disable-programs
41+
--disable-autodetect
42+
--enable-static
43+
--disable-shared
44+
--enable-libfreetype
45+
--enable-libharfbuzz
46+
)
47+
48+
QT_CONFIGURE_OPTS=()
49+
50+
if sw_vers >/dev/null 2>&1 ; then
51+
OS=mac
52+
export CFLAGS="-mmacosx-version-min=11.0 $CFLAGS"
53+
export CXXFLAGS="-mmacosx-version-min=11.0 $CXXFLAGS"
54+
export LDFLAGS="-mmacosx-version-min=11.0 $LDFLAGS"
55+
FFMPEG_CONFIGURE_OPTS+=(--extra-cflags="-mmacosx-version-min=11.0" --extra-ldflags="-mmacosx-version-min=11.0")
56+
if [[ -n "$MULTIARCH" ]] ; then
57+
QT_CONFIGURE_OPTS+=(QMAKE_APPLE_DEVICE_ARCHS="x86_64 arm64")
58+
mkdir -p $INSTALL_DIR/output/lib
59+
fi
60+
fi
61+
62+
# get dependencies
63+
while read LINE; do
64+
DIR=$(echo "$LINE" | cut -d: -f1)
65+
URL=$(echo "$LINE" | cut -d: -f2-)
66+
if [[ -z "$DIR" || -z "$URL" ]] ; then
67+
continue
68+
fi
69+
if [[ ! -e "$DIR" ]] ; then
70+
mkdir "$DIR"
71+
pushd "$DIR"
72+
curl -LO "$URL"
73+
tar --extract --strip-components=1 --file=${URL##*/}
74+
rm -f ${URL##*/}
75+
popd
76+
fi
77+
done < $SCRIPT_DIR/dependencies.txt
78+
79+
# freetype
80+
echo "Build FreeType"
81+
if [[ -d freetype/build ]] ; then
82+
rm -fr freetype/build
83+
fi
84+
mkdir freetype/build
85+
pushd freetype/build
86+
if [[ "$OS" == "mac" && -n "$MULTIARCH" ]] ; then
87+
mkdir x86_64
88+
pushd x86_64
89+
(
90+
export PKG_CONFIG_PATH=$INSTALL_DIR/output/x86_64/lib/pkgconfig
91+
export CFLAGS="$CFLAGS -arch x86_64"
92+
export CXXFLAGS="$CXXFLAGS -arch x86_64"
93+
export LDFLAGS="$LDFLAGS -arch x86_64"
94+
meson setup --prefix $INSTALL_DIR/output/x86_64 --default-library=static -Dzlib=internal -Dbzip2=disabled -Dpng=disabled -Dharfbuzz=disabled -Dbrotli=disabled ../..
95+
ninja install
96+
)
97+
popd
98+
mkdir arm64
99+
pushd arm64
100+
(
101+
export PKG_CONFIG_PATH=$INSTALL_DIR/output/arm64/lib/pkgconfig
102+
export CFLAGS="$CFLAGS -arch arm64"
103+
export CXXFLAGS="$CXXFLAGS -arch arm64"
104+
export LDFLAGS="$LDFLAGS -arch arm64"
105+
meson setup --prefix $INSTALL_DIR/output/arm64 --default-library=static -Dzlib=disabled -Dbzip2=disabled -Dpng=disabled -Dharfbuzz=disabled -Dbrotli=disabled ../..
106+
ninja install
107+
)
108+
popd
109+
lipo -create $INSTALL_DIR/output/x86_64/lib/libfreetype.a $INSTALL_DIR/output/arm64/lib/libfreetype.a -output $INSTALL_DIR/output/lib/libfreetype.a
110+
else
111+
(
112+
export PKG_CONFIG_PATH=$INSTALL_DIR/output/lib/pkgconfig
113+
meson setup --prefix $INSTALL_DIR/output --default-library=static -Dzlib=disabled -Dbzip2=disabled -Dpng=disabled -Dharfbuzz=disabled -Dbrotli=disabled ..
114+
ninja install
115+
)
116+
fi
117+
popd
118+
119+
# harfbuzz
120+
echo "Build HarfBuzz"
121+
if [[ -d harfbuzz/build ]] ; then
122+
rm -fr harfbuzz/build
123+
fi
124+
mkdir harfbuzz/build
125+
pushd harfbuzz/build
126+
if [[ "$OS" == "mac" && -n "$MULTIARCH" ]] ; then
127+
mkdir x86_64
128+
pushd x86_64
129+
(
130+
export PKG_CONFIG_PATH=$INSTALL_DIR/output/x86_64/lib/pkgconfig
131+
export CFLAGS="$CFLAGS -arch x86_64"
132+
export CXXFLAGS="$CXXFLAGS -arch x86_64"
133+
export LDFLAGS="$LDFLAGS -arch x86_64"
134+
meson setup --prefix $INSTALL_DIR/output/x86_64 --default-library=static -Dglib=disabled -Dgobject=disabled -Dcairo=disabled -Dchafa=disabled -Dicu=disabled -Dgraphite=disabled -Dgraphite2=disabled -Dgdi=disabled -Ddirectwrite=disabled -Dcoretext=disabled -Dwasm=disabled -Dtests=disabled -Dintrospection=disabled -Ddocs=disabled -Ddoc_tests=false -Dutilities=disabled ../..
135+
ninja install
136+
)
137+
popd
138+
mkdir arm64
139+
pushd arm64
140+
(
141+
export PKG_CONFIG_PATH=$INSTALL_DIR/output/arm64/lib/pkgconfig
142+
export CFLAGS="$CFLAGS -arch arm64"
143+
export CXXFLAGS="$CXXFLAGS -arch arm64"
144+
export LDFLAGS="$LDFLAGS -arch arm64"
145+
meson setup --prefix $INSTALL_DIR/output/arm64 --default-library=static -Dglib=disabled -Dgobject=disabled -Dcairo=disabled -Dchafa=disabled -Dicu=disabled -Dgraphite=disabled -Dgraphite2=disabled -Dgdi=disabled -Ddirectwrite=disabled -Dcoretext=disabled -Dwasm=disabled -Dtests=disabled -Dintrospection=disabled -Ddocs=disabled -Ddoc_tests=false -Dutilities=disabled ../..
146+
ninja install
147+
)
148+
popd
149+
lipo -create $INSTALL_DIR/output/x86_64/lib/libharfbuzz.a $INSTALL_DIR/output/arm64/lib/libharfbuzz.a -output $INSTALL_DIR/output/lib/libharfbuzz.a
150+
else
151+
(
152+
export PKG_CONFIG_PATH=$INSTALL_DIR/output/lib/pkgconfig
153+
meson setup --prefix $INSTALL_DIR/output --default-library=static -Dglib=disabled -Dgobject=disabled -Dcairo=disabled -Dchafa=disabled -Dicu=disabled -Dgraphite=disabled -Dgraphite2=disabled -Dgdi=disabled -Ddirectwrite=disabled -Dcoretext=disabled -Dwasm=disabled -Dtests=disabled -Dintrospection=disabled -Ddocs=disabled -Ddoc_tests=false -Dutilities=disabled ..
154+
ninja install
155+
)
156+
fi
157+
popd
158+
159+
# ffmpeg
160+
echo "Build FFmpeg"
161+
if [[ -d ffmpeg/build ]] ; then
162+
rm -fr ffmpeg/build
163+
fi
164+
mkdir ffmpeg/build
165+
pushd ffmpeg/build
166+
if [[ "$OS" == "mac" && -n "$MULTIARCH" ]] ; then
167+
mkdir x86_64
168+
pushd x86_64
169+
(
170+
export PKG_CONFIG_PATH=$INSTALL_DIR/output/x86_64/lib/pkgconfig
171+
../../configure --arch=x86_64 --extra-cflags="-arch x86_64" --extra-ldflags="-arch x86_64" --prefix=$INSTALL_DIR/output/x86_64 "${FFMPEG_CONFIGURE_OPTS[@]}"
172+
make install
173+
)
174+
popd
175+
mkdir arm64
176+
pushd arm64
177+
(
178+
export PKG_CONFIG_PATH=$INSTALL_DIR/output/arm64/lib/pkgconfig
179+
../../configure --arch=arm64 --extra-cflags="-arch arm64" --extra-ldflags="-arch arm64" --prefix=$INSTALL_DIR/output/arm64 "${FFMPEG_CONFIGURE_OPTS[@]}"
180+
make install
181+
)
182+
popd
183+
lipo -create $INSTALL_DIR/output/x86_64/lib/libavcodec.a $INSTALL_DIR/output/arm64/lib/libavcodec.a -output $INSTALL_DIR/output/lib/libavcodec.a
184+
lipo -create $INSTALL_DIR/output/x86_64/lib/libavdevice.a $INSTALL_DIR/output/arm64/lib/libavdevice.a -output $INSTALL_DIR/output/lib/libavdevice.a
185+
lipo -create $INSTALL_DIR/output/x86_64/lib/libavfilter.a $INSTALL_DIR/output/arm64/lib/libavfilter.a -output $INSTALL_DIR/output/lib/libavfilter.a
186+
lipo -create $INSTALL_DIR/output/x86_64/lib/libavformat.a $INSTALL_DIR/output/arm64/lib/libavformat.a -output $INSTALL_DIR/output/lib/libavformat.a
187+
lipo -create $INSTALL_DIR/output/x86_64/lib/libavutil.a $INSTALL_DIR/output/arm64/lib/libavutil.a -output $INSTALL_DIR/output/lib/libavutil.a
188+
lipo -create $INSTALL_DIR/output/x86_64/lib/libpostproc.a $INSTALL_DIR/output/arm64/lib/libpostproc.a -output $INSTALL_DIR/output/lib/libpostproc.a
189+
lipo -create $INSTALL_DIR/output/x86_64/lib/libswresample.a $INSTALL_DIR/output/arm64/lib/libswresample.a -output $INSTALL_DIR/output/lib/libswresample.a
190+
lipo -create $INSTALL_DIR/output/x86_64/lib/libswscale.a $INSTALL_DIR/output/arm64/lib/libswscale.a -output $INSTALL_DIR/output/lib/libswscale.a
191+
cp -r $INSTALL_DIR/output/x86_64/include $INSTALL_DIR/output
192+
else
193+
(
194+
export PKG_CONFIG_PATH=$INSTALL_DIR/output/lib/pkgconfig
195+
../configure --prefix=$INSTALL_DIR/output "${FFMPEG_CONFIGURE_OPTS[@]}"
196+
make install
197+
)
198+
fi
199+
popd
200+
201+
# qwt
202+
echo "Build Qwt"
203+
if [[ -d qwt/build ]] ; then
204+
rm -fr qwt/build
205+
fi
206+
mkdir qwt/build
207+
pushd qwt/build
208+
(
209+
git -C .. apply "$SCRIPT_DIR/qwt.patch"
210+
export QWT_STATIC=1 QWT_NO_SVG=1 QWT_NO_OPENGL=1 QWT_NO_DESIGNER=1 QWT_NO_EXAMPLES=1 QWT_NO_PLAYGROUND=1 QWT_NO_TESTS=1 QWT_INSTALL_PREFIX=$INSTALL_DIR/output
211+
$BINQMAKE "${QT_CONFIGURE_OPTS[@]}" ..
212+
make install
213+
)
214+
popd
215+
216+
# qctools
217+
echo "Build QCTools"
218+
if [[ -d qctools/Project/QtCreator/build ]] ; then
219+
rm -fr qctools/Project/QtCreator/build
220+
fi
221+
mkdir qctools/Project/QtCreator/build
222+
pushd qctools/Project/QtCreator/build
223+
(
224+
export QWT_ROOT=$INSTALL_DIR/output FFMPEG=$INSTALL_DIR/output
225+
$BINQMAKE "${QT_CONFIGURE_OPTS[@]}" STATIC=1 ..
226+
make
227+
)
228+
popd
229+
230+
echo QCTools binary is in $INSTALL_DIR/qctools/Project/QtCreator/build/qctools-gui
231+
echo qcli binary is in $INSTALL_DIR/qctools/Project/QtCreator/build/qctools-cli

Project/BuildAllFromSource/build_qctools.sh

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)