-
Notifications
You must be signed in to change notification settings - Fork 128
Expand file tree
/
Copy pathbuild_solvers.bat
More file actions
135 lines (116 loc) · 4 KB
/
build_solvers.bat
File metadata and controls
135 lines (116 loc) · 4 KB
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
@echo off
setlocal
:: ============================================================================
:: build_solvers.bat -- Build mGear Maya solver plugins (.mll)
::
:: Usage:
:: build_solvers.bat (auto-detect Maya 2022-2027)
:: build_solvers.bat 2027 (target a specific Maya version)
:: build_solvers.bat clean (delete build folder and rebuild)
:: build_solvers.bat clean 2027 (clean + specific version)
:: ============================================================================
set "SCRIPT_DIR=%~dp0"
if "%SCRIPT_DIR:~-1%"=="\" set "SCRIPT_DIR=%SCRIPT_DIR:~0,-1%"
set "CMAKE_DIR=%SCRIPT_DIR%\cmake"
set "SRC_DIR=%SCRIPT_DIR%\src"
:: ----- Parse arguments -----------------------------------------------------
set "MAYA_VER="
set "DO_CLEAN=0"
if /i "%~1"=="clean" (
set "DO_CLEAN=1"
if not "%~2"=="" set "MAYA_VER=%~2"
) else if not "%~1"=="" (
set "MAYA_VER=%~1"
)
:: ----- Auto-detect Maya version if not specified ---------------------------
if "%MAYA_VER%"=="" (
for %%V in (2027 2026 2025 2024 2023 2022) do (
if exist "C:\Program Files\Autodesk\Maya%%V\include\maya\MFn.h" (
set "MAYA_VER=%%V"
goto :found_maya
)
)
echo.
echo ERROR: Could not find a Maya SDK installation.
echo Pass the version as argument: build_solvers.bat 2027
echo.
exit /b 1
)
:found_maya
:: ----- Determine Visual Studio generator -----------------------------------
:: Maya 2022-2024 were built with VS 2019; 2025+ with VS 2022.
set "VS_GEN=Visual Studio 17 2022"
if "%MAYA_VER%"=="2024" set "VS_GEN=Visual Studio 16 2019"
if "%MAYA_VER%"=="2023" set "VS_GEN=Visual Studio 16 2019"
if "%MAYA_VER%"=="2022" set "VS_GEN=Visual Studio 16 2019"
set "MAYA_ROOT=C:\Program Files\Autodesk\Maya%MAYA_VER%"
set "BUILD_DIR=%CMAKE_DIR%\build_%MAYA_VER%"
set "PLUGIN_DIR=%SCRIPT_DIR%\release\platforms\%MAYA_VER%\windows\x64\plug-ins"
echo.
echo mGear Solver Plugin Build
echo =========================
echo Maya version : %MAYA_VER%
echo Maya root : %MAYA_ROOT%
echo VS generator : %VS_GEN%
echo Build dir : %BUILD_DIR%
echo Output dir : %PLUGIN_DIR%
echo.
:: Verify Maya SDK exists
if not exist "%MAYA_ROOT%\include\maya\MFn.h" (
echo ERROR: Maya %MAYA_VER% SDK not found at "%MAYA_ROOT%\include\maya\"
exit /b 1
)
:: ----- Clean if requested --------------------------------------------------
if %DO_CLEAN%==1 (
echo Cleaning build directory...
if exist "%BUILD_DIR%" rmdir /s /q "%BUILD_DIR%"
echo.
)
:: ----- Create directories --------------------------------------------------
if not exist "%BUILD_DIR%" mkdir "%BUILD_DIR%"
if not exist "%PLUGIN_DIR%" mkdir "%PLUGIN_DIR%"
:: ----- Configure with CMake ------------------------------------------------
echo [1/3] Configuring with CMake...
echo.
cmake -G "%VS_GEN%" -A x64 -DMAYA_VERSION=%MAYA_VER% -S "%SCRIPT_DIR%" -B "%BUILD_DIR%"
if errorlevel 1 (
echo.
echo ERROR: CMake configure failed.
echo Make sure CMake and Visual Studio Build Tools are installed.
exit /b 1
)
:: ----- Build ---------------------------------------------------------------
echo.
echo [2/3] Building (Release)...
echo.
cmake --build "%BUILD_DIR%" --config Release
if errorlevel 1 (
echo.
echo ERROR: Build failed. Check the errors above.
exit /b 1
)
:: ----- Copy output to platforms directory ----------------------------------
echo.
echo [3/3] Copying plugins to %PLUGIN_DIR%...
echo.
set "FOUND_PLUGINS=0"
for %%D in ("%BUILD_DIR%\src\Release" "%BUILD_DIR%\Release" "%BUILD_DIR%") do (
for %%F in ("%%~D\*.mll") do (
copy /y "%%F" "%PLUGIN_DIR%\" >nul
echo Copied: %%~nxF
set /a FOUND_PLUGINS+=1
)
)
if %FOUND_PLUGINS%==0 (
echo WARNING: No .mll files found in build output.
echo Check %BUILD_DIR% for the compiled plugins.
exit /b 1
)
echo.
echo =========================================
echo BUILD SUCCESSFUL
echo Plugins in: %PLUGIN_DIR%
echo =========================================
echo.
pause
endlocal