Skip to content

Controller Design Documentation

yashlala edited this page Feb 2, 2021 · 1 revision

Controller Design

The controller has three main tasks:

  1. Read input from the user -- namely, a Makefile and a Docker image name.
  2. Extract a list of targets from the Makefile, along with the dependency information for each target.
  3. Intelligently design a job queue using the list of targets. Convey this queue to the client.

Part 1 is trivial.

Part 2 is conceptually simple, but there are a lot of edge cases to cover. Makefiles are difficult to parse, use non-explicit syntax to build certain fles, and are often called recursively.

We can avoid these issues by appending a special target to the end of the the Makefile. When called, this target will recursively call make on the other targets in the file, effectively performing a dry-run of the final build process. By using make itself to handle dependencies + recursion, we sidestep a lot of the complexity associated with Makefile parsing.

This method requires that the host operating system supports GNU make (ie. non-windows targets). We can either stop supporting Windows platforms or run step 2 inside a Docker container. It's ugly, but it should work.

Clone this wiki locally