2021-08-09 12:19:27 +02:00
|
|
|
#!/bin/bash
|
2021-08-29 10:15:55 +02:00
|
|
|
set -e
|
2021-08-09 12:19:27 +02:00
|
|
|
|
|
|
|
if [ ! -e "src/api/api.h" ]; then
|
2021-08-29 10:15:55 +02:00
|
|
|
echo "Please run this script from the root directory of Lite XL."; exit 1
|
2021-08-09 12:19:27 +02:00
|
|
|
fi
|
|
|
|
|
2021-08-29 10:15:55 +02:00
|
|
|
source scripts/common.sh
|
|
|
|
|
|
|
|
show_help() {
|
2021-08-09 12:19:27 +02:00
|
|
|
echo
|
|
|
|
echo "Usage: $0 <OPTIONS>"
|
|
|
|
echo
|
|
|
|
echo "Available options:"
|
|
|
|
echo
|
|
|
|
echo "-b --builddir DIRNAME Sets the name of the build directory (not path)."
|
2021-08-29 10:15:55 +02:00
|
|
|
echo " Default: '$(get_default_build_dir)'."
|
|
|
|
echo " --debug Debug this script."
|
|
|
|
echo "-f --forcefallback Force to build dependencies statically."
|
|
|
|
echo "-h --help Show this help and exit."
|
|
|
|
echo "-p --prefix PREFIX Install directory prefix. Default: '/'."
|
|
|
|
echo "-B --bundle Create an App bundle (macOS only)"
|
|
|
|
echo "-P --portable Create a portable binary package."
|
2021-09-05 15:43:22 +02:00
|
|
|
echo "-O --pgo Use profile guided optimizations (pgo)."
|
2022-06-16 07:35:38 +02:00
|
|
|
echo "-U --windows-lua-utf Use the UTF8 patch for Lua."
|
2021-08-29 10:15:55 +02:00
|
|
|
echo " macOS: disabled when used with --bundle,"
|
|
|
|
echo " Windows: Implicit being the only option."
|
2022-09-25 22:59:01 +02:00
|
|
|
echo "-r --release Compile in release mode."
|
2021-08-09 12:19:27 +02:00
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
2021-08-29 10:15:55 +02:00
|
|
|
main() {
|
|
|
|
local platform="$(get_platform_name)"
|
|
|
|
local build_dir="$(get_default_build_dir)"
|
2022-09-25 22:59:01 +02:00
|
|
|
local build_type="debug"
|
2021-08-29 10:15:55 +02:00
|
|
|
local prefix=/
|
|
|
|
local force_fallback
|
|
|
|
local bundle
|
|
|
|
local portable
|
2021-09-05 15:43:22 +02:00
|
|
|
local pgo
|
2022-06-16 07:35:38 +02:00
|
|
|
local patch_lua
|
|
|
|
|
|
|
|
local lua_subproject_path
|
2021-08-09 12:19:27 +02:00
|
|
|
|
2021-08-29 10:15:55 +02:00
|
|
|
for i in "$@"; do
|
|
|
|
case $i in
|
|
|
|
-h|--help)
|
|
|
|
show_help
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
-b|--builddir)
|
|
|
|
build_dir="$2"
|
|
|
|
shift
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--debug)
|
|
|
|
set -x
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-f|--forcefallback)
|
|
|
|
force_fallback="--wrap-mode=forcefallback"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-p|--prefix)
|
|
|
|
prefix="$2"
|
|
|
|
shift
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-B|--bundle)
|
|
|
|
if [[ "$platform" != "macos" ]]; then
|
|
|
|
echo "Warning: ignoring --bundle option, works only under macOS."
|
|
|
|
else
|
|
|
|
bundle="-Dbundle=true"
|
|
|
|
fi
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-P|--portable)
|
|
|
|
portable="-Dportable=true"
|
|
|
|
shift
|
|
|
|
;;
|
2021-09-05 15:43:22 +02:00
|
|
|
-O|--pgo)
|
|
|
|
pgo="-Db_pgo=generate"
|
|
|
|
shift
|
|
|
|
;;
|
2022-06-16 07:35:38 +02:00
|
|
|
-U|--windows-lua-utf)
|
|
|
|
patch_lua="true"
|
|
|
|
shift
|
|
|
|
;;
|
2022-09-25 22:59:01 +02:00
|
|
|
-r|--release)
|
|
|
|
build_type="release"
|
|
|
|
shift
|
|
|
|
;;
|
2021-08-29 10:15:55 +02:00
|
|
|
*)
|
|
|
|
# unknown option
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2021-08-09 12:19:27 +02:00
|
|
|
|
2021-08-29 10:15:55 +02:00
|
|
|
if [[ -n $1 ]]; then
|
|
|
|
show_help
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-08-09 12:19:27 +02:00
|
|
|
|
2021-08-29 10:15:55 +02:00
|
|
|
if [[ $platform == "macos" && -n $bundle && -n $portable ]]; then
|
|
|
|
echo "Warning: \"bundle\" and \"portable\" specified; excluding portable package."
|
|
|
|
portable=""
|
2021-08-09 12:19:27 +02:00
|
|
|
fi
|
|
|
|
|
2021-08-29 10:15:55 +02:00
|
|
|
rm -rf "${build_dir}"
|
|
|
|
|
2021-08-09 12:19:27 +02:00
|
|
|
CFLAGS=$CFLAGS LDFLAGS=$LDFLAGS meson setup \
|
2022-09-25 22:59:01 +02:00
|
|
|
--buildtype=$build_type \
|
2021-08-29 10:15:55 +02:00
|
|
|
--prefix "$prefix" \
|
|
|
|
$force_fallback \
|
|
|
|
$bundle \
|
|
|
|
$portable \
|
2021-09-05 15:43:22 +02:00
|
|
|
$pgo \
|
2021-08-29 10:15:55 +02:00
|
|
|
"${build_dir}"
|
2021-08-09 12:19:27 +02:00
|
|
|
|
2022-06-17 17:04:53 +02:00
|
|
|
lua_subproject_path=$(echo subprojects/lua-*/)
|
2022-06-16 07:35:38 +02:00
|
|
|
if [[ $patch_lua == "true" ]] && [[ ! -z $force_fallback ]] && [[ -d $lua_subproject_path ]]; then
|
|
|
|
patch -d $lua_subproject_path -p1 --forward < resources/windows/001-lua-unicode.diff
|
|
|
|
fi
|
|
|
|
|
2021-08-29 10:15:55 +02:00
|
|
|
meson compile -C "${build_dir}"
|
2021-09-05 15:43:22 +02:00
|
|
|
|
|
|
|
if [ ! -z ${pgo+x} ]; then
|
|
|
|
cp -r data "${build_dir}/src"
|
|
|
|
"${build_dir}/src/lite-xl"
|
|
|
|
meson configure -Db_pgo=use "${build_dir}"
|
|
|
|
meson compile -C "${build_dir}"
|
|
|
|
rm -fr "${build_dir}/data"
|
|
|
|
fi
|
2021-08-09 12:19:27 +02:00
|
|
|
}
|
|
|
|
|
2021-08-29 10:15:55 +02:00
|
|
|
main "$@"
|