From 3224a2cf83b3f6d42b579dc3d916dbabcca98e67 Mon Sep 17 00:00:00 2001 From: Stinkfist0 Date: Fri, 4 Dec 2015 17:01:33 +0200 Subject: [PATCH] build-ifcopenshell & install-ifcopenshell batch files --- README.md | 19 +++++++++++---- win/build-deps.cmd | 3 +-- win/build-ifcopenshell.cmd | 46 ++++++++++++++++++++++++++++++++++++ win/install-ifcopenshell.cmd | 46 ++++++++++++++++++++++++++++++++++++ win/readme.md | 8 +++++-- win/run-cmake.bat | 1 - win/vs-cfg.cmd | 2 ++ 7 files changed, 115 insertions(+), 10 deletions(-) create mode 100644 win/build-ifcopenshell.cmd create mode 100644 win/install-ifcopenshell.cmd diff --git a/README.md b/README.md index 42c444def6..696cd75be4 100644 --- a/README.md +++ b/README.md @@ -33,17 +33,26 @@ Users are advised to build IfcOpenShell using the CMake file provided in the cmake/ folder. The preferred way to fetch and build this project's dependencies is to use the build scripts -in win/ folder. See [win/readme.md] for more information. Instructions in a nutshell +in win/ folder. **See [win/readme.md] for more information**. Instructions in a nutshell (**assuming Visual Studio 2015 x64 environment variables set**): > git clone https://github.com/IfcOpenShell/IfcOpenShell.git - > cd oce\win - > build-deps.cmd (defaults to RelWithDebInfo build) + > cd IfcOpenShell\win + > build-deps.cmd > run-cmake.bat + +You can now open and build the solution file in Visual Studio: + > ..\build-vs2015-x64\IfcOpenShell.sln -You can now build the solution using the `RelWithDebInfo` configuration (freshly created solution by CMake defaults to `Debug`). -Build the `INSTALL` project to deploy the headers and binaries into a single location if wanted/needed. +As the scripts default to using the `RelWithDebInfo` configuration, and a freshly created solution by CMake defaults +to `Debug`, make sure to switch the used build configuration. Build the `INSTALL` project (right-click -> Project +Only) to deploy the headers and binaries into a single location if wanted/needed. + +Alternatively, one can use the utility batch files to build and install the project easily from the command-line: + + > build-ifcopenshell.cmd + > install-ifcopenshell.cmd Alternatively, the old Visual Studio solution and project files requiring manual work can be found from the win/sln folder. diff --git a/win/build-deps.cmd b/win/build-deps.cmd index 5d48eec686..bc8e68768f 100644 --- a/win/build-deps.cmd +++ b/win/build-deps.cmd @@ -18,7 +18,7 @@ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: This batch file expects CMake generator as %1 and build configuration type as %2. If not provided, -:: the GENERATOR_DEFAULT will be used for %1 and BUILD_CFG_DEFAULT for %2 (both set in vs-cfg.cmd) +:: a deduced generator will be used for %1 and BUILD_CFG_DEFAULT for %2 (both set in vs-cfg.cmd) :: Optionally a build type (Build/Rebuild/Clean) can be passed as %3. @echo off @@ -72,7 +72,6 @@ set MSBUILD_CMD=MSBuild.exe /nologo /m:%IFCOS_NUM_BUILD_PROCS% /t:%BUILD_TYPE% REM /clp:ErrorsOnly;WarningsOnly :: Note BUILD_TYPE not passed, Clean e.g. wouldn't delete the installed files. set INSTALL_CMD=MSBuild.exe /nologo /m:%IFCOS_NUM_BUILD_PROCS% -set BUILD_DIR=build-vs%VS_VER%-%TARGET_ARCH% echo. diff --git a/win/build-ifcopenshell.cmd b/win/build-ifcopenshell.cmd new file mode 100644 index 0000000000..ac973b6e06 --- /dev/null +++ b/win/build-ifcopenshell.cmd @@ -0,0 +1,46 @@ +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: :: +:: 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 batch file expects CMake generator as %1 and build configuration type as %2. If not provided, +:: a deduced generator will be used for %1 and BUILD_CFG_DEFAULT for %2 (both set in vs-cfg.cmd) +:: Possible extra parameters are passed for the MSBuild call. + +@echo off +set PROJECT_NAME=IfcOpenShell + +:: Enable the delayed environment variable expansion needed in VSConfig.cmd. +setlocal EnableDelayedExpansion +call vs-cfg.cmd %1 %2 +IF NOT %ERRORLEVEL%==0 GOTO :Error + +echo. +call cecho.cmd 0 13 "Building %VS_PLATFORM% %BUILD_CFG% %PROJECT_NAME%" +MSBuild ..\%BUILD_DIR%\%PROJECT_NAME%.sln /nologo /m /p:Platform=%VS_PLATFORM% /p:Configuration=%BUILD_CFG% %3 %4 %5 %6 %7 %8 %9 +IF NOT %ERRORLEVEL%==0 GOTO :Error + +echo. +call cecho.cmd 0 10 "%VS_PLATFORM% %BUILD_CFG% %PROJECT_NAME% build finished." +goto :End + +:Error +echo. +call %~dp0\utils\cecho.cmd 0 12 "%VS_PLATFORM% %BUILD_CFG% %PROJECT_NAME% build failed!" + +:End +endlocal diff --git a/win/install-ifcopenshell.cmd b/win/install-ifcopenshell.cmd new file mode 100644 index 0000000000..be2c348c13 --- /dev/null +++ b/win/install-ifcopenshell.cmd @@ -0,0 +1,46 @@ +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: :: +:: 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 batch file expects CMake generator as %1 and build configuration type as %2. If not provided, +:: a deduced generator will be used for %1 and BUILD_CFG_DEFAULT for %2 (both set in vs-cfg.cmd) +:: Possible extra parameters are passed for the MSBuild call. + +@echo off +set PROJECT_NAME=IfcOpenShell + +:: Enable the delayed environment variable expansion needed in VSConfig.cmd. +setlocal EnableDelayedExpansion +call vs-cfg.cmd %1 %2 +IF NOT %ERRORLEVEL%==0 GOTO :Error + +echo. +call cecho.cmd 0 13 "Installing %VS_PLATFORM% %BUILD_CFG% %PROJECT_NAME%" +MSBuild ..\%BUILD_DIR%\INSTALL.%VCPROJ_FILE_EXT% /nologo /m /p:Platform=%VS_PLATFORM% /p:Configuration=%BUILD_CFG% %3 %4 %5 %6 %7 %8 %9 +IF NOT %ERRORLEVEL%==0 GOTO :Error + +echo. +call cecho.cmd 0 10 "%VS_PLATFORM% %BUILD_CFG% %PROJECT_NAME% installation finished." +goto :End + +:Error +echo. +call %~dp0\utils\cecho.cmd 0 12 "%VS_PLATFORM% %BUILD_CFG% %PROJECT_NAME% installation failed!" + +:End +endlocal diff --git a/win/readme.md b/win/readme.md index aa232dd260..89a6922be0 100644 --- a/win/readme.md +++ b/win/readme.md @@ -31,8 +31,10 @@ Note that building IfcOpenShell as 64-bit is recommended as many of real life IF 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. 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. +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 +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. @@ -49,6 +51,8 @@ Directory Structure \---win | 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 +| 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 | vs-cfg.cmd - Utility file used by the build scripts diff --git a/win/run-cmake.bat b/win/run-cmake.bat index e689ea28ab..6594a2812b 100644 --- a/win/run-cmake.bat +++ b/win/run-cmake.bat @@ -35,7 +35,6 @@ pushd .. set CMAKE_INSTALL_PREFIX=%CD%\installed-vs%VS_VER%-%TARGET_ARCH% popd -set BUILD_DIR=build-vs%VS_VER%-%TARGET_ARCH% IF NOT EXIST ..\%BUILD_DIR%. mkdir ..\%BUILD_DIR% pushd ..\%BUILD_DIR% diff --git a/win/vs-cfg.cmd b/win/vs-cfg.cmd index 3f8294699f..21677b9610 100644 --- a/win/vs-cfg.cmd +++ b/win/vs-cfg.cmd @@ -166,6 +166,8 @@ pushd .. set DEPS_DIR=%CD%\deps set INSTALL_DIR=%CD%\deps-vs%VS_VER%-%TARGET_ARCH%-installed REM set INSTALL_DIR=%CD%\deps-vs%VS_VER%-%TARGET_ARCH%-%DEBUG_OR_RELEASE_LOWERCASE%-installed +:: BUILD_DIR is a relative build directory used for CMake-based projects +set BUILD_DIR=build-vs%VS_VER%-%TARGET_ARCH% popd GOTO :EOF