Fix command-line argument parsing in run-cmake.bat and build-all.cmd

This commit is contained in:
Stinkfist0
2016-02-03 22:16:50 +02:00
parent 2e1699beea
commit d095bfecde
2 changed files with 17 additions and 9 deletions
+10 -3
View File
@@ -22,16 +22,23 @@
:: build-ifcopenshell and install-ifcopenshell. The rest of the arguments are passed for run-cmake.
:: Usage example for doing an optimized vs2015-x64 build with debug information and using IFC 4:
:: > build-all.cmd vs2015-x64 RelWithDebInfo -DUSE_IFC4=1 -DENABLE_BUILD_OPTIMIZATIONS=1
@echo off
for /f "tokens=2,* delims= " %%a in ("%*") do set ALL_BUT_FIRST_TWO=%%b
setlocal EnableDelayedExpansion
call vs-cfg.cmd %1
if not %ERRORLEVEL%==0 GOTO :Error
:: Use "yes" trick to break the pause in build-deps.cmd
echo y>y.txt
call .\build-deps %1 %2<y.txt
if not %ERRORLEVEL%==0 goto :EOF
del .\y.txt
call .\run-cmake %1 %ALL_BUT_FIRST_TWO%
if not %ERRORLEVEL%==0 goto :EOF
:: Same trick as in run-cmake.bat
set ARGUMENTS=%*
call set ARGUMENTS=%%ARGUMENTS:%1=%%
call set ARGUMENTS=%%ARGUMENTS:%2=%%
call .\run-cmake %1 %ARGUMENTS%
if not %ERRORLEVEL%==0 goto :EOF
call .\build-ifcopenshell %1 %2
ECHO %ERRORLEVEL%
+7 -6
View File
@@ -22,11 +22,15 @@ echo.
set PROJECT_NAME=IfcOpenShell
:: Enable the delayed environment variable expansion needed in vs-cfg.cmd.
setlocal EnableDelayedExpansion
call vs-cfg.cmd %1
IF NOT %ERRORLEVEL%==0 GOTO :Error
:: As CMake options are typically of format -DSOMETHING:BOOL=ON or -DSOMETHING=1, i.e. they contain an equal sign,
:: they will mess up the batch file argument parsing if the arguments are passed on by splitting them %2 %3 %4 %5
:: %6 %7 %8 %9. Work around that, http://scripts.dragon-it.co.uk/scripts.nsf/docs/batch-search-replace-substitute
set ARGUMENTS=%*
call set ARGUMENTS=%%ARGUMENTS:%1=%%
:: Read Python related variables from BuildDepsCache.txt
for /f "delims== tokens=1,2" %%G in (BuildDepsCache-%TARGET_ARCH%.txt) do set %%G=%%H
@@ -54,13 +58,10 @@ set SWIG_DIR=%INSTALL_DIR%\swigwin
set PATH=%PATH%;%SWIG_DIR%;%PYTHONPATH%
:: TODO 3ds Max SDK?
:: http://stackoverflow.com/a/26732879
for /f "tokens=1,* delims= " %%a in ("%*") do set ALL_BUT_FIRST=%%b
echo.
call cecho.cmd 0 10 "Script configuration:"
echo Generator = %GENERATOR%
echo Arguments = %ALL_BUT_FIRST%
echo Arguments = %ARGUMENTS%
echo.
call cecho.cmd 0 10 "Dependency Environment Variables for %PROJECT_NAME%:"
echo BOOST_ROOT = %BOOST_ROOT%
@@ -83,7 +84,7 @@ set CMAKELISTS_DIR=..\cmake
:: For now clear CMakeCache.txt always in order to assure that when changing build options everything goes smoothly.
IF EXIST CMakeCache.txt. del /Q CMakeCache.txt
call cecho.cmd 0 13 "Running CMake for %PROJECT_NAME%."
cmake.exe %CMAKELISTS_DIR% -G %GENERATOR% -DCMAKE_INSTALL_PREFIX="%CMAKE_INSTALL_PREFIX%" %ALL_BUT_FIRST%
cmake.exe %CMAKELISTS_DIR% -G %GENERATOR% -DCMAKE_INSTALL_PREFIX="%CMAKE_INSTALL_PREFIX%" %ARGUMENTS%
IF NOT %ERRORLEVEL%==0 GOTO :Error
echo.