blob: b67362e72f4ec19885bca07eb6a797a8e6c69f4f [file] [log] [blame]
Jason Macnakcb5ce072023-12-08 12:59:15 -08001#!/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
17set -o errexit
18
19WORKING_DIRECTORY="/tmp/gfxstream-nested-vulkan-loader"
20if [ ! -z "$1" ]; then
21 WORKING_DIRECTORY=$1
22fi
23
24if [ ! -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
30else
31 echo "Reusing existing working directory $WORKING_DIRECTORY."
32 cd $WORKING_DIRECTORY
33fi
34
35echo "Applying edits for Gfxstream."
36VK_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)
51for 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
55done
56echo "- Adding in \"GFXSTREAM\" prefix to logging."
57sed -i -e "s/ fputs(cmd_line_msg, stderr);/ fputs(\\\"GFXSTREAM-LOADER: \\\", stderr); fputs(cmd_line_msg, stderr);/g" loader/log.c
58
59if [ ! -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 ..
65else
66 echo "Reusing existing build directory."
67 cd build
68fi
69
70echo "Building."
71cmake --build .
72
73cp loader/libvulkan.so loader/libvulkan_gfxstream.so
74
75echo "Use export LD_LIBRARY_PATH=\"\$LD_LIBRARY_PATH:$(pwd)/loader\" to add to your path."