Files
spark/tools/sparkd.sh
T
John Colvin 5163ca4cae refactor: Organize libspark proj w/ stuttering include
This new structure provides several benefits:

* Allows us to install multiple CMake projects in the same destination
  dir (without include path conflicts).
  - This makes shipping the trading algo sdk a trivial excercise. Simply
    copy the lib and include dirs from the install dest. That's it!
* Puts us in a position to break up the monolithic libspark into smaller
  modules, which are easier to manage.

Windows specific notes:

* Get rid of unnecessary script vs_filters.cmake
* Define WebsocketConnectionGateway directly in cs (instead of proto)
  - The proto would no longer be in the include path passed to protoc.
    Moving it to c# because there wasn't a compelling reason for it to
    be a proto in the first place.
* Set spark output prefix to "lib" on windows
  - So we get "libspark.dll" instead of "spark.dll", which conflicts
    with the csharp lib, "Spark.dll".
* Copy libspark.dll to net8.0 & net8.0-windows in a single cmake build
  target

fix build: Copy libspark to both dirs net8.0, net8.0-windows
2025-06-16 11:08:53 -04:00

102 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
##
# @file sparkd.sh
#
# @brief Run sparkd. Renames log file with timestamp so each run has its
# own log.
##
get_unique_file() {
filename="$1"
unique_filename="$filename"
declare -i count=1
declare -ir MAX_COUNT=60
while [ -e "$unique_filename" ]; do
unique_filename="$filename($count)"
count=$count+1
if [ $count -eq $MAX_COUNT ]; then
echo "Failed to make unique name for '$filename'"
exit 1
fi
done
echo "$unique_filename"
}
roll_over_log() {
log_dir="/home/bts/sparkdata/data/logging.sparkd"
log_file="$log_dir/log"
if [ ! -f "$log_file" ]; then
return
fi
archived_log_file="$(get_unique_file "${log_file}_$(date "+%Y%m%d-%H%M")")"
echo "Renaming existing log file $archived_log_file"
mv "$log_file" "$archived_log_file"
}
declare build_type=""
declare compiler=""
declare -a sparkd_args
while [[ $# -gt 0 ]]; do
declare -l arg="$1"
case "$arg" in
debug)
;&
--debug)
build_type="debug"
shift 1
;;
release)
;&
--release)
build_type="release"
shift 1
;;
clang)
;&
--clang)
compiler="clang"
shift 1
;;
gcc)
;&
--gcc)
compiler="gcc"
shift 1
;;
roll-logs)
roll_over_log
exit
;;
--)
shift 1
sparkd_args=($@)
shift ${#@}
;;
*)
sparkd_args+=("$1")
shift 1
;;
esac
done
if [ -z "$build_type" ]; then
build_type="debug"
fi
if [ -z "$compiler" ]; then
if [ "$build_type" = "debug" ]; then
compiler="clang"
else
compiler="gcc"
fi
fi
this_dir="$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")"
sparkd_dir="$(realpath "$this_dir/../build/sparkd-${build_type}-${compiler}/src/app_sparkd")"
roll_over_log
echo "Running sparkd ${build_type} ${compiler}"
echo "------------------------------------------------------------------------"
cd $sparkd_dir
./sparkd ${sparkd_args[@]}