• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1@rem Copyright 2021 The Tint Authors.
2@rem
3@rem Licensed under the Apache License, Version 2.0 (the "License");
4@rem you may not use this file except in compliance with the License.
5@rem You may obtain a copy of the License at
6@rem
7@rem     http://www.apache.org/licenses/LICENSE-2.0
8@rem
9@rem Unless required by applicable law or agreed to in writing, software
10@rem distributed under the License is distributed on an "AS IS" BASIS,
11@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12@rem See the License for the specific language governing permissions and
13@rem limitations under the License.
14
15@echo off
16SETLOCAL ENABLEDELAYEDEXPANSION
17
18goto :main
19
20:task_begin
21set TASK_NAME=%~1
22echo %TASK_NAME% starting at %Time%
23exit /b 0
24
25:print_last_task_duration
26if not "%TASK_NAME%" == "" (
27    echo %TASK_NAME% completed at %Time%
28)
29exit /b 0
30
31:status
32echo.
33echo.
34call :print_last_task_duration
35echo.
36echo *****************************************************************
37echo %~1
38echo *****************************************************************
39echo.
40call :task_begin "%~1"
41exit /b 0
42
43:main
44
45set ORIGINAL_SRC_DIR= %~dp0\..\..
46set TEMP_DIR=%TEMP%\tint-temp
47set SRC_DIR="%TEMP_DIR%\tint-src"
48set BUILD_DIR="%TEMP_DIR%\tint-build"
49
50cd /d %ORIGINAL_SRC_DIR%
51if not exist ".git\" (
52    echo "ORIGINAL_SRC_DIR should point to project root: %ORIGINAL_SRC_DIR%"
53    goto :error
54)
55
56if exist %TEMP_DIR% (
57    call :status "Deleting %TEMP_DIR%"
58    del /q/f/s %TEMP_DIR% > NUL || goto :error
59    rmdir /q/s %TEMP_DIR% > NUL || goto :error
60)
61mkdir %TEMP_DIR% || goto :error
62
63call :status "Fetching DXC"
64@echo on
65set DXC_LATEST_ARTIFACT="https://ci.appveyor.com/api/projects/dnovillo/directxshadercompiler/artifacts/build%%2FRelease%%2Fdxc-artifacts.zip?branch=master&pr=false&job=image%%3A%%20Visual%%20Studio%%202019"
66curl -L %DXC_LATEST_ARTIFACT% --output "%TEMP_DIR%\dxc.zip" || goto :error
67@echo off
68
69call :status "Unpacking DXC"
70@echo on
71powershell.exe -Command "Expand-Archive -LiteralPath '%TEMP_DIR%\dxc.zip' -DestinationPath '%TEMP_DIR%\dxc'" || goto :error
72set PATH=%TEMP_DIR%\dxc\bin;%PATH%
73@echo off
74
75call :status "Installing depot_tools"
76@echo on
77pushd %TEMP_DIR%
78rem For Windows, we must download and extract a bundle.
79rem See https://chromium.googlesource.com/chromium/src/+/HEAD/docs/windows_build_instructions.md#install
80powershell -Command "(New-Object Net.WebClient).DownloadFile('https://storage.googleapis.com/chrome-infra/depot_tools.zip', 'depot_tools.zip')" || goto :error
81powershell -Command "Expand-Archive -Force 'depot_tools.zip' 'depot_tools'" || goto :error
82rem Run gclient once to install deps
83set PATH=%TEMP_DIR%\depot_tools;%PATH%
84set DEPOT_TOOLS_UPDATE=1
85set DEPOT_TOOLS_WIN_TOOLCHAIN=0
86call gclient || goto :error
87@echo off
88popd
89
90call :status "Cloning to clean source directory"
91@echo on
92mkdir %SRC_DIR% || goto :error
93cd /d %SRC_DIR% || goto :error
94call git clone %ORIGINAL_SRC_DIR% . || goto :error
95@echo off
96
97call :status "Fetching dependencies"
98@echo on
99copy standalone.gclient .gclient || goto :error
100call gclient sync || goto :error
101@echo off
102
103call :status "Configuring build system"
104@echo on
105mkdir %BUILD_DIR%
106cd /d %BUILD_DIR%
107set COMMON_CMAKE_FLAGS=-DTINT_BUILD_DOCS=O
108@echo off
109
110call :status "Building tint"
111@echo on
112rem Disable msbuild "Intermediate or Output directory cannot reside in Temporary directory"
113set IgnoreWarnIntDirInTempDetected=true
114rem Add Python3 to path as this Kokoro image only has Python2 in it
115set PATH=C:\Python37;%PATH%
116cmake %SRC_DIR% %CMAKE_FLAGS% %COMMON_CMAKE_FLAGS% || goto :error
117cmake --build . --config %BUILD_TYPE% || goto :error
118@echo off
119
120call :status "Running tint_unittests"
121@echo on
122%BUILD_TYPE%\tint_unittests.exe || goto :error
123@echo off
124
125call :status "Testing test/test-all.sh"
126@echo on
127cd /d %SRC_DIR% || goto :error
128set PATH=C:\Program Files\Metal Developer Tools\macos\bin;%PATH%
129where metal.exe
130git bash -- ./test/test-all.sh ../tint-build/%BUILD_TYPE%/tint.exe --verbose
131@echo off
132
133call :status "Done"
134exit /b 0
135
136:error
137echo BUILD FAILED! errorlevel: %errorlevel%
138exit /b %errorlevel%
139