Puhomir

About Index Contact

Home / Oil-Rig

Build automation

To make my life a bit easier I've decided to invest a bit of my time to create a simple utility program which allows me to execute scripts when files in my project change.

Usually I write small shell scripts such as: build, run, test, etc. and run them manually in the command line. This works fine, but it's a silly waste of time and I'm annoyed by constant context switching.

It's high time for some process improvement.

Watchdog

Watchdog is a command-line utility I wrote which runs in the background and invokes commands when the files on disk change. Here's how I run it:

@echo off
start cmd.exe /k Watchdog.exe ^
    delay_ms="32" ^
    working_directory="C:/Puhomir/Projects/Oil_Rig/" ^
    -dirs ^
        src/ ^
        modules/ ^
        build/
    -ignore ^
        build_generated/ ^
    -command ^
        scripts/build.bat

It's super simple, the program is one infinite loop which uses the standard module: File_Watcher which ships with the Jai compiler. When any file in directories specified after the -dirs switch change, it will call the -command which in this case is build.bat script relative to the working_directory. Any sub-directories may be excluded with the -ignore switch, so in the case above all files in the: src/build_generated directory will be ignored by the Watchdog.

It's a really simple tool, but it significantly improved my quality of life. Whenever I make a change and save, the project will rebuild itself automatically. Later I also added the ability to specify extra arguments when specific file changes, but I will write about this more in the next post!

You can find the source code for this utility here: GitHub. Please note that this tool was built rather quickly and for my specific use-case, so it's probably not good for anything else.


Next: Asset management - Loading and using game assets.