forked from spatialos/UnrealGDK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Setup.bat
166 lines (135 loc) · 9.18 KB
/
Setup.bat
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
@echo off
if not defined NO_SET_LOCAL (
setlocal
)
pushd "%~dp0"
call :MarkStartOfBlock "%~0"
call :MarkStartOfBlock "Setup the git hooks"
if not exist .git\hooks goto SkipGitHooks
rem Remove the old post-checkout hook.
if exist .git\hooks\post-checkout del .git\hooks\post-checkout
rem Remove the old post-merge hook.
if exist .git\hooks\post-merge del .git\hooks\post-merge
rem Add git hook to run Setup.bat when RequireSetup file has been updated.
echo #!/usr/bin/env bash>.git\hooks\post-merge
echo changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)">>.git\hooks\post-merge
echo check_run() {>>.git\hooks\post-merge
echo echo "$changed_files" ^| grep --quiet "$1" ^&^& exec $2>>.git\hooks\post-merge
echo }>>.git\hooks\post-merge
echo check_run RequireSetup "cmd.exe /c Setup.bat">>.git\hooks\post-merge
:SkipGitHooks
call :MarkEndOfBlock "Setup the git hooks"
call :MarkStartOfBlock "Check dependencies"
call "%~dp0SpatialGDK\Build\Scripts\FindMSBuild.bat"
if not defined MSBUILD_EXE (
echo Error: Could not find the MSBuild executable. Please make sure you have Microsoft Visual Studio or Microsoft Build Tools installed.
pause
exit /b 1
)
where spatial >nul
if ERRORLEVEL 1 (
echo Error: Could not find spatial. Please make sure you have it installed and the containing directory added to PATH environment variable.
pause
exit /b 1
)
call :MarkEndOfBlock "Check dependencies"
call :MarkStartOfBlock "Setup variables"
set /p PINNED_CORE_SDK_VERSION=<.\SpatialGDK\Extras\core-sdk.version
set /p PINNED_SPOT_VERSION=<.\SpatialGDK\Extras\spot.version
set BUILD_DIR=%~dp0SpatialGDK\Build
set CORE_SDK_DIR=%BUILD_DIR%\core_sdk
set WORKER_SDK_DIR=%~dp0SpatialGDK\Source\SpatialGDK\Public\WorkerSDK
set WORKER_SDK_DIR_OLD=%~dp0SpatialGDK\Source\Public\WorkerSdk
set BINARIES_DIR=%~dp0SpatialGDK\Binaries\ThirdParty\Improbable
rem Copy schema to the projects spatial directory.
set SCHEMA_COPY_DIR=%~dp0..\..\..\spatial\schema\unreal\gdk
set SCHEMA_STD_COPY_DIR=%~dp0..\..\..\spatial\build\dependencies\schema\standard_library
set SPATIAL_DIR=%~dp0..\..\..\spatial
set DOMAIN_ENVIRONMENT_VAR=
set DOWNLOAD_MOBILE=
for %%A in (%*) do (
if "%%A"=="--china" set DOMAIN_ENVIRONMENT_VAR=--environment cn-production
if "%%A"=="--mobile" set DOWNLOAD_MOBILE=True
)
call :MarkEndOfBlock "Setup variables"
call :MarkStartOfBlock "Clean folders"
rd /s /q "%CORE_SDK_DIR%" 2>nul
rd /s /q "%WORKER_SDK_DIR%" 2>nul
rd /s /q "%WORKER_SDK_DIR_OLD%" 2>nul
rd /s /q "%BINARIES_DIR%" 2>nul
if exist "%SPATIAL_DIR%" (
rd /s /q "%SCHEMA_STD_COPY_DIR%" 2>nul
rd /s /q "%SCHEMA_COPY_DIR%" 2>nul
)
call :MarkEndOfBlock "Clean folders"
call :MarkStartOfBlock "Create folders"
md "%WORKER_SDK_DIR%" >nul 2>nul
md "%CORE_SDK_DIR%\schema" >nul 2>nul
md "%CORE_SDK_DIR%\tools" >nul 2>nul
md "%CORE_SDK_DIR%\worker_sdk" >nul 2>nul
md "%BINARIES_DIR%" >nul 2>nul
md "%BINARIES_DIR%\Android" >nul 2>nul
md "%BINARIES_DIR%\Programs" >nul 2>nul
if exist "%SPATIAL_DIR%" (
md "%SCHEMA_STD_COPY_DIR%" >nul 2>nul
md "%SCHEMA_COPY_DIR%" >nul 2>nul
)
call :MarkEndOfBlock "Create folders"
call :MarkStartOfBlock "Retrieve dependencies"
spatial package retrieve tools schema_compiler-x86_64-win32 %PINNED_CORE_SDK_VERSION% %DOMAIN_ENVIRONMENT_VAR% "%CORE_SDK_DIR%\tools\schema_compiler-x86_64-win32.zip"
spatial package retrieve schema standard_library %PINNED_CORE_SDK_VERSION% %DOMAIN_ENVIRONMENT_VAR% "%CORE_SDK_DIR%\schema\standard_library.zip"
spatial package retrieve worker_sdk c_headers %PINNED_CORE_SDK_VERSION% %DOMAIN_ENVIRONMENT_VAR% "%CORE_SDK_DIR%\worker_sdk\c_headers.zip"
spatial package retrieve worker_sdk c-dynamic-x86-vc141_md-win32 %PINNED_CORE_SDK_VERSION% %DOMAIN_ENVIRONMENT_VAR% "%CORE_SDK_DIR%\worker_sdk\c-dynamic-x86-vc141_md-win32.zip"
spatial package retrieve worker_sdk c-dynamic-x86_64-vc141_md-win32 %PINNED_CORE_SDK_VERSION% %DOMAIN_ENVIRONMENT_VAR% "%CORE_SDK_DIR%\worker_sdk\c-dynamic-x86_64-vc141_md-win32.zip"
spatial package retrieve worker_sdk c-dynamic-x86_64-gcc510-linux %PINNED_CORE_SDK_VERSION% %DOMAIN_ENVIRONMENT_VAR% "%CORE_SDK_DIR%\worker_sdk\c-dynamic-x86_64-gcc510-linux.zip"
if defined DOWNLOAD_MOBILE (
spatial package retrieve worker_sdk c-static-fullylinked-arm-clang-ios %PINNED_CORE_SDK_VERSION% %DOMAIN_ENVIRONMENT_VAR% "%CORE_SDK_DIR%\worker_sdk\c-static-fullylinked-arm-clang-ios.zip"
spatial package retrieve worker_sdk c-dynamic-arm64v8a-clang_ndk16b-android %PINNED_CORE_SDK_VERSION% %DOMAIN_ENVIRONMENT_VAR% "%CORE_SDK_DIR%\worker_sdk\c-dynamic-arm64v8a-clang_ndk16b-android.zip"
spatial package retrieve worker_sdk c-dynamic-armv7a-clang_ndk16b-android %PINNED_CORE_SDK_VERSION% %DOMAIN_ENVIRONMENT_VAR% "%CORE_SDK_DIR%\worker_sdk\c-dynamic-armv7a-clang_ndk16b-android.zip"
spatial package retrieve worker_sdk c-dynamic-x86_64-clang_ndk16b-android %PINNED_CORE_SDK_VERSION% %DOMAIN_ENVIRONMENT_VAR% "%CORE_SDK_DIR%\worker_sdk\c-dynamic-x86_64-clang_ndk16b-android.zip"
)
spatial package retrieve worker_sdk csharp %PINNED_CORE_SDK_VERSION% %DOMAIN_ENVIRONMENT_VAR% "%CORE_SDK_DIR%\worker_sdk\csharp.zip"
spatial package retrieve spot spot-win64 %PINNED_SPOT_VERSION% %DOMAIN_ENVIRONMENT_VAR% "%BINARIES_DIR%\Programs\spot.exe"
call :MarkEndOfBlock "Retrieve dependencies"
call :MarkStartOfBlock "Unpack dependencies"
powershell -Command "Expand-Archive -Path \"%CORE_SDK_DIR%\worker_sdk\c_headers.zip\" -DestinationPath \"%BINARIES_DIR%\Headers\" -Force; "^
"Expand-Archive -Path \"%CORE_SDK_DIR%\worker_sdk\c-dynamic-x86-vc141_md-win32.zip\" -DestinationPath \"%BINARIES_DIR%\Win32\" -Force; "^
"Expand-Archive -Path \"%CORE_SDK_DIR%\worker_sdk\c-dynamic-x86_64-vc141_md-win32.zip\" -DestinationPath \"%BINARIES_DIR%\Win64\" -Force; "^
"Expand-Archive -Path \"%CORE_SDK_DIR%\worker_sdk\c-dynamic-x86_64-gcc510-linux.zip\" -DestinationPath \"%BINARIES_DIR%\Linux\" -Force; "^
"Expand-Archive -Path \"%CORE_SDK_DIR%\worker_sdk\csharp.zip\" -DestinationPath \"%BINARIES_DIR%\Programs\worker_sdk\csharp\" -Force; "^
"Expand-Archive -Path \"%CORE_SDK_DIR%\tools\schema_compiler-x86_64-win32.zip\" -DestinationPath \"%BINARIES_DIR%\Programs\" -Force; "^
"Expand-Archive -Path \"%CORE_SDK_DIR%\schema\standard_library.zip\" -DestinationPath \"%BINARIES_DIR%\Programs\schema\" -Force;"
if defined DOWNLOAD_MOBILE (
powershell -Command "Expand-Archive -Path \"%CORE_SDK_DIR%\worker_sdk\c-static-fullylinked-arm-clang-ios.zip\" -DestinationPath \"%BINARIES_DIR%\IOS\" -Force;"^
"Expand-Archive -Path \"%CORE_SDK_DIR%\worker_sdk\c-dynamic-arm64v8a-clang_ndk16b-android.zip\" -DestinationPath \"%BINARIES_DIR%\Android\arm64-v8a\" -Force; "^
"Expand-Archive -Path \"%CORE_SDK_DIR%\worker_sdk\c-dynamic-armv7a-clang_ndk16b-android.zip\" -DestinationPath \"%BINARIES_DIR%\Android\armeabi-v7a\" -Force; "^
"Expand-Archive -Path \"%CORE_SDK_DIR%\worker_sdk\c-dynamic-x86_64-clang_ndk16b-android.zip\" -DestinationPath \"%BINARIES_DIR%\Android\x86_64\" -Force; "^
)
xcopy /s /i /q "%BINARIES_DIR%\Headers\include" "%WORKER_SDK_DIR%"
call :MarkEndOfBlock "Unpack dependencies"
if exist "%SPATIAL_DIR%" (
call :MarkStartOfBlock "Copy standard library schema"
echo Copying standard library schemas to "%SCHEMA_STD_COPY_DIR%"
xcopy /s /i /q "%BINARIES_DIR%\Programs\schema" "%SCHEMA_STD_COPY_DIR%"
call :MarkEndOfBlock "Copy standard library schema"
call :MarkStartOfBlock "Copy GDK schema"
echo Copying schemas to "%SCHEMA_COPY_DIR%".
xcopy /s /i /q "%~dp0\SpatialGDK\Extras\schema" "%SCHEMA_COPY_DIR%"
call :MarkEndOfBlock "Copy GDK schema"
)
call :MarkStartOfBlock "Build C# utilities"
%MSBUILD_EXE% /nologo /verbosity:minimal .\SpatialGDK\Build\Programs\Improbable.Unreal.Scripts\Improbable.Unreal.Scripts.sln /property:Configuration=Release /restore
call :MarkEndOfBlock "Build C# utilities"
call :MarkEndOfBlock "%~0"
popd
echo UnrealGDK build completed successfully^!
if not defined NO_PAUSE (
pause
)
exit /b %ERRORLEVEL%
:MarkStartOfBlock
echo Starting: %~1
exit /b 0
:MarkEndOfBlock
echo Finished: %~1
exit /b 0