Files
IfcOpenShell/win/readme.md
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

122 lines
7.9 KiB
Markdown
Raw Normal View History

Windows Build Tools and Scripts
===============================
2017-02-24 16:46:14 +02:00
This folder contains build tools and script for automatic building and deployment of IfcOpenShell ("IFCOS")
2015-11-14 20:18:29 +02:00
and its dependencies.
2016-06-17 23:30:33 +03:00
As a general guideline, `.cmd` files are non-standalone batch files that need to be run from command prompt or from
2017-02-24 16:46:14 +02:00
another batch file, and/or while the Visual Studio ("MSVC") environment variables set, and `.bat` files are standalone batch
files that can also be invoked e.g. by double-clicking in the File Explorer. `.sh` files are for MSYS**2** + MinGW ("MSYS"
) compilation.
Usage Instructions
------------------
2017-02-24 16:46:14 +02:00
### MSYS
2017-02-24 16:46:14 +02:00
Building using MSYS is very similar to using the MSVC batch files, but instead the shell scripts
2016-09-01 12:28:17 +03:00
are used. Note that the MSYS support is currently a bit experimental. It is advised to check out the contents
2017-02-24 16:46:14 +02:00
of the shell scripts before using them. Note that contrary to MSVC, with MSYS all of the dependencies are not
2018-09-06 12:23:07 -04:00
built or used as static libraries. Currently Release build is used for all libraries.
2017-02-24 16:46:14 +02:00
### MSVC
Launch the proper Visual Studio command prompt, cd to the 'win' directory inside the IfcOpenShell directory and execute `build-deps.cmd` to fetch, build and install the dependencies. The batch file will print the requirements for a successful execution. The script allows a few user-configurable build options which are listed below.
`build-deps.cmd` expects a CMake generator as `%1` and a build configuration type (`RelWithDebInfo`, `Release`, `MinSizeRel`, or `Debug`, defaults to `RelWithDebInfo`) as `%2`. If the generator is not provided, the generator is deduced from the MSVC environment variables.
User-friendly CMake Visual Studio generator shorthands are supported. They are converted to the appropriate CMake generators and options. Shorthands are indeed the preferable way to specify the generator, since they allow a more accurate platform and toolset configuration. Here are some examples:
```
"vs2013" => cmake -G "Visual Studio 12 2013" -A Win32
"vs2013-x86" => cmake -G "Visual Studio 12 2013" -A Win32
"vs2015-x64" => cmake -G "Visual Studio 14 2015" -A x64
"vs2017-ARM64" => cmake -G "Visual Studio 15 2017" -A ARM64
"vs2019-x86-v141_xp" => cmake -G "Visual Studio 16 2019" -A Win32 -T v141_xp
```
Of course not all Visual C++ compilers support any platform or toolset, refer to the Visual Studio and CMake documentation for this. If you do not specify a toolset, the compiler will use the default toolset for the version, i.e. vs2019 will use the v142 toolset.
A build type (`Build`, `Rebuild`, or `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<VERSION>-<PLATFORM>[-<TOOLSET>]-installed\` directories to the project root. Debug and release builds of the dependencies can co-exist by simply running:
2016-06-17 23:30:33 +03:00
```
> build-deps.cmd <GENERATOR> Debug
> build-deps.cmd <GENERATOR> <Release|RelWithDebInfo|MinSizeRel>
```
After the dependencies are build, execute `run-cmake.bat`. The batch file expects a CMake generator as `%1`, that is interpreted just like the `build-deps.cmd` script, and the rest of possible parameters are passed as is. If a generator is not provided, the generator is read from the BuildDepsCache file, or tried to be deduced from the location of `cl.exe`. 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<VERSION>-<PLATFORM>[-<TOOLSET>]\` which will contain the solution and project files for MSVC.
2015-11-14 20:18:29 +02:00
Note that building IfcOpenShell as 64-bit is recommended as many of real life IFC files has been observed to take easily more than 2 GBs of RAM while converting.
2015-11-14 20:18:29 +02:00
After this, one can build the project using the `IfcOpenShell.sln` file in the build folder. Build the `INSTALL` project
2016-06-17 23:30:33 +03:00
if wanted. Convenience batch files `build-ifcopenshell.bat` and `install-ifcopenshell.bat` 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.
`run-cmake.bat`, `build-ifcopenshell.bat`, and `install-ifcopenshell.bat` can also be directly invoked from Filer Explorer
or regular Command Prompt if BuildDepsCache file exists (the last modified version is used). Running the scripts without extra
parameters reads the build options from an existing CMakeCache.txt.
The project will be installed to `installed-vs<VERSION>-<ARCHITECTURE>\` folder in the project's root folder and the
required IfcOpenShell-Python parts are deployed to the `<PYTHONHOME>\Lib\site-packages\` folder. The 3ds Max plug-in,
`IfcMax.dli`, needs to be copied manually to the 3ds Max's `plugins` folder.
2016-06-17 23:30:33 +03:00
**Note:** Currently all of the dependencies are build as static libraries against the static run-time allowing the
developer to effortlessly deploy standalone IFCOS executables.
2016-09-01 12:28:17 +03:00
Using the official Open CASCADE release instead of community edition
---------------------------------------------
Before building the dependencies, enable the OCCT usage:
```
> set IFCOS_USE_OCCT=TRUE
2022-01-07 12:31:58 +01:00
> build-deps.cmd
2016-09-01 12:28:17 +03:00
```
Please note that this option is not yet available in the MSYS build scripts.
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
```
2016-06-17 23:30:33 +03:00
After building the dependencies, append Python version and installation directory information to the BuildDepsCache file
in `IfcOpenShell\win`:
```
2016-06-17 23:30:33 +03:00
> echo PY_VER_MAJOR_MINOR=35>> BuildDepsCache-x64.txt
2016-02-18 14:57:57 +01:00
> echo PYTHONHOME=C:\Python3>> BuildDepsCache-x64.txt
```
2016-06-17 23:30:33 +03:00
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
------------------
```
2015-11-14 20:18:29 +02:00
..
+---build-* - Created by run-cmake.bat/sh, specific for a certain compiler and and target architecture
+---deps - Created by build-deps.cmd/sh, common for all compilers
+---deps-*-installed - Created by build-deps.cmd/sh, specific for a certain compiler and target architecture
+---installed-* - Created by installing the IFCOS project, specific for a certain compiler and target architecture
2015-11-14 20:18:29 +02:00
\---win
2016-01-31 20:26:40 +02:00
| build-all.cmd - Runs all of the build scripts for IFCOS and it dependencies in a row without pauses
2017-02-24 16:46:14 +02:00
| build-deps.cmd - Fetches and builds all needed dependencies for IFCOS using MSVC
2016-09-01 12:28:17 +03:00
| build-deps.sh - Fetches and builds all needed dependencies for IFCOS using MSYS
2015-11-14 20:18:29 +02:00
| BuildDepsCache-<ARCH>.txt - Cache file created by build-deps.cmd
2017-02-24 16:46:14 +02:00
| build-ifcopenshell.bat - Builds IFCOS using MSVC
2016-09-01 12:28:17 +03:00
| build-ifcopenshell.sh - Builds IFCOS using MSYS
| build-type-cfg.cmd - Utility file used by the build scripts
2017-02-24 16:46:14 +02:00
| install-ifcopenshell.bat - Installs/deploys IFCOS using MSVC.
| install-ifcopenshell.sh - Installs/deploys IFCOS using MSYS.
2015-11-14 20:18:29 +02:00
| readme.md - This file
2017-02-24 16:46:14 +02:00
| run-cmake.bat - Sets environment variables for the dependencies and runs CMake for IFCOS using MSVC
2016-09-01 12:28:17 +03:00
| run-cmake.sh - Sets environment variables for the dependencies and runs CMake for IFCOS using MSYS
2016-02-18 14:57:57 +01:00
| set-python-to-path.bat - Utility for setting PYTHONHOME (read from BuildDepsCache-<ARCH>.txt) to PATH
2015-11-14 20:18:29 +02:00
| vs-cfg.cmd - Utility file used by the build scripts
\---patches - Contains patches for the dependencies
2015-11-14 20:18:29 +02:00
\---utils - Contains various utilities for the build scripts
```