Skip to content

Commit

Permalink
merge meson & cmake build scripts
Browse files Browse the repository at this point in the history
Signed-off-by: Vadim Lomovtsev <[email protected]>
  • Loading branch information
vlomovtsev committed Apr 1, 2024
1 parent 0997003 commit 9ee136c
Show file tree
Hide file tree
Showing 3 changed files with 149 additions and 163 deletions.
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
129 changes: 0 additions & 129 deletions build-meson-windows.sh

This file was deleted.

177 changes: 143 additions & 34 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 @@ -88,21 +92,42 @@ 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 in '$_dist_arg'!"
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()
Expand Down Expand Up @@ -159,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 $2 ;;
"--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

0 comments on commit 9ee136c

Please sign in to comment.