CMakeLists.txt: remove bootstrap script, use executable directly; move its functionalities to twn tooling

This commit is contained in:
veclav talica 2024-10-07 14:16:53 +03:00
parent 771d8b9c2f
commit cc1e64531c
2 changed files with 28 additions and 46 deletions

View File

@ -275,7 +275,7 @@ function(use_townengine target sources output_directory data_dir)
endif()
set_target_properties(${target}_app PROPERTIES
OUTPUT_NAME launcher
OUTPUT_NAME ${target}
LIBRARY_OUTPUT_DIRECTORY ${output_directory}
RUNTIME_OUTPUT_DIRECTORY ${output_directory})
@ -306,47 +306,6 @@ function(use_townengine target sources output_directory data_dir)
COMMAND_EXPAND_LISTS)
endif()
# bootstrapping scripts are used to setup the expected state for an application
set(TWN_BOOTSTRAP_EXEC_ARGS
"$<IF:$<BOOL:${TWN_ARCHIVE_DATA}>,--data-dir ./data.${PACKAGE_EXTENSION},--data-dir ${data_dir}>")
# todo: generate by python script instead
# todo: handle the case where no numerical trace exists
string(JOIN "\n" TWN_BOOTSTRAP_SH
"#!/bin/env sh"
"cd \"$(dirname \"$0\")\""
"export LD_LIBRARY_PATH=\"\$LD_LIBRARY_PATH:./\""
"if [ \"\$1\" = \"gdb\" ]; then"
" unset DEBUGINFOD_URLS"
" gdb -ex run --args ./launcher ${TWN_BOOTSTRAP_EXEC_ARGS}"
"elif [ \"\$1\" = \"apitrace-take\" ]; then"
" export ASAN_OPTIONS=verify_asan_link_order=0"
" export LD_PRELOAD=\"/usr/lib/libubsan.so.1 /usr/lib/apitrace/wrappers/glxtrace.so \$LD_PRELOAD\""
" ./launcher ${TWN_BOOTSTRAP_EXEC_ARGS}"
"elif [ \"\$1\" = \"apitrace-use\" ]; then"
" traces=( launcher.*.trace )"
" trace=\${traces[-1]}"
" qapitrace \${trace}"
"else"
" ./launcher ${TWN_BOOTSTRAP_EXEC_ARGS}"
"fi"
"")
FILE(GENERATE OUTPUT ${output_directory}/${target}
CONTENT "${TWN_BOOTSTRAP_SH}"
FILE_PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ)
if(WIN32)
string(JOIN "\n" TWN_BOOTSTRAP_BAT
"pushd \"%~dp0\""
"launcher ${TWN_BOOTSTRAP_EXEC_ARGS}"
"")
FILE(GENERATE OUTPUT ${output_directory}/${target}.bat
CONTENT "${TWN_BOOTSTRAP_BAT}"
FILE_PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ)
endif()
if (TWN_ARCHIVE_DATA)
# zip up assets
add_custom_target(archive-data ALL

View File

@ -7,9 +7,32 @@ toolpath="$(dirname -- "${BASH_SOURCE[0]}")"
export TWNROOT=$(realpath "$toolpath"/../)
export TWNBUILDDIR=$(realpath "$toolpath"/../.build)
exe="$(basename $PWD)"
case "$1" in
build ) "$toolpath"/build.sh "${@:2}"
;;
gdb ) unset DEBUGINFOD_URLS
gdb -ex run --args "$(basename $PWD)" "${@:2}"
;;
apitrace ) case "$2" in
take ) export ASAN_OPTIONS=verify_asan_link_order=0
export LD_PRELOAD="/usr/lib/libubsan.so /usr/lib/apitrace/wrappers/glxtrace.so $LD_PRELOAD"
./$exe "${@:3}"
;;
show ) traces=( "$exe.*.trace" )
trace=${traces[-1]}
if [ "$trace" = "$exe.*.trace" ]; then
trace="$exe.trace"
fi
qapitrace ${trace}
;;
esac
;;
* ) echo "Unknown command."
;;
esac