|
| 1 | +# OpenModelica Cross Compile Docker Image |
| 2 | + |
| 3 | +[![Build Docker Image][gh-build-badge]][gh-build-workflow] |
| 4 | +[![Publish Docker Image][gh-publish-badge]][gh-publish-workflow] |
| 5 | + |
| 6 | +The Docker image used to cross compile OpenModelica FMUs from Linux to target |
| 7 | +platforms and create multi-platform FMUs. |
| 8 | + |
| 9 | +## Toolchains |
| 10 | + |
| 11 | +| Toolchain file | OS | C | Note | |
| 12 | +|------------------------------------------|-----------------------|------------------------|---------| |
| 13 | +| [i686-linux-gnu][i686-linux-gnu] | x86-64 Linux 32-bit | gcc -m32 | | |
| 14 | +| [x86_64-linux-gnu][x86_64-linux-gnu] | x86-64 Linux 64-bit | gcc -m64 | | |
| 15 | +| [i686-w64-mingw32][i686-w64-mingw32] | x86-64 Windows 32-bit | i686-w64-mingw32-gcc | MINGW | |
| 16 | +| [x86_64-w64-mingw32][x86_64-w64-mingw32] | x86-64 Windows 64-bit | x86_64-w64-mingw32-gcc | MINGW | |
| 17 | + |
| 18 | +## Versioning |
| 19 | + |
| 20 | +The cross compilation image is versioned together with the version number of |
| 21 | +OpenModelica. So OpenModelica `v1.26.0` expects to use this image with tag |
| 22 | +`v1.26.0` for cross compiling Linux and Windows. |
| 23 | + |
| 24 | +## Build |
| 25 | + |
| 26 | +```bash |
| 27 | +export TAG=v1.26.0 |
| 28 | +docker build --pull --no-cache --tag crossbuild:$TAG . |
| 29 | +``` |
| 30 | + |
| 31 | +## Example usage inside container |
| 32 | + |
| 33 | +### Windows 32-bit |
| 34 | + |
| 35 | +```bash |
| 36 | +cd path/to/FMU/sources/ |
| 37 | +cmake -S . -B build_win32 -DCMAKE_TOOLCHAIN_FILE=/opt/cmake/toolchain/i686-w64-mingw32.cmake |
| 38 | +cmake --build build_win32 --target create_fmu |
| 39 | +``` |
| 40 | + |
| 41 | +### Windows 64-bit |
| 42 | + |
| 43 | +```bash |
| 44 | +cd path/to/FMU/sources/ |
| 45 | +cmake -S . -B build_win64 -DCMAKE_TOOLCHAIN_FILE=/opt/cmake/toolchain/x86_64-w64-mingw32.cmake |
| 46 | +cmake --build build_win64 --target create_fmu |
| 47 | +``` |
| 48 | + |
| 49 | +### Linux 32-bit |
| 50 | + |
| 51 | +```bash |
| 52 | +cd path/to/FMU/sources/ |
| 53 | +cmake -S . -B build_linux32 -DCMAKE_TOOLCHAIN_FILE=/opt/cmake/toolchain/i686-linux-gnu.cmake |
| 54 | +cmake --build build_linux32 --target create_fmu |
| 55 | +``` |
| 56 | + |
| 57 | +### Linux 64-bit |
| 58 | + |
| 59 | +```bash |
| 60 | +cd path/to/FMU/sources/ |
| 61 | +cmake -S . -B build_linux64 -DCMAKE_TOOLCHAIN_FILE=/opt/cmake/toolchain/x86_64-linux-gnu.cmake |
| 62 | +cmake --build build_linux64 --target create_fmu |
| 63 | +``` |
| 64 | + |
| 65 | +## Upload |
| 66 | + |
| 67 | +The [publish.yml][gh-publish-file] workflow will build and |
| 68 | +upload the Docker image to |
| 69 | +[OpenModelica/crossbuild][docker-hub] |
| 70 | +for each release. |
| 71 | + |
| 72 | +To do it manually run: |
| 73 | + |
| 74 | +```bash |
| 75 | +export REGISTRY=openmodelica |
| 76 | +export TAG=v1.26.0 |
| 77 | +docker login |
| 78 | +docker image tag crossbuild:$TAG $REGISTRY/crossbuild:$TAG |
| 79 | +docker push $REGISTRY/crossbuild:$TAG |
| 80 | +``` |
| 81 | + |
| 82 | +## License |
| 83 | + |
| 84 | +The Dockerfile is licensed withthe MIT License, see |
| 85 | +[LICENSE.md][license]. |
| 86 | +The C test files in test/resources are part of OpenModelica and licensed with |
| 87 | +PUBLIC LICENSE (OSMC-PL) VERSION 1.8, see |
| 88 | +[test/resources/OSMC-License.txt][osmc-license]. |
| 89 | + |
| 90 | +[gh-build-badge]: https://github.com/OpenModelica/crossbuild/actions/workflows/build.yml/badge.svg?branch=main |
| 91 | +[gh-build-workflow]: https://github.com/OpenModelica/crossbuild/actions/workflows/build.yml |
| 92 | +[gh-publish-badge]: https://github.com/OpenModelica/crossbuild/actions/workflows/publish.yml/badge.svg |
| 93 | +[gh-publish-workflow]: https://github.com/OpenModelica/crossbuild/actions/workflows/publish.yml |
| 94 | +[i686-linux-gnu]: ./toolchain/i686-linux-gnu.cmake |
| 95 | +[x86_64-linux-gnu]: ./toolchain/x86_64-linux-gnu.cmake |
| 96 | +[i686-w64-mingw32]: ./toolchain/i686-w64-mingw32.cmake |
| 97 | +[x86_64-w64-mingw32]: ./toolchain/x86_64-w64-mingw32.cmake |
| 98 | +[gh-publish-file]: ./.github/workflows/publish.yml |
| 99 | +[docker-hub]: https://hub.docker.com/repository/docker/OpenModelica/crossbuild |
| 100 | +[license]: ./LICENSE.md |
| 101 | +[osmc-license]: ./test/resources/OSMC-License.txt |
0 commit comments