Skip to content

Commit 7caa4e3

Browse files
committed
Replace cecho.exe with PowerShell snippet, fix exit bug in vs-cfg.cmd, fix Visual Studio download URL, rename IFCOS_NUM_BUILD_PROCESSES -> IFCOS_NUM_BUILD_PROCS
1 parent d721dab commit 7caa4e3

7 files changed

Lines changed: 76 additions & 136 deletions

File tree

win/build-deps.cmd

Lines changed: 60 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ setlocal EnableDelayedExpansion
3131

3232
:: Make sure vcvarsall.bat is called and dev env set is up.
3333
IF "%VSINSTALLDIR%"=="" (
34-
utils\cecho {0C}Visual Studio environment variables not set - cannot proceed!{# #}{\n}
34+
call utils\cecho.cmd 0 12 "Visual Studio environment variables not set - cannot proceed!"
3535
GOTO :Error
3636
)
3737

3838
set PROJECT_NAME=IfcOpenShell
3939

40-
utils\cecho {F0}This script fetches and builds all %PROJECT_NAME% dependencies{# #}{\n}
40+
call utils\cecho.cmd 15 0 "This script fetches and builds all %PROJECT_NAME% dependencies"
4141
echo.
4242

4343
:: Set up variables depending on the used Visual Studio version
@@ -47,14 +47,14 @@ IF NOT %ERRORLEVEL%==0 GOTO :Error
4747
set BUILD_TYPE=%3
4848

4949
IF %GENERATOR%=="" (
50-
cecho {0C}GENERATOR not specified - cannot proceed!{# #}{\n}
50+
call cecho.cmd 0 12 "GENERATOR not specified - cannot proceed!"
5151
GOTO :Error
5252
)
5353

5454
IF "%BUILD_TYPE%"=="" set BUILD_TYPE=Build
5555

5656
IF NOT "!BUILD_TYPE!"=="Build" IF NOT "!BUILD_TYPE!"=="Rebuild" IF NOT "!BUILD_TYPE!"=="Clean" (
57-
utils\cecho {0C}Invalid build type passed: !BUILD_TYPE!. Cannot proceed, aborting!{# #}{\n}
57+
call utils\cecho.cmd 0 12 "Invalid build type passed: !BUILD_TYPE!. Cannot proceed, aborting!"
5858
GOTO :Error
5959
)
6060

@@ -68,63 +68,64 @@ IF %VS_VER%==2008 set PATH=C:\Windows\Microsoft.NET\Framework\v3.5;%PATH%
6868
:: User-configurable build options
6969
IF "%IFCOS_INSTALL_PYTHON%"=="" set IFCOS_INSTALL_PYTHON=TRUE
7070
IF "%IFCOS_USE_PYTHON2%"=="" set IFCOS_USE_PYTHON2=FALSE
71-
IF "%IFCOS_NUM_BUILD_PROCESSES%"=="" set IFCOS_NUM_BUILD_PROCESSES=%NUMBER_OF_PROCESSORS%
71+
IF "%IFCOS_NUM_BUILD_PROCS%"=="" set IFCOS_NUM_BUILD_PROCS=%NUMBER_OF_PROCESSORS%
7272

7373
:: For subroutines
74-
set MSBUILD_CMD=MSBuild.exe /nologo /m:%IFCOS_NUM_BUILD_PROCESSES% /t:%BUILD_TYPE%
74+
set MSBUILD_CMD=MSBuild.exe /nologo /m:%IFCOS_NUM_BUILD_PROCS% /t:%BUILD_TYPE%
7575
REM /clp:ErrorsOnly;WarningsOnly
7676
:: Note BUILD_TYPE not passed, Clean e.g. wouldn't delete the installed files.
77-
set INSTALL_CMD=MSBuild.exe /nologo /m:%IFCOS_NUM_BUILD_PROCESSES%
77+
set INSTALL_CMD=MSBuild.exe /nologo /m:%IFCOS_NUM_BUILD_PROCS%
7878
set BUILD_DIR=build-vs%VS_VER%-%TARGET_ARCH%
7979

8080
REM echo.
81-
REM cecho {F0}This script fetches and builds all %PROJECT_NAME% dependencies{# #}{\n}
81+
REM call cecho.cmd 0 15 "This script fetches and builds all %PROJECT_NAME% dependencies"
8282

8383
:: Print build configuration information
8484
echo.
85-
cecho {0A}Script configuration:{# #}{\n}
86-
cecho {0D} CMake Generator = %GENERATOR%{# #}{\n}
87-
echo - Passed to CMake -G option.
88-
cecho {0D} Target Architecture = %TARGET_ARCH%{# #}{\n}
89-
echo - Whether were doing 32-bit (x86) or 64-bit (x64) build.
90-
cecho {0D} Dependency Directory = %DEPS_DIR%{# #}{\n}
91-
echo - The directory where %PROJECT_NAME% dependencies are fetched and built.
92-
cecho {0D} Installation Directory = %INSTALL_DIR%{# #}{\n}
93-
echo - The directory where %PROJECT_NAME% dependencies are installed.
94-
cecho {0D} Build Config Type = %BUILD_CFG%{# #}{\n}
95-
echo - The used build configuration type for the dependencies.
85+
86+
call cecho.cmd 0 10 "Script configuration:"
87+
call cecho.cmd 0 13 "* CMake Generator`t= '`"%GENERATOR_DEFAULT%`'`t
88+
echo - Passed to CMake -G option.
89+
call cecho.cmd 0 13 "* Target Architecture`t= %TARGET_ARCH%"
90+
echo - Whether were doing 32-bit (x86) or 64-bit (x64) build.
91+
call cecho.cmd 0 13 "* Dependency Directory`t= %DEPS_DIR%"
92+
echo - The directory where %PROJECT_NAME% dependencies are fetched and built.
93+
call cecho.cmd 0 13 "* Installation Directory = %INSTALL_DIR%"
94+
echo - The directory where %PROJECT_NAME% dependencies are installed.
95+
call cecho.cmd 0 13 "* Build Config Type`t= %BUILD_CFG%"
96+
echo - The used build configuration type for the dependencies.
9697
echo Defaults to RelWithDebInfo if not specified.
97-
IF %BUILD_CFG%==MinSizeRel cecho {0E} WARNING: MinSizeRel build can suffer from a significant performance loss.{# #}{\n}
98-
cecho {0D} Build Type = %BUILD_TYPE%{# #}{\n}
99-
echo - The used build type for the dependencies (Build, Rebuild, Clean).
98+
IF %BUILD_CFG%==MinSizeRel call cecho.cmd 0 14 " WARNING: MinSizeRel build can suffer from a significant performance loss."
99+
call cecho.cmd 0 13 "* Build Type`t`t= %BUILD_TYPE%"
100+
echo - The used build type for the dependencies (Build, Rebuild, Clean).
100101
echo Defaults to Build if not specified. Rebuild/Clean also uninstalls Python (if it was installed by this script).
101-
cecho {0D} IFCOS_INSTALL_PYTHON = %IFCOS_INSTALL_PYTHON%{# #}{\n}
102-
echo - Download and install Python.
102+
call cecho.cmd 0 13 "* IFCOS_INSTALL_PYTHON`t= %IFCOS_INSTALL_PYTHON%"
103+
echo - Download and install Python.
103104
echo Set to something other than TRUE if you wish to use an already installed version of Python.
104-
cecho {0D} IFCOS_USE_PYTHON2 = %IFCOS_USE_PYTHON2%{# #}{\n}
105-
echo - Use Python 2 instead of 3.
105+
call cecho.cmd 0 13 "* IFCOS_USE_PYTHON2`t= %IFCOS_USE_PYTHON2%"
106+
echo - Use Python 2 instead of 3.
106107
echo Set to TRUE if you wish to use Python 2 instead of 3. Has no effect if IFCOS_INSTALL_PYTHON is not TRUE.
107-
cecho {0D} IFCOS_NUM_BUILD_PROCESSES = %IFCOS_NUM_BUILD_PROCESSES%{# #}{\n}
108-
echo - How many MSBuild.exe processes may be run in parallel.
108+
call cecho.cmd 0 13 "* IFCOS_NUM_BUILD_PROCS`t= %IFCOS_NUM_BUILD_PROCS%"
109+
echo - How many MSBuild.exe processes may be run in parallel.
109110
echo Defaults to NUMBER_OF_PROCESSORS.
110111
echo.
111112

112113
:: Print script's usage information
113-
cecho {0A}Requirements for a successful execution:{# #}{\n}
114-
echo 1. Install PowerShell (preinstalled in Windows ^>= 7) and make sure 'powershell' is accessible from PATH.
115-
echo - https://support.microsoft.com/en-us/kb/968929
116-
echo 2. Install Git and make sure 'git' is accessible from PATH.
117-
echo - http://code.google.com/p/tortoisegit/
118-
echo 3. Install CMake and make sure 'cmake' is accessible from PATH.
119-
echo - http://www.cmake.org/
120-
echo 4. Visual Studio 2008 or newer (2013 or newer recommended).
121-
echo - http://www.cmake.org/
122-
echo 5. Run this batch script with Visual Studio environment variables set.
123-
echo - https://msdn.microsoft.com/en-us/library/ms229859(v=vs.110).aspx
114+
call cecho.cmd 0 10 "Requirements for a successful execution:"
115+
echo 1. Install PowerShell (preinstalled in Windows ^>= 7) and make sure 'powershell' is accessible from PATH.
116+
echo - https://support.microsoft.com/en-us/kb/968929
117+
echo 2. Install Git and make sure 'git' is accessible from PATH.
118+
echo - http://code.google.com/p/tortoisegit/
119+
echo 3. Install CMake and make sure 'cmake' is accessible from PATH.
120+
echo - http://www.cmake.org/
121+
echo 4. Visual Studio 2008 or newer (2013 or newer recommended).
122+
echo - https://www.visualstudio.com/
123+
echo 5. Run this batch script with Visual Studio environment variables set.
124+
echo - https://msdn.microsoft.com/en-us/library/ms229859(v=vs.110).aspx
124125
echo.
125126
REM TODO 3ds Max SDK?
126127

127-
cecho {0E}Warning: You will need roughly 8 GB of disk space to proceed (VS 2015 x64 RelWithDebInfo).{# #}{\n}
128+
call cecho.cmd 0 14 "Warning: You will need roughly 8 GB of disk space to proceed `(VS 2015 x64 RelWithDebInfo`)."
128129
echo.
129130

130131
echo If you are not ready with the above, press Ctrl-C to abort!
@@ -150,6 +151,7 @@ set ZIP_EXT=7z
150151
set BOOST_ZIP=boost_%BOOST_VER%.%ZIP_EXT%
151152

152153
call :DownloadFile http://downloads.sourceforge.net/project/boost/boost/%BOOST_VERSION%/%BOOST_ZIP% "%DEPS_DIR%" %BOOST_ZIP%
154+
153155
IF NOT %ERRORLEVEL%==0 GOTO :Error
154156
call :ExtractArchive %BOOST_ZIP% "%DEPS_DIR%" "%DEPS_DIR%\boost"
155157
IF NOT %ERRORLEVEL%==0 GOTO :Error
@@ -160,17 +162,17 @@ IF EXIST "%DEPS_DIR%\boost_%BOOST_VER%". (
160162
ren boost_%BOOST_VER% boost
161163
IF NOT EXIST "%DEPS_DIR%\boost\boost.css" GOTO :Error
162164
cd "%DEPS_DIR%\boost"
163-
cecho {0D}Building Boost build script.{# #}{\n}
165+
call cecho.cmd 0 13 "Building Boost build script."
164166
call bootstrap vc%VC_VER%
165167
IF NOT %ERRORLEVEL%==0 GOTO :Error
166168
)
167169

168170
set BOOST_LIBS=--with-system --with-regex --with-thread --with-program_options --with-date_time
169171
:: NOTE Boost is fast to build with limited set of libraries so build it always.
170172
cd "%DEPS_DIR%\boost"
171-
cecho {0D}Building %DEPENDENCY_NAME% %BOOST_LIBS% Please be patient, this will take a while.{# #}{\n}
173+
call cecho.cmd 0 13 "Building %DEPENDENCY_NAME% %BOOST_LIBS% Please be patient, this will take a while."
172174
IF EXIST "%DEPS_DIR%\boost\bin.v2\project-cache.jam" del "%DEPS_DIR%\boost\bin.v2\project-cache.jam"
173-
call .\b2 toolset=msvc-%VC_VER%.0 runtime-link=static address-model=%ARCH_BITS% -j%IFCOS_NUM_BUILD_PROCESSES% ^
175+
call .\b2 toolset=msvc-%VC_VER%.0 runtime-link=static address-model=%ARCH_BITS% -j%IFCOS_NUM_BUILD_PROCS% ^
174176
variant=%DEBUG_OR_RELEASE_LOWERCASE% %BOOST_LIBS% stage --stagedir=stage/vs%VS_VER%-%VS_PLATFORM%
175177
IF NOT %ERRORLEVEL%==0 GOTO :Error
176178

@@ -301,18 +303,18 @@ IF "%IFCOS_INSTALL_PYTHON%"=="TRUE" (
301303
IF NOT %ERRORLEVEL%==0 GOTO :Error
302304
REM Uninstall if build Rebuild/Clean used
303305
IF NOT %BUILD_TYPE%==Build (
304-
cecho {0D}Uninstalling %DEPENDENCY_NAME%. Please be patient, this will take a while.{# #}{\n}
306+
call cecho.cmd 0 13 "Uninstalling %DEPENDENCY_NAME%. Please be patient, this will take a while."
305307
msiexec /x %PYTHON_INSTALLER% /qn
306308
)
307309

308310
IF NOT EXIST "%PYTHONPATH%". (
309-
cecho {0D}Installing %DEPENDENCY_NAME%. Please be patient, this will take a while.{# #}{\n}
311+
call cecho.cmd 0 13 "Installing %DEPENDENCY_NAME%. Please be patient, this will take a while."
310312
msiexec /qn /i %PYTHON_INSTALLER% TARGETDIR="%PYTHONPATH%"
311313
) ELSE (
312-
cecho {0D}%DEPENDENCY_NAME% already installed. Skipping.{# #}{\n}
314+
call cecho.cmd 0 13 "%DEPENDENCY_NAME% already installed. Skipping."
313315
)
314316
) ELSE (
315-
cecho {0D}IFCOS_INSTALL_PYTHON not true, skipping installation of Python.{# #}{\n}
317+
call cecho.cmd 0 13 "IFCOS_INSTALL_PYTHON not true, skipping installation of Python."
316318
)
317319

318320
:SWIG
@@ -334,12 +336,12 @@ IF EXIST "%DEPS_DIR%\swigwin\". robocopy "%DEPS_DIR%\swigwin" "%INSTALL_DIR%\swi
334336

335337
:Successful
336338
echo.
337-
%TOOLS%\utils\cecho {0A}%PROJECT_NAME% dependencies built.{# #}{\n}
339+
call %TOOLS%\utils\cecho.cmd 0 10 "%PROJECT_NAME% dependencies built."
338340
goto :Finish
339341

340342
:Error
341343
echo.
342-
%TOOLS%\utils\cecho {0C}An error occurred! Aborting!{# #}{\n}
344+
call %TOOLS%\utils\cecho.cmd 0 12 "An error occurred! Aborting!"
343345
goto :Finish
344346

345347
:Finish
@@ -355,11 +357,11 @@ goto :EOF
355357
:DownloadFile
356358
pushd %2
357359
IF NOT EXIST "%3". (
358-
cecho {0D}Downloading %DEPENDENCY_NAME% into %2.{# #}{\n}
360+
call cecho.cmd 0 13 "Downloading %DEPENDENCY_NAME% into %2."
359361
powershell -Command "$webClient = new-object System.Net.WebClient; $webClient.DownloadFile('%1', '%3')"
360362
REM Old wget version in case someone has problem with PowerShell: wget --no-check-certificate %1
361363
) ELSE (
362-
cecho {0D}%DEPENDENCY_NAME% already downloaded. Skipping.{# #}{\n}
364+
call cecho.cmd 0 13 "%DEPENDENCY_NAME% already downloaded. Skipping."
363365
)
364366
set RET=%ERRORLEVEL%
365367
popd
@@ -369,10 +371,10 @@ exit /b %RET%
369371
:: Params: %1 filename, %2 destinationDir, %3 dirAfterExtraction
370372
:ExtractArchive
371373
IF NOT EXIST "%3". (
372-
cecho {0D}Extracting %DEPENDENCY_NAME% into %2.{# #}{\n}
374+
call cecho.cmd 0 13 "Extracting %DEPENDENCY_NAME% into %2."
373375
7za x %1 -y -o%2
374376
) ELSE (
375-
cecho {0D}%DEPENDENCY_NAME% already extracted into %3. Skipping.{# #}{\n}
377+
call cecho.cmd 0 13 "%DEPENDENCY_NAME% already extracted into %3. Skipping."
376378
)
377379
exit /b %ERRORLEVEL%
378380

@@ -381,11 +383,11 @@ exit /b %ERRORLEVEL%
381383
:: F.ex. call :GitCloneRepository https://github.com/KhronosGroup/OpenCOLLADA.git "%DEPS_DIR%\OpenCOLLADA\"
382384
:GitCloneOrPullRepository
383385
IF NOT EXIST %2. (
384-
cecho {0D}Cloning %DEPENDENCY_NAME% into %2.{# #}{\n}
386+
call cecho.cmd 0 13 "Cloning %DEPENDENCY_NAME% into %2."
385387
pushd "%DEPS_DIR%"
386388
call git clone %1 %2
387389
) ELSE (
388-
cecho {0D}%DEPENDENCY_NAME% already cloned. Pulling latest changes.{# #}{\n}
390+
call cecho.cmd 0 13 "%DEPENDENCY_NAME% already cloned. Pulling latest changes."
389391
pushd %2
390392
call git pull
391393
)
@@ -397,7 +399,7 @@ exit /b %RET%
397399
:: Params: %* cmakeOptions
398400
:: NOTE cd to root CMakeLists.txt folder before calling this if the CMakeLists.txt is not in the repo root.
399401
:RunCMake
400-
cecho {0D}Running CMake for %DEPENDENCY_NAME%.{# #}{\n}
402+
call cecho.cmd 0 13 "Running CMake for %DEPENDENCY_NAME%."
401403
IF NOT EXIST %BUILD_DIR%. mkdir %BUILD_DIR%
402404
IF NOT %ERRORLEVEL%==0 GOTO :Error
403405
pushd %BUILD_DIR%
@@ -412,7 +414,7 @@ exit /b %RET%
412414
:: BuildSolution - Builds/Rebuilds/Cleans a solution using MSBuild
413415
:: Params: %1 solutioName, %2 configuration
414416
:BuildSolution
415-
cecho {0D}%BUILD_TYPE%ing %2 %DEPENDENCY_NAME%. Please be patient, this will take a while.{# #}{\n}
417+
call cecho.cmd 0 13 "%BUILD_TYPE%ing %2 %DEPENDENCY_NAME%. Please be patient, this will take a while."
416418
%MSBUILD_CMD% %1 /p:configuration=%2;platform=%VS_PLATFORM%
417419
exit /b %ERRORLEVEL%
418420

@@ -421,7 +423,7 @@ exit /b %ERRORLEVEL%
421423
:: NOTE the actual install dir is set during cmake run.
422424
:InstallCMakeProject
423425
pushd %1
424-
cecho {0D}Installing %2 %DEPENDENCY_NAME%. Please be patient, this will take a while.{# #}{\n}
426+
call cecho.cmd 0 13 "Installing %2 %DEPENDENCY_NAME%. Please be patient, this will take a while."
425427
%INSTALL_CMD% INSTALL.%VCPROJ_FILE_EXT% /p:configuration=%2;platform=%VS_PLATFORM%
426428
set RET=%ERRORLEVEL%
427429
popd

win/run-cmake.bat

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ set PATH=%PATH%;%SWIG_DIR%;%PYTHONPATH%
5656
:: TODO 3ds Max SDK?
5757

5858
echo.
59-
cecho {0A}Script configuration:{# #}{\n}
59+
call cecho.cmd 0 10 "Script configuration:"
6060
echo CMake Generator = %GENERATOR%
6161
echo All arguments = %*
6262
echo.
63-
cecho {0A}Dependency Environment Variables for %PROJECT_NAME%:{# #}{\n}
63+
call cecho.cmd 0 10 "Dependency Environment Variables for %PROJECT_NAME%:"
6464
echo BOOST_ROOT = %BOOST_ROOT%
6565
REM echo BOOST_INCLUDEDIR = %BOOST_INCLUDEDIR%
6666
echo BOOST_LIBRARYDIR = %BOOST_LIBRARYDIR%
@@ -81,7 +81,7 @@ echo.
8181
set CMAKELISTS_DIR=..\cmake
8282
REM IF NOT EXIST %PROJECT_NAME%.sln. (
8383
IF EXIST CMakeCache.txt. del /Q CMakeCache.txt
84-
cecho {0D}Running CMake for %PROJECT_NAME%.{# #}{\n}
84+
call cecho.cmd 0 13 "Running CMake for %PROJECT_NAME%."
8585
IF "%2"=="" (
8686
REM No extra arguments provided, trust that GENERATOR is set properly.
8787
cmake.exe %CMAKELISTS_DIR% -G %GENERATOR% -DCMAKE_INSTALL_PREFIX="%CMAKE_INSTALL_PREFIX%"
@@ -94,16 +94,16 @@ REM IF NOT EXIST %PROJECT_NAME%.sln. (
9494
)
9595
IF NOT %ERRORLEVEL%==0 GOTO :Error
9696
REM ) ELSE (
97-
REM cecho {0A}%PROJECT_NAME%.sln exists. Skipping CMake call for %PROJECT_NAME%.{# #}{\n}
98-
REM cecho {0A}Delete %CD%\%PROJECT_NAME%.sln to trigger a CMake rerun.{# #}{\n}
97+
REM call cecho.cmd 0 10 "%PROJECT_NAME%.sln exists. Skipping CMake call for %PROJECT_NAME%."
98+
REM call cecho.cmd 0 10 "Delete %BUILD_DIR%\%PROJECT_NAME%.sln to trigger a CMake rerun."
9999
REM )
100100
echo.
101101

102102
goto :Finish
103103

104104
:Error
105105
echo.
106-
cecho {0C}An error occurred! Aborting!{# #}{\n}
106+
cecho {0C}An error occurred! Aborting!"
107107
goto :Finish
108108

109109
:Finish

win/utils/cecho test.bat

Lines changed: 0 additions & 65 deletions
This file was deleted.

win/utils/cecho.cmd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
:: Usage: call cecho.cmd background foreground "message here"
2+
:: NOTES/TODOS 1) This is super slow 2) leading spaces are omitted 3) printing string with quotes doesn't work (quotes must be escaped awkwardly)
3+
@powershell -command write-host -background %~1 -foreground "%~2" "%3"
4+
@exit /b

win/utils/cecho.exe

-25.5 KB
Binary file not shown.

win/utils/cecho.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)