aboutsummaryrefslogtreecommitdiff
path: root/arnold/mkwin.bat
blob: c526e0d1f37116fbbe28f85c3333e843adc82fc9 (plain) (blame)
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
167
168
169
170
171
172
173
174
175
@echo off

rem  Shave and a Haircut
rem  (c) 2019 Epic Games
rem  US Patent 6720962

set result=0
setlocal

if "%~1"=="" (
    echo No maya version provided.
    goto error
)

if not defined SHAVE_ARNOLD_SDKS (
    echo SHAVE_ARNOLD_SDKS not defined. Shave will be built without Arnold support.
    goto error
)

call ..\utils\splitMayaVersion %1
set mayaCompactVersion=%mayaVersionMajor%%mayaVersionMinor%
call ..\utils\getVSVersion

if %vsVersion%==vs11 (
    call "%VS110COMNTOOLS%\..\..\VC\bin\x86_amd64\vcvarsx86_amd64.bat"
) else if %vsVersion%==vs14 (
    call "%VS140COMNTOOLS%\..\..\VC\bin\x86_amd64\vcvarsx86_amd64.bat"
) else (
    goto error
)

rem  Clean out any old builds
rem
set target=Release\%mayaVersion%
if exist "%target%" rmdir /s /q "%target%"

rem  Find all the ranges of MtoA/Arnold which we support for this version of
rem  Maya and build the plugins for them.
rem
for /f "tokens=1,*" %%i in ('findstr "^%mayaVersion%:" supportedMtoAVersions.txt') do call :buildRange %%j
if errorlevel 1 goto error
goto done

rem -----------------------------------------------------------------------

:buildRange

set minVer=%1
set maxVer=%2
set buildVer=%3

for /f "tokens=1 delims=/" %%i in ("%minVer%") do set mtoaMin=%%i
set arnoldMin=%minVer:*/=%

for /f "tokens=1 delims=/" %%i in ("%maxVer%") do set mtoaMax=%%i
set arnoldMax=%maxVer:*/=%

for /f "tokens=1 delims=/" %%i in ("%buildVer%") do set mtoaBuild=%%i
set arnoldBuild=%buildVer:*/=%

set safeMtoABuild=%mtoaBuild:.=_%
set safeArnoldBuild=%arnoldBuild:.=_%

set arnoldPath=%SHAVE_ARNOLD_SDKS%\arnold\%arnoldBuild%\win
set mtoaPath=%SHAVE_ARNOLD_SDKS%\mtoa\%mtoaBuild%\maya%mayaVersion%\win

set OUTDIR=Release\%mayaVersion%\%mtoaBuild%

if not exist %OUTDIR% mkdir %OUTDIR%

cl /Fo%OUTDIR%\plugin.obj ^
	/c plugin\plugin.cpp ^
	/TP /nologo /W3 /wd 4005 /EHsc /Gd /fp:precise /Ob2 /GL /MD /Ox ^
	/DENABLE_COLOR_MANAGEMENT /DNDEBUG /D_CRT_SECURE_NO_WARNINGS ^
	/DENABLE_XGEN /DENABLE_VP2 /DENABLE_BIFROST /DENABLE_LOOKDEVKIT ^
	/DENABLE_RENDERSETUP /D_WINDOWS /D_WIN32 /DWIN32 /D_WIN64 /DNT_PLUGIN ^
	/DREQUIRE_IOSTREAM ^
	/I..\mayaPlug ^
	/I%arnoldPath%\include ^
	/Iplugin ^
	/I..\maya\devkits\%mayaVersion%\win\devkitBase\include ^
	"/IC:\Program Files\Autodesk\Maya%mayaVersion%\include" ^
	/I%mtoaPath%\include
if errorlevel 1 exit /b %errorlevel%

cl /Fo%OUTDIR%\ShaveAndHaircut.obj ^
	/c plugin\ShaveAndHaircut.cpp ^
	/TP /nologo /W3 /wd 4005 /EHsc /Gd /fp:precise /Ob2 /GL /MD /Ox ^
	/DENABLE_COLOR_MANAGEMENT /DNDEBUG /D_CRT_SECURE_NO_WARNINGS ^
	/DENABLE_XGEN /DENABLE_VP2 /DENABLE_BIFROST /DENABLE_LOOKDEVKIT ^
	/DENABLE_RENDERSETUP /D_WINDOWS /D_WIN32 /DWIN32 /D_WIN64 /DNT_PLUGIN ^
	/DREQUIRE_IOSTREAM ^
	/I..\mayaPlug ^
	/I%arnoldPath%\include ^
	/Iplugin ^
	/I..\maya\devkits\%mayaVersion%\win\devkitBase\include ^
	"/IC:\Program Files\Autodesk\Maya%mayaVersion%\include" ^
	/I%mtoaPath%\include
if errorlevel 1 exit /b %errorlevel%

link /nologo /MANIFEST /LTCG /dll ^
	/out:%OUTDIR%\shave.dll ^
	/implib:%OUTDIR%\shave.lib ^
	/LIBPATH:%mtoaPath%\lib ^
	/LIBPATH:%arnoldPath%\lib ^
	/LIBPATH:..\raw64\release\%mayaCompactVersion% ^
	"/LIBPATH:C:\Program Files\Autodesk\Maya%mayaVersion%\lib" ^
	ai.lib mtoa_api.lib libShaveAPI.lib ^
	OpenGl32.lib Foundation.lib OpenMaya.lib OpenMayaRender.lib ^
	OpenMayaUI.lib OpenMayaAnim.lib OpenMayaFX.lib shell32.lib ^
	%OUTDIR%\plugin.obj %OUTDIR%\ShaveAndHaircut.obj
if errorlevel 1 exit /b %errorlevel%

mt.exe -nologo -manifest %OUTDIR%\shave.dll.manifest ^
	-outputresource:%OUTDIR%\shave.dll;2
if errorlevel 1 exit /b %errorlevel%

cl /Fo%OUTDIR%\ShaveHair.obj ^
	/c shaders\ShaveHair.cpp ^
	/DMIN_ARNOLD_VERSION=%arnoldMin% /DMAX_ARNOLD_VERSION=%arnoldMax% ^
	/TP /nologo /W3 /wd 4005 /EHsc /Gd /fp:precise /Ob2 /GL /MD /Od /Zi ^
	/DENABLE_COLOR_MANAGEMENT /DNDEBUG /D_CRT_SECURE_NO_WARNINGS ^
	/DENABLE_XGEN /DENABLE_VP2 /DENABLE_BIFROST /DENABLE_LOOKDEVKIT ^
	/DENABLE_RENDERSETUP /D_WINDOWS /D_WIN32 /DWIN32 /D_WIN64 ^
	/I%arnoldPath%\include
if errorlevel 1 exit /b %errorlevel%

link /nologo /MANIFEST /LTCG /dll /DEBUG ^
	/out:%OUTDIR%\shave_shaders-%safeArnoldBuild%.dll ^
	/implib:%OUTDIR%\shave_shaders-%safeArnoldBuild%.lib ^
	/LIBPATH:%arnoldPath%\lib ^
	ai.lib ^
	%OUTDIR%\ShaveHair.obj
if errorlevel 1 exit /b %errorlevel%

mt.exe -nologo -manifest %OUTDIR%\shave_shaders-%safeArnoldBuild%.dll.manifest ^
	-outputresource:%OUTDIR%\shave_shaders-%safeArnoldBuild%.dll;2
if errorlevel 1 exit /b %errorlevel%
exit /b

rem -----------------------------------------------------------------------

:cleanVersions
if "%1"=="" exit /b

rem  Each version is in the form:
rem
rem     mtoaVersion:arnoldVersion
rem
rem  We need to split out the mtoaVersion
rem
for /f "tokens=1,2 delims=:" %%i in ("%1") do call :cleanOneVersion %%i
if errorlevel 1 exit /b %errorlevel%
shift
goto :cleanVersions

rem -----------------------------------------------------------------------

:cleanOneVersion
if "%1"=="" exit /b

set target=Release\%mayaVersion%\%1

if exist "%target%" rmdir /s /q "%target%"
exit /b

rem -----------------------------------------------------------------------

:error
endlocal
set result=1
goto :eof

:done
endlocal