User:Visualphoenix
Jump to navigation
Jump to search
sdkshaders: fix for spaces in path
Issue: Any attempt to compile the SDK shaders for a mod with spaces in the path name results in failure:
(ie: "C:\Program Files\Steam\SteamApps\SourceMods\MODNAME\src\src\sdkshaders")
This is due to the fact that the perl scripts and bat files have not been properly modified to handle spaces in the path.
Ray "VisualPhoenix" Barbiero has provided the following patches:
Note: These patches have been tested on paths with and without spaces.
updateshaders.pl
--- mod/src/devtools/bin/updateshaders.pl 2005-10-11 22:51:26.000000000 -0500 +++ mod/src/devtools/bin/updateshaders.pl 2005-07-14 09:58:54.000000000 -0500 @@ -7,7 +7,7 @@ { local( $shadername ) = shift; local( *SHADER ); - + open SHADER, "<$shadername"; while( <SHADER> ) { @@ -105,7 +105,7 @@ { $xboxswitch = "-xbox "; } - print MAKEFILE "\t\"$g_SourceDir\\devtools\\bin\\perl.exe\" \"$g_SourceDir\\devtools\\bin\\" . $shadertype . "_prep.pl\" $xboxswitch -shaderoutputdir $shaderoutputdir -source \"$g_SourceDir\" $shadername\n"; + print MAKEFILE "\t$g_SourceDir\\devtools\\bin\\perl.exe $g_SourceDir\\devtools\\bin\\" . $shadertype . "_prep.pl $xboxswitch -shaderoutputdir $shaderoutputdir -source \"$g_SourceDir\" $shadername\n"; my $filename; if( $shadertype eq "fxc" ) { @@ -199,14 +199,14 @@ # We only generate inc files for fxc and vsh files. if( $g_xbox ) { - print MAKEFILE " \"$shadertype" . "tmp_xbox\\" . $shaderbase . "\.inc\""; + print MAKEFILE " $shadertype" . "tmp_xbox\\" . $shaderbase . "\.inc"; } else { - print MAKEFILE " \"$shadertype" . "tmp9\\" . $shaderbase . "\.inc\""; + print MAKEFILE " $shadertype" . "tmp9\\" . $shaderbase . "\.inc"; } } - print MAKEFILE " \"$shaderoutputdir\\$shadertype\\$shaderbase\.vcs\""; + print MAKEFILE " $shaderoutputdir\\$shadertype\\$shaderbase\.vcs"; } print MAKEFILE "\n\n"; @@ -221,11 +221,11 @@ # We only generate inc files for fxc and vsh files. if( $g_xbox ) { - print MAKEFILE "\tdel /f /q \"$shadertype" . "tmp_xbox\\" . $shaderbase . "\.inc\"\n"; + print MAKEFILE "\tdel /f /q $shadertype" . "tmp_xbox\\" . $shaderbase . "\.inc\n"; } else { - print MAKEFILE "\tdel /f /q \"$shadertype" . "tmp9\\" . $shaderbase . "\.inc\"\n"; + print MAKEFILE "\tdel /f /q $shadertype" . "tmp9\\" . $shaderbase . "\.inc\n"; } } print MAKEFILE "\tdel /f /q \"$shaderoutputdir\\$shadertype\\$shaderbase\.vcs\"\n";
buildshaders.bat
--- mod/src/materialsystem/stdshaders/buildshaders.bat 2005-10-11 23:01:08.000000000 -0500 +++ mod/src/materialsystem/stdshaders/buildshaders.bat 2005-07-14 10:00:36.000000000 -0500 @@ -36,7 +36,7 @@ REM **************** :set_xbox_args set xbox_args=-xbox -set targetdir="%vproject%\shaders_xbox" +set targetdir=%vproject%\shaders_xbox goto build_shaders @@ -45,8 +45,8 @@ REM **************** :set_mod_args -if not exist "%sourcesdk%\bin\shadercompile.exe" goto NoShaderCompile -set ChangeToDir="%sourcesdk%\bin" +if not exist %sourcesdk%\bin\shadercompile.exe goto NoShaderCompile +set ChangeToDir=%sourcesdk%\bin if /i "%4" NEQ "-source" goto NoSourceDirSpecified set SrcDirBase=%~5 @@ -75,7 +75,7 @@ :NoShaderCompile echo - -echo - ERROR: shadercompile.exe doesn't exist in "%sourcesdk%\bin" +echo - ERROR: shadercompile.exe doesn't exist in %sourcesdk%\bin echo - goto end @@ -129,7 +129,7 @@ REM **************** REM Execute distributed process on work/build list REM **************** -"%SrcDirBase%\devtools\bin\perl" "%SrcDirBase%\materialsystem\stdshaders\runvmpi.pl" %xbox_args% -changetodir %ChangeToDir% %SDKArgs% +"%SrcDirBase%\devtools\bin\perl" "%SrcDirBase%\materialsystem\stdshaders\runvmpi.pl" %xbox_args% -changetodir "%ChangeToDir%" %SDKArgs% REM **************** REM Copy the generated files to the output dir.
runvmpi.pl
--- mod/src/materialsystem/stdshaders/runvmpi.pl 2005-10-11 22:34:02.000000000 -0500 +++ mod/src/materialsystem/stdshaders/runvmpi.pl 2005-07-14 10:00:34.000000000 -0500 @@ -41,7 +41,7 @@ $shaderpath =~ s,/,\\,g; chdir $changeToDir; -$cmdToRun = "shadercompile.exe $noMPI $xboxFlag -shaderpath \"$shaderpath\" -mpi_workercount 32 -allowdebug $gameFlag"; +$cmdToRun = "shadercompile.exe $noMPI $xboxFlag -shaderpath $shaderpath -mpi_workercount 32 -allowdebug $gameFlag"; system $cmdToRun; # other options..
build_sample_shaders.bat
--- mod/src/sdkshaders/build_sample_shaders.bat 2005-10-11 23:02:00.000000000 -0500 +++ mod/src/sdkshaders/build_sample_shaders.bat 2005-07-14 09:57:02.000000000 -0500 @@ -9,7 +9,7 @@ rem **** Call the batch files to build our stuff. -call ..\materialsystem\stdshaders\buildshaders.bat kmp_shaders -game "%__GameDir%" -source .\.. +call ..\materialsystem\stdshaders\buildshaders.bat sdk_shaders -game "%__GameDir%" -source .. goto end