diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..61e7a7d136 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,100 @@ +name: CI + +on: + push: + + +jobs: + + activate: + runs-on: ubuntu-latest + if: | + github.repository == 'feelpp/IfcOpenShell' && + !startsWith(github.event.head_commit.message, 'Release ') && + !contains(github.event.head_commit.message, 'ci skip') + steps: + - run: echo ok go + + build: + runs-on: ubuntu-20.04 + needs: activate + steps: + - uses: actions/checkout@v2 + + - + name: Update ubuntu + run: | + sudo apt update + sudo apt-get install git cmake gcc g++ libboost1.67-all-dev python3-all-dev swig libpcre3-dev libxml2-dev + sudo apt-get install liboce-foundation-dev liboce-modeling-dev liboce-ocaf-dev liboce-visualization-dev liboce-ocaf-lite-dev + - + name: Build ifcopenshell + run: | + mkdir build && cd build + cmake \ + -DCMAKE_INSTALL_PREFIX=$PWD/install/ \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_PREFIX_PATH=/usr \ + -DCMAKE_SYSTEM_PREFIX_PATH=/usr \ + -DOCC_INCLUDE_DIR=/usr/include/oce \ + -DOCC_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu \ + -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3 \ + -DPYTHON_INCLUDE_DIR:PATH=/usr/include/python3.8 \ + -DPYTHON_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libpython3.8.so \ + -DCOLLADA_SUPPORT=Off \ + -DLIBXML2_INCLUDE_DIR=/usr/include/libxml2 \ + -DLIBXML2_LIBRARIES=/usr/lib/x86_64-linux-gnu/libxml2.so \ + ../cmake + make -j10 + make install + - + name: Package + run: | + make package + working-directory: build + - name: Upload + uses: actions/upload-artifact@v2 + with: + # Artifact name + name: ifcos-artifacts + # Directory containing files to upload + path: build/assets/Ifc* + + deliver: + runs-on: ubuntu-20.04 + needs: build + name: Docker Build, Tag, Push + + steps: + - uses: actions/checkout@v2 + with: + lfs: true + + - name: Download + uses: actions/download-artifact@v2 + with: + # Artifact name + name: ifcos-artifacts + path: artifacts/ + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.CR_PAT }} + - + name: Build container image + uses: docker/build-push-action@v2 + with: + context: artifacts + repository: feelpp/ifcopenshell + tags: ghcr.io/feelpp/ifcopenshell:latest + file: ./Dockerfile + push: true \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000000..629710aa0a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,95 @@ +name: Release + +on: + push: + tags: + - 'v[0-9].[0-9].[0-9]*' + +jobs: + activate: + if: github.repository == 'feelpp/IfcOpenShell' + runs-on: ubuntu-latest + steps: + - run: echo ok go + build: + needs: activate + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + lfs: true + - + name: Update ubuntu + run: | + sudo apt update + sudo apt-get install git cmake gcc g++ libboost1.67-all-dev python3-all-dev swig libpcre3-dev libxml2-dev + sudo apt-get install liboce-foundation-dev liboce-modeling-dev liboce-ocaf-dev liboce-visualization-dev liboce-ocaf-lite-dev + - name: Build + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CHANGELOG_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + mkdir build && cd build + cmake \ + -DCMAKE_INSTALL_PREFIX=$PWD/install/ \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_PREFIX_PATH=/usr \ + -DCMAKE_SYSTEM_PREFIX_PATH=/usr \ + -DOCC_INCLUDE_DIR=/usr/include/oce \ + -DOCC_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu \ + -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3 \ + -DPYTHON_INCLUDE_DIR:PATH=/usr/include/python3.8 \ + -DPYTHON_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libpython3.8.so \ + -DCOLLADA_SUPPORT=Off \ + -DLIBXML2_INCLUDE_DIR=/usr/include/libxml2 \ + -DLIBXML2_LIBRARIES=/usr/lib/x86_64-linux-gnu/libxml2.so \ + ../cmake + make -j10 + make install + - name: Package + id: package + run: | + make package + echo ::set-output name=tgz::$( ls assets/*.tar.gz | head -n 1 | xargs basename ) + echo ::set-output name=deb::$( ls assets/*.deb | head -n 1 | xargs basename ) + working-directory: build + env: + CHANGELOG_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Release + id: release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: true + body: | + Changes to this release + - add github actions support #1306 + - add boost depends to ifcopenshell deb packaging + - + See more details in the documentation +# body_path: build/CHANGELOG.md + - name: Upload TGZ + id: upload-tgz + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: build/assets/${{ steps.package.outputs.tgz }} + asset_name: ${{ steps.package.outputs.tgz }} + asset_content_type: application/x-gzip + - name: Upload DEB + id: upload-deb + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: build/assets/${{ steps.package.outputs.deb }} + asset_name: ${{ steps.package.outputs.deb }} + asset_content_type: application/vnd.debian.binary-package diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..723158e8dc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,37 @@ +# -*- mode: Dockerfile -*- + +FROM ubuntu:focal + +ARG CHANNEL +ENV CHANNEL=${CHANNEL:-latest} +RUN apt-get update \ + && apt-get install -y \ + vim \ + ssh \ + sudo \ + wget \ + software-properties-common ;\ + rm -rf /var/lib/apt/lists/* + +RUN useradd --user-group --create-home --shell /bin/bash feelpp ;\ + echo "feelpp ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers + + +ENV DEBIAN_FRONTEND=noninteractive +RUN echo "deb http://archive.ubuntu.com/ubuntu focal-proposed main restricted" | tee -a /etc/apt/sources.list; \ + echo "deb http://archive.ubuntu.com/ubuntu focal-proposed universe" | tee -a /etc/apt/sources.list; \ + echo "deb http://archive.ubuntu.com/ubuntu focal-proposed multiverse" | tee -a /etc/apt/sources.list; \ + apt-get -qq update; \ + apt-get -y install tzdata dos2unix rsync; \ + apt-get -y install python3 libxml2 liboce-foundation11 liboce-modeling11 liboce-ocaf11 liboce-visualization11 \ + liboce-ocaf-lite11 libpython3.8 libboost-system1.67.0 libboost-program-options1.67.0 \ + libboost-regex1.67.0 libboost-thread1.67.0 libboost-date-time1.67.0; \ + rm -rf /var/lib/apt/lists/* ; + +COPY . /home/feelpp/ +RUN ls -lrtR /home/feelpp + +RUN dpkg -i /home/feelpp/*.deb + +USER feelpp + diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index ce2b7914a7..788ffd8a5a 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -21,7 +21,10 @@ cmake_minimum_required(VERSION 3.1.3) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) # not necessary, but encouraged -project (IfcOpenShell) +project (IfcOpenShell VERSION 0.6.0) + +# use extra version to make pre-release using eg semver +set( EXTRA_VERSION "-alpha.3") foreach(max_year RANGE 2014 2030) set(max_sdk "$ENV{ADSK_3DSMAX_SDK_${max_year}}") @@ -54,7 +57,7 @@ OPTION(USERSPACE_PYTHON_PREFIX "Installs IfcPython for the current user only ins # 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) - +include(GNUInstallDirs) if((BUILD_CONVERT OR BUILD_GEOMSERVER OR BUILD_IFCPYTHON) AND (NOT BUILD_IFCGEOM)) message(STATUS "'IfcGeom' is required with current outputs") set(BUILD_IFCGEOM ON) @@ -65,7 +68,7 @@ IF(NOT BINDIR) set(BINDIR bin) ENDIF() IF(NOT IS_ABSOLUTE ${BINDIR}) - set(BINDIR ${CMAKE_INSTALL_PREFIX}/${BINDIR}) + set(BINDIR ${CMAKE_INSTALL_BINDIR}) ENDIF() MESSAGE(STATUS "BINDIR: ${BINDIR}") @@ -73,7 +76,7 @@ IF(NOT INCLUDEDIR) set(INCLUDEDIR include) ENDIF() IF(NOT IS_ABSOLUTE ${INCLUDEDIR}) - set(INCLUDEDIR ${CMAKE_INSTALL_PREFIX}/${INCLUDEDIR}) + set(INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR}) ENDIF() MESSAGE(STATUS "INCLUDEDIR: ${INCLUDEDIR}") @@ -81,11 +84,11 @@ IF(NOT LIBDIR) set(LIBDIR lib) ENDIF() IF(NOT IS_ABSOLUTE ${LIBDIR}) - set(LIBDIR ${CMAKE_INSTALL_PREFIX}/${LIBDIR}) + set(LIBDIR ${CMAKE_INSTALL_LIBDIR}) ENDIF() MESSAGE(STATUS "LIBDIR: ${LIBDIR}") -set(IFCOPENSHELL_LIBARY_DIR "") # for *nix rpaths +set(IFCOPENSHELL_LIBRARY_DIR "") # for *nix rpaths if (BUILD_SHARED_LIBS) add_definitions(-DIFC_SHARED_BUILD) @@ -95,7 +98,7 @@ if (BUILD_SHARED_LIBS) # There will be couple hundreds of these so suppress them away, https://msdn.microsoft.com/en-us/library/esew7y1w.aspx add_definitions(-wd4251) endif() - set(IFCOPENSHELL_LIBARY_DIR "${LIBDIR}") + set(IFCOPENSHELL_LIBRARY_DIR "${LIBDIR}") endif() # Create cache entries if absent for environment variables @@ -625,7 +628,7 @@ if ((NOT WIN32) AND BUILD_SHARED_LIBS) # Only set RPATHs when building shared libraries (i.e. IfcParse and # IfcGeom are dynamically linked). Not necessarily a perfect solution # but probably a good indication of whether RPATHs are necessary. - SET_INSTALL_RPATHS(IfcConvert "${IFCOPENSHELL_LIBARY_DIR};${OCC_LIBRARY_DIR};${Boost_LIBRARY_DIRS};${OPENCOLLADA_LIBRARY_DIR}") + SET_INSTALL_RPATHS(IfcConvert "${IFCOPENSHELL_LIBRARY_DIR};${OCC_LIBRARY_DIR};${Boost_LIBRARY_DIRS};${OPENCOLLADA_LIBRARY_DIR}") endif() INSTALL(TARGETS IfcConvert @@ -646,7 +649,7 @@ ADD_EXECUTABLE(IfcGeomServer ${SOURCE_FILES}) TARGET_LINK_LIBRARIES(IfcGeomServer ${IFCOPENSHELL_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${Boost_LIBRARIES}) if ((NOT WIN32) AND BUILD_SHARED_LIBS) - SET_INSTALL_RPATHS(IfcGeomServer "${IFCOPENSHELL_LIBARY_DIR};${OCC_LIBRARY_DIR};${Boost_LIBRARY_DIRS}") + SET_INSTALL_RPATHS(IfcGeomServer "${IFCOPENSHELL_LIBRARY_DIR};${OCC_LIBRARY_DIR};${Boost_LIBRARY_DIRS}") endif() INSTALL(TARGETS IfcGeomServer @@ -717,3 +720,43 @@ INSTALL(FILES ${SERIALIZERS_S_FILES} DESTINATION ${INCLUDEDIR}/serializers/schema_dependent ) endif() + + +list(APPEND CPACK_SOURCE_IGNORE_FILES + .git + .gitignore + ) + +set(CPACK_PACKAGE_NAME "${PROJECT_NAME}-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}${EXTRA_VERSION}") +set(CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}${EXTRA_VERSION}") +SET(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}${EXTRA_VERSION}-${CMAKE_SYSTEM_NAME}") +set(CPACK_PACKAGE_DIRECTORY "${PROJECT_BINARY_DIR}/assets") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "IfcOpenShell") +set(CPACK_PACKAGE_DESCRIPTION "IfcOpenShell.") +set(CPACK_PACKAGE_VENDOR "Cemosis") +set(CPACK_PACKAGE_CONTACT "Christophe Prud'homme ") +set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}") +set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}") +set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}") + + +set(CPACK_GENERATOR "TGZ;DEB") +set(CPACK_SOURCE_GENERATOR "TGZ") + +FOREACH(COMPONENT IN ITEMS ${BOOST_COMPONENTS}) + string(REPLACE "_" "-" COMP ${COMPONENT}) + set(BOOST_DEPS "${BOOST_DEPS}, libboost-${COMP}1.67.0") +endforeach(COMPONENT) + +set(CPACK_DEBIAN_PACKAGE_NAME "${PROJECT_NAME}") +set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${CPACK_PACKAGE_CONTACT}") +set(CPACK_DEBIAN_PACKAGE_DEPENDS "python3, libxml2, liboce-foundation11, liboce-modeling11, liboce-ocaf11, liboce-visualization11, liboce-ocaf-lite11, libpython3.8 ${BOOST_DEPS}") +set(CPACK_DEBIAN_PACKAGE_DESCRIPTION_SUMMARY "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}") +set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION}") +set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional") +set(CPACK_DEBIAN_PACKAGE_SECTION "science") +set(CPACK_DEBIAN_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}${EXTRA_VERSION}") +set(CPACK_DEBIAN_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}") +#set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/cmake/debian/postinst") + +include(CPack) diff --git a/src/ifcwrap/CMakeLists.txt b/src/ifcwrap/CMakeLists.txt index 0e8a695656..32ceaf1a8a 100644 --- a/src/ifcwrap/CMakeLists.txt +++ b/src/ifcwrap/CMakeLists.txt @@ -21,7 +21,7 @@ FIND_PACKAGE(SWIG) IF(NOT SWIG_FOUND) MESSAGE(FATAL_ERROR "BUILD_IFCPYTHON enabled, but unable to find SWIG. Disable BUILD_IFCPYTHON or fix SWIG paths to proceed.") ENDIF() - +include(GNUInstallDirs) INCLUDE(${SWIG_USE_FILE}) IF(NOT "$ENV{PYTHON_INCLUDE_DIR}" STREQUAL "") @@ -79,9 +79,9 @@ IF(PYTHONINTERP_FOUND AND NOT "${PYTHON_EXECUTABLE}" STREQUAL "") OUTPUT_VARIABLE python_package_dir ) ENDIF() - + set(python_package_dir ${CMAKE_INSTALL_LIBDIR}/python${PYTHON_VERSION_MAJOR}/dist-packages/) IF("${python_package_dir}" STREQUAL "") - MESSAGE(WARNING "Unable to locate Python site-package directory, unable to install the Python wrapper") + MESSAGE(WARNING "Unable to locate Python site-package directory, unals /ble to install the Python wrapper") ELSE() FILE(GLOB_RECURSE sourcefiles "${CMAKE_CURRENT_SOURCE_DIR}/../ifcopenshell-python/ifcopenshell/*"