mirror of
https://gitea.windcorp.ru/Wind-Corporation/Progressia.git
synced 2025-04-21 19:20:45 +03:00
TMP / Removed old build tools
This commit is contained in:
parent
abc8b93823
commit
a021ebce3b
@ -1,66 +0,0 @@
|
|||||||
#!/bin/false
|
|
||||||
|
|
||||||
# Writes a message to stderr.
|
|
||||||
# Parameters:
|
|
||||||
# $@ - the message to display
|
|
||||||
function error() {
|
|
||||||
echo >&2 "`basename "$0"`: $@"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Writes a message to stderr and exits with code 1.
|
|
||||||
# Parameters:
|
|
||||||
# $@ - the message to display
|
|
||||||
function fail() {
|
|
||||||
error "$@"
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Ensures that a variable with name $1 has a valid executable. If it does not,
|
|
||||||
# this function attempts to find an executable with a name suggested in $2...$n.
|
|
||||||
# In either way, if the variable does not end up naming an executable, fail() is
|
|
||||||
# called.
|
|
||||||
# Parameters:
|
|
||||||
# $1 - name of the variable to check and modify
|
|
||||||
# $2...$n - suggested executables (at least one)
|
|
||||||
# $FAIL_SILENTLY - if set, don't call exit and don't print anything on failure
|
|
||||||
function find_cmd() {
|
|
||||||
declare -n target="$1"
|
|
||||||
|
|
||||||
if [ -z "${target+x}" ]; then
|
|
||||||
for candidate in "${@:2}"; do
|
|
||||||
if command -v "$candidate" >/dev/null; then
|
|
||||||
target="$candidate"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! command -v "$target" >/dev/null; then
|
|
||||||
[ -n "${FAIL_SILENTLY+x}" ] && return 1
|
|
||||||
fail "Command $2 is not available. Check \$PATH or set \$$1."
|
|
||||||
fi
|
|
||||||
|
|
||||||
unset -n target
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# Displays the command and then runs it.
|
|
||||||
# Parameters:
|
|
||||||
# $@ - the command to run
|
|
||||||
function echo_and_run() {
|
|
||||||
echo " > $*"
|
|
||||||
command "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
root_dir="$(dirname "$(dirname "$(realpath "${BASH_SOURCE[0]}")")")"
|
|
||||||
source_dir="$root_dir"
|
|
||||||
build_dir="$root_dir/build"
|
|
||||||
tools_dir="$root_dir/tools"
|
|
||||||
|
|
||||||
# Load private.sh
|
|
||||||
private_sh="$tools_dir/private.sh"
|
|
||||||
if [ -f "$private_sh" ]; then
|
|
||||||
[ -x "$private_sh" ] \
|
|
||||||
|| fail 'tools/private.sh exists but it is not executable'
|
|
||||||
source "$private_sh"
|
|
||||||
fi
|
|
199
tools/build.sh
199
tools/build.sh
@ -1,199 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
usage=\
|
|
||||||
"Usage: build.sh [OPTIONS...]
|
|
||||||
Build and run the game.
|
|
||||||
|
|
||||||
Options:
|
|
||||||
--debug make a debug build (default)
|
|
||||||
--release make a release build
|
|
||||||
--build-id=ID set the build ID. Default is dev.
|
|
||||||
--cmake-gen=ARGS pass additional arguments to pass to cmake when
|
|
||||||
generating build files. ARGS is the ;-separated list.
|
|
||||||
--dont-generate don't generate build instructions; use existing
|
|
||||||
configuration if building
|
|
||||||
--dont-build don't build; run existing binaries or generate build
|
|
||||||
instructions only
|
|
||||||
--debug-vulkan enable Vulkan validation layers from LunarG
|
|
||||||
-R, --run run the game after building
|
|
||||||
--memcheck[=ARGS] run the game using valgrind's memcheck dynamic memory
|
|
||||||
analysis tool. Implies -R. ARGS is the ;-separated
|
|
||||||
list of arguments to pass to valgrind/memcheck.
|
|
||||||
|
|
||||||
-h, --help display this help and exit
|
|
||||||
|
|
||||||
Environment variables:
|
|
||||||
PARALLELISM threads to use, default is 1
|
|
||||||
|
|
||||||
CMAKE cmake executable
|
|
||||||
VALGRIND valgrind executable
|
|
||||||
|
|
||||||
private.sh variables:
|
|
||||||
private_cmake_gen_args array of additional arguments to pass to cmake when
|
|
||||||
generating build files
|
|
||||||
|
|
||||||
See also: tools/cppcheck/use-cppcheck.sh --help
|
|
||||||
tools/clang-format/use-clang-format.sh --help
|
|
||||||
tools/setup.sh --help"
|
|
||||||
|
|
||||||
rsrc="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
|
|
||||||
source "$rsrc/bashlib.sh"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Parse arguments
|
|
||||||
|
|
||||||
build_type=Debug
|
|
||||||
do_generate=true
|
|
||||||
cmake_gen_args=()
|
|
||||||
do_build=true
|
|
||||||
|
|
||||||
run_type=Normal
|
|
||||||
do_run=''
|
|
||||||
|
|
||||||
debug_vulkan=''
|
|
||||||
memcheck_args=()
|
|
||||||
|
|
||||||
for arg in "$@"; do
|
|
||||||
case "$arg" in
|
|
||||||
-h | --help )
|
|
||||||
echo "$usage"
|
|
||||||
exit
|
|
||||||
;;
|
|
||||||
--debug )
|
|
||||||
build_type=Debug
|
|
||||||
;;
|
|
||||||
--release )
|
|
||||||
build_type=Release
|
|
||||||
;;
|
|
||||||
--build-id )
|
|
||||||
fail "Option --build-id=ID requires a parameter"
|
|
||||||
;;
|
|
||||||
--build-id=* )
|
|
||||||
build_id="${arg#*=}"
|
|
||||||
;;
|
|
||||||
--cmake-gen )
|
|
||||||
fail "Option --cmake-gen=ARGS requires a parameter"
|
|
||||||
;;
|
|
||||||
--cmake-gen=* )
|
|
||||||
readarray -t -d ';' new_cmake_gen_args <<<"${arg#*=};"
|
|
||||||
unset new_cmake_gen_args[-1]
|
|
||||||
cmake_gen_args+=("${new_cmake_gen_args[@]}")
|
|
||||||
unset new_cmake_gen_args
|
|
||||||
;;
|
|
||||||
--debug-vulkan )
|
|
||||||
debug_vulkan=true
|
|
||||||
;;
|
|
||||||
-R | --run )
|
|
||||||
do_run=true
|
|
||||||
;;
|
|
||||||
--memcheck )
|
|
||||||
do_run=true
|
|
||||||
run_type=memcheck
|
|
||||||
;;
|
|
||||||
--memcheck=* )
|
|
||||||
do_run=true
|
|
||||||
run_type=memcheck
|
|
||||||
readarray -t -d ';' new_memcheck_args <<<"${arg#*=};"
|
|
||||||
unset new_memcheck_args[-1]
|
|
||||||
memcheck_args+=("${new_memcheck_args[@]}")
|
|
||||||
unset new_memcheck_args
|
|
||||||
;;
|
|
||||||
--dont-generate )
|
|
||||||
do_generate=''
|
|
||||||
;;
|
|
||||||
--dont-build )
|
|
||||||
do_build=''
|
|
||||||
;;
|
|
||||||
* )
|
|
||||||
fail "Unknown option '$arg'"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ -z "$do_build" -a -z "$do_generate" -a ${#cmake_gen_args[@]} != 0 ]; then
|
|
||||||
fail "CMake arguments are set, but no build is requested. Aborting"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$do_build" -a -z "$do_generate" -a -z "$do_run" ]; then
|
|
||||||
fail "Nothing to do"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Generate build files
|
|
||||||
|
|
||||||
find_cmd CMAKE cmake
|
|
||||||
if [ $do_generate ]; then
|
|
||||||
|
|
||||||
cmake_gen_managed_args=(
|
|
||||||
-DCMAKE_BUILD_TYPE=$build_type
|
|
||||||
-DVULKAN_ERROR_CHECKING=`[ $debug_vulkan ] && echo ON || echo OFF`
|
|
||||||
-UBUILD_ID
|
|
||||||
)
|
|
||||||
|
|
||||||
[ -n "${build_id+x}" ] && cmake_gen_managed_args+=(
|
|
||||||
-DBUILD_ID="$build_id"
|
|
||||||
)
|
|
||||||
|
|
||||||
echo_and_run "$CMAKE" \
|
|
||||||
-B "$build_dir" \
|
|
||||||
-S "$source_dir" \
|
|
||||||
"${cmake_gen_managed_args[@]}" \
|
|
||||||
"${private_cmake_gen_args[@]}" \
|
|
||||||
"${cmake_gen_args[@]}" \
|
|
||||||
|| fail "Could not generate build files"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Build
|
|
||||||
|
|
||||||
find_cmd CMAKE cmake
|
|
||||||
if [ $do_build ]; then
|
|
||||||
options=()
|
|
||||||
|
|
||||||
[ -n "${PARALLELISM+x}" ] && options+=(-j "$PARALLELISM")
|
|
||||||
|
|
||||||
echo_and_run "$CMAKE" \
|
|
||||||
--build "$build_dir" \
|
|
||||||
"${options[@]}" \
|
|
||||||
|| fail "Build failed"
|
|
||||||
|
|
||||||
unset options
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Run
|
|
||||||
|
|
||||||
if [ $do_run ]; then
|
|
||||||
|
|
||||||
run_command=()
|
|
||||||
|
|
||||||
if [ $run_type == memcheck ]; then
|
|
||||||
find_cmd VALGRIND valgrind
|
|
||||||
|
|
||||||
run_command+=(
|
|
||||||
"$VALGRIND"
|
|
||||||
--tool=memcheck
|
|
||||||
--suppressions="$tools_dir"/memcheck/suppressions.supp
|
|
||||||
"${memcheck_args[@]}"
|
|
||||||
--
|
|
||||||
)
|
|
||||||
fi
|
|
||||||
|
|
||||||
run_command+=(
|
|
||||||
"$build_dir/progressia"
|
|
||||||
)
|
|
||||||
|
|
||||||
run_dir="$root_dir/run"
|
|
||||||
mkdir -p "$run_dir"
|
|
||||||
|
|
||||||
(
|
|
||||||
cd "$run_dir"
|
|
||||||
echo_and_run "${run_command[@]}"
|
|
||||||
echo "Process exited with code $?"
|
|
||||||
)
|
|
||||||
|
|
||||||
fi
|
|
@ -1,102 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
usage=\
|
|
||||||
"Usage: use-clang-format.sh git
|
|
||||||
or: use-clang-format.sh files FILES...
|
|
||||||
or: use-clang-format.sh raw ARGUMENTS...
|
|
||||||
In the 1st form, format all files that have changed since last git commit.
|
|
||||||
In the 2nd form, format all FILES, treating directories recursively.
|
|
||||||
In the 3rd form, run \`clang-format --style=<style> ARGUMENTS...\`.
|
|
||||||
|
|
||||||
Environment variables:
|
|
||||||
CLANG_FORMAT clang-format executable
|
|
||||||
CLANG_FORMAT_DIFF clang-format-diff script"
|
|
||||||
|
|
||||||
rsrc="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
|
|
||||||
source "$rsrc/../bashlib.sh"
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
git )
|
|
||||||
find_cmd CLANG_FORMAT_DIFF \
|
|
||||||
clang-format-diff-13 \
|
|
||||||
clang-format-diff \
|
|
||||||
clang-format-diff.py
|
|
||||||
;;
|
|
||||||
files | raw )
|
|
||||||
find_cmd CLANG_FORMAT \
|
|
||||||
clang-format-13 \
|
|
||||||
clang-format
|
|
||||||
;;
|
|
||||||
-h | --help | '' )
|
|
||||||
echo "$usage"
|
|
||||||
exit
|
|
||||||
;;
|
|
||||||
* )
|
|
||||||
fail "Unknown option '$1'"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Generate style argument
|
|
||||||
style=''
|
|
||||||
while IFS='' read line; do
|
|
||||||
[ -z "$line" ] && continue
|
|
||||||
[ "${line:0:1}" = '#' ] && continue
|
|
||||||
[ -n "$style" ] && style+=', '
|
|
||||||
style+="$line"
|
|
||||||
done < "$rsrc/clang-format.yml"
|
|
||||||
style="{$style}" # Not typo
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
git )
|
|
||||||
unstaged_changes="`git diff --name-only`"
|
|
||||||
if [ -n "$unstaged_changes" ]; then
|
|
||||||
fail "Refusing to operate in git repository with unstaged changes:
|
|
||||||
$unstaged_changes"
|
|
||||||
fi
|
|
||||||
|
|
||||||
git diff -U0 --no-color --relative HEAD \
|
|
||||||
{desktop,main}/{'*.cpp','*.h','*.inl'} \
|
|
||||||
| command "$CLANG_FORMAT_DIFF" -p1 -style="$style" -i --verbose
|
|
||||||
exit_code="$?"
|
|
||||||
git add "$root_dir"
|
|
||||||
exit "$exit_code"
|
|
||||||
;;
|
|
||||||
|
|
||||||
raw )
|
|
||||||
command "$CLANG_FORMAT" -style="$style" "$@"
|
|
||||||
;;
|
|
||||||
|
|
||||||
files )
|
|
||||||
files=()
|
|
||||||
|
|
||||||
for input in "${@:2}"; do
|
|
||||||
if [ -d "$input" ]; then
|
|
||||||
readarray -d '' current_files < <(
|
|
||||||
find "$input" \
|
|
||||||
\( -name '*.cpp' -o -name '*.h' -o -name '*.inl' \) \
|
|
||||||
-type f \
|
|
||||||
-print0 \
|
|
||||||
)
|
|
||||||
|
|
||||||
[ "${#current_files[@]}" -eq 0 ] \
|
|
||||||
&& fail "No suitable files found in directory $input"
|
|
||||||
|
|
||||||
files+=("${current_files[@]}")
|
|
||||||
else
|
|
||||||
case "$input" in
|
|
||||||
*.cpp | *.h | *.inl )
|
|
||||||
files+=("$input")
|
|
||||||
;;
|
|
||||||
* )
|
|
||||||
error "Refusing to format file '$input': `
|
|
||||||
`only .cpp, .h and .inl supported"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
[ "${#files[@]}" -eq 0 ] && fail "No files to format"
|
|
||||||
|
|
||||||
command "$CLANG_FORMAT" -style="$style" -i --verbose "${files[@]}"
|
|
||||||
;;
|
|
||||||
esac
|
|
@ -1,28 +0,0 @@
|
|||||||
# CppCheck command line arguments
|
|
||||||
# Each line is treated as one argument, unless it is empty or it starts with #.
|
|
||||||
#
|
|
||||||
# Available variables:
|
|
||||||
# ${CMAKE_SOURCE_DIR} project root
|
|
||||||
# ${CMAKE_BINARY_DIR} CMake build directory
|
|
||||||
|
|
||||||
--enable=warning,style,information
|
|
||||||
#--enable=unusedFunction # Unused functions are often OK since they are intended
|
|
||||||
# # to be used later
|
|
||||||
#--enable=missingInclude # Very prone to false positives; system-dependent
|
|
||||||
--inconclusive
|
|
||||||
|
|
||||||
# SUPPRESSIONS
|
|
||||||
# Warnings that are suppressed on a case-by-case basis should be suppressed
|
|
||||||
# using inline suppressions.
|
|
||||||
# Warnings that were decided to be generally inapplicable should be suppressed
|
|
||||||
# using suppressions.txt.
|
|
||||||
# Warnings that result from the way cppcheck is invoked should be suppressed
|
|
||||||
# using this file.
|
|
||||||
|
|
||||||
--inline-suppr
|
|
||||||
--suppressions-list=${CMAKE_SOURCE_DIR}/tools/cppcheck/suppressions.txt
|
|
||||||
|
|
||||||
# N.B.: this path is also mentioned in use scripts
|
|
||||||
--cppcheck-build-dir=${CMAKE_BINARY_DIR}/cppcheck
|
|
||||||
|
|
||||||
--error-exitcode=2
|
|
@ -1,21 +0,0 @@
|
|||||||
# CppCheck global suppressions
|
|
||||||
# Do not use this file for suppressions that could easily be declared inline.
|
|
||||||
|
|
||||||
# Allow the use of implicit constructors.
|
|
||||||
noExplicitConstructor:*
|
|
||||||
|
|
||||||
# In most cases using STL algorithm functions causes unnecessary code bloat.
|
|
||||||
useStlAlgorithm:*
|
|
||||||
|
|
||||||
# Non-static non-virtual stubs are often useful for establishing code structure.
|
|
||||||
functionStatic:*
|
|
||||||
|
|
||||||
# cppcheck trips on #include <embedded_resources.h> and there's no way to
|
|
||||||
# suppress that exlusively
|
|
||||||
missingInclude:*
|
|
||||||
|
|
||||||
# Shut up. Just shut up.
|
|
||||||
unmatchedSuppression:*
|
|
||||||
|
|
||||||
# Do not check third-party libraries
|
|
||||||
*:*lib*
|
|
@ -1,65 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
usage=\
|
|
||||||
"Usage: use-cppcheck.sh
|
|
||||||
Run cppcheck with correct options.
|
|
||||||
|
|
||||||
Environment variables:
|
|
||||||
PARALLELISM threads to use, default is 1
|
|
||||||
|
|
||||||
CPPCHECK cppcheck executable
|
|
||||||
CMAKE cmake executable"
|
|
||||||
|
|
||||||
rsrc="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
|
|
||||||
source "$rsrc/../bashlib.sh"
|
|
||||||
|
|
||||||
find_cmd CPPCHECK cppcheck
|
|
||||||
find_cmd CMAKE cmake
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
-h | --help )
|
|
||||||
echo "$usage"
|
|
||||||
exit
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Generate compile database for CppCheck
|
|
||||||
command "$CMAKE" \
|
|
||||||
-B "$build_dir" \
|
|
||||||
-S "$source_dir" \
|
|
||||||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
|
||||||
|
|
||||||
compile_database="$build_dir/compile_commands.json"
|
|
||||||
|
|
||||||
mkdir -p "$build_dir/cppcheck"
|
|
||||||
|
|
||||||
options=()
|
|
||||||
|
|
||||||
while IFS='' read -r line; do
|
|
||||||
[ -z "$line" ] && continue
|
|
||||||
[ "${line:0:1}" = '#' ] && continue
|
|
||||||
|
|
||||||
option="$(
|
|
||||||
CMAKE_SOURCE_DIR="$source_dir" \
|
|
||||||
CMAKE_BINARY_DIR="$build_dir" \
|
|
||||||
envsubst <<<"$line"
|
|
||||||
)"
|
|
||||||
|
|
||||||
options+=("$option")
|
|
||||||
done < "$tools_dir/cppcheck/options.txt"
|
|
||||||
|
|
||||||
[ -n "${PARALLELISM+x}" ] && options+=(-j "$PARALLELISM")
|
|
||||||
|
|
||||||
errors="`
|
|
||||||
echo_and_run "$CPPCHECK" \
|
|
||||||
--project="$compile_database" \
|
|
||||||
-D__CPPCHECK__ \
|
|
||||||
"${options[@]}" \
|
|
||||||
2>&1 >/dev/fd/0 # Store stderr into variable, pass stdout to our stdout
|
|
||||||
`"
|
|
||||||
|
|
||||||
exit_code="$?"
|
|
||||||
if [ "$exit_code" -eq 2 ]; then
|
|
||||||
less - <<<"$errors"
|
|
||||||
exit "$exit_code"
|
|
||||||
fi
|
|
@ -1,51 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
me="$(realpath "${BASH_SOURCE[0]}")"
|
|
||||||
if [ "$(basename "$me")" = 'pre-commit' ]; then
|
|
||||||
# i write good shell scripts - Javapony 2022-10-07
|
|
||||||
root_dir="$(realpath "$(dirname "$me")/../../")"
|
|
||||||
|
|
||||||
hook_source="$root_dir/tools/git/hook_pre_commit.sh"
|
|
||||||
if [ "$hook_source" -nt "$me" ]; then
|
|
||||||
if [ -n "${ALREADY_UPDATED+x}" ]; then
|
|
||||||
echo >&2 "git pre-commit hook: Attempted recursive hook update. `
|
|
||||||
`Something is very wrong."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ''
|
|
||||||
echo "===== tools/git/hook_pre_commit.sh updated; `
|
|
||||||
`replacing pre-commit hook ====="
|
|
||||||
echo ''
|
|
||||||
|
|
||||||
cp "$hook_source" "$me" &&
|
|
||||||
chmod +x "$me" \
|
|
||||||
|| fail 'Update failed'
|
|
||||||
|
|
||||||
ALREADY_UPDATED=true "$me"
|
|
||||||
exit $?
|
|
||||||
fi
|
|
||||||
|
|
||||||
source "$root_dir/tools/bashlib.sh"
|
|
||||||
else
|
|
||||||
rsrc="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
|
|
||||||
source "$rsrc/../bashlib.sh"
|
|
||||||
fi
|
|
||||||
|
|
||||||
unstaged_changes="`git diff --name-only`"
|
|
||||||
if [ -n "$unstaged_changes" ]; then
|
|
||||||
fail "Please stage all stash all unstaged changes in the following files:
|
|
||||||
$unstaged_changes"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo_and_run "$tools_dir/cppcheck/use-cppcheck.sh" \
|
|
||||||
|| fail "Cppcheck has generated warnings, aborting commit"
|
|
||||||
|
|
||||||
echo_and_run "$tools_dir/clang-format/use-clang-format.sh" git \
|
|
||||||
|| fail "clang-format has failed, aborting commit"
|
|
||||||
|
|
||||||
echo_and_run "$tools_dir/build.sh" --dont-generate \
|
|
||||||
|| fail "Could not build project, aborting commit"
|
|
||||||
|
|
||||||
echo 'All checks passed'
|
|
||||||
|
|
146
tools/setup.sh
146
tools/setup.sh
@ -1,146 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
usage=\
|
|
||||||
"Usage: setup.sh [--for-development]
|
|
||||||
Set up the development environment after \`git clone\`
|
|
||||||
|
|
||||||
Options:
|
|
||||||
--for-development perform additional setup only necessary for developers
|
|
||||||
|
|
||||||
-h, --help display this help and exit"
|
|
||||||
|
|
||||||
rsrc="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
|
|
||||||
source "$rsrc/bashlib.sh" || {
|
|
||||||
echo >&2 'Could not load bashlib'
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
cd "$root_dir"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Parse arguments
|
|
||||||
|
|
||||||
for_development=''
|
|
||||||
|
|
||||||
for arg in "$@"; do
|
|
||||||
case "$arg" in
|
|
||||||
-h | --help )
|
|
||||||
echo "$usage"
|
|
||||||
exit
|
|
||||||
;;
|
|
||||||
--for-development )
|
|
||||||
for_development=true
|
|
||||||
;;
|
|
||||||
* )
|
|
||||||
fail "Unknown option '$arg'"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Сreate private.sh
|
|
||||||
|
|
||||||
if [ ! -e "$private_sh" ]; then
|
|
||||||
echo '#!/bin/bash
|
|
||||||
|
|
||||||
# This file is ignored by git. Use it to configure shell scripts in tools/
|
|
||||||
# for your development environment.
|
|
||||||
|
|
||||||
PARALLELISM=1
|
|
||||||
#PATH="$PATH:/opt/whatever"
|
|
||||||
' >"$private_sh" &&
|
|
||||||
chmod +x "$private_sh" ||
|
|
||||||
fail "tools/private.sh was not found; could not create it"
|
|
||||||
|
|
||||||
echo "Created tools/private.sh"
|
|
||||||
else
|
|
||||||
echo "Found and loaded private.sh"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Check available commands
|
|
||||||
|
|
||||||
failed=()
|
|
||||||
|
|
||||||
function check_cmd() {
|
|
||||||
if FAIL_SILENTLY=true find_cmd found "$@"; then
|
|
||||||
echo "Found command $found"
|
|
||||||
else
|
|
||||||
failed+=("command $1")
|
|
||||||
echo "Could not find command $1"
|
|
||||||
fi
|
|
||||||
unset found
|
|
||||||
}
|
|
||||||
|
|
||||||
check_cmd cmake
|
|
||||||
check_cmd python3
|
|
||||||
check_cmd glslc
|
|
||||||
|
|
||||||
if [ $for_development ]; then
|
|
||||||
check_cmd git
|
|
||||||
check_cmd cppcheck
|
|
||||||
check_cmd clang-format-13 clang-format
|
|
||||||
check_cmd clang-format-diff-13 clang-format-diff clang-format-diff.py
|
|
||||||
check_cmd valgrind
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Try generating build files
|
|
||||||
|
|
||||||
if FAIL_SILENTLY=true find_cmd CMAKE cmake; then
|
|
||||||
if CMAKE="$CMAKE" "$tools_dir/build.sh" --dont-build; then
|
|
||||||
echo 'CMake did not encounter any problems'
|
|
||||||
else
|
|
||||||
echo 'Could not generate build files; libraries are probably missing'
|
|
||||||
failed+=('some libraries, probably (see CMake messages for details)')
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo 'Skipping CMake test because cmake was not found'
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Display accumulated errors
|
|
||||||
|
|
||||||
[ ${#failed[@]} -ne 0 ] &&
|
|
||||||
fail "Could not find the following required commands or libraries:
|
|
||||||
|
|
||||||
`for f in "${failed[@]}"; do echo " $f"; done`
|
|
||||||
|
|
||||||
You can resolve these errors in the following ways:
|
|
||||||
1. Install required software packages. See README for specific instructions.
|
|
||||||
2. Edit PATH or CMAKE_MODULE_PATH environment variables in tools/private.sh
|
|
||||||
to include your installation directories.
|
|
||||||
"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Set executable flags
|
|
||||||
|
|
||||||
chmod -v +x tools/build.sh \
|
|
||||||
tools/embed/embed.py \
|
|
||||||
|| fail 'Could not make scripts executable'
|
|
||||||
|
|
||||||
if [ $for_development ]; then
|
|
||||||
chmod -v +x tools/clang-format/use-clang-format.sh \
|
|
||||||
tools/cppcheck/use-cppcheck.sh \
|
|
||||||
|| fail 'Could not make developer scripts executable'
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Set git hook
|
|
||||||
|
|
||||||
if [ $for_development ]; then
|
|
||||||
mkdir -vp .git/hooks &&
|
|
||||||
cp -v tools/git/hook_pre_commit.sh .git/hooks/pre-commit &&
|
|
||||||
chmod -v +x .git/hooks/pre-commit \
|
|
||||||
|| fail 'Could not setup git pre-commit hook'
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
echo 'Setup complete'
|
|
Loading…
x
Reference in New Issue
Block a user