forked from NVIDIA/Audio2Face-3D-SDK
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_sample.sh
More file actions
executable file
·79 lines (71 loc) · 2.45 KB
/
Copy pathrun_sample.sh
File metadata and controls
executable file
·79 lines (71 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
# Set the base directories.
BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BUILD_DIR="$BASE_DIR/_build"
TARGET_DEPS="$BASE_DIR/_deps/target-deps"
# Detect release or debug mode from the first argument, remove it from the command.
if [[ "$1" == "debug" ]]; then
BUILD_TYPE="debug"
shift
DEBUG_DIR="${BUILD_DIR}/debug/"
if [[ ! -d "$DEBUG_DIR" ]]; then
echo "Debug build directory does not exist: $DEBUG_DIR"
echo "Please run \`build.sh all debug\` first."
exit 1
fi
elif [[ "$1" == "release" ]]; then
BUILD_TYPE="release"
shift
RELEASE_DIR="${BUILD_DIR}/release/"
if [[ ! -d "$RELEASE_DIR" ]]; then
echo "Release build directory does not exist: $RELEASE_DIR"
echo "Please run \`build.sh all release\` first."
exit 1
fi
fi
# If BUILD_TYPE is not set, check if only one of the build directories exists and set BUILD_TYPE accordingly.
if [[ -z "$BUILD_TYPE" ]]; then
RELEASE_DIR="${BUILD_DIR}/release/"
DEBUG_DIR="${BUILD_DIR}/debug/"
if [[ -d "$RELEASE_DIR" && ! -d "$DEBUG_DIR" ]]; then
BUILD_TYPE="release"
elif [[ -d "$DEBUG_DIR" && ! -d "$RELEASE_DIR" ]]; then
BUILD_TYPE="debug"
elif [[ -d "$RELEASE_DIR" && -d "$DEBUG_DIR" ]]; then
# Default to release if both build directories exist and no argument is provided.
BUILD_TYPE="release"
else
echo "No build directory exists. Please run \`build.sh all\` first."
exit 1
fi
fi
export PATH="${BUILD_DIR}/${BUILD_TYPE}/audio2x-sdk/bin:${PATH}"
export PYTHONPATH="${BASE_DIR}/audio2x-common/scripts:${PYTHONPATH}"
# Add CUDA bin dir to PATH if CUDA_PATH is defined
if [ -n "${CUDA_PATH}" ]; then
export PATH="${CUDA_PATH}/bin:${PATH}"
else
echo CUDA_PATH is not defined
exit 1
fi
# Add TensorRT lib dir to PATH if TENSORRT_ROOT_DIR is defined
if [ -n "${TENSORRT_ROOT_DIR}" ]; then
export PATH="${TENSORRT_ROOT_DIR}/lib:${PATH}"
else
echo TENSORRT_ROOT_DIR is not defined
exit 1
fi
# If the first argument is not a file, try to find the corresponding executable in the build directory.
if [ ! -f "$1" ]; then
RELATIVE_PATH="${BUILD_DIR}/${BUILD_TYPE}/"
if [ -f "$RELATIVE_PATH/$1" ]; then
exec "$RELATIVE_PATH/$1" "${@:2}"
else
echo "Error: Found neither an absolute path:"
echo " $1"
echo "nor a relative path to the build directory:"
echo " $ALT_CMD"
exit 1
fi
fi
exec "$@"