From a52901344c6fa1d19b9f1bac126ce1e32844f6b6 Mon Sep 17 00:00:00 2001 From: Stinkfist0 Date: Tue, 26 Jan 2016 13:41:19 +0200 Subject: [PATCH 01/27] build-deps.cmd: print start, end, and elapsed time + .gitignore doc tweak --- .gitignore | 1 + win/build-deps.cmd | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/.gitignore b/.gitignore index 2c5e2e40be..ba3b75032f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,6 @@ /build*/ /install*/ /win/BuildDepsCache*.txt +# IfcExpressParser residue /src/ifcexpressparser/__pycache__ /src/ifcexpressparser/express_parser.py diff --git a/win/build-deps.cmd b/win/build-deps.cmd index 655163ab26..2ea1e471ae 100644 --- a/win/build-deps.cmd +++ b/win/build-deps.cmd @@ -115,8 +115,12 @@ call cecho.cmd 0 14 "Warning: You will need roughly 8 GB of disk space to procee echo. call cecho.cmd black cyan "If you are not ready with the above, press Ctrl-C to abort!" + pause echo. +set START_TIME=%TIME% +echo Build started at %START_TIME%. +echo. cd %DEPS_DIR% @@ -308,6 +312,22 @@ call %~dp0\utils\cecho.cmd 0 12 "An error occurred! Aborting!" goto :Finish :Finish +:: Print end time and elapsed time, http://stackoverflow.com/a/9935540 +set END_TIME=%TIME% +for /F "tokens=1-4 delims=:.," %%a in ("%START_TIME%") do ( + set /A "start=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100" +) +for /F "tokens=1-4 delims=:.," %%a in ("%END_TIME%") do ( + set /A "end=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100" +) +set /A elapsed=end-start +set /A hh=elapsed/(60*60*100), rest=elapsed%%(60*60*100), mm=rest/(60*100), rest%%=60*100, ss=rest/100, cc=rest%%100 +if %mm% lss 10 set mm=0%mm% +if %ss% lss 10 set ss=0%ss% +if %cc% lss 10 set cc=0%cc% +echo. +echo Build ended at %END_TIME%. Time elapsed %hh%:%mm%:%ss%.%cc%. + set PATH=%ORIGINAL_PATH% cd %~dp0 endlocal From 18e451b8747560c48d4c3260f581598e76da04a6 Mon Sep 17 00:00:00 2001 From: Stinkfist0 Date: Tue, 19 Jan 2016 16:43:42 +0200 Subject: [PATCH 02/27] Windows build scripts: detect case where user installed Visual Studio but not the C++ toolset. Also detect case where user's CMake version is too old for the desired generator. --- README.md | 11 ++++++----- win/build-deps.cmd | 12 ++++++++++-- win/vs-cfg.cmd | 13 ++++++++++--- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 696cd75be4..304f93a90c 100644 --- a/README.md +++ b/README.md @@ -8,14 +8,14 @@ Open source (LGPL) software library for working with the IFC file format. Prerequisites ============= -* Git, CMake (2.6 or newer), Visual Studio 2008 or newer (Windows), or GCC (*nix, Clang untested). +* Git, CMake (2.6 or newer), Visual Studio 2008 or newer with C++ toolset (Windows), or GCC (*nix, Clang untested). Dependencies ============ * [Boost](http://www.boost.org/) * Open Cascade *optional*, but required for building IfcGeom - [Official](http://www.opencascade.org/getocc/download/loadocc/) or [community edition](https://github.com/tpaviot/oce) + ([official](http://www.opencascade.org/getocc/download/loadocc/) or [community edition](https://github.com/tpaviot/oce)) For converting IFC representation items into BRep solids and tesselated meshes * [ICU](http://site.icu-project.org/) *optional* For handling code pages and Unicode in the parser @@ -92,7 +92,10 @@ To build IfcOpenShell please take the following steps: $ cmake ../ $ make -If all worked out correctly you can now use IfcOpenShell. For example: +If all worked out correctly you can now use IfcOpenShell. See the examples below. + +Usage examples +============== **Invoking IfcConvert from the command line** @@ -101,8 +104,6 @@ If all worked out correctly you can now use IfcOpenShell. For example: $ ./IfcConvert Munkerud_hus6_BE.ifc $ less Munkerud_hus6_BE.obj -Or: - **Using the IfcOpenShell Python interface** $ wget -O duplex.zip http://projects.buildingsmartalliance.org/files/?artifact_id=4278 diff --git a/win/build-deps.cmd b/win/build-deps.cmd index 2ea1e471ae..75ec4caa99 100644 --- a/win/build-deps.cmd +++ b/win/build-deps.cmd @@ -33,10 +33,18 @@ setlocal EnableDelayedExpansion :: Make sure vcvarsall.bat is called and dev env set is up. IF "%VSINSTALLDIR%"=="" ( - call utils\cecho.cmd 0 12 "Visual Studio environment variables not set - cannot proceed!" + call utils\cecho.cmd 0 12 "Visual Studio environment variables not set- cannot proceed." GOTO :ErrorAndPrintUsage ) +:: Check for cl.exe - at least the "Typical" Visual Studio 2015 installation does not include the C++ toolset by default, +:: http://blogs.msdn.com/b/vcblog/archive/2015/07/24/setup-changes-in-visual-studio-2015-affecting-c-developers.aspx +where cl.exe 2>&1>NUL +if not %ERRORLEVEL%==0 ( + call utils\cecho.cmd 0 12 "%~nx0: cl.exe not in PATH. Make sure to select the C++ toolset when installing Visual Studio- cannot proceed." + GOTO :ErrorAndPrintUsage +) + :: Set up variables depending on the used Visual Studio version call vs-cfg.cmd %1 %2 IF NOT %ERRORLEVEL%==0 GOTO :Error @@ -422,7 +430,7 @@ echo 2. Install Git and make sure 'git' is accessible from PATH. echo - http://code.google.com/p/tortoisegit/ echo 3. Install CMake and make sure 'cmake' is accessible from PATH. echo - http://www.cmake.org/ -echo 4. Visual Studio 2008 or newer (2013 or newer recommended). +echo 4. Visual Studio 2008 or newer (2013 or newer recommended) with C++ toolset. echo - https://www.visualstudio.com/ echo 5. Run this batch script with Visual Studio environment variables set. echo - https://msdn.microsoft.com/en-us/library/ms229859(v=vs.110).aspx diff --git a/win/vs-cfg.cmd b/win/vs-cfg.cmd index cf70bb5265..9eb6494d8b 100644 --- a/win/vs-cfg.cmd +++ b/win/vs-cfg.cmd @@ -47,7 +47,7 @@ set GENERATORS[8]="Visual Studio 14 2015 Win64" set GENERATORS[9]="Visual Studio 14 2015" set LAST_GENERATOR_IDX=9 -REM Deduce desired architecture from the location of cl.exe +:: Deduce desired architecture from the location of cl.exe where cl.exe | findstr /r /c:"amd64" >nul set START=%ERRORLEVEL% set STEP=2 @@ -65,11 +65,18 @@ IF "!GENERATOR!"=="" IF NOT "%VisualStudioVersion%"=="" ( ) ) ) +:: Check that the used CMake version supports the chosen generator +set GENERATOR_CHECK=%GENERATOR: Win64=% +cmake --help | findstr /c:%GENERATOR_CHECK% +if not %ERRORLEVEL%==0 ( + call utils\cecho.cmd 0 12 "%~nx0: The used CMake version does not support '`"!GENERATOR!`'"- cannot proceed." + exit /b 1 +) FOR /l %%i in (0,1,%LAST_GENERATOR_IDX%) DO ( IF !GENERATOR!==!GENERATORS[%%i]! GOTO :GeneratorValid ) -call utils\cecho.cmd 0 12 "%~nx0: Invalid or unsupported CMake generator string passed: '`"!GENERATOR!`'". Cannot proceed, aborting!" +call utils\cecho.cmd 0 12 "%~nx0: Invalid or unsupported CMake generator string passed: '`"!GENERATOR!`'"- cannot proceed." echo Supported CMake generator strings: FOR /l %%i in (0,1,%LAST_GENERATOR_IDX%) DO ( echo !GENERATORS[%%i]! @@ -133,7 +140,7 @@ IF "!BUILD_CFG!"=="" ( ) IF NOT !BUILD_CFG!==%BUILD_CFG_MINSIZEREL% IF NOT !BUILD_CFG!==%BUILD_CFG_RELEASE% ( IF NOT !BUILD_CFG!==%BUILD_CFG_RELWITHDEBINFO% IF NOT !BUILD_CFG!==%BUILD_CFG_DEBUG% ( - call utils\cecho.cmd 0 12 "%~nx0: Invalid or unsupported CMake build configuration type passed: !BUILD_CFG!. Cannot proceed, aborting!" + call utils\cecho.cmd 0 12 "%~nx0: Invalid or unsupported CMake build configuration type passed: !BUILD_CFG!. Cannot proceed." exit /b 1 )) From c7bf03e8f807758990e9ec50e104e79faf62f44c Mon Sep 17 00:00:00 2001 From: Stinkfist0 Date: Tue, 19 Jan 2016 17:03:05 +0200 Subject: [PATCH 03/27] Add set-python-to-path.bat helper, add instructions for using preinstalled Python. --- win/readme.md | 20 +++++++++++++++++++- win/set-python-to-path.bat | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 win/set-python-to-path.bat diff --git a/win/readme.md b/win/readme.md index 89a6922be0..8af62504c2 100644 --- a/win/readme.md +++ b/win/readme.md @@ -32,13 +32,30 @@ easily more than 2 GBs of RAM while converting. After this, one can build the project using the `IfcOpenShell.sln` file in the build folder. Build the `INSTALL` project if wanted. Convenience batch files `build-ifcopenshell.cmd` and `install-ifcopenshell.cmd` can also be used. The batch files -expect `%1` and `%2` in same fashion as above and possible extra parameters are passed for the `MSBuild`call. The project will +expect `%1` and `%2` in same fashion as above and possible extra parameters are passed for the `MSBuild` call. The project will be installed to `installed-vs-\` folder in the project's root folder and the required IfcOpenShell-Python parts are deployed to the `\Lib\site-packages\` folder. **Note:** All of the dependencies are build as static libraries against the static run-time allowing the developer to effortlessly deploy standalone IFCOS binaries. +Using an already existing Python installation +--------------------------------------------- + +Let's say you have already installed 64-bit Python 3.5.1 to `C:\Python3`. +Before building the dependencies, disable the script from installing Python: +``` +> set IFCOS_INSTALL_PYTHON=FALSE +> buid-deps.cmd +``` + +After bulding the dependencies, create BuildDepsCache file to `IfcOpenShell\win` which tells the used Python version and intallation directory: +``` +> echo PY_VER_MAJOR_MINOR=35> BuildDepsCache-x64.txt +> echo PYTHONPATH=C:\Python3>> BuildDepsCache-x64.txt +``` + +After this you should be able to run `run-cmake.bat` normally. If using 32-bit Python, the name of the file must be `BuildDepsCache-x86.txt`. Directory Structure ------------------ @@ -55,6 +72,7 @@ Directory Structure | install-ifcopenshell.cmd - Builds IFCOS's INSTALL project | readme.md - This file | run-cmake.bat - Sets environment variables for the dependencies and runs CMake for IFCOS +| set-python-to-path.bat - Utility for setting PYTHONPATH (read from BuildDepsCache-.txt) to PATH | vs-cfg.cmd - Utility file used by the build scripts +---sln - Contains the old Visual Studio solution and project files \---utils - Contains various utilities for the build scripts diff --git a/win/set-python-to-path.bat b/win/set-python-to-path.bat new file mode 100644 index 0000000000..613a69c149 --- /dev/null +++ b/win/set-python-to-path.bat @@ -0,0 +1,36 @@ +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: :: +:: This file is part of IfcOpenShell. :: +:: :: +:: IfcOpenShell is free software: you can redistribute it and/or modify :: +:: it under the terms of the Lesser GNU General Public License as published by :: +:: the Free Software Foundation, either version 3.0 of the License, or :: +:: (at your option) any later version. :: +:: :: +:: IfcOpenShell is distributed in the hope that it will be useful, :: +:: but WITHOUT ANY WARRANTY; without even the implied warranty of :: +:: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the :: +:: Lesser GNU General Public License for more details. :: +:: :: +:: You should have received a copy of the Lesser GNU General Public License :: +:: along with this program. If not, see . :: +:: :: +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +:: Pass x86 or x64 as %1, if not specified x64 assumed. + +@echo off +set TARGET_ARCH=%1 +if "%TARGET_ARCH%"=="" set TARGET_ARCH=x64 +if not exist BuildDepsCache-%TARGET_ARCH%.txt. ( + echo BuildDepsCache-%TARGET_ARCH%.txt does not exist + goto :EOF +) +for /f "delims== tokens=1,2" %%G in (BuildDepsCache-%TARGET_ARCH%.txt) do set %%G=%%H +if not defined PYTHONPATH ( + echo PYTHONPATH PYTHONPATH not defined + goto :EOF +) + +echo %PYTHONPATH% set to PATH +set PATH=%PYTHONPATH%;%PATH% From f2bdfbd049678b9ebaea287ee1d3cf632a1247fa Mon Sep 17 00:00:00 2001 From: Stinkfist0 Date: Tue, 26 Jan 2016 09:21:38 +0200 Subject: [PATCH 04/27] Windows build scripts: move build configuration type to a separate file. --- win/build-deps.cmd | 16 +++++------ win/build-type-cfg.cmd | 60 ++++++++++++++++++++++++++++++++++++++++++ win/readme.md | 1 + win/run-cmake.bat | 8 +++--- win/vs-cfg.cmd | 50 +++++------------------------------ 5 files changed, 76 insertions(+), 59 deletions(-) create mode 100644 win/build-type-cfg.cmd diff --git a/win/build-deps.cmd b/win/build-deps.cmd index 75ec4caa99..2115e2316b 100644 --- a/win/build-deps.cmd +++ b/win/build-deps.cmd @@ -46,16 +46,12 @@ if not %ERRORLEVEL%==0 ( ) :: Set up variables depending on the used Visual Studio version -call vs-cfg.cmd %1 %2 +call vs-cfg.cmd %1 +IF NOT %ERRORLEVEL%==0 GOTO :Error +call build-type-cfg.cmd %2 IF NOT %ERRORLEVEL%==0 GOTO :Error set BUILD_TYPE=%3 - -IF %GENERATOR%=="" ( - call cecho.cmd 0 12 "GENERATOR not specified - cannot proceed!" - GOTO :Error -) - IF "%BUILD_TYPE%"=="" set BUILD_TYPE=Build IF NOT "!BUILD_TYPE!"=="Build" IF NOT "!BUILD_TYPE!"=="Rebuild" IF NOT "!BUILD_TYPE!"=="Clean" ( @@ -71,9 +67,9 @@ IF NOT EXIST %INSTALL_DIR%. mkdir %INSTALL_DIR% IF %VS_VER%==2008 set PATH=C:\Windows\Microsoft.NET\Framework\v3.5;%PATH% :: User-configurable build options -IF "%IFCOS_INSTALL_PYTHON%"=="" set IFCOS_INSTALL_PYTHON=TRUE -IF "%IFCOS_USE_PYTHON2%"=="" set IFCOS_USE_PYTHON2=FALSE -IF "%IFCOS_NUM_BUILD_PROCS%"=="" set IFCOS_NUM_BUILD_PROCS=%NUMBER_OF_PROCESSORS% +IF NOT DEFINED IFCOS_INSTALL_PYTHON set IFCOS_INSTALL_PYTHON=TRUE +IF NOT DEFINED IFCOS_USE_PYTHON2 set IFCOS_USE_PYTHON2=FALSE +IF NOT DEFINED IFCOS_NUM_BUILD_PROCS set IFCOS_NUM_BUILD_PROCS=%NUMBER_OF_PROCESSORS% :: For subroutines set MSBUILD_CMD=MSBuild.exe /nologo /m:%IFCOS_NUM_BUILD_PROCS% /t:%BUILD_TYPE% diff --git a/win/build-type-cfg.cmd b/win/build-type-cfg.cmd new file mode 100644 index 0000000000..acb75d64ad --- /dev/null +++ b/win/build-type-cfg.cmd @@ -0,0 +1,60 @@ +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: :: +:: This file is part of IfcOpenShell. :: +:: :: +:: IfcOpenShell is free software: you can redistribute it and/or modify :: +:: it under the terms of the Lesser GNU General Public License as published by :: +:: the Free Software Foundation, either version 3.0 of the License, or :: +:: (at your option) any later version. :: +:: :: +:: IfcOpenShell is distributed in the hope that it will be useful, :: +:: but WITHOUT ANY WARRANTY; without even the implied warranty of :: +:: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the :: +:: Lesser GNU General Public License for more details. :: +:: :: +:: You should have received a copy of the Lesser GNU General Public License :: +:: along with this program. If not, see . :: +:: :: +::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::: + +:: This script initializes various CMake build configuration type related variables. +:: This batch file expects CMake build configuration type as %1. + +@echo off + +:: Set up variables depending on the used build configuration type. +set BUILD_CFG=%1 + +:: The default build types provided by CMake +set BUILD_CFG_MINSIZEREL=MinSizeRel +set BUILD_CFG_RELEASE=Release +set BUILD_CFG_RELWITHDEBINFO=RelWithDebInfo +set BUILD_CFG_DEBUG=Debug +set BUILD_CFG_DEFAULT=%BUILD_CFG_RELWITHDEBINFO% + +IF "!BUILD_CFG!"=="" ( + set BUILD_CFG=%BUILD_CFG_DEFAULT% + call utils\cecho.cmd 0 14 "%~nx0: Warning: BUILD_CFG not specified - using the default %BUILD_CFG_DEFAULT%" +) +IF NOT !BUILD_CFG!==%BUILD_CFG_MINSIZEREL% IF NOT !BUILD_CFG!==%BUILD_CFG_RELEASE% ( +IF NOT !BUILD_CFG!==%BUILD_CFG_RELWITHDEBINFO% IF NOT !BUILD_CFG!==%BUILD_CFG_DEBUG% ( + call utils\cecho.cmd 0 12 "%~nx0: Invalid or unsupported CMake build configuration type passed: !BUILD_CFG!. Cannot proceed." + exit /b 1 +)) + +:: DEBUG_OR_RELEASE and DEBUG_OR_RELEASE_LOWERCASE are "Debug" and "debug" for Debug build and "Release" and +:: "release" for all of the Release variants. +:: POSTFIX_D, POSTFIX_UNDERSCORE_D and POSTFIX_UNDERSCORE_DEBUG are helpers for performing file copies and +:: checking for existence of files. In release build these variables are empty. +set DEBUG_OR_RELEASE=Release +set DEBUG_OR_RELEASE_LOWERCASE=release +set POSTFIX_D= +set POSTFIX_UNDERSCORE_D= +set POSTFIX_UNDERSCORE_DEBUG= +IF %BUILD_CFG%==Debug ( + set DEBUG_OR_RELEASE=Debug + set DEBUG_OR_RELEASE_LOWERCASE=debug + set POSTFIX_D=d + set POSTFIX_UNDERSCORE_D=_d + set POSTFIX_UNDERSCORE_DEBUG=_debug +) diff --git a/win/readme.md b/win/readme.md index 8af62504c2..5cb1138074 100644 --- a/win/readme.md +++ b/win/readme.md @@ -69,6 +69,7 @@ Directory Structure | build-deps.cmd - Fetches and builds all needed dependencies for IFCOS | BuildDepsCache-.txt - Cache file created by build-deps.cmd | build-ifcopenshell.cmd - Builds IFCOS +| build-type-cfg.cmd - Utility file used by the build scripts | install-ifcopenshell.cmd - Builds IFCOS's INSTALL project | readme.md - This file | run-cmake.bat - Sets environment variables for the dependencies and runs CMake for IFCOS diff --git a/win/run-cmake.bat b/win/run-cmake.bat index 6594a2812b..b3b7e1cd4c 100644 --- a/win/run-cmake.bat +++ b/win/run-cmake.bat @@ -24,7 +24,7 @@ set PROJECT_NAME=IfcOpenShell :: Enable the delayed environment variable expansion needed in vs-cfg.cmd. setlocal EnableDelayedExpansion -:: TODO Getting warning print in vs-cfg.cmd for missing build type although this script doesn't need it specified + call vs-cfg.cmd %1 IF NOT %ERRORLEVEL%==0 GOTO :Error @@ -39,7 +39,6 @@ IF NOT EXIST ..\%BUILD_DIR%. mkdir ..\%BUILD_DIR% pushd ..\%BUILD_DIR% set BOOST_ROOT=%DEPS_DIR%\boost -REM set BOOST_INCLUDEDIR=%DEPS_DIR%\boost set BOOST_LIBRARYDIR=%DEPS_DIR%\boost\stage\vs%VS_VER%-%VS_PLATFORM%\lib set ICU_INCLUDE_DIR=%INSTALL_DIR%\icu\include set ICU_LIBRARY_DIR=%INSTALL_DIR%\icu\lib @@ -47,8 +46,8 @@ set OCC_INCLUDE_DIR=%INSTALL_DIR%\oce\include\oce set OCC_LIBRARY_DIR=%INSTALL_DIR%\oce\Win%ARCH_BITS%\lib set OPENCOLLADA_INCLUDE_DIR=%INSTALL_DIR%\OpenCOLLADA\include\opencollada set OPENCOLLADA_LIBRARY_DIR=%INSTALL_DIR%\OpenCOLLADA\lib\opencollada -if "%PY_VER_MAJOR_MINOR%"=="" set PY_VER_MAJOR_MINOR=34 -if "%PYTHONPATH%"=="" set PYTHONPATH=%INSTALL_DIR%\Python%PY_VER_MAJOR_MINOR% +if not defined PY_VER_MAJOR_MINOR set PY_VER_MAJOR_MINOR=34 +if not defined PYTHONPATH set PYTHONPATH=%INSTALL_DIR%\Python%PY_VER_MAJOR_MINOR% set PYTHON_INCLUDE_DIR=%PYTHONPATH%\include set PYTHON_LIBRARY=%PYTHONPATH%\libs\python%PY_VER_MAJOR_MINOR%.lib set SWIG_DIR=%INSTALL_DIR%\swigwin @@ -62,7 +61,6 @@ echo All arguments = %* echo. call cecho.cmd 0 10 "Dependency Environment Variables for %PROJECT_NAME%:" echo BOOST_ROOT = %BOOST_ROOT% -REM echo BOOST_INCLUDEDIR = %BOOST_INCLUDEDIR% echo BOOST_LIBRARYDIR = %BOOST_LIBRARYDIR% echo ICU_INCLUDE_DIR = %ICU_INCLUDE_DIR% echo ICU_LIBRARY_DIR = %ICU_LIBRARY_DIR% diff --git a/win/vs-cfg.cmd b/win/vs-cfg.cmd index 9eb6494d8b..98bedad576 100644 --- a/win/vs-cfg.cmd +++ b/win/vs-cfg.cmd @@ -15,11 +15,11 @@ :: You should have received a copy of the Lesser GNU General Public License :: :: along with this program. If not, see . :: :: :: -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::: -:: This script initializes various Visual Studio -related environment variables needed for building -:: This batch file expects CMake generator as %1 and build configuration type as %2. -:: If %1 is not provided, it is deduced from the VisualStudioVersion environment variable and from the location of cl.exe. +:: This script initializes various Visual Studio related environment variables needed for building. +:: the dependencies. This batch file expects a CMake generator as %1. If %1 is not provided, it is +:: deduced from the VisualStudioVersion environment variable and from the location of cl.exe. :: NOTE This batch file expects the generator string to be CMake 3.0.0 and newer format, i.e. :: "Visual Studio 10 2010" instead of "Visual Studio 10". However, one can use this batch file @@ -31,8 +31,7 @@ set GENERATOR=%1 -:: TODO IDEA: Take more user-friendly VS generators and convert them to the CMake ones? -:: F.ex. "vs2013-32" and/or "vc14-64" +:: TODO IDEA: Take more user-friendly VS generators (e.g. "vs2013-x86") and convert them to the CMake ones? :: Supported Visual Studio versions: set GENERATORS[0]="Visual Studio 9 2008 Win64" @@ -67,7 +66,7 @@ IF "!GENERATOR!"=="" IF NOT "%VisualStudioVersion%"=="" ( ) :: Check that the used CMake version supports the chosen generator set GENERATOR_CHECK=%GENERATOR: Win64=% -cmake --help | findstr /c:%GENERATOR_CHECK% +cmake --help | findstr /c:%GENERATOR_CHECK% >nul if not %ERRORLEVEL%==0 ( call utils\cecho.cmd 0 12 "%~nx0: The used CMake version does not support '`"!GENERATOR!`'"- cannot proceed." exit /b 1 @@ -124,43 +123,6 @@ set GENERATOR=%GENERATOR: 2010=% set VCPROJ_FILE_EXT=vcxproj IF %VS_VER%==2008 set VCPROJ_FILE_EXT=vcproj -:: Set up variables depending on the used build configuration type. -set BUILD_CFG=%2 - -:: The default build types provided by CMake -set BUILD_CFG_MINSIZEREL=MinSizeRel -set BUILD_CFG_RELEASE=Release -set BUILD_CFG_RELWITHDEBINFO=RelWithDebInfo -set BUILD_CFG_DEBUG=Debug -set BUILD_CFG_DEFAULT=%BUILD_CFG_RELWITHDEBINFO% - -IF "!BUILD_CFG!"=="" ( - set BUILD_CFG=%BUILD_CFG_DEFAULT% - call utils\cecho.cmd 0 14 "%~nx0: Warning: BUILD_CFG not specified - using the default %BUILD_CFG_DEFAULT%" -) -IF NOT !BUILD_CFG!==%BUILD_CFG_MINSIZEREL% IF NOT !BUILD_CFG!==%BUILD_CFG_RELEASE% ( -IF NOT !BUILD_CFG!==%BUILD_CFG_RELWITHDEBINFO% IF NOT !BUILD_CFG!==%BUILD_CFG_DEBUG% ( - call utils\cecho.cmd 0 12 "%~nx0: Invalid or unsupported CMake build configuration type passed: !BUILD_CFG!. Cannot proceed." - exit /b 1 -)) - -:: DEBUG_OR_RELEASE and DEBUG_OR_RELEASE_LOWERCASE are "Debug" and "debug" for Debug build and "Release" and -:: "release" for all of the Release variants. -:: POSTFIX_D, POSTFIX_UNDERSCORE_D and POSTFIX_UNDERSCORE_DEBUG are helpers for performing file copies and -:: checking for existence of files. In release build these variables are empty. -set DEBUG_OR_RELEASE=Release -set DEBUG_OR_RELEASE_LOWERCASE=release -set POSTFIX_D= -set POSTFIX_UNDERSCORE_D= -set POSTFIX_UNDERSCORE_DEBUG= -IF %BUILD_CFG%==Debug ( - set DEBUG_OR_RELEASE=Debug - set DEBUG_OR_RELEASE_LOWERCASE=debug - set POSTFIX_D=d - set POSTFIX_UNDERSCORE_D=_d - set POSTFIX_UNDERSCORE_DEBUG=_debug -) - :: Add utils to PATH set ORIGINAL_PATH=%PATH% set PATH=%PATH%;%~dp0utils From 01f8882311cddd4c5fe9be47d6f7775951651f03 Mon Sep 17 00:00:00 2001 From: Stinkfist0 Date: Sun, 31 Jan 2016 18:45:33 +0200 Subject: [PATCH 05/27] adjust build-ifcopenshell & install-ifcopenshell to the build cfg batch file change --- win/build-ifcopenshell.cmd | 4 +++- win/install-ifcopenshell.cmd | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/win/build-ifcopenshell.cmd b/win/build-ifcopenshell.cmd index c08858ae85..3b332de9e1 100644 --- a/win/build-ifcopenshell.cmd +++ b/win/build-ifcopenshell.cmd @@ -27,7 +27,9 @@ echo. :: Enable the delayed environment variable expansion needed in VSConfig.cmd. setlocal EnableDelayedExpansion -call vs-cfg.cmd %1 %2 +call vs-cfg.cmd %1 +IF NOT %ERRORLEVEL%==0 GOTO :Error +call build-type-cfg.cmd %2 IF NOT %ERRORLEVEL%==0 GOTO :Error echo. diff --git a/win/install-ifcopenshell.cmd b/win/install-ifcopenshell.cmd index d112772a90..99c743bd28 100644 --- a/win/install-ifcopenshell.cmd +++ b/win/install-ifcopenshell.cmd @@ -27,7 +27,9 @@ echo. :: Enable the delayed environment variable expansion needed in VSConfig.cmd. setlocal EnableDelayedExpansion -call vs-cfg.cmd %1 %2 +call vs-cfg.cmd %1 +IF NOT %ERRORLEVEL%==0 GOTO :Error +call build-type-cfg.cmd %2 IF NOT %ERRORLEVEL%==0 GOTO :Error echo. From a041d289c6db3eb3b4888d1c69b1d9e974c48ab5 Mon Sep 17 00:00:00 2001 From: Stinkfist0 Date: Sun, 31 Jan 2016 20:26:40 +0200 Subject: [PATCH 06/27] Add build-all.cmd script for convenience. --- win/build-all.cmd | 32 ++++++++++++++++++++++++++++++++ win/build-deps.cmd | 5 +++-- win/build-ifcopenshell.cmd | 4 +++- win/install-ifcopenshell.cmd | 4 +++- win/readme.md | 1 + win/run-cmake.bat | 5 +++-- 6 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 win/build-all.cmd diff --git a/win/build-all.cmd b/win/build-all.cmd new file mode 100644 index 0000000000..91caa9786c --- /dev/null +++ b/win/build-all.cmd @@ -0,0 +1,32 @@ +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: :: +:: This file is part of IfcOpenShell. :: +:: :: +:: IfcOpenShell is free software: you can redistribute it and/or modify :: +:: it under the terms of the Lesser GNU General Public License as published by :: +:: the Free Software Foundation, either version 3.0 of the License, or :: +:: (at your option) any later version. :: +:: :: +:: IfcOpenShell is distributed in the hope that it will be useful, :: +:: but WITHOUT ANY WARRANTY; without even the implied warranty of :: +:: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the :: +:: Lesser GNU General Public License for more details. :: +:: :: +:: You should have received a copy of the Lesser GNU General Public License :: +:: along with this program. If not, see . :: +:: :: +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +:: TODO Allow passing cmd line args +@echo off +:: Use "yes" trick to break the pause in build-deps.cmd +echo y>y.txt +call .\build-deps - - Created by build-deps.cmd, for a certain VS version and target architecture +---installed-vs- - Created by building the IFCOS's INSTALL project \---win +| build-all.cmd - Runs all of the build scripts for IFCOS and it dependencies in a row without pauses | build-deps.cmd - Fetches and builds all needed dependencies for IFCOS | BuildDepsCache-.txt - Cache file created by build-deps.cmd | build-ifcopenshell.cmd - Builds IFCOS diff --git a/win/run-cmake.bat b/win/run-cmake.bat index b3b7e1cd4c..7d482bc87e 100644 --- a/win/run-cmake.bat +++ b/win/run-cmake.bat @@ -97,14 +97,15 @@ REM ) ELSE ( REM ) echo. +set IFCOS_SCRIPT_RET=0 goto :Finish :Error echo. call %~dp0\utils\cecho.cmd 0 12 "An error occurred! Aborting!" +set IFCOS_SCRIPT_RET=1 goto :Finish :Finish popd -set PATH=%ORIGINAL_PATH% -endlocal +exit /b %IFCOS_SCRIPT_RET% From 634932e6e788dfff7675f59a3666d2cefe221480 Mon Sep 17 00:00:00 2001 From: Stinkfist0 Date: Mon, 1 Feb 2016 18:08:27 +0200 Subject: [PATCH 07/27] run-cmake.bat: set CMAKE_INSTALL_PREFIX also when passing extra parameters for the script --- win/run-cmake.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win/run-cmake.bat b/win/run-cmake.bat index 7d482bc87e..1b84643bd6 100644 --- a/win/run-cmake.bat +++ b/win/run-cmake.bat @@ -88,7 +88,7 @@ REM IF NOT EXIST %PROJECT_NAME%.sln. ( REM i.e. they contain an equal sign, they will mess up the batch file argument parsing if the arguments are passed on REM by splitting them %2 %3 %4 %5 %6 %7 %8 %9. In the extra argument case trust that user has provided the generator REM as the first argument as pass all arguments as is by using %*. - cmake.exe %CMAKELISTS_DIR% -G %* + cmake.exe %CMAKELISTS_DIR% -G %* -DCMAKE_INSTALL_PREFIX="%CMAKE_INSTALL_PREFIX%" ) IF NOT %ERRORLEVEL%==0 GOTO :Error REM ) ELSE ( From 2e6601b3e786d78c01497453a1ad7fdc316a2305 Mon Sep 17 00:00:00 2001 From: Stinkfist0 Date: Wed, 3 Feb 2016 12:01:53 +0200 Subject: [PATCH 08/27] build-deps.cmd: do not print build times if build did not even start properly. --- win/build-deps.cmd | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/win/build-deps.cmd b/win/build-deps.cmd index e526309f70..b145347bf9 100644 --- a/win/build-deps.cmd +++ b/win/build-deps.cmd @@ -124,6 +124,7 @@ pause echo. set START_TIME=%TIME% echo Build started at %START_TIME%. +set BUILD_STARTED=TRUE echo. cd %DEPS_DIR% @@ -319,6 +320,7 @@ goto :Finish :Finish :: Print end time and elapsed time, http://stackoverflow.com/a/9935540 +if not defined BUILD_STARTED goto :BuildTimeSkipped set END_TIME=%TIME% for /F "tokens=1-4 delims=:.," %%a in ("%START_TIME%") do ( set /A "start=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100" @@ -333,7 +335,7 @@ if %ss% lss 10 set ss=0%ss% if %cc% lss 10 set cc=0%cc% echo. echo Build ended at %END_TIME%. Time elapsed %hh%:%mm%:%ss%.%cc%. - +:BuildTimeSkipped set PATH=%ORIGINAL_PATH% cd %~dp0 exit /b %IFCOS_SCRIPT_RET% From 21e8a1e8e64ed9019adfb8bcb9e66d81359af0b1 Mon Sep 17 00:00:00 2001 From: Stinkfist0 Date: Wed, 3 Feb 2016 15:21:12 +0200 Subject: [PATCH 09/27] vs-cfg.cmd: provide support for user-friendly VS generators, e.g. vs2013-x86, and converted them to the appropriate CMake ones. --- win/readme.md | 9 +++++---- win/vs-cfg.cmd | 31 ++++++++++++++++++++++++------- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/win/readme.md b/win/readme.md index 4f1ea5ca37..0c1f0357bf 100644 --- a/win/readme.md +++ b/win/readme.md @@ -16,10 +16,11 @@ running the script. `build-deps.cmd` expects a CMake generator as `%1` and a build configuration type (`RelWithDebInfo/Release/MinSizeRel/Debug`, defaults to `RelWithDebInfo`) as `%2`. If the generator is not provided, the generator is deduced from the Visual Studio -environment variables. A build type (`Build/Rebuild/Clean`, defaults to `Build`) can be provided as `%3`. See `vs-cfg.cmd` -if you wish to change the defaults. The batch file will create `deps\` and `deps-vs--installed\` -directories to the project root. Debug and release builds of the depedencies can co-exist by simply running -`build-deps.cmd Debug` and `build-deps.cmd `. +environment variables. User-friendly VS generator shorthands are supported, e.g. `vs2013-x86` or `vs2015-x64`, and these are +converted to the appropriate CMake ones by the scripts. A build type (`Build/Rebuild/Clean`, defaults to `Build`) can be +provided as `%3`. See `vs-cfg.cmd` if you wish to change the defaults. The batch file will create `deps\` and +`deps-vs--installed\` directories to the project root. Debug and release builds of the depedencies +can co-exist by simply running `build-deps.cmd Debug` and `build-deps.cmd `. After the dependencies are build, execute `run-cmake.bat`. The batch file expects always a CMake generator as `%1` (if not provided, the same default value as above is used), and the rest of possible parameters are passed as is. diff --git a/win/vs-cfg.cmd b/win/vs-cfg.cmd index 98bedad576..5b5d1de346 100644 --- a/win/vs-cfg.cmd +++ b/win/vs-cfg.cmd @@ -20,6 +20,7 @@ :: This script initializes various Visual Studio related environment variables needed for building. :: the dependencies. This batch file expects a CMake generator as %1. If %1 is not provided, it is :: deduced from the VisualStudioVersion environment variable and from the location of cl.exe. +:: User-friendly VS generators are allowed (e.g. "vs2013-x86") and converted to the appropriate CMake ones. :: NOTE This batch file expects the generator string to be CMake 3.0.0 and newer format, i.e. :: "Visual Studio 10 2010" instead of "Visual Studio 10". However, one can use this batch file @@ -31,8 +32,6 @@ set GENERATOR=%1 -:: TODO IDEA: Take more user-friendly VS generators (e.g. "vs2013-x86") and convert them to the CMake ones? - :: Supported Visual Studio versions: set GENERATORS[0]="Visual Studio 9 2008 Win64" set GENERATORS[1]="Visual Studio 9 2008" @@ -46,17 +45,35 @@ set GENERATORS[8]="Visual Studio 14 2015 Win64" set GENERATORS[9]="Visual Studio 14 2015" set LAST_GENERATOR_IDX=9 -:: Deduce desired architecture from the location of cl.exe -where cl.exe | findstr /r /c:"amd64" >nul -set START=%ERRORLEVEL% set STEP=2 +:: Is generator shorthand used? +set GEN_SHORTHAND=!GENERATOR:vs=! +if !GEN_SHORTHAND!==!GENERATOR! goto :GeneratorShorthandCheckDone +set START=%LAST_GENERATOR_IDX% +:: "echo if" trick from http://stackoverflow.com/a/8758579 +echo(!GEN_SHORTHAND! | findstr /c:"-x86" >nul && ( set START=1 ) +echo(!GEN_SHORTHAND! | findstr /c:"-x64" >nul && ( set START=0 ) +set VS_VER=!GEN_SHORTHAND:-x86=! +set VS_VER=!VS_VER:-x64=! +echo(!GENERATOR! | findstr /c:"vs20" >nul && ( + for /l %%i in (!START!,!STEP!,%LAST_GENERATOR_IDX%) do ( + echo(!GENERATORS[%%i]! | findstr /c:"!VS_VER!" >nul && ( + set GENERATOR=!GENERATORS[%%i]! + goto :GeneratorShorthandCheckDone + ) + ) +) +:GeneratorShorthandCheckDone + +:: Deduce desired architecture from the location of cl.exe +where cl.exe | findstr /c:"amd64" >nul +set START=%ERRORLEVEL% IF "!GENERATOR!"=="" IF NOT "%VisualStudioVersion%"=="" ( set VC_VER=%VisualStudioVersion:.0=% FOR /l %%i in (%START%,%STEP%,%LAST_GENERATOR_IDX%) DO ( - REM http://stackoverflow.com/a/8758579 REM NOTE add space before VC_VER so that e.g. "12" doesn't match with "2012" - echo(!GENERATORS[%%i]! | findstr /r /c:" !VC_VER!" >nul && ( + echo(!GENERATORS[%%i]! | findstr /c:" !VC_VER!" >nul && ( set GENERATOR=!GENERATORS[%%i]! call utils\cecho.cmd black cyan "Generator not passed, but VisualStudioVersion=%VisualStudioVersion% environment variable detected:" call utils\cecho.cmd black cyan "using '`"!GENERATOR!`'" as the generator." From 0fa05faee8fad46a39c0a4bc65e6dfc97fe33dd9 Mon Sep 17 00:00:00 2001 From: Stinkfist0 Date: Wed, 3 Feb 2016 16:01:06 +0200 Subject: [PATCH 10/27] Simplify run-cmake.bat, the script can now be used e.g. run-cmake.bat vs2015-x64 -UDUSE_IFC4=1 -DCMAKE_INSTALL_PREFIX=C:/IfcOpenShell/Ifc4 --- win/readme.md | 5 +++++ win/run-cmake.bat | 29 ++++++++++------------------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/win/readme.md b/win/readme.md index 0c1f0357bf..f91e3a7bae 100644 --- a/win/readme.md +++ b/win/readme.md @@ -24,6 +24,11 @@ can co-exist by simply running `build-deps.cmd Debug` and `build-dep After the dependencies are build, execute `run-cmake.bat`. The batch file expects always a CMake generator as `%1` (if not provided, the same default value as above is used), and the rest of possible parameters are passed as is. +If passing build options for the script, the generator must be always passed as the first option: +``` +> run-cmake.bat vs2015-x64 -DUSE_IFC4=1 -DBUILD_IFCPYTHON=0 +``` + **If you wish to use any library from a custom location, modify the paths in `run-cmake.bat` accordingly**. The batch script will create a folder of form `build-vs-\` which will contain the solution and project files for Visual Studio. diff --git a/win/run-cmake.bat b/win/run-cmake.bat index 1b84643bd6..614173dc79 100644 --- a/win/run-cmake.bat +++ b/win/run-cmake.bat @@ -54,10 +54,13 @@ 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 CMake Generator = %GENERATOR% -echo All arguments = %* +echo All arguments = %ALL_BUT_FIRST% echo. call cecho.cmd 0 10 "Dependency Environment Variables for %PROJECT_NAME%:" echo BOOST_ROOT = %BOOST_ROOT% @@ -77,24 +80,12 @@ echo CMAKE_INSTALL_PREFIX = %CMAKE_INSTALL_PREFIX% echo. set CMAKELISTS_DIR=..\cmake -REM IF NOT EXIST %PROJECT_NAME%.sln. ( - IF EXIST CMakeCache.txt. del /Q CMakeCache.txt - call cecho.cmd 0 13 "Running CMake for %PROJECT_NAME%." - IF "%2"=="" ( - REM No extra arguments provided, trust that GENERATOR is set properly. - cmake.exe %CMAKELISTS_DIR% -G %GENERATOR% -DCMAKE_INSTALL_PREFIX="%CMAKE_INSTALL_PREFIX%" - ) ELSE ( - REM Extra arguments has been provided. As CMake options are typically of format -DSOMETHING:BOOL=ON, - REM i.e. they contain an equal sign, they will mess up the batch file argument parsing if the arguments are passed on - REM by splitting them %2 %3 %4 %5 %6 %7 %8 %9. In the extra argument case trust that user has provided the generator - REM as the first argument as pass all arguments as is by using %*. - cmake.exe %CMAKELISTS_DIR% -G %* -DCMAKE_INSTALL_PREFIX="%CMAKE_INSTALL_PREFIX%" - ) - IF NOT %ERRORLEVEL%==0 GOTO :Error -REM ) ELSE ( - REM call cecho.cmd 0 10 "%PROJECT_NAME%.sln exists. Skipping CMake call for %PROJECT_NAME%." - REM call cecho.cmd 0 10 "Delete %BUILD_DIR%\%PROJECT_NAME%.sln to trigger a CMake rerun." -REM ) +:: 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% +IF NOT %ERRORLEVEL%==0 GOTO :Error + echo. set IFCOS_SCRIPT_RET=0 From 5c07c8dc951fa18779aa82c82e5c66a82469fb8b Mon Sep 17 00:00:00 2001 From: Stinkfist0 Date: Wed, 3 Feb 2016 16:15:40 +0200 Subject: [PATCH 11/27] run-cmake.bat print tweak --- win/run-cmake.bat | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/win/run-cmake.bat b/win/run-cmake.bat index 614173dc79..4ab6751d27 100644 --- a/win/run-cmake.bat +++ b/win/run-cmake.bat @@ -59,8 +59,8 @@ for /f "tokens=1,* delims= " %%a in ("%*") do set ALL_BUT_FIRST=%%b echo. call cecho.cmd 0 10 "Script configuration:" -echo CMake Generator = %GENERATOR% -echo All arguments = %ALL_BUT_FIRST% +echo Generator = %GENERATOR% +echo Arguments = %ALL_BUT_FIRST% echo. call cecho.cmd 0 10 "Dependency Environment Variables for %PROJECT_NAME%:" echo BOOST_ROOT = %BOOST_ROOT% From 2e1699beea0c579992fc6f4fab46cb17353af3f6 Mon Sep 17 00:00:00 2001 From: Stinkfist0 Date: Wed, 3 Feb 2016 16:36:07 +0200 Subject: [PATCH 12/27] build-all.cmd: support for passing arguments, e.g. build-all.cmd vs2015-x64 RelWithDebInfo -DUSE_IFC4=1 -DENABLE_BUILD_OPTIMIZATIONS=1 --- win/build-all.cmd | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/win/build-all.cmd b/win/build-all.cmd index 91caa9786c..fab1b422a8 100644 --- a/win/build-all.cmd +++ b/win/build-all.cmd @@ -17,16 +17,23 @@ :: :: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: TODO Allow passing cmd line args +:: The first argument is assumed to be a CMake generator and it is passed for build-deps, run-cmake, build-ifcopenshell, +:: and install-ifcopenshell. The second argument is assumed to be a build configuration type and it is passed for build-deps, +:: 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 + :: Use "yes" trick to break the pause in build-deps.cmd echo y>y.txt -call .\build-deps Date: Wed, 3 Feb 2016 22:16:50 +0200 Subject: [PATCH 13/27] Fix command-line argument parsing in run-cmake.bat and build-all.cmd --- win/build-all.cmd | 13 ++++++++++--- win/run-cmake.bat | 13 +++++++------ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/win/build-all.cmd b/win/build-all.cmd index fab1b422a8..00f9e779a7 100644 --- a/win/build-all.cmd +++ b/win/build-all.cmd @@ -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 Date: Wed, 3 Feb 2016 22:34:50 +0200 Subject: [PATCH 14/27] Fix warning regarding shadowing variable names. --- src/ifcgeom/IfcGeomFunctions.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/ifcgeom/IfcGeomFunctions.cpp b/src/ifcgeom/IfcGeomFunctions.cpp index b70808fc77..1ed8ee1627 100644 --- a/src/ifcgeom/IfcGeomFunctions.cpp +++ b/src/ifcgeom/IfcGeomFunctions.cpp @@ -1275,8 +1275,7 @@ std::pair IfcGeom::Kernel::initializeUnits(IfcSchema::IfcUn } const IfcSchema::IfcRepresentationItem* IfcGeom::Kernel::find_item_carrying_style(const IfcSchema::IfcRepresentationItem* item) { - IfcSchema::IfcStyledItem::list::ptr styles = item->StyledByItem(); - if (styles->size()) { + if (item->StyledByItem()->size()) { return item; } @@ -1284,9 +1283,7 @@ const IfcSchema::IfcRepresentationItem* IfcGeom::Kernel::find_item_carrying_styl // All instantiations of IfcBooleanOperand (type of FirstOperand) are subtypes of // IfcGeometricRepresentationItem item = (IfcSchema::IfcGeometricRepresentationItem*) ((IfcSchema::IfcBooleanClippingResult*) item)->FirstOperand(); - - IfcSchema::IfcStyledItem::list::ptr styles = item->StyledByItem(); - if (styles->size()) { + if (item->StyledByItem()->size()) { return item; } } @@ -1297,4 +1294,4 @@ const IfcSchema::IfcRepresentationItem* IfcGeom::Kernel::find_item_carrying_styl // distinctly styled union operands. return item; -} \ No newline at end of file +} From 72999e04d938cab47af66737b752dee0a3dc8ba5 Mon Sep 17 00:00:00 2001 From: Stinkfist0 Date: Thu, 4 Feb 2016 00:43:52 +0200 Subject: [PATCH 15/27] vs-cfg.cmd: clean up output when used wrongly (VS tools not in path and empty/no generator argument passed). --- win/vs-cfg.cmd | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/win/vs-cfg.cmd b/win/vs-cfg.cmd index 5b5d1de346..eb10384abf 100644 --- a/win/vs-cfg.cmd +++ b/win/vs-cfg.cmd @@ -48,7 +48,7 @@ set LAST_GENERATOR_IDX=9 set STEP=2 :: Is generator shorthand used? set GEN_SHORTHAND=!GENERATOR:vs=! -if !GEN_SHORTHAND!==!GENERATOR! goto :GeneratorShorthandCheckDone +if not "!GEN_SHORTHAND!"=="" if !GEN_SHORTHAND!==!GENERATOR! goto :GeneratorShorthandCheckDone set START=%LAST_GENERATOR_IDX% :: "echo if" trick from http://stackoverflow.com/a/8758579 echo(!GEN_SHORTHAND! | findstr /c:"-x86" >nul && ( set START=1 ) @@ -83,10 +83,12 @@ IF "!GENERATOR!"=="" IF NOT "%VisualStudioVersion%"=="" ( ) :: Check that the used CMake version supports the chosen generator set GENERATOR_CHECK=%GENERATOR: Win64=% -cmake --help | findstr /c:%GENERATOR_CHECK% >nul -if not %ERRORLEVEL%==0 ( - call utils\cecho.cmd 0 12 "%~nx0: The used CMake version does not support '`"!GENERATOR!`'"- cannot proceed." - exit /b 1 +IF "!GENERATOR_CHECK!"=="" ( + cmake --help | findstr /c:%GENERATOR_CHECK% >nul + if not %ERRORLEVEL%==0 ( + call utils\cecho.cmd 0 12 "%~nx0: The used CMake version does not support '`"!GENERATOR!`'"- cannot proceed." + exit /b 1 + ) ) FOR /l %%i in (0,1,%LAST_GENERATOR_IDX%) DO ( From 17ecc43f7892ae45b61519acca00883240762a87 Mon Sep 17 00:00:00 2001 From: Stinkfist0 Date: Thu, 4 Feb 2016 11:46:53 +0200 Subject: [PATCH 16/27] vs-cfg.cmd: remove if-clause, an erroneous syntax print comes if this script is called when VS env vars not set but that's OK. --- win/vs-cfg.cmd | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/win/vs-cfg.cmd b/win/vs-cfg.cmd index eb10384abf..92c0a1217d 100644 --- a/win/vs-cfg.cmd +++ b/win/vs-cfg.cmd @@ -83,12 +83,10 @@ IF "!GENERATOR!"=="" IF NOT "%VisualStudioVersion%"=="" ( ) :: Check that the used CMake version supports the chosen generator set GENERATOR_CHECK=%GENERATOR: Win64=% -IF "!GENERATOR_CHECK!"=="" ( - cmake --help | findstr /c:%GENERATOR_CHECK% >nul - if not %ERRORLEVEL%==0 ( - call utils\cecho.cmd 0 12 "%~nx0: The used CMake version does not support '`"!GENERATOR!`'"- cannot proceed." - exit /b 1 - ) +cmake --help | findstr /c:%GENERATOR_CHECK% >nul +if not %ERRORLEVEL%==0 ( +call utils\cecho.cmd 0 12 "%~nx0: The used CMake version does not support '`"!GENERATOR!`'"- cannot proceed." +exit /b 1 ) FOR /l %%i in (0,1,%LAST_GENERATOR_IDX%) DO ( From 178c34fb22c2fd3bc3b0d243e22b0dfddfc22346 Mon Sep 17 00:00:00 2001 From: Stinkfist0 Date: Fri, 5 Feb 2016 14:48:51 +0200 Subject: [PATCH 17/27] README.md: document the supported IFC releases with links --- README.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 304f93a90c..10d03630a1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ IfcOpenShell ============ -Open source (LGPL) software library for working with the IFC file format. +Open source (LGPL) software library for working with the IFC ([IFC2x3 TC1] and [IFC4]) file format. [http://ifcopenshell.org](http://ifcopenshell.org) [http://academy.ifcopenshell.org](http://academy.ifcopenshell.org) @@ -14,16 +14,16 @@ Prerequisites Dependencies ============ * [Boost](http://www.boost.org/) -* Open Cascade *optional*, but required for building IfcGeom +* Open Cascade - *optional*, but required for building IfcGeom ([official](http://www.opencascade.org/getocc/download/loadocc/) or [community edition](https://github.com/tpaviot/oce)) For converting IFC representation items into BRep solids and tesselated meshes -* [ICU](http://site.icu-project.org/) *optional* +* [ICU](http://site.icu-project.org/) - *optional* For handling code pages and Unicode in the parser -* [OpenCOLLADA](https://github.com/khronosGroup/OpenCOLLADA/) *optional* +* [OpenCOLLADA](https://github.com/khronosGroup/OpenCOLLADA/) - *optional* For IfcConvert to be able to write tessellated Collada (.dae) files -* [SWIG](http://www.swig.org/), [Python](https://www.python.org/) libraries *optional* +* [SWIG](http://www.swig.org/), [Python](https://www.python.org/) libraries - *optional* For building the IfcOpenShell Python interface and the Blender add-on -* 3ds Max SDK *optional* +* 3ds Max SDK - *optional* For building the 3ds Max plug-in @@ -165,4 +165,6 @@ Usage examples >>> # Writing IFC-SPF files to disk: >>> f.write("out.ifc") -[win/readme.md]: https://github.com/IfcOpenShell/IfcOpenShell/tree/master/win/readme.md "win/readme.md" \ No newline at end of file +[win/readme.md]: https://github.com/IfcOpenShell/IfcOpenShell/tree/master/win/readme.md "win/readme.md" +[IFC2x3 TC1]: http://www.buildingsmart-tech.org/specifications/ifc-releases/ifc2x3-tc1-release "IFC2x3 TC1" +[IFC4]: http://www.buildingsmart-tech.org/specifications/ifc-releases/ifc4-release "IFC4" \ No newline at end of file From 33772a47104cf2cfafb0ba8665c925cd1cf360fa Mon Sep 17 00:00:00 2001 From: Stinkfist0 Date: Sat, 6 Feb 2016 18:48:18 +0200 Subject: [PATCH 18/27] run-cmake.bat & build-all.cmd: fix cmake arguments parsing when arguments passed for the batch scripts --- win/build-all.cmd | 4 ++-- win/run-cmake.bat | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/win/build-all.cmd b/win/build-all.cmd index 00f9e779a7..c907de928a 100644 --- a/win/build-all.cmd +++ b/win/build-all.cmd @@ -36,8 +36,8 @@ del .\y.txt 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=%% +if not (%1)==() call set ARGUMENTS=%%ARGUMENTS:%1=%% +if not (%2)==() call set ARGUMENTS=%%ARGUMENTS:%2=%% call .\run-cmake %1 %ARGUMENTS% if not %ERRORLEVEL%==0 goto :EOF call .\build-ifcopenshell %1 %2 diff --git a/win/run-cmake.bat b/win/run-cmake.bat index 61371539e2..d9fb548743 100644 --- a/win/run-cmake.bat +++ b/win/run-cmake.bat @@ -29,8 +29,10 @@ 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=%% +if not (%1)==() ( + 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 From cde1c5f2ee7e894ce3f30e3f1ee29012ddce363b Mon Sep 17 00:00:00 2001 From: Stinkfist0 Date: Sun, 7 Feb 2016 00:30:08 +0200 Subject: [PATCH 19/27] Add build option for using Visual Leak Detector for debugging memory leaks. Initial report: - IfcConvert (no arguments): 2 leaks (140 bytes) (from OCE) - IfcConvert (acad2010_objects.ifc): 47 memory leaks (6,158 bytes) - IfcGeomServer: 2 leaks (from OCE) - IfcOpenHouse: 11,952 leaks (1,169,658 bytes)! - IfcParseExamples (acad2010_objects.ifc): 40 memory leaks (4,564 bytes) --- cmake/CMakeLists.txt | 4 ++++ src/examples/IfcOpenHouse.cpp | 6 ++++++ src/examples/IfcParseExamples.cpp | 4 ++++ src/ifcconvert/IfcConvert.cpp | 4 ++++ src/ifcgeomserver/IfcGeomServer.cpp | 12 +++++++++++- 5 files changed, 29 insertions(+), 1 deletion(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index ef6fc19f60..68925c68c0 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -28,6 +28,7 @@ OPTION(ENABLE_BUILD_OPTIMIZATIONS "Enable certain compiler and linker optimizati OPTION(USE_IFC4 "Use IFC 4 instead of IFC 2x3 (full rebuild recommended when switching this)" OFF) OPTION(BUILD_IFCPYTHON "Build IfcPython." ON) OPTION(BUILD_EXAMPLES "Build example applications." ON) +OPTION(USE_VLC "Use Visual Leak Detector for debugging memory leaks, MSVC-only." OFF) # TODO QtViewer is deprecated ATM as it uses the 0.4 API # OPTION(BUILD_QTVIEWER "Build IfcOpenShell Qt GUI Viewer (requires Qt 4 framework)." OFF) @@ -237,6 +238,9 @@ if(ENABLE_BUILD_OPTIMIZATIONS) endif() IF(MSVC) + IF(USE_VLC) + ADD_DEFINITIONS(-DUSE_VLC) + ENDIF() # Enforce Unicode for CRT and Win32 API calls ADD_DEFINITIONS(-D_UNICODE -DUNICODE) # Disable warnings about unsafe C functions; we could use the safe C99 & C11 versions if we have no need for supporting old compilers. diff --git a/src/examples/IfcOpenHouse.cpp b/src/examples/IfcOpenHouse.cpp index af9de2bebe..ce811161e7 100644 --- a/src/examples/IfcOpenHouse.cpp +++ b/src/examples/IfcOpenHouse.cpp @@ -41,6 +41,10 @@ #include "../ifcparse/IfcHierarchyHelper.h" #include "../ifcgeom/IfcGeom.h" +#if USE_VLC +#include +#endif + // Some convenience typedefs and definitions. typedef std::string S; typedef IfcParse::IfcGlobalId guid; @@ -531,6 +535,8 @@ void createGroundShape(TopoDS_Shape& shape) { TColStd_Array1OfInteger mult(0, 1); mult(0) = 5; mult(1) = 5; +#undef new + Handle(Geom_BSplineSurface) surf = new Geom_BSplineSurface(cv, knots, knots, mult, mult, 4, 4); #if OCC_VERSION_HEX < 0x60502 shape = BRepBuilderAPI_MakeFace(surf); diff --git a/src/examples/IfcParseExamples.cpp b/src/examples/IfcParseExamples.cpp index 342a6e8674..1d418ee628 100644 --- a/src/examples/IfcParseExamples.cpp +++ b/src/examples/IfcParseExamples.cpp @@ -19,6 +19,10 @@ #include "../ifcparse/IfcFile.h" +#if USE_VLC +#include +#endif + using namespace IfcSchema; int main(int argc, char** argv) { diff --git a/src/ifcconvert/IfcConvert.cpp b/src/ifcconvert/IfcConvert.cpp index 73ecb1ad95..da8184acb7 100644 --- a/src/ifcconvert/IfcConvert.cpp +++ b/src/ifcconvert/IfcConvert.cpp @@ -46,6 +46,10 @@ #include #include +#if USE_VLC +#include +#endif + static std::string DEFAULT_EXTENSION = "obj"; void printVersion() { diff --git a/src/ifcgeomserver/IfcGeomServer.cpp b/src/ifcgeomserver/IfcGeomServer.cpp index fa3a356b4d..3ba7cedb82 100644 --- a/src/ifcgeomserver/IfcGeomServer.cpp +++ b/src/ifcgeomserver/IfcGeomServer.cpp @@ -37,6 +37,10 @@ #include "../ifcgeom/IfcGeomIterator.h" +#if USE_VLC +#include +#endif + using namespace boost; template @@ -282,7 +286,13 @@ public: Bye() : Command(BYE) {}; }; -int main () { +int main () +{ + // Memory leak debugging in MSVC debug mode +#if defined(_MSC_VER) && defined(_DEBUG) + _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); +#endif + // Redirect stdout to this stream, so that involuntary // writes to stdout do not interfere with our protocol. std::ostringstream oss; From 7b2197fa37d9d1a5272db47fa27c0098c5b9f932 Mon Sep 17 00:00:00 2001 From: Stinkfist0 Date: Sun, 7 Feb 2016 00:31:29 +0200 Subject: [PATCH 20/27] add /test/__pycache__ to ignore list --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index ba3b75032f..3b83ce65bc 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ # IfcExpressParser residue /src/ifcexpressparser/__pycache__ /src/ifcexpressparser/express_parser.py +# Python test residue +/test/__pycache__ From 450baf224f6c3b67d8d5ac13278323fbf652135e Mon Sep 17 00:00:00 2001 From: Stinkfist0 Date: Sun, 7 Feb 2016 00:51:10 +0200 Subject: [PATCH 21/27] Remove accidentally committed lines --- src/examples/IfcOpenHouse.cpp | 2 -- src/ifcgeomserver/IfcGeomServer.cpp | 8 +------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/examples/IfcOpenHouse.cpp b/src/examples/IfcOpenHouse.cpp index ce811161e7..f27a34cf88 100644 --- a/src/examples/IfcOpenHouse.cpp +++ b/src/examples/IfcOpenHouse.cpp @@ -535,8 +535,6 @@ void createGroundShape(TopoDS_Shape& shape) { TColStd_Array1OfInteger mult(0, 1); mult(0) = 5; mult(1) = 5; -#undef new - Handle(Geom_BSplineSurface) surf = new Geom_BSplineSurface(cv, knots, knots, mult, mult, 4, 4); #if OCC_VERSION_HEX < 0x60502 shape = BRepBuilderAPI_MakeFace(surf); diff --git a/src/ifcgeomserver/IfcGeomServer.cpp b/src/ifcgeomserver/IfcGeomServer.cpp index 3ba7cedb82..f70d82f7a0 100644 --- a/src/ifcgeomserver/IfcGeomServer.cpp +++ b/src/ifcgeomserver/IfcGeomServer.cpp @@ -286,13 +286,7 @@ public: Bye() : Command(BYE) {}; }; -int main () -{ - // Memory leak debugging in MSVC debug mode -#if defined(_MSC_VER) && defined(_DEBUG) - _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); -#endif - +int main () { // Redirect stdout to this stream, so that involuntary // writes to stdout do not interfere with our protocol. std::ostringstream oss; From 61ccd8a7cffb1d4936b60f5db10da67b0bb73be9 Mon Sep 17 00:00:00 2001 From: Stinkfist0 Date: Sun, 7 Feb 2016 12:28:05 +0200 Subject: [PATCH 22/27] VLD, not VLC... --- cmake/CMakeLists.txt | 6 +++--- src/examples/IfcOpenHouse.cpp | 2 +- src/examples/IfcParseExamples.cpp | 2 +- src/ifcconvert/IfcConvert.cpp | 2 +- src/ifcgeomserver/IfcGeomServer.cpp | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 68925c68c0..dc567be5bf 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -28,7 +28,7 @@ OPTION(ENABLE_BUILD_OPTIMIZATIONS "Enable certain compiler and linker optimizati OPTION(USE_IFC4 "Use IFC 4 instead of IFC 2x3 (full rebuild recommended when switching this)" OFF) OPTION(BUILD_IFCPYTHON "Build IfcPython." ON) OPTION(BUILD_EXAMPLES "Build example applications." ON) -OPTION(USE_VLC "Use Visual Leak Detector for debugging memory leaks, MSVC-only." OFF) +OPTION(USE_VLD "Use Visual Leak Detector for debugging memory leaks, MSVC-only." OFF) # TODO QtViewer is deprecated ATM as it uses the 0.4 API # OPTION(BUILD_QTVIEWER "Build IfcOpenShell Qt GUI Viewer (requires Qt 4 framework)." OFF) @@ -238,8 +238,8 @@ if(ENABLE_BUILD_OPTIMIZATIONS) endif() IF(MSVC) - IF(USE_VLC) - ADD_DEFINITIONS(-DUSE_VLC) + IF(USE_VLD) + ADD_DEFINITIONS(-DUSE_VLD) ENDIF() # Enforce Unicode for CRT and Win32 API calls ADD_DEFINITIONS(-D_UNICODE -DUNICODE) diff --git a/src/examples/IfcOpenHouse.cpp b/src/examples/IfcOpenHouse.cpp index f27a34cf88..c7414e76e7 100644 --- a/src/examples/IfcOpenHouse.cpp +++ b/src/examples/IfcOpenHouse.cpp @@ -41,7 +41,7 @@ #include "../ifcparse/IfcHierarchyHelper.h" #include "../ifcgeom/IfcGeom.h" -#if USE_VLC +#if USE_VLD #include #endif diff --git a/src/examples/IfcParseExamples.cpp b/src/examples/IfcParseExamples.cpp index 1d418ee628..7ae158a67f 100644 --- a/src/examples/IfcParseExamples.cpp +++ b/src/examples/IfcParseExamples.cpp @@ -19,7 +19,7 @@ #include "../ifcparse/IfcFile.h" -#if USE_VLC +#if USE_VLD #include #endif diff --git a/src/ifcconvert/IfcConvert.cpp b/src/ifcconvert/IfcConvert.cpp index da8184acb7..8f1e285ea8 100644 --- a/src/ifcconvert/IfcConvert.cpp +++ b/src/ifcconvert/IfcConvert.cpp @@ -46,7 +46,7 @@ #include #include -#if USE_VLC +#if USE_VLD #include #endif diff --git a/src/ifcgeomserver/IfcGeomServer.cpp b/src/ifcgeomserver/IfcGeomServer.cpp index f70d82f7a0..975c3c471e 100644 --- a/src/ifcgeomserver/IfcGeomServer.cpp +++ b/src/ifcgeomserver/IfcGeomServer.cpp @@ -37,7 +37,7 @@ #include "../ifcgeom/IfcGeomIterator.h" -#if USE_VLC +#if USE_VLD #include #endif From 993e322a8e3b71df661bcc313625995f53604f45 Mon Sep 17 00:00:00 2001 From: Stinkfist0 Date: Sun, 7 Feb 2016 13:14:14 +0200 Subject: [PATCH 23/27] Fix memory leakage from IfcSpfHeader --- src/ifcparse/IfcSpfHeader.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/ifcparse/IfcSpfHeader.h b/src/ifcparse/IfcSpfHeader.h index 0b349003f5..44eb719932 100644 --- a/src/ifcparse/IfcSpfHeader.h +++ b/src/ifcparse/IfcSpfHeader.h @@ -43,7 +43,7 @@ protected: } } - ~HeaderEntity() { + virtual ~HeaderEntity() { delete _list; } @@ -166,7 +166,14 @@ public: _file_name = new FileName(); _file_schema = new FileSchema(); } - + + ~IfcSpfHeader() + { + delete _file_schema; + delete _file_name; + delete _file_description; + } + IfcSpfLexer* lexer() { return _lexer; } void lexer(IfcSpfLexer* l) { _lexer = l; } From 2f8fa3282bd634d5488126faa944e5f630290970 Mon Sep 17 00:00:00 2001 From: Stinkfist0 Date: Sun, 7 Feb 2016 22:45:42 +0200 Subject: [PATCH 24/27] Fix mem leak in IfcSpfStream (not closed upon destruction), make Entity's dtor virtual. --- src/ifcparse/IfcParse.cpp | 5 +++++ src/ifcparse/IfcParse.h | 2 +- src/ifcparse/IfcSpfStream.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ifcparse/IfcParse.cpp b/src/ifcparse/IfcParse.cpp index 764d5143fb..a32f64baad 100644 --- a/src/ifcparse/IfcParse.cpp +++ b/src/ifcparse/IfcParse.cpp @@ -127,6 +127,11 @@ IfcSpfStream::IfcSpfStream(void* data, int l) { len = l; } +IfcSpfStream::~IfcSpfStream() +{ + Close(); +} + void IfcSpfStream::Close() { #ifdef BUF_SIZE if ( paging ) fclose(stream); diff --git a/src/ifcparse/IfcParse.h b/src/ifcparse/IfcParse.h index 2733f26d83..16907cf786 100644 --- a/src/ifcparse/IfcParse.h +++ b/src/ifcparse/IfcParse.h @@ -248,7 +248,7 @@ namespace IfcParse { unsigned int offset; Entity(unsigned int i, IfcFile* t); Entity(unsigned int i, IfcFile* t, unsigned int o); - ~Entity(); + virtual ~Entity(); IfcEntityList::ptr getInverse(IfcSchema::Type::Enum type, int attribute_index); void Load(std::vector& ids, bool seek=false) const; Argument* getArgument (unsigned int i); diff --git a/src/ifcparse/IfcSpfStream.h b/src/ifcparse/IfcSpfStream.h index 9f5799f2a2..a3d947606c 100644 --- a/src/ifcparse/IfcSpfStream.h +++ b/src/ifcparse/IfcSpfStream.h @@ -64,6 +64,7 @@ namespace IfcParse { IfcSpfStream(const std::string& fn); IfcSpfStream(std::istream& f, int len); IfcSpfStream(void* data, int len); + ~IfcSpfStream(); /// Returns the character at the cursor char Peek(); /// Returns the character at specified offset From c575352d205735a9986ddb017d1acead649f8126 Mon Sep 17 00:00:00 2001 From: Stinkfist0 Date: Sun, 7 Feb 2016 23:01:34 +0200 Subject: [PATCH 25/27] ~IfcCharacterDecoder: call ucnv_flushCache() to fix two ICU mem leaks. --- src/ifcparse/IfcCharacterDecoder.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ifcparse/IfcCharacterDecoder.cpp b/src/ifcparse/IfcCharacterDecoder.cpp index a49cee2eed..30e8518cab 100644 --- a/src/ifcparse/IfcCharacterDecoder.cpp +++ b/src/ifcparse/IfcCharacterDecoder.cpp @@ -118,6 +118,7 @@ IfcCharacterDecoder::~IfcCharacterDecoder() { destination = 0; converter = 0; compatibility_converter = 0; + ucnv_flushCache(); #endif } IfcCharacterDecoder::operator std::string() { From 4979deb111983b0f711227ea7fa17ccee4f9d1bb Mon Sep 17 00:00:00 2001 From: Stinkfist0 Date: Tue, 9 Feb 2016 15:51:18 +0200 Subject: [PATCH 26/27] CMakeLists.txt: Remove sources specific to an IFC release we are not using from the project --- cmake/CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index dc567be5bf..a232058a13 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -276,14 +276,22 @@ endif() IF(USE_IFC4) ADD_DEFINITIONS(-DUSE_IFC4) + SET(IFC_RELEASE_NOT_USED "2x3") ELSE() ADD_DEFINITIONS(-DUSE_IFC2x3) # TODO Make all caps? i.e. USE_IFC2X3 + SET(IFC_RELEASE_NOT_USED "4") ENDIF() # IfcParse file(GLOB CPP_FILES ../src/ifcparse/*.cpp) file(GLOB H_FILES ../src/ifcparse/*.h) set(SOURCE_FILES ${CPP_FILES} ${H_FILES}) +# Remove sources specific to an IFC release we are not using +list(REMOVE_ITEM SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../src/ifcparse/Ifc${IFC_RELEASE_NOT_USED}.h) +list(REMOVE_ITEM SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../src/ifcparse/Ifc${IFC_RELEASE_NOT_USED}enum.h) +list(REMOVE_ITEM SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../src/ifcparse/Ifc${IFC_RELEASE_NOT_USED}-latebound.h) +list(REMOVE_ITEM SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../src/ifcparse/Ifc${IFC_RELEASE_NOT_USED}.cpp) +list(REMOVE_ITEM SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../src/ifcparse/Ifc${IFC_RELEASE_NOT_USED}-latebound.cpp) ADD_LIBRARY(IfcParse STATIC ${SOURCE_FILES}) IF(UNICODE_SUPPORT) TARGET_LINK_LIBRARIES(IfcParse ${ICU_LIBRARIES}) From f12e980bfe8fcd3455c1ba0ccaa9897d9a9b01e1 Mon Sep 17 00:00:00 2001 From: Stinkfist0 Date: Mon, 15 Feb 2016 15:08:13 +0200 Subject: [PATCH 27/27] build-all.cmd: simplify "yes" trick --- win/build-all.cmd | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/win/build-all.cmd b/win/build-all.cmd index c907de928a..4f29f0edd3 100644 --- a/win/build-all.cmd +++ b/win/build-all.cmd @@ -30,9 +30,7 @@ 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