merge meson & cmake build scripts

Signed-off-by: Vadim Lomovtsev <jelezny@gmail.com>
This commit is contained in:
Vadim Lomovtsev 2024-03-29 15:58:47 +03:00 committed by Maxim Logaev
parent 4912be6cff
commit 9afa4ddb72
3 changed files with 170 additions and 177 deletions

View file

@ -61,6 +61,12 @@ Build on Windows (x86_64)
```sh ```sh
./build-win64.sh ./build-win64.sh
``` ```
If you want to use meson build system, please use `-s meson` key as the first argument, i.e.
```sh
bash build-win64.sh -s meson -c -b
```
will do the same as commands above, but using meson.
Note: the build script has some other options, their description can be found using the `--help`. Note: the build script has some other options, their description can be found using the `--help`.
Build Windows Installer (NSIS) Build Windows Installer (NSIS)

View file

@ -1,125 +0,0 @@
#!/bin/bash
set -eu
PROJ_DIR=$PWD
BUILD_DIR=$PROJ_DIR/build/meson
DIST_DIR=$PROJ_DIR/windows-installer/win64-meson
prepare()
{
if [ -d ${PROJ_DIR}/plugins/windows-notification/yolort ]; then
echo "No need to re-download packages & yolort sources."
else
bash build-win64.sh --prepare
fi
}
configure()
{
arg=${1:-"none"}
encr=${2:-"auto"}
local cmd=""
if [ x"${arg}" == x"reconfig" ]; then
cmd=--reconfigure
fi
mkdir -p $BUILD_DIR
meson setup ${cmd} --prefix "$DIST_DIR" \
-D crypto-backend=${encr} \
-D plugin-ice=enabled \
$PROJ_DIR $BUILD_DIR
}
build()
{
cd $BUILD_DIR && ninja
ninja install
}
clean()
{
rm -rf $DIST_DIR $BUILD_DIR
}
help()
{
cat << EOF
Script to build Dino for windows using meson build-system.
By default it will be build using build directory
$BUILD_DIR
and installed to
$DIST_DIR
Usage: $0 [option]
--prepare, -p
install build dependencies. may be done once.
--configure, -c
configure build using meson.
--build, -b
invoked build.
--reconfig, -r
reconfigure project, if minor changes were
done tobuild config files but build has been
configured already.
--whipe, -w
remove build artifacts from $BUILD_DIR
--verbose, -v
verbose output enable.
--help, -h
print this help message.
EOF
}
# Main
if [[ "$(uname)" != "MINGW64_NT"* ]]; then
fatal "This is not a MINGW64 environment!"
fi
if [[ $# == 0 ]]; then
prepare
configure
build
exit 0
fi
while [[ $# > 0 ]];
do
case $1 in
--prepare|-p)
prepare
;;
--configure|-c)
configure
;;
--build|-b)
build
;;
--reconfig|-r)
configure reconfig
;;
--whipe|-w)
clean
;;
--verbose|-v)
set -xv
;;
--help|-h)
help
;;
*)
echo "Unkown option $1"
exit 1
;;
esac
shift
done

View file

@ -1,8 +1,12 @@
#!/bin/bash #!/bin/bash
set -e
DIST_DIR="$PWD/windows-installer/win64-dist" set -eu
PROJ_DIR=$PWD
DIST_DIR=${PROJ_DIR}/windows-installer/win64-dist
BUILD_DIR=$PROJ_DIR/build
JOBS=$NUMBER_OF_PROCESSORS JOBS=$NUMBER_OF_PROCESSORS
build_sys='cmake'
msg() msg()
{ {
@ -18,7 +22,7 @@ fatal()
download_yolort() download_yolort()
{ {
file_name=cppwinrt-2.0.210122.3+windows-10.0.19041+yolort-835cd4e.zip file_name=cppwinrt-2.0.210122.3+windows-10.0.19041+yolort-835cd4e.zip
yolort_dir="$PWD/plugins/windows-notification/yolort" yolort_dir="$PROJ_DIR/plugins/windows-notification/yolort"
rm -rf "$yolort_dir" rm -rf "$yolort_dir"
mkdir "$yolort_dir" mkdir "$yolort_dir"
@ -71,6 +75,7 @@ prepare()
mingw64/mingw-w64-x86_64-libsignal-protocol-c \ mingw64/mingw-w64-x86_64-libsignal-protocol-c \
mingw64/mingw-w64-x86_64-icu \ mingw64/mingw-w64-x86_64-icu \
mingw64/mingw-w64-x86_64-webrtc-audio-processing \ mingw64/mingw-w64-x86_64-webrtc-audio-processing \
mingw64/mingw-w64-x86_64-meson \
git \ git \
make \ make \
unzip \ unzip \
@ -87,60 +92,83 @@ prepare()
} }
configure() configure_cmake()
{ {
msg "Running configuration for Windows" msg "Running configuration for Windows"
./configure --program-prefix="$DIST_DIR" --no-debug --release --disable-fast-vapi --with-libsoup3 ./configure --program-prefix="$DIST_DIR" --no-debug --release --disable-fast-vapi --with-libsoup3
msg "Configured!" msg "Configured!"
} }
build() build_cmake()
{ {
msg "Started building on $JOBS threads" msg "Started building on $JOBS threads"
make -j"$JOBS" make -j"$JOBS"
msg "Successfully builded!" msg "Successfully builded!"
msg "Installing Dino .."
make install
}
configure_meson()
{
arg=${1:-"none"}
encr=${2:-"auto"}
local cmd=""
if [ x"${arg}" == x"reconfig" ]; then
cmd=--reconfigure
fi
mkdir -p $BUILD_DIR
meson setup ${cmd} --prefix "$DIST_DIR" \
-D crypto-backend=${encr} \
-D plugin-ice=enabled \
$PROJ_DIR $BUILD_DIR
}
build_meson()
{
cd $BUILD_DIR && ninja
ninja install
cd $PROJ_DIR
} }
dist_install() dist_install()
{ {
msg "Installing Dino in '$DIST_DIR'!" _dist_arg=${1:-$DIST_DIR}
make install
msg "Copying MINGW64 dependencies" msg "Copying MINGW64 dependencies"
cp /mingw64/bin/gdbus.exe "$DIST_DIR/bin" cp /mingw64/bin/gdbus.exe "$_dist_arg/bin"
cp /mingw64/bin/gspawn-win64-helper.exe "$DIST_DIR/bin" cp /mingw64/bin/gspawn-win64-helper.exe "$_dist_arg/bin"
cp /mingw64/bin/libcrypto-*-x64.dll "$DIST_DIR/bin/" cp /mingw64/bin/libcrypto-*-x64.dll "$_dist_arg/bin/"
cp -r /mingw64/lib/gstreamer-1.0 "$DIST_DIR/lib" cp -r /mingw64/lib/gstreamer-1.0 "$_dist_arg/lib"
mkdir -p "$DIST_DIR/lib/gdk-pixbuf-2.0/" && cp -r /mingw64/lib/gdk-pixbuf-2.0 "$DIST_DIR/lib/" mkdir -p "$_dist_arg/lib/gdk-pixbuf-2.0/" && cp -r /mingw64/lib/gdk-pixbuf-2.0 "$_dist_arg/lib/"
mkdir -p "$DIST_DIR/lib/gio/" && cp -r /mingw64/lib/gio "$DIST_DIR/lib/" mkdir -p "$_dist_arg/lib/gio/" && cp -r /mingw64/lib/gio "$_dist_arg/lib/"
list=`find "$DIST_DIR" -type f \( -name "*.exe" -o -name "*.dll" \) -exec \ list=`find "$_dist_arg" -type f \( -name "*.exe" -o -name "*.dll" \) -exec \
ntldd -R {} + | \ ntldd -R {} + | \
grep "mingw64" | \ grep "mingw64" | \
cut -f1 -d "=" | sort | uniq` cut -f1 -d "=" | sort | uniq`
for a in $list; do for a in $list; do
cp -fv "/mingw64/bin/$a" "$DIST_DIR/bin/" cp -fv "/mingw64/bin/$a" "$_dist_arg/bin/"
done done
msg "Removing debug information from all EXE and DLL files" msg "Removing debug information from all EXE and DLL files"
find "$DIST_DIR" -iname "*.exe" -exec strip -s {} + find "$_dist_arg" -iname "*.exe" -exec strip -s {} +
find "$DIST_DIR" -iname "*.dll" -exec strip -s {} + find "$_dist_arg" -iname "*.dll" -exec strip -s {} +
find "$DIST_DIR" -iname "*.a" -exec rm {} + find "$_dist_arg" -iname "*.a" -exec rm {} +
msg "Removing redudant header files" msg "Removing redudant header files"
rm -rf "$DIST_DIR/include" rm -rf "$_dist_arg/include"
msg "Copy LICENSE" msg "Copy LICENSE"
cp -f "$PWD/LICENSE" "$DIST_DIR/LICENSE" cp -f "$PWD/LICENSE" "$_dist_arg/LICENSE"
msg "Copy icons, themes, locales and fonts" msg "Copy icons, themes, locales and fonts"
cp -f "$PWD/main/dino.ico" "$DIST_DIR/dino.ico" cp -f "$PWD/main/dino.ico" "$_dist_arg/dino.ico"
cp -rf "/mingw64/share/xml" "$DIST_DIR/share" cp -rf "/mingw64/share/xml" "$_dist_arg/share"
mkdir -p "$DIST_DIR/etc/fonts" && cp -r /mingw64/etc/fonts "$DIST_DIR/etc/" mkdir -p "$_dist_arg/etc/fonts" && cp -r /mingw64/etc/fonts "$_dist_arg/etc/"
mkdir -p "$DIST_DIR/share/icons" && cp -r /mingw64/share/icons "$DIST_DIR/share/" mkdir -p "$_dist_arg/share/icons" && cp -r /mingw64/share/icons "$_dist_arg/share/"
mkdir -p "$DIST_DIR/share/glib-2.0/schemas" && cp -rf /mingw64/share/glib-2.0/schemas "$DIST_DIR/share/glib-2.0/" mkdir -p "$_dist_arg/share/glib-2.0/schemas" && cp -rf /mingw64/share/glib-2.0/schemas "$_dist_arg/share/glib-2.0/"
msg "Successfully installed!" msg "Successfully installed!"
} }
@ -156,24 +184,68 @@ build_installer()
clean() clean()
{ {
rm -rf build "$DIST_DIR" rm -rf $BUILD_DIR $DIST_DIR
msg "Build artifacts removed successfull!" msg "Build artifacts removed successfull!"
} }
help() help()
{ {
cat << EOF cat << EOF
usage: $0 [OPTION] Script to build Dino for windows using cmake or meson build-system.
--prepare install build dependencies By default it will be build using build directory
--configure configure the project $BUILD_DIR
--build build the project and installed to
--dist-install install the builded project $DIST_DIR
--build-installer build installer (using NSIS)
--clean remove build artifacts
--help show this help
Running without parameters is equivalent to running: Usage: $0 [option]
'--configure', '--build' and '--dist-install'
Note: you may set the multiple options, but be surem that they will be
processed sequentially (one-by-one), e.g. command
$0 -s meson -c -b
will run buld config and _after_ that run build using meson, while
$0 -c -b -s meson
will run cmake-based configure & build commands and the -s option
wont have any effect. And the one
$0 -b -s meson -c
is incorrect, as it willtry to run build(for cmake), then configure
with for meson build.
--help, -h
print this help message.
--set-buildsys, -s
set (specify) build system name to be used
possible options are: cmake or meson
--prepare, -p
install build dependencies. may be done once.
--configure, -c
configure build using selected build-system.
--build, -b
invoked build.
--reconfig, -r
reconfigure project, if minor changes were
done to build config files but build has been
configured already (only for meson!).
--whipe, -w
remove build artifacts from $BUILD_DIR
--verbose, -v
verbose output enable.
--dist-install, -i
install the builded project along with its'
dependencies.
--build-installer
build installer (using NSIS)
Running without parameters will run configure, build & install
using cmake-based build-system as default one.
EOF EOF
} }
@ -181,18 +253,58 @@ if [[ "$(uname)" != "MINGW64_NT"* ]]; then
fatal "This is not a MINGW64 environment!" fatal "This is not a MINGW64 environment!"
fi fi
case $1 in # no options provided,simply build with defaults
"--prepare" ) prepare ;; if [[ $# == 0 ]]; then
"--configure" ) configure ;; prepare
"--build" ) build ;; configure_${build_sys}
"--dist-install" ) dist_install ;; build_${build_sys}
"--build-installer") build_installer ;; dist_install
"--clean" ) clean ;;
"--help" ) help ;; exit 0
"" ) fi
configure
build while [[ $# > 0 ]];
do
case $1 in
--prepare|-p)
prepare
;;
--configure|-c)
configure_${build_sys}
;;
--build|-b)
build_${build_sys}
;;
--reconfig|-r)
configure_${build_sys} reconfig
;;
--whipe|-w)
clean
;;
--dist-install|-i)
dist_install dist_install
;; ;;
*) fatal "Unknown argument!" --verbose|-v)
esac set -xv
;;
--help|-h)
help
exit 0;
;;
--build-installer)
build_installer
;;
--set-buildsys|-s)
if [ x"$2" != x"cmake" -a x"$2" != x"meson" ]; then
fatal "Improper build system selected: ${2}!"
exit 1;
fi
build_sys=$2
;;
-*)
echo "Unknown option $1"
exit 1
;;
esac
shift
done