Assignment 1 for CSC209 course at University of Toronto in Software Tools and Systems Programming
In this assignment a student is required to write a program in Bourne shell that performs some of the same operations that make does . A simpler file format for a build file is specified , which does not follow all rules of the make program .
Build file format
There are 4 types of valid lines in a build file:
- A blank line. I.e., a line containing nothing but whitespace.
- A line whose first character is # which indicates that the remainder of the line is a comment.
- A line whose first character is an @ followed by a space, and then followed by one or more words separated by a single space. This type of line marks the beginning of a build rule. The @ is ignored. The first word in the sequence is the target of the rule, and the remaining words, if any, are the prerequisites for the rule.
- Other lines are considered action lines which should be executable statements.
@target prerequisite1 prerequisite2
action with arguments
Functionality and Implementation
build program will take one or two arguments. The first argument is the target that you want to build. The second argument is the name of the build file to the program will read. If the second argument is not present, the program will try to read a file in the current working directory called
- Read the build file looking for the appropriate rule. If found:
- Update prerequisites. (as with
make, each prerequisite corresponds to a target in the buildfile, so we might need to execute another rule to ensure that a prerequisite is up to date.)
- If the target is a file and has been modified more recently than all of its prerequisites, then the actions are not executed.
- If the target is not a file, or any of the prerequisites are newer than the target, then the rule’s actions are executed.
- If a rule has no prerequisites, then the rule will always be executed when it is encountered. Note that this differs from
makewhere a rule with no prerequisites is only executed if it is called explicitly.
- You don’t need to handle recursive targets and prerequisites.
The build process will likely want to call the
build program from within the
build program. (Recursion comes in many forms.) The best way to do this is to make sure that
build is in a directory in the
Another obvious use for shell scripts is to automate testing programs. We will also write a shell script called
testbuild that will run several tests of the
testbuild program will run at least 3 different test cases that test different parts of the program. We will also need to include one or more build files and possibly some other files. The
touch (see “man touch”) command will come in quite handy when we want to change a file’s modification time automatically.
Zip archive can be obtained here: http://zenebo.com/csc209a1.zip