Elevator Pitch
Have you ever sat at your computer, hammering out verbose terminal commands for all the different steps in your development workflow, wishing there were a better way? A clean, easy-to-type, easy-to-understand means of automating your project’s build, test, or deploy steps? Enter: GNU Make!
Description
GNU Make is a program that ships with nearly all operating systems that come with GNU software, and can also be installed on Windows and macOS. Make was originally written for a relatively specific purpose: recompile the parts of a (probably C) program that have changed since last compile, and update those parts’ dependencies as well. And in this regard, Make is still an incredibly powerful tool for dependency management, compilation orchestration, etc. However, many developers these days may not have even heard of Make, because they either write small enough programs to “not need it”, or write high-level code that removes the need for compilation altogether.
But, the beauty & promise of Make isn’t that it’s a program for C developers, or
even for developers of compiled languages (I’ve never written a line of compiled
code in my life). Make isn’t bootstrapped by the Cs; its steps are written as
shell commands. So, if you can write shell commands to run your software’s bits
& pieces, then you can use Make! This includes high-level software like Python,
Ruby, R, or even Bash itself. For example, instead of writing a verbose and ugly
case
block for different arguments that Bash might take (via getopts
, for
instance), you can just define those arguments as “targets” in Make. And perhaps
the greatest benefit to Make is that the Makefile
s that it uses move entirely
with your codebase in version control, so these “recipes” for common commands
are always with your code, on any system that Make runs on. This is not only a
boon for developers of your code, but great for reducing verbosity in custom
definitions in CI/CD tools like Jenkins Pipelines.
In this short talk, I’ll walk through a sample Makefile
structure that I use
for Python packages, and others if time permits. This short-and-sweet Python
Makefile
format is one I actually use in production; no silly “Hello World”
examples here, but it might feel like it given how concise it is. I will
demonstrate that the common venv
, build, test, and install commands that can
be tedious to type out are reduced to simple make
commands that take as few as
four characters to run.
Notes
Technical Requirements
There are no strict audience requirements for this talk, especially given its
length. Having a machine handy that has make
installed, with internet access
for the GitHub repo would be helpful, but not necessary.
Why Me
As someone who has wasted a lot of development time hammering out ad-hoc
commands to test, build, and deploy my own code, I stumbled upon GNU Make not
terribly long ago, and I was enthralled by its promise. After looking through
the source code of various FOSS projects to see how their Makefile
s were
written, I was surprised to see very few! Much of the tooling for the
build/test/etc steps had been abstracted out to the CI/CD tool of choice,
defined in YAML files for tools like Travis, AppVeyor, Bitbucket, etc. This
leaves the local development work up to the user to understand on their own.
Questions are then raised such as:
-
Does the developer know how to run the tests?
-
Do they know how to install the software?
-
Do they know how the build system works for the tool?
While these CI/CD tools’ abstractions are also greatly beneficial in their own right, I feel that it is important to arm developers with the right tools to step back from that abstraction, without needing to fully rely on an external tool alone. This implicitly advocates for better understanding of the software itself, how the tests are run (and using what test suite, for example), how installation is actually called, etc. Make serves to document this information as code that moves with the project itself, and is uniquely valuable in that regard. This is a very important concept to me, and I am passionate in speaking on matters related to it.