File: util.sh

package info (click to toggle)
virglrenderer 0.8.2-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 58,348 kB
  • sloc: ansic: 46,856; sh: 1,062; python: 460; makefile: 274
file content (40 lines) | stat: -rwxr-xr-x 837 bytes parent folder | download | duplicates (2)
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
#!/bin/bash

# Try to find locally defined paths for external resources
CI_CONFIG="$HOME/.virgl-ci.conf"
if [ -f "$CI_CONFIG" ]; then
   . "$CI_CONFIG"
fi

# Test paths for existence, if found assign to variable
# try_paths() MESA_PATH ../mesa /mesa
try_paths()
{
   VARIABLE_NAME=$1
   shift
   for VARIABLE_PATH in "$@"
   do
      if [ -d "$VARIABLE_PATH" ]; then
         VARIABLE_PATH="$(realpath $VARIABLE_PATH)"
         eval "export $VARIABLE_NAME=\"$VARIABLE_PATH\""
         return
      fi
   done
}

PROJECT_PATH="$(dirname $(readlink -f "$0"))/../.."

try_paths VIRGL_PATH \
   "$VIRGL_PATH" \
   "/virglrenderer" \
   "${PROJECT_PATH}/virglrenderer"

try_paths CTS_PATH \
   "$CTS_PATH" \
   "/VK-GL-CTS" \
   "${PROJECT_PATH}/VK-GL-CTS"

try_paths MESA_PATH \
   "$MESA_PATH" \
   "/local_mesa" \
   "${PROJECT_PATH}/mesa"