When I was first using Code for IBM i and trying to get to grips with how it works with BOB and SOURCE ORBIT these Rules.mk files seemed to be the files that hold it all together.
That's because Rules.mk is the magic sauce!
What is Rules.mk?
In the context of software development, particularly in build automation tools like Make, a "Rules.mk" file is a common convention.
A "Rules.mk" file typically contains a set of predefined rules for building software projects. These rules define how to compile, link, and assemble source code files into executable programs or libraries
In Make-based build systems, the "Rules.mk" file typically includes generic rules that are applicable across various projects, such as:
In short the Rules.mk is the very saucy magic config file for our VS Code for IBM i Projects.
How can I auto-generate each folders Rules.mk file?
SourceOrbit will auto generate either Rules.mk files or it can generate make files as well. Also, it will create a json object of dependencies if needed.
The best way to do this is to use the Generate Build File button in the Project Explorer
NOTE: we can also do this manually from the terminal using the command so -bf bob
on the command line at the root of your project (but why do it the hard way?)
Set the Source Folders to be scanned
Edit the Rules.mk file in the root of the workspace to include the names of all the folders that contain source code. These will be scanned by Source Orbit and each of those source folders will have its own Rules.mk file added. These subfolders Rules.mk files will contain a line for each and every source file found in that folder.
Let's build a Rules.mk file in real time!
As I always say "a picture paints a thousand words" so let's do this: