Skip to content

Commit

Permalink
Merge pull request #62 from GaloisInc/49-mps-makefile-improvements
Browse files Browse the repository at this point in the history
Refactor MPS Makefile to support separate build directories

This branch refactors the MPS `src/Makefile` to put all generated files (except the final binary) in a build directory and to use separate build directories for separate configurations.  For example, this allows for the following:

```sh
make CONFIG=self_test
make CONFIG=no_self_test TARGET=aarch64
```

This produces separate `rts.self_test` and `rts.no_self_test.aarch64` binaries.  Object files and other intermediate files are placed in separate `build.self_test/` and `build.self_test.aarch64/` directories, so they don't conflict and there's no need to `make clean` between the two builds.

If `CONFIG` and `TARGET` aren't specified, it's still possible to configure the build by specifying options directly:

```sh
make SENSORS=NotSimulated SELF_TEST=Enabled \
  CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++
```

This produces an unsuffixed `rts` binary and uses `build/` for intermediate files.
  • Loading branch information
spernsteiner authored Jun 11, 2024
2 parents 155c3a4 + b2066fd commit 6c05ebf
Show file tree
Hide file tree
Showing 10 changed files with 189 additions and 155 deletions.
45 changes: 24 additions & 21 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,25 @@ jobs:
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v4
- name: Install aarch64 toolchain
run: sudo apt-get install -y {gcc,g++}-aarch64-linux-gnu
- name: Install verilator
run: sudo apt-get install -y verilator
- name: Build MPS
uses: addnab/docker-run-action@v3
with:
image: galoisinc/hardens:latest
options: -v ${{ github.workspace }}:/HARDENS
run: |
cd components/mission_protection_system/src
SENSORS=NotSimulated SELF_TEST=Enabled make rts_bottom
make clean
SENSORS=NotSimulated SELF_TEST=Disabled make rts
mv rts rts.no_self_test
make clean
SENSORS=NotSimulated SELF_TEST=Enabled make rts
mv rts rts.self_test
run: |
cd components/mission_protection_system/src
make clean
# Build, then check it created the correct output file.
make rts_bottom CONFIG=self_test
[ -f rts_bottom.self_test ]
make rts CONFIG=self_test
[ -f rts.self_test ]
make rts CONFIG=no_self_test
[ -f rts.no_self_test ]
make rts CONFIG=self_test TARGET=aarch64
[ -f rts.self_test.aarch64 ]
make rts CONFIG=no_self_test TARGET=aarch64
[ -f rts.no_self_test.aarch64 ]
- name: Upload MPS binaries
uses: actions/upload-artifact@v4
with:
Expand All @@ -51,15 +56,13 @@ jobs:
run: |
chmod +x rts.*
mv rts.* components/mission_protection_system/src/.
- name: Install pip3
run: sudo apt-get install -y python3-pip
- name: Test MPS
uses: addnab/docker-run-action@v3
with:
image: galoisinc/hardens:latest
options: -v ${{ github.workspace }}:/HARDENS
run: |
cd components/mission_protection_system/tests
pip3 install -r requirements.txt
RTS_DEBUG=1 QUICK=1 python3 ./run_all.py
run: |
cd components/mission_protection_system/tests
pip3 install -r requirements.txt
RTS_DEBUG=1 QUICK=1 python3 ./run_all.py
vmrunner:
runs-on: ubuntu-22.04
Expand Down
7 changes: 2 additions & 5 deletions components/mission_protection_system/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ src/self_test_data/tests.inc.c
# src/generated/SystemVerilog/actuator_impl.sv
# src/generated/SystemVerilog/instrumentation_impl.sv

# Ignore verilator files
src/generated/SystemVerilog/verilator/
src/handwritten/SystemVerilog/verilator/

# Ignore the compiled binary
# Ignore the build directories and compiled binaries
src/rts*
src/build*/
10 changes: 0 additions & 10 deletions components/mission_protection_system/build_aarch64.sh

This file was deleted.

Loading

0 comments on commit 6c05ebf

Please sign in to comment.