2021-08-31 14:15:21 +02:00
|
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
2021-08-31 21:07:03 +02:00
|
|
|
|
usage_and_die() {
|
|
|
|
|
|
echo "Usage: ${0} none|partial|full|full-headless-sway|[auto] <source-dir> <build-dir>"
|
2021-08-31 14:15:21 +02:00
|
|
|
|
exit 1
|
2021-08-31 21:07:03 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[ ${#} -ge 3 ] || usage_and_die
|
|
|
|
|
|
|
|
|
|
|
|
mode=${1}
|
|
|
|
|
|
source_dir=$(realpath "${2}")
|
|
|
|
|
|
build_dir=$(realpath "${3}")
|
|
|
|
|
|
shift 3
|
2021-08-31 14:15:21 +02:00
|
|
|
|
|
|
|
|
|
|
case ${mode} in
|
2021-08-31 16:48:49 +02:00
|
|
|
|
none|auto|partial|full|full-headless-sway)
|
2021-08-31 21:07:03 +02:00
|
|
|
|
;;
|
2021-08-31 14:15:21 +02:00
|
|
|
|
|
|
|
|
|
|
*)
|
2021-08-31 21:07:03 +02:00
|
|
|
|
usage_and_die
|
2021-08-31 14:15:21 +02:00
|
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
|
|
|
|
2021-08-31 21:07:03 +02:00
|
|
|
|
# meson will complain if source dir is invalid
|
|
|
|
|
|
|
|
|
|
|
|
if [ -d "${build_dir}" ]; then
|
|
|
|
|
|
echo "${build_dir}: build directory already exists"
|
|
|
|
|
|
exit 1
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
2021-08-31 14:15:21 +02:00
|
|
|
|
compiler=other
|
|
|
|
|
|
do_pgo=no
|
|
|
|
|
|
|
|
|
|
|
|
CFLAGS="${CFLAGS} -O3"
|
|
|
|
|
|
|
|
|
|
|
|
case $(${CC-cc} --version) in
|
|
|
|
|
|
*GCC*)
|
|
|
|
|
|
compiler=gcc
|
|
|
|
|
|
do_pgo=yes
|
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
|
|
*clang*)
|
|
|
|
|
|
compiler=clang
|
|
|
|
|
|
|
|
|
|
|
|
if command -v llvm-profdata > /dev/null; then
|
|
|
|
|
|
do_pgo=yes
|
|
|
|
|
|
CFLAGS="${CFLAGS} -Wno-ignored-optimization-argument"
|
|
|
|
|
|
fi
|
|
|
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
|
|
|
|
2021-08-31 16:48:49 +02:00
|
|
|
|
case ${mode} in
|
|
|
|
|
|
none)
|
|
|
|
|
|
do_pgo=no
|
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
|
|
auto)
|
|
|
|
|
|
if command -v sway > /dev/null; then
|
|
|
|
|
|
mode=full-headless-sway
|
|
|
|
|
|
elif [ -n "${WAYLAND_DISPLAY+x}" ]; then
|
|
|
|
|
|
mode=full
|
|
|
|
|
|
else
|
|
|
|
|
|
mode=partial
|
|
|
|
|
|
fi
|
|
|
|
|
|
;;
|
|
|
|
|
|
esac
|
2021-08-31 14:15:21 +02:00
|
|
|
|
|
|
|
|
|
|
# echo "source: ${source_dir}"
|
|
|
|
|
|
# echo "build: ${build_dir}"
|
|
|
|
|
|
# echo "compiler: ${compiler}"
|
|
|
|
|
|
# echo "mode: ${mode}"
|
|
|
|
|
|
|
|
|
|
|
|
export CFLAGS
|
|
|
|
|
|
meson "${@}" "${build_dir}"
|
|
|
|
|
|
|
|
|
|
|
|
if [ ${do_pgo} = yes ]; then
|
|
|
|
|
|
find . -name "*.gcda" -delete
|
|
|
|
|
|
meson configure "${build_dir}" -Db_pgo=generate
|
|
|
|
|
|
ninja -C "${build_dir}"
|
|
|
|
|
|
|
|
|
|
|
|
# If fcft/tllist are subprojects, we need to ensure their tests
|
|
|
|
|
|
# have been executed, or we’ll get “profile count data file not
|
|
|
|
|
|
# found” errors.
|
|
|
|
|
|
ninja -C "${build_dir}" test
|
|
|
|
|
|
|
|
|
|
|
|
script_options="--scroll --scroll-region --colors-regular --colors-bright --colors-256 --colors-rgb --attr-bold --attr-italic --attr-underline --sixel"
|
|
|
|
|
|
|
|
|
|
|
|
tmp_file=$(mktemp)
|
|
|
|
|
|
pwd=$(pwd)
|
|
|
|
|
|
|
|
|
|
|
|
cleanup() {
|
|
|
|
|
|
rm -f "${tmp_file}"
|
|
|
|
|
|
cd "${pwd}"
|
|
|
|
|
|
}
|
|
|
|
|
|
trap cleanup EXIT INT HUP TERM
|
|
|
|
|
|
|
|
|
|
|
|
cd "${build_dir}"
|
2021-08-31 16:25:44 +02:00
|
|
|
|
case ${mode} in
|
|
|
|
|
|
full)
|
|
|
|
|
|
./footclient --version
|
|
|
|
|
|
./foot \
|
|
|
|
|
|
--config=/dev/null \
|
|
|
|
|
|
--term=xterm \
|
|
|
|
|
|
sh -c "${source_dir}/scripts/generate-alt-random-writes.py ${script_options} ${tmp_file} && cat ${tmp_file}"
|
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
|
|
full-headless-sway)
|
|
|
|
|
|
./footclient --version
|
|
|
|
|
|
sway_conf=$(mktemp)
|
|
|
|
|
|
echo "exec ${build_dir}/foot -o tweak.render-timer=log --config=/dev/null --term=xterm sh -c \"${source_dir}/scripts/generate-alt-random-writes.py ${script_options} ${tmp_file} && cat ${tmp_file}\" && swaymsg exit" > "${sway_conf}"
|
|
|
|
|
|
export WLR_BACKENDS=headless
|
|
|
|
|
|
sway -c "${sway_conf}"
|
|
|
|
|
|
rm "${sway_conf}"
|
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
|
|
partial)
|
|
|
|
|
|
./footclient --version
|
|
|
|
|
|
./foot --version
|
|
|
|
|
|
"${source_dir}/scripts/generate-alt-random-writes.py" \
|
|
|
|
|
|
--rows=67 \
|
|
|
|
|
|
--cols=135 \
|
|
|
|
|
|
${script_options} \
|
|
|
|
|
|
"${tmp_file}"
|
|
|
|
|
|
./pgo "${tmp_file}"
|
|
|
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
|
|
|
|
2021-08-31 14:15:21 +02:00
|
|
|
|
cd "${pwd}"
|
|
|
|
|
|
rm "${tmp_file}"
|
|
|
|
|
|
|
|
|
|
|
|
if [ ${compiler} = clang ]; then
|
|
|
|
|
|
llvm-profdata merge "${build_dir}"/default_*.profraw --output="${build_dir}/default.profdata"
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
meson configure "${build_dir}" -Db_pgo=use
|
|
|
|
|
|
fi
|