pioneers / runtime

Firmware for the PiE kit robots and devices
7 stars 2 forks source link

[BUILD][MISC] Rewritten all Makefiles for efficiency and correctness #269

Closed benliao1 closed 1 year ago

benliao1 commented 1 year ago

In the past, our builds / Makefiles had two problems:

  1. They were inefficient (i.e. compiling all the tests took a really long time; or compiling all of Runtime)
  2. (more importantly) they were "incorrect", in the sense that you could change the dependency of a file, run ./runtime build again, and not have all dependent files be rebuilt again.

This PR fixes these issues by:

  1. Compiling all source files into object files first, then linking them together into executables
  2. Using the -MMD and -MP compiler flags to autogenerate dependency files for each object file

This does make our Makefiles somewhat more complex, however, I tried my best to keep the number of syntax features to a minimum while still getting the job done in a more or less general way.

In addition to the Makefile changes, I fixed / cleaned up / added a few things:

benliao1 commented 1 year ago

A lot of small extra cleanup / QOL items were added in this PR. The tests/Makefile in particular got a lot of extra functionality, i.e. it is now possible to run all of the following:

I also managed to silence some formatting warnings in the compilation that was cluttering our CI output, and write our own formatting bash script specific to Runtime that is much much simpler than the Python script we had before.

The test script now can take ./runtime test tc_150_1. You used to have to specify either the integration/ or performance/ folders, i.e. with ./runtime test integration/tc_150_1. Both of these now work.

I also deleted the scripts/install_raspi.sh and scripts/provision_raspi.sh scripts because they aren't being referred to and don't really belong in the repo. We should create more wiki pages with how to provision / install Runtime on Raspberry Pi's (or put it in the root README.md)!