|
| 1 | +name: Build OpenVic-Simulation |
| 2 | +description: Setup and Build OpenVic-Simulation with the provided options |
| 3 | + |
| 4 | +inputs: |
| 5 | + identifier: |
| 6 | + description: Identifier of this build |
| 7 | + type: string |
| 8 | + target: |
| 9 | + description: Target type to build for |
| 10 | + type: choice |
| 11 | + options: [template_release, template_debug, editor] |
| 12 | + platform: |
| 13 | + description: Platform to build for |
| 14 | + type: choice |
| 15 | + options: [windows, linux, macos] |
| 16 | + arch: |
| 17 | + description: Architecture to build for |
| 18 | + type: choice |
| 19 | + options: [x86_64, universal] |
| 20 | + scons-flags: |
| 21 | + description: Additional flags to send to SCons |
| 22 | + required: false |
| 23 | + default: 'build_ovsim_benchmarks=yes' |
| 24 | + type: string |
| 25 | + build-library: |
| 26 | + description: Whether to build the library file |
| 27 | + default: true |
| 28 | + type: boolean |
| 29 | + cache-base-branch: |
| 30 | + description: | |
| 31 | + Branch to base the cache upon |
| 32 | + required: false |
| 33 | + default: 'master' |
| 34 | + type: string |
| 35 | + disable-cache: |
| 36 | + description: Whether to disable the build cache |
| 37 | + default: false |
| 38 | + type: boolean |
| 39 | + |
| 40 | +runs: |
| 41 | + using: composite |
| 42 | + steps: |
| 43 | + - name: Setup build cache |
| 44 | + uses: OpenVicProject/openvic-cache@master |
| 45 | + if: ${{ !inputs.disable-cache }} |
| 46 | + with: |
| 47 | + cache-name: ${{ inputs.identifier }} |
| 48 | + base-branch: ${{ inputs.cache-base-branch }} |
| 49 | + continue-on-error: true |
| 50 | + |
| 51 | + - name: Set up Python |
| 52 | + uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 |
| 53 | + with: |
| 54 | + python-version: "3.x" |
| 55 | + |
| 56 | + - name: Set up SCons |
| 57 | + shell: bash |
| 58 | + run: | |
| 59 | + python -c "import sys; print(sys.version)" |
| 60 | + python -m pip install scons |
| 61 | + scons --version |
| 62 | +
|
| 63 | + - name: Install APT dependencies |
| 64 | + if: ${{ inputs.platform == 'linux' }} |
| 65 | + uses: awalsh128/cache-apt-pkgs-action@acb598e5ddbc6f68a970c5da0688d2f3a9f04d05 # v1.6.0 |
| 66 | + with: |
| 67 | + packages: build-essential pkg-config libtbb-dev |
| 68 | + |
| 69 | + - name: Install and Set g++ to version 13 |
| 70 | + if: ${{ inputs.platform == 'linux' }} |
| 71 | + shell: sh |
| 72 | + run: | |
| 73 | + g++ --version |
| 74 | + sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y |
| 75 | + sudo apt update -y |
| 76 | + sudo apt install g++-13 |
| 77 | + sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 13 |
| 78 | + sudo update-alternatives --set g++ /usr/bin/g++-13 |
| 79 | + g++ --version |
| 80 | +
|
| 81 | + - name: Compile with SCons |
| 82 | + uses: OpenVicProject/openvic-build@master |
| 83 | + with: |
| 84 | + platform: ${{ inputs.platform }} |
| 85 | + target: ${{ inputs.target }} |
| 86 | + sconsflags: arch=${{ inputs.arch }} ${{ inputs.build-library && 'build_ovsim_library=yes' }} ${{ inputs.scons-flags }} |
| 87 | + |
| 88 | + - name: Delete compilation files |
| 89 | + if: ${{ inputs.platform == 'windows' }} |
| 90 | + shell: pwsh |
| 91 | + run: | |
| 92 | + Remove-Item bin/* -Include *.exp,*.pdb -Force |
| 93 | +
|
| 94 | + - name: Upload library artifact |
| 95 | + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 96 | + with: |
| 97 | + name: ${{ github.event.repository.name }}-${{ inputs.identifier }}-library |
| 98 | + path: | |
| 99 | + ${{ github.workspace }}/bin/libopenvic-simulation.* |
| 100 | +
|
| 101 | + - name: Upload executable artifact |
| 102 | + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 103 | + with: |
| 104 | + name: ${{ github.event.repository.name }}-${{ inputs.identifier }}-executable |
| 105 | + path: | |
| 106 | + ${{ github.workspace }}/bin/openvic-simulation.headless.* |
0 commit comments