blob: 8eb7744a2cfd065dde4e8d10d1ab463869cc3d73 [file] [log] [blame]
Nicolas Capens4c9f04b2019-01-31 22:09:03 -05001#!/bin/bash
2
3# This shell script is for (re)generating Visual Studio project files from CMake
4# files, making them path relative so they can be checked into the repository.
5
6# exit when any command fails
7set -e
8
9if [[ "$OSTYPE" != "msys" ]]; then
10 echo This script is meant for generation of path relative Visual Studio project
11 echo files from CMake. It should be run from an MSYS/MinGW bash shell, such as
12 echo the one that comes with Git for Windows.
13 exit 1
14fi
15
16CMAKE_GENERATOR="Visual Studio 15 2017 Win64"
17
18CMAKE_BUILD_PATH="build/$CMAKE_GENERATOR"
19
20if [ ! -d "$CMAKE_BUILD_PATH" ]; then
21 mkdir -p "$CMAKE_BUILD_PATH"
22fi
23cd "$CMAKE_BUILD_PATH"
24
25cmake -G"$CMAKE_GENERATOR" \
26 -Thost=x64 \
27 -DSPIRV-Headers_SOURCE_DIR="${CMAKE_HOME_DIRECTORY}/third_party/SPIRV-Headers" \
28 -DCMAKE_CONFIGURATION_TYPES="Debug;Release" \
29 -DSKIP_SPIRV_TOOLS_INSTALL=true \
30 -DSPIRV_SKIP_EXECUTABLES=true \
31 -DSPIRV_SKIP_TESTS=true \
32 ../..
33
34cd ../..
35
36echo Making project files path relative. This might take a minute.
37
38# Current directory with forward slashes
39CD=$(pwd -W)/
40# Current directory with (escaped) backslashes
41CD2=$(echo $(pwd -W) | sed 's?/?\\\\?g')\\\\
42# Phython executable path
43PYTHON=$(where python | head --lines=1 | sed 's?\\?\\\\?g')
44# CMake executable path
45CMAKE=$(where cmake | head --lines=1 | sed 's?\\?\\\\?g')
46
47find . -type f \( -name \*.vcxproj -o -name \*.vcxproj.filters -o -name \*.sln \) \
48 -execdir sed --in-place --binary --expression="s?$CD?\$(SolutionDir)?g" {} \
49 --expression="s?$CD2?\$(SolutionDir)?g" {} \
50 --expression="s?$PYTHON?python?g" {} \
Nicolas Capens73c31242019-02-12 00:09:23 -050051 --expression="s?$CMAKE?cmake?g" {} \
52 --expression="s?MultiThreadedDebugDLL?MultiThreadedDebug?g" {} \
53 --expression="s?MultiThreadedDLL?MultiThreaded?g" {} \;