Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

meson build system updates #31

Merged
merged 7 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Makefile
.idea
.sqlite3
gschemas.compiled
windows-installer/win64-dist/
windows-installer/win64-*/
*.exe
*.dll
*.flatpak
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ Build on Windows (x86_64)
```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`.

Build Windows Installer (NSIS)
Expand Down
218 changes: 165 additions & 53 deletions build-win64.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#!/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
build_sys='cmake'

msg()
{
Expand All @@ -18,7 +22,7 @@ fatal()
download_yolort()
{
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"
mkdir "$yolort_dir"
Expand Down Expand Up @@ -71,6 +75,7 @@ prepare()
mingw64/mingw-w64-x86_64-libsignal-protocol-c \
mingw64/mingw-w64-x86_64-icu \
mingw64/mingw-w64-x86_64-webrtc-audio-processing \
mingw64/mingw-w64-x86_64-meson \
git \
make \
unzip \
Expand All @@ -87,60 +92,83 @@ prepare()

}

configure()
configure_cmake()
{
msg "Running configuration for Windows"
./configure --program-prefix="$DIST_DIR" --no-debug --release --disable-fast-vapi --with-libsoup3
msg "Configured!"
}

build()
build_cmake()
{
msg "Started building on $JOBS threads"
make -j"$JOBS"
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()
{
msg "Installing Dino in '$DIST_DIR'!"
make install
_dist_arg=${1:-$DIST_DIR}

msg "Copying MINGW64 dependencies"
cp /mingw64/bin/gdbus.exe "$DIST_DIR/bin"
cp /mingw64/bin/gspawn-win64-helper.exe "$DIST_DIR/bin"
cp /mingw64/bin/gdbus.exe "$_dist_arg/bin"
cp /mingw64/bin/gspawn-win64-helper.exe "$_dist_arg/bin"

cp /mingw64/bin/libcrypto-*-x64.dll "$DIST_DIR/bin/"
cp -r /mingw64/lib/gstreamer-1.0 "$DIST_DIR/lib"
mkdir -p "$DIST_DIR/lib/gdk-pixbuf-2.0/" && cp -r /mingw64/lib/gdk-pixbuf-2.0 "$DIST_DIR/lib/"
mkdir -p "$DIST_DIR/lib/gio/" && cp -r /mingw64/lib/gio "$DIST_DIR/lib/"
cp /mingw64/bin/libcrypto-*-x64.dll "$_dist_arg/bin/"
cp -r /mingw64/lib/gstreamer-1.0 "$_dist_arg/lib"
mkdir -p "$_dist_arg/lib/gdk-pixbuf-2.0/" && cp -r /mingw64/lib/gdk-pixbuf-2.0 "$_dist_arg/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 {} + | \
grep "mingw64" | \
cut -f1 -d "=" | sort | uniq`
for a in $list; do
cp -fv "/mingw64/bin/$a" "$DIST_DIR/bin/"
cp -fv "/mingw64/bin/$a" "$_dist_arg/bin/"
done

msg "Removing debug information from all EXE and DLL files"
find "$DIST_DIR" -iname "*.exe" -exec strip -s {} +
find "$DIST_DIR" -iname "*.dll" -exec strip -s {} +
find "$_dist_arg" -iname "*.exe" -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"
rm -rf "$DIST_DIR/include"
rm -rf "$_dist_arg/include"

msg "Copy LICENSE"
cp -f "$PWD/LICENSE" "$DIST_DIR/LICENSE"
cp -f "$PWD/LICENSE" "$_dist_arg/LICENSE"

msg "Copy icons, themes, locales and fonts"
cp -f "$PWD/main/dino.ico" "$DIST_DIR/dino.ico"
cp -rf "/mingw64/share/xml" "$DIST_DIR/share"
mkdir -p "$DIST_DIR/etc/fonts" && cp -r /mingw64/etc/fonts "$DIST_DIR/etc/"
mkdir -p "$DIST_DIR/share/icons" && cp -r /mingw64/share/icons "$DIST_DIR/share/"
mkdir -p "$DIST_DIR/share/glib-2.0/schemas" && cp -rf /mingw64/share/glib-2.0/schemas "$DIST_DIR/share/glib-2.0/"
cp -f "$PWD/main/dino.ico" "$_dist_arg/dino.ico"
cp -rf "/mingw64/share/xml" "$_dist_arg/share"
mkdir -p "$_dist_arg/etc/fonts" && cp -r /mingw64/etc/fonts "$_dist_arg/etc/"
mkdir -p "$_dist_arg/share/icons" && cp -r /mingw64/share/icons "$_dist_arg/share/"
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!"
}
Expand All @@ -156,43 +184,127 @@ build_installer()

clean()
{
rm -rf build "$DIST_DIR"
rm -rf $BUILD_DIR $DIST_DIR
msg "Build artifacts removed successfull!"
}

help()
{
cat << EOF
usage: $0 [OPTION]
--prepare install build dependencies
--configure configure the project
--build build the project
--dist-install install the builded project
--build-installer build installer (using NSIS)
--clean remove build artifacts
--help show this help

Running without parameters is equivalent to running:
'--configure', '--build' and '--dist-install'
cat << EOF
Script to build Dino for windows using cmake or meson build-system.
By default it will be build using build directory
$BUILD_DIR
and installed to
$DIST_DIR

Usage: $0 [option]

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
}

if [[ "$(uname)" != "MINGW64_NT"* ]]; then
fatal "This is not a MINGW64 environment!"
fi

case $1 in
"--prepare" ) prepare ;;
"--configure" ) configure ;;
"--build" ) build ;;
"--dist-install" ) dist_install ;;
"--build-installer") build_installer ;;
"--clean" ) clean ;;
"--help" ) help ;;
"" )
configure
build
dist_install
;;
*) fatal "Unknown argument!"
esac
# no options provided,simply build with defaults
if [[ $# == 0 ]]; then
prepare
configure_${build_sys}
build_${build_sys}
dist_install

exit 0
fi

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
;;
--verbose|-v)
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
2 changes: 2 additions & 0 deletions crypto-vala/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ GENERATE_VAPI
crypto-vala
GENERATE_HEADER
crypto-vala
DEFINITIONS
GCRYPT
)

add_custom_target(crypto-vala-vapi
Expand Down
7 changes: 6 additions & 1 deletion crypto-vala/meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dependencies = [
dep_gio,
dep_glib,
dep_libgcrypt,
dep_libgcrypt_or_openssl,
dep_libsrtp2,
]
sources = files(
Expand All @@ -17,6 +17,11 @@ c_args = [
vala_args = [
'--vapidir', meson.current_source_dir() / 'vapi',
]
if crypto_backend == 'openssl'
vala_args += ['--pkg', 'openssl'] # Work around https://github.com/mesonbuild/meson/issues/2103.
elif crypto_backend == 'gnutls'
vala_args += ['-D', 'GCRYPT']
endif
lib_crypto_vala = library('crypto-vala', sources, c_args: c_args, vala_args: vala_args, dependencies: dependencies, version: '0.0', install: true, install_dir: [true, true, true])
dep_crypto_vala = declare_dependency(link_with: lib_crypto_vala, include_directories: include_directories('.'))

Expand Down
Loading
Loading