Jason Macnak | cb5ce07 | 2023-12-08 12:59:15 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Copyright 2023 The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | set -o errexit |
| 18 | |
| 19 | WORKING_DIRECTORY="/tmp/gfxstream-nested-vulkan-loader" |
| 20 | if [ ! -z "$1" ]; then |
| 21 | WORKING_DIRECTORY=$1 |
| 22 | fi |
| 23 | |
| 24 | if [ ! -d $WORKING_DIRECTORY ]; then |
| 25 | echo "Creating working directory $WORKING_DIRECTORY." |
| 26 | mkdir -p $WORKING_DIRECTORY |
| 27 | cd $WORKING_DIRECTORY |
| 28 | git clone https://github.com/KhronosGroup/Vulkan-Loader.git . |
| 29 | git checkout -b v1.3.273 tags/v1.3.273 |
| 30 | else |
| 31 | echo "Reusing existing working directory $WORKING_DIRECTORY." |
| 32 | cd $WORKING_DIRECTORY |
| 33 | fi |
| 34 | |
| 35 | echo "Applying edits for Gfxstream." |
| 36 | VK_LOADER_ENV_VARS=( |
| 37 | "VK_ADD_DRIVER_FILES" |
| 38 | "VK_ADD_LAYER_PATH" |
| 39 | "VK_DRIVER_FILES" |
| 40 | "VK_ICD_FILENAMES" |
| 41 | "VK_INSTANCE_LAYERS" |
| 42 | "VK_LAYER_PATH" |
| 43 | "VK_LAYER_PATH" |
| 44 | "VK_LOADER_DEBUG" |
| 45 | "VK_LOADER_DRIVERS_DISABLE" |
| 46 | "VK_LOADER_DRIVERS_SELECT" |
| 47 | "VK_LOADER_LAYERS_ALLOW" |
| 48 | "VK_LOADER_LAYERS_DISABLE" |
| 49 | "VK_LOADER_LAYERS_ENABLE" |
| 50 | ) |
| 51 | for var in ${VK_LOADER_ENV_VARS[@]}; do |
| 52 | echo "- Replacing occurrences of \"$var\" with \"GFXSTREAM_$var\"." |
| 53 | sed -i -e "s/\\\"$var\\\"/\\\"GFXSTREAM_$var\\\"/g" loader/*.c |
| 54 | sed -i -e "s/\\\"$var\\\"/\\\"GFXSTREAM_$var\\\"/g" loader/*.h |
| 55 | done |
| 56 | echo "- Adding in \"GFXSTREAM\" prefix to logging." |
| 57 | sed -i -e "s/ fputs(cmd_line_msg, stderr);/ fputs(\\\"GFXSTREAM-LOADER: \\\", stderr); fputs(cmd_line_msg, stderr);/g" loader/log.c |
| 58 | |
| 59 | if [ ! -d build ]; then |
| 60 | echo "Creating build directory." |
| 61 | mkdir build |
| 62 | cd build |
| 63 | python ../scripts/update_deps.py |
| 64 | cmake -C helper.cmake -D CMAKE_BUILD_TYPE=Debug .. |
| 65 | else |
| 66 | echo "Reusing existing build directory." |
| 67 | cd build |
| 68 | fi |
| 69 | |
| 70 | echo "Building." |
| 71 | cmake --build . |
| 72 | |
| 73 | cp loader/libvulkan.so loader/libvulkan_gfxstream.so |
| 74 | |
| 75 | echo "Use export LD_LIBRARY_PATH=\"\$LD_LIBRARY_PATH:$(pwd)/loader\" to add to your path." |