diff --git a/.github/workflows/ci-ifcopenshell-conda-daily.yml b/.github/workflows/ci-ifcopenshell-conda-daily.yml index a1640f078f..c346375348 100644 --- a/.github/workflows/ci-ifcopenshell-conda-daily.yml +++ b/.github/workflows/ci-ifcopenshell-conda-daily.yml @@ -1,23 +1,15 @@ -name: ci-ifcopenshell-conda-daily +name: ci-ifcopenshell-conda-daily-v0.8.0 on: push: - paths: - - .github/workflows/ci-ifcopenshell-conda-daily.yml - schedule: - # ┌───────────── minute (0 - 59) - # │ ┌───────────── hour (0 - 23) - # │ │ ┌───────────── day of the month (1 - 31) - # │ │ │ ┌───────────── month (1 - 12 or JAN-DEC) - # │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT) - # * * * * * - - cron: "49 23 * * *" # 11min before utc midnight every day + branches: + - v0.8.0-compile-daily jobs: activate: runs-on: ubuntu-latest if: | - github.repository == 'IfcOpenShell/IfcOpenShell' + github.repository == 'krande/IfcOpenShell' steps: - name: Set env run: echo ok go @@ -33,38 +25,48 @@ jobs: fail-fast: false matrix: pyver: [ - { name: py310, distver: '3.10'}, - { name: py311, distver: '3.11'} + { name: py311, distver: '3.11' } ] platform: [ { name: Windows, distver: windows-2022, upload: 'true' }, { name: Linux, distver: ubuntu-22.04, upload: 'true' }, - { name: macOS, distver: macos-12, upload: 'true' } + { name: macOS, distver: macos-13, upload: 'true' } ] steps: - uses: actions/checkout@v3 with: submodules: recursive - - name: Download MacOSX SDK + + - name: Download and extract MacOSX SDK if: ${{ matrix.platform.name == 'macOS' }} run: | - curl -o MacOSX10.13.sdk.tar.xz -L https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX10.13.sdk.tar.xz && \ - tar xf MacOSX10.13.sdk.tar.xz && \ - sudo mv -v MacOSX10.13.sdk /opt/ && \ - ls /opt/ - - uses: seanmiddleditch/gha-setup-ninja@master - - uses: conda-incubator/setup-miniconda@v2 # https://github.com/conda-incubator/setup-miniconda + curl -L https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX10.13.sdk.tar.xz | tar -xvJf - -C /Users/runner/work/ + + - name: Install ninja + run: | + if [[ "$OSTYPE" == "linux-gnu"* ]]; then + sudo apt-get install ninja-build + elif [[ "$OSTYPE" == "darwin"* ]]; then + brew install ninja + elif [[ "$OSTYPE" == "win32" ]]; then + choco install ninja + fi + - uses: mamba-org/setup-micromamba@v1 # https://github.com/mamba-org/setup-micromamba with: - activate-environment: conda-build - python-version: ${{ matrix.pyver.distver }} - environment-file: conda/environment.yml - - name: build, test and upload ifcopenshell - if: ${{ matrix.platform.upload == 'true' }} + environment-file: conda/environment.build.yml + create-args: >- + python=${{ matrix.pyver.distver }} + anaconda-client + + - name: create conda package dist dir run: | - conda-build . --python ${{ matrix.pyver.distver }} -c conda-forge --token ${{ secrets.ANACONDA_TOKEN }} --user ifcopenshell - working-directory: ./conda + mkdir -p ${{ github.workspace }}/dist + - name: build & test ifcopenshell - if: ${{ matrix.platform.upload == 'false' }} run: | - conda-build . --python ${{ matrix.pyver.distver }} -c conda-forge + boa build . --python ${{ matrix.pyver.distver }} --no-remove-work-dir --output-folder '${{ github.workspace }}/dist' working-directory: ./conda + + - name: upload to anaconda + run: | + anaconda -t ${{ secrets.ANACONDA_TOKEN }} upload --force --user ${{ secrets.ANACONDA_USER }} --label dev ${{ github.workspace }}/dist/${{ matrix.pyver.pkg_dir }}/*.tar.bz2 \ No newline at end of file diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 27d53f1a03..7be853b599 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -65,6 +65,7 @@ OPTION(USERSPACE_PYTHON_PREFIX "Installs IfcPython for the current user only ins OPTION(ADD_COMMIT_SHA "Add commit sha and branch in version number, warning results in many rebuilds, requires git" OFF) OPTION(WITH_OPENCASCADE "Enable geometry interpretation using Open CASCADE" ON) OPTION(WITH_CGAL "Enable geometry interpretation using CGAL" ON) +OPTION(CITYJSON_SUPPORT "Build IfcConvert with CityJSON support (requires CityJSON library)." ON) IF(NOT CMAKE_BUILD_TYPE) SET(CMAKE_BUILD_TYPE "Release") @@ -154,6 +155,17 @@ endif() UNIFY_ENVVARS_AND_CACHE(EIGEN_DIR) +# Include the 'convert_env_var_to_bool' and 'get_all_option_flags' functions +include(utilities.cmake) + +# Get a list of all OPTION flags from the CMakeLists.txt +get_all_option_flags(option_flags) + +# Loop through the list of OPTION flags and convert the corresponding environment variables +foreach(option_flag IN LISTS option_flags) + convert_env_var_to_bool("${option_flag}") +endforeach() + if(WASM_BUILD) # when using the nix/build-all.py build script we should not # look into the sysroot for most of the dependencies but rather @@ -178,8 +190,11 @@ endif() if (NOT MINIMAL_BUILD) if (WITH_CGAL) -add_definitions(-DIFOPSH_WITH_CGAL) -set(SWIG_DEFINES ${SWIG_DEFINES} -DIFOPSH_WITH_CGAL) + if (CITYJSON_SUPPORT) + add_definitions(-DIFOPSH_WITH_CGAL) + set(SWIG_DEFINES ${SWIG_DEFINES} -DIFOPSH_WITH_CGAL) + endif () + list(APPEND GEOMETRY_KERNELS cgal) endif() endif() @@ -939,7 +954,8 @@ endif() if (BUILD_CONVERT) -if (WITH_CGAL) +if (WITH_CGAL AND CITYJSON_SUPPORT) + message(STATUS "Building CityJSON support") set(CITYJSON_CONVERT_FILES ../src/ifcconvert/cityjson/geobim.cpp ../src/ifcconvert/cityjson/global_execution_context.cpp diff --git a/cmake/utilities.cmake b/cmake/utilities.cmake new file mode 100644 index 0000000000..b75a998537 --- /dev/null +++ b/cmake/utilities.cmake @@ -0,0 +1,32 @@ +function(get_all_option_flags output_list) + # Read the contents of the CMakeLists.txt + file(READ "${CMAKE_SOURCE_DIR}/CMakeLists.txt" cmake_contents) + + # Find all OPTION flags using a regular expression + string(REGEX MATCHALL "OPTION\\s*\\(\\s*([A-Za-z0-9_]+)" matches "${cmake_contents}") + + # Extract the variable names from the matches + set(option_flags) + foreach(match IN LISTS matches) + string(REGEX REPLACE "OPTION\\s*\\(\\s*([A-Za-z0-9_]+)" "\\1" option_flag "${match}") + list(APPEND option_flags "${option_flag}") + endforeach() + + # Return the list of OPTION flags + set(${output_list} "${option_flags}" PARENT_SCOPE) +endfunction() + +function(convert_env_var_to_bool var_name) + if(DEFINED ENV{${var_name}}) + string(TOUPPER "$ENV{${var_name}}" bool_value) + if(bool_value STREQUAL "ON" OR bool_value STREQUAL "TRUE" OR bool_value STREQUAL "1") + set(${var_name} ON CACHE BOOL "${var_name} as boolean" FORCE) + elseif(bool_value STREQUAL "OFF" OR bool_value STREQUAL "FALSE" OR bool_value STREQUAL "0") + set(${var_name} OFF CACHE BOOL "${var_name} as boolean" FORCE) + else() + # Not a bool, leave it as a string + endif() + else() + # Not defined, leave it as a string + endif() +endfunction() \ No newline at end of file diff --git a/conda/.gitignore b/conda/.gitignore new file mode 100644 index 0000000000..2eea525d88 --- /dev/null +++ b/conda/.gitignore @@ -0,0 +1 @@ +.env \ No newline at end of file diff --git a/conda/Makefile b/conda/Makefile deleted file mode 100644 index c4cb211f1f..0000000000 --- a/conda/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -compile: - conda activate conda-build && conda-build -c conda-forge . --keep-old-work --python 3.10.5 - -debug: - conda activate conda-build && conda-debug -c conda-forge . --python 3.10.4 - -env: - conda env update --f environment.yml --prune \ No newline at end of file diff --git a/conda/bld.bat b/conda/bld.bat index b25f46c9d6..2034f2e076 100644 --- a/conda/bld.bat +++ b/conda/bld.bat @@ -1,7 +1,7 @@ mkdir build && cd build set MY_PY_VER=%PY_VER:.=% -set LIBXML2="%LIBRARY_PREFIX%/lib/libxml2.lib" +rem set LIBXML2="%LIBRARY_PREFIX%/lib/libxml2.lib" cmake -G "Ninja" ^ -D CMAKE_BUILD_TYPE:STRING=Release ^ @@ -11,6 +11,9 @@ cmake -G "Ninja" ^ -D OCC_INCLUDE_DIR:FILEPATH="%LIBRARY_PREFIX%\include\opencascade" ^ -D OCC_LIBRARY_DIR:FILEPATH="%LIBRARY_PREFIX%\lib" ^ -D CGAL_INCLUDE_DIR:FILEPATH="%LIBRARY_PREFIX%\include" ^ + -D EIGEN_DIR:FILEPATH="%LIBRARY_PREFIX%\include\eigen3" ^ + -D LIBXML2_INCLUDE_DIR=%LIBRARY_PREFIX%/include/libxml2 ^ + -D LIBXML2_LIBRARIES=%LIBRARY_PREFIX%/lib/libxml2.lib ^ -D GMP_INCLUDE_DIR:FILEPATH="%LIBRARY_PREFIX%\include" ^ -D GMP_LIBRARY_DIR:FILEPATH="%LIBRARY_PREFIX%\lib" ^ -D MPFR_LIBRARY_DIR:FILEPATH="%LIBRARY_PREFIX%\lib" ^ @@ -31,9 +34,10 @@ cmake -G "Ninja" ^ -D BUILD_CONVERT:BOOL=ON ^ -D BUILD_IFCMAX:BOOL=OFF ^ -D IFCXML_SUPPORT:BOOL=ON ^ - -D Boost_LIBRARYDIR:FILEPATH="%LIBRARY_PREFIX%\lib" ^ - -D Boost_INCLUDEDIR:FILEPATH="%LIBRARY_PREFIX%\include" ^ + -D Boost_LIBRARY_DIR:FILEPATH="%LIBRARY_PREFIX%\lib" ^ + -D Boost_INCLUDE_DIR:FILEPATH="%LIBRARY_PREFIX%\include" ^ -D Boost_USE_STATIC_LIBS:BOOL=OFF ^ + -D CITYJSON_SUPPORT:BOOL=OFF ^ %SRC_DIR%/cmake if errorlevel 1 exit 1 diff --git a/conda/build.sh b/conda/build.sh index a16859085f..9ba21cba3a 100644 --- a/conda/build.sh +++ b/conda/build.sh @@ -1,16 +1,18 @@ #!/bin/bash -declare -a CMAKE_PLATFORM_FLAGS +# IF osx use file lib suffix .dylib +# IF linux use file lib suffix .so +# IF windows use file lib suffix .dll -if [[ ${HOST} =~ .*linux.* ]]; then - CMAKE_PLATFORM_FLAGS+=(-DCMAKE_TOOLCHAIN_FILE=$RECIPE_DIR/cross-linux.cmake) +if [ "$(uname)" == "Darwin" ]; then + export FSUFFIX=dylib + export CFLAGS="$CFLAGS -Wl,-flat_namespace,-undefined,suppress" + export CXXFLAGS="$CXXFLAGS -Wl,-flat_namespace,-undefined,suppress" + export LDFLAGS="$LDFLAGS -Wl,-flat_namespace,-undefined,suppress" +elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then + export FSUFFIX=so fi -if [ `uname` == Darwin ]; then - export CFLAGS="$CFLAGS -Wl,-flat_namespace,-undefined,suppress" - export CXXFLAGS="$CXXFLAGS -Wl,-flat_namespace,-undefined,suppress" - export LDFLAGS="$LDFLAGS -Wl,-flat_namespace,-undefined,suppress" -fi cmake -G Ninja \ -DCMAKE_BUILD_TYPE=Release \ @@ -28,7 +30,10 @@ cmake -G Ninja \ -DHDF5_LIBRARY_DIR=$PREFIX/lib \ -DJSON_INCLUDE_DIR=$PREFIX/include \ -DCGAL_INCLUDE_DIR=$PREFIX/include \ - -DCOLLADA_SUPPORT=0 \ + -DLIBXML2_INCLUDE_DIR=$PREFIX/include/libxml2 \ + -DLIBXML2_LIBRARIES=$PREFIX/lib/libxml2.$FSUFFIX \ + -DEIGEN_DIR:FILEPATH=$PREFIX/include/eigen3 \ + -DCOLLADA_SUPPORT:BOOL=OFF \ -DBUILD_EXAMPLES:BOOL=OFF \ -DIFCXML_SUPPORT:BOOL=ON \ -DGLTF_SUPPORT:BOOL=ON \ @@ -37,8 +42,9 @@ cmake -G Ninja \ -DBUILD_IFCGEOM:BOOL=ON \ -DBUILD_GEOMSERVER:BOOL=OFF \ -DBOOST_USE_STATIC_LIBS:BOOL=OFF \ + -DCITYJSON_SUPPORT:BOOL=OFF \ ./cmake ninja -ninja install -j 2 +ninja install -j 1 diff --git a/conda/conda_build_config.yaml b/conda/conda_build_config.yaml index 5a72b972fe..dae1d1bb7b 100644 --- a/conda/conda_build_config.yaml +++ b/conda/conda_build_config.yaml @@ -1,2 +1,11 @@ -CONDA_BUILD_SYSROOT: - - /opt/MacOSX10.13.sdk # [osx] \ No newline at end of file +CONDA_BUILD_SYSROOT: # used for github actions conda daily build + - /Users/runner/work/MacOSX10.13.sdk # [osx] + +occt: + - 7.7.1 + +c_compiler: + - vs2022 # [win] + +cxx_compiler: + - vs2022 # [win] \ No newline at end of file diff --git a/conda/cross-linux.cmake b/conda/cross-linux.cmake deleted file mode 100644 index 89834cda14..0000000000 --- a/conda/cross-linux.cmake +++ /dev/null @@ -1,16 +0,0 @@ -# this one is important -set(CMAKE_SYSTEM_NAME Linux) -set(CMAKE_PLATFORM Linux) - -# specify the cross compiler -set(CMAKE_C_COMPILER $ENV{CC}) -set(CMAKE_CXX_COMPILER $ENV{CXX}) - -# where is the target environment -set(CMAKE_FIND_ROOT_PATH $ENV{PREFIX} $ENV{BUILD_PREFIX}/$ENV{HOST}/sysroot) - -# search for programs in the build host directories -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -# for libraries and headers in the target directories -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) \ No newline at end of file diff --git a/conda/env.bat b/conda/env.bat new file mode 100644 index 0000000000..d7aac33012 --- /dev/null +++ b/conda/env.bat @@ -0,0 +1,58 @@ +@echo off + +:: This is a batch file to set the environment variables for the project +:: It is not necessary for conda compilation, but it provides you with type hints when working with the c++ libraries +:: OpenCascade, CGAL, Eigen, etc distributed using conda-forge in your IDE. +:: +:: mamba env update -f environment.build.yml --prune +:: mamba activate ifcopenshell-build +:: +:: Note! +:: You have to add a .env file next to this env.bat file where you set PREFIX= +set CONDA_BUILD=1 +set MY_PY_VER=311 + +:: set this file's parent directory as a variable +set THIS_DIR=%~dp0 + +:: read the .env file located in THIS_DIR and set the environment variables. +:: the .env file should contain a line like this: +:: PREFIX=C:\Users\your_user_name\mambaforge3\envs\ifcopenshell-build +for /f "tokens=*" %%i in (%THIS_DIR%.env) do set %%i + +set LIBRARY_PREFIX=%PREFIX%/Library +set CMAKE_PREFIX_PATH=%PREFIX%;%LIBRARY_PREFIX%/include;%LIBRARY_PREFIX%/lib;%LIBRARY_PREFIX%/bin + +set OCC_LIBRARY_DIR=%LIBRARY_PREFIX%/lib +set OCC_INCLUDE_DIR=%LIBRARY_PREFIX%/include/opencascade + +set CGAL_DIR=%LIBRARY_PREFIX%/lib/cmake/CGAL +set CGAL_INCLUDE_DIR=%LIBRARY_PREFIX%/include +set EIGEN_DIR=%LIBRARY_PREFIX%/include/eigen3 +set LIBXML2_INCLUDE_DIR=%LIBRARY_PREFIX%/include/libxml2 +set LIBXML2_LIBRARIES=%LIBRARY_PREFIX%/lib/libxml2.lib +set Boost_LIBRARY_DIR=%LIBRARY_PREFIX%/lib +set Boost_INCLUDE_DIR=%LIBRARY_PREFIX%/include +set Boost_USE_STATIC_LIBS=OFF + +set GMP_INCLUDE_DIR=%LIBRARY_PREFIX%/include +set GMP_LIBRARY_DIR=%LIBRARY_PREFIX%/lib +set MPFR_LIBRARY_DIR=%LIBRARY_PREFIX%/lib + +set HDF5_INCLUDE_DIR=%LIBRARY_PREFIX%/include +set HDF5_LIBRARY_DIR=%LIBRARY_PREFIX%/lib +set JSON_INCLUDE_DIR=%LIBRARY_PREFIX%/include + +set HDF5_SUPPORT=ON +set BUILD_IFCPYTHON=ON +set BUILD_IFCGEOM=ON +set COLLADA_SUPPORT=OFF +set BUILD_EXAMPLES=OFF +set BUILD_GEOMSERVER=OFF +set GLTF_SUPPORT=ON +set BUILD_CONVERT=ON +set BUILD_IFCMAX=OFF +set IFCXML_SUPPORT=ON + +set PYTHON_EXECUTABLE=%PREFIX%/python.exe +set PYTHON_LIBRARY=%PREFIX%/libs/python%MY_PY_VER%.lib \ No newline at end of file diff --git a/conda/environment.build.yml b/conda/environment.build.yml new file mode 100644 index 0000000000..bd36042a18 --- /dev/null +++ b/conda/environment.build.yml @@ -0,0 +1,17 @@ +name: ifcopenshell-build +channels: + - conda-forge +dependencies: + - boa + - boost-cpp + - occt + - libxml2 + - cgal-cpp + - hdf5 + - mpfr + - nlohmann_json + - swig + - zlib + # These needs to be installed per platform + #- sel(unix): gmp + #- sel(win): mpir diff --git a/conda/environment.yml b/conda/environment.yml deleted file mode 100644 index d77e4052fa..0000000000 --- a/conda/environment.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: conda-build -channels: - - conda-forge -dependencies: - - conda-build - - conda-verify - - anaconda-client - - ninja - - doxygen - - ripgrep - - pip - - pip: - - --extra-index-url https://lief.s3-website.fr-par.scw.cloud/latest - - lief==0.13.0.dev0 \ No newline at end of file diff --git a/conda/meta.yaml b/conda/recipe.yaml similarity index 66% rename from conda/meta.yaml rename to conda/recipe.yaml index befa7b6c54..3772d20498 100644 --- a/conda/meta.yaml +++ b/conda/recipe.yaml @@ -1,22 +1,21 @@ -{% set name = "ifcopenshell" %} -{% set version = "0.7.0" %} - +context: + name: ifcopenshell + version: 0.8.0alpha1 package: - name: {{ name }} - version: {{ version }} + name: '{{ name|lower }}' + version: '{{ version }}' source: path: .. build: - binary_relocation: false [osx] number: 1 requirements: build: - - {{ compiler('c') }} - - {{ compiler('cxx') }} + - "{{ compiler('c') }}" + - "{{ compiler('cxx') }}" - ninja >=1.10.2 - cmake - swig >=4.0.2 @@ -28,10 +27,12 @@ requirements: - libxml2 - cgal-cpp - hdf5 + - eigen - mpfr - - gmp # [unix] - - mpir # [win] + - sel(unix): gmp + - sel(win): mpir - nlohmann_json + - zlib run: - python @@ -40,22 +41,24 @@ requirements: - libxml2 - cgal-cpp - hdf5 + - eigen - mpfr - - gmp # [unix] - - mpir # [win] + - sel(unix): gmp + - sel(win): mpir - nlohmann_json + - zlib test: imports: - ifcopenshell about: - home: http://ifcopenshell.org + home: https://ifcopenshell.org license: LGPL-3.0-or-later license_file: COPYING summary: 'IfcOpenShell is a library to support the IFC file format' description: | IfcOpenShell is an open source (LGPL) software library for working with the Industry Foundation Classes (IFC) file format. - doc_url: http://ifcopenshell.org/ + doc_url: https://blenderbim.org/docs-python/ dev_url: https://github.com/IfcOpenShell/IfcOpenShell