Skip to content

Commit

Permalink
Merge pull request #15 from openfedem/fmu-deployment
Browse files Browse the repository at this point in the history
Build and deploy Fedem FMU libraries for Linux and Windows platforms
  • Loading branch information
kmokstad authored Oct 18, 2024
2 parents d389826 + bc25a07 commit d550a4a
Show file tree
Hide file tree
Showing 12 changed files with 413 additions and 250 deletions.
10 changes: 10 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# SPDX-FileCopyrightText: 2023 SAP SE
#
# SPDX-License-Identifier: Apache-2.0
#
# This file is part of FEDEM - https://openfedem.org

# The following line will ensure the auto-generated tar-balls that
# github creates when makeing a new Release is empty.

* export-ignore
4 changes: 3 additions & 1 deletion .github/workflows/build_doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ on:

jobs:
build-doc:
name: Build API documentation

runs-on: ubuntu-latest

steps:
Expand All @@ -30,7 +32,7 @@ jobs:

- name: Checkout the latest release tag
run: |
git checkout `git tag | tail -1`
git checkout `git tag | grep fedem- | tail -1`
git submodule update
- name: Configure for build
Expand Down
53 changes: 0 additions & 53 deletions .github/workflows/build_fedempy.yml

This file was deleted.

110 changes: 110 additions & 0 deletions .github/workflows/build_fmu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# SPDX-FileCopyrightText: 2023 SAP SE
#
# SPDX-License-Identifier: Apache-2.0
#
# This file is part of FEDEM - https://openfedem.org

name: Build and release fedem FMU

on:
push:
tags:
- fmu-*

workflow_dispatch:
branches:
- main

jobs:
build-linux:
name: Build FMU for Linux

runs-on: ubuntu-latest

steps:
- name: Silence some advice and hint
run: |
git config --global advice.detachedHead false
git config --global init.defaultBranch main
- name: Check out source repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Configure the build
run: cmake -S ./FMU -B ./build -DCMAKE_BUILD_TYPE=Release

- name: Build FMU library
run: cmake --build ./build --target fedem_fmu

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: fmu-linux
path: build/src/libfedem_fmu.so

build-win:
name: Build FMU for Windows

runs-on: windows-latest

steps:
- name: Silence some advice and hint
run: |
git config --global advice.detachedHead false
git config --global init.defaultBranch main
- name: Check out source repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Configure the build
run: cmake -S ./FMU -B ./build -G "Visual Studio 17 2022"

- name: Build FMU library
run: cmake --build ./build --config Release --target fedem_fmu

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: fmu-win
path: build\src\Release\fedem_fmu.dll

release-fmu:
name: Release FMU package

needs: [ build-linux, build-win ]

runs-on: ubuntu-latest

steps:
- name: Silence some advice and hint
run: |
git config --global advice.detachedHead false
git config --global init.defaultBranch main
- name: Check out source repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.ACCESS_PAT }}

- name: Get latest release tag
run: |
git checkout `git tag | grep fmu- tail -1`
echo "MY_TAG=`git tag | grep fmu- tail -1`" >> $GITHUB_ENV
echo "MY_VER=`cat cfg/VERSION`" >> $GITHUB_ENV
- name: Download artifacts
uses: actions/download-artifact@v4

- name: Create release
uses: ncipollo/release-action@v1
with:
tag: ${{ env.MY_TAG }}
name: "Fedem FMU ${{ env.MY_VER }}"
token: ${{ secrets.ACCESS_PAT }}
artifacts: "fmu-linux/libfedem_fmu.so,fmu-win/fedem_fmu.dll"
body: "FMU libraries for the FEDEM dynamics solver"
80 changes: 80 additions & 0 deletions .github/workflows/build_solvers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# SPDX-FileCopyrightText: 2023 SAP SE
#
# SPDX-License-Identifier: Apache-2.0
#
# This file is part of FEDEM - https://openfedem.org

name: Build and release fedem solvers

on:
push:
tags:
- fedem-*

workflow_dispatch:
branches:
- main

jobs:
publish-solvers:
name: Publish solver packages

runs-on: ubuntu-latest

steps:
- name: Silence some advice and hint
run: |
git config --global advice.detachedHead false
git config --global init.defaultBranch main
- name: Check out source repository
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
token: ${{ secrets.ACCESS_PAT }}

- name: Checkout the latest release tag
run: |
git checkout `git tag | grep fedem- | tail -1`
echo "MY_TAG=`git tag | grep fedem- | tail -1`" >> $GITHUB_ENV
echo "MY_VER=`cat cfg/VERSION`" >> $GITHUB_ENV
- name: Configure main build
run: >
cmake -B ./build -DCMAKE_BUILD_TYPE=Release
-DBUILD_TESTS=OFF
-DBUILD_SOLVER_AS_DLL=ON
-DBUILD_CONTROL_AS_DLL=ON
-DUSE_CONCURRENT_RECOVERY=ON
-DUSE_SP_RECOVERY=ON
-DUSE_FFTPACK=ON
- name: Build binaries
run: cmake --build ./build --target all_solvers

- name: Prepare release package
run: |
mkdir bin
find build/src -name '*.so' -exec cp -p {} bin/ \;
find build/src -name 'fedem_*' -type f -exec cp -p {} bin/ \;
tar cfvz fedem-solvers-${{ env.MY_VER }}_linux64.tar.gz bin
sed "1 s/.*$/Solver package for Fedem &/" cfg/RELEASE | tr '\n' ' ' > body.md
sed "1 s/^.*\./(build /;s/.*$/&) for Linux 64-bit (Ubuntu)/" cfg/VERSION >> body.md
- name: Build the fedempy package
run: |
sed "1 s/.*$/fedempy package for Fedem &/" cfg/RELEASE | tr '\n' ' ' >> body.md
sed "1 s/^.*\./(build /;s/.*$/& and later)/" cfg/VERSION >> body.md
cd PythonAPI
python -m setup sdist
- name: Create release
uses: ncipollo/release-action@v1
with:
tag: ${{ env.MY_TAG }}
name: "Fedem solvers ${{ env.MY_VER }}"
token: ${{ secrets.ACCESS_PAT }}
artifacts: "fedem-solvers-${{ env.MY_VER }}_linux64.tar.gz,PythonAPI/dist/fedempy-${{ env.MY_VER }}.tar.gz"
bodyFile: "body.md"
allowUpdates: true
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,25 @@

# FEDEM solvers Changelog

## [fedem-8.0.6] (2024-10-18)

### :rocket: Added

- Binaries for the solvers are automatically built for the Linux platform
whenever a new release tag is pushed, and attached as an artifact together with
the fedempy package on the [Releases](https://github.com/openfedem/fedem-solvers/releases) page.
- The FMU wrapper for the FEDEM solvers is built for both Windows and Linux platforms
and deployed as a separate release, whenever a tag named `fmu-*` is pushed.
- The auto-generated source code tar-balls associated with each realease are now empty,
since they will be incomplete anyway (missing submodule parts).

### :bug: Fixed

- https://github.com/openfedem/fedem-gui/issues/32 :
Wrong data format in the FMU shared object library.
Also handle missing definition of environment variable FEDEM_SOLVER in the FMU,
such that is does not crash but exits with a console error message.

## [fedem-8.0.5] (2024-09-27)

### :rocket: Added
Expand Down Expand Up @@ -73,3 +92,4 @@
[fedem-8.0.3]: https://github.com/openfedem/fedem-solvers/compare/fedem-8.0.1...fedem-8.0.3
[fedem-8.0.4]: https://github.com/openfedem/fedem-solvers/compare/fedem-8.0.3...fedem-8.0.4
[fedem-8.0.5]: https://github.com/openfedem/fedem-solvers/compare/fedem-8.0.4...fedem-8.0.5
[fedem-8.0.6]: https://github.com/openfedem/fedem-solvers/compare/fedem-8.0.5...fedem-8.0.6
41 changes: 41 additions & 0 deletions FMU/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# SPDX-FileCopyrightText: 2023 SAP SE
#
# SPDX-License-Identifier: Apache-2.0
#
# This file is part of FEDEM - https://openfedem.org

################################################################################
# This is the top-level cmake project file for the Fedem FMU module.
################################################################################

cmake_minimum_required ( VERSION 2.8...3.5 )
if ( POLICY CMP0076 )
cmake_policy ( SET CMP0076 NEW ) # convert relative target source path names
endif ( POLICY CMP0076 )

# Project setup

set ( APPLICATION_ID fedemFMU )
set ( DOMAIN_ID FEDEM )
set ( PACKAGE_ID SOLVERS )

project ( ${APPLICATION_ID} CXX )
message ( STATUS "Generating build project for ${PROJECT_SOURCE_DIR}" )
get_filename_component ( PARENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY )

find_path ( _MODULES FedemConfig.cmake
PATHS $ENV{CMAKE_MODULES}
"${PARENT_SOURCE_DIR}/fedem-foundation/cmake/Modules/"
)
if ( _MODULES )
message ( STATUS "NOTE : Using ${_MODULES}" )
list ( APPEND CMAKE_MODULE_PATH ${_MODULES} )
else ( _MODULES )
message ( STATUS "ERROR : Missing path to FedemConfig.cmake" )
message ( FATAL_ERROR "Set environment variable CMAKE_MODULES and try again" )
endif ( _MODULES )
unset ( _MODULES CACHE )

include ( FedemConfig )

add_subdirectory ( ../src/FMU "${CMAKE_CURRENT_BINARY_DIR}/src" )
2 changes: 1 addition & 1 deletion PythonAPI/doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
author = "Knut Morten Okstad"

# The short X.Y version
version = "3.5"
version = "3.6"
# The full version, including alpha/beta/rc tags
release = "3.5.2"

Expand Down
2 changes: 1 addition & 1 deletion cfg/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.5.2
3.6.0
2 changes: 1 addition & 1 deletion fedem-foundation
5 changes: 2 additions & 3 deletions src/FMU/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ set ( UNIT_ID ${DOMAIN_ID}_${PACKAGE_ID}_${LIB_ID} )
message ( STATUS "INFORMATION : Processing unit ${UNIT_ID}" )

string ( APPEND CMAKE_CXX_FLAGS_DEBUG " -DFMU_DEBUG" )
if ( FTENV_WARNINGS AND LINUX AND NOT USE_INTEL_FORTRAN )
if ( ${CMAKE_CXX_COMPILER_ID} STREQUAL GNU )
string ( APPEND CMAKE_CXX_FLAGS " -Wno-unused-parameter" )
endif ( FTENV_WARNINGS AND LINUX AND NOT USE_INTEL_FORTRAN )
endif ( ${CMAKE_CXX_COMPILER_ID} STREQUAL GNU )

# Build and install

include_directories ( "${CMAKE_CURRENT_SOURCE_DIR}/FMI2/headers" )
add_library ( ${LIB_ID} SHARED fmu_template.C )
add_dependencies ( all_solvers ${LIB_ID} )

set ( CLOUD_DIR "${CMAKE_INSTALL_PREFIX}/bin/Templates/cloudsim" )
install ( TARGETS ${LIB_ID}
Expand Down
Loading

0 comments on commit d550a4a

Please sign in to comment.