Got make?

I'm @robashton

Things I don't like

AngularJS,Rails,Ruby,C#,Java,JavaScript,Ember,Node,Semicolons, Object orientated code, Design patterns, Procedural code, Imperative code, Dynamic languages, Bad coffee,Visual Studio,Emacs, Making slide decks, MacOS,Wearing clothes,Wearing shoes,Exercise,Software development

Things I do like

???

Some context

Make (GNU)

Make

  • As old as the hills
  • Full of weirdness
  • FUN!

Demo

(Variable Expansion)

We learned

  • Make is not procedural
  • Recursive Variables are pretty lazy
  • Simply expanded variables are not

Targets, Pre-reqs, Recipes

Demo

(A simple recipe)

We learned

  • Targets are (usually) actual physical outputs
  • Pre-requisites can be files or other targets
  • Recipes are just scripts that do a->b

Pattern Rules

Demo

(Pattern rules)

We learned

  • Pattern rules are just subsitutions with %
  • Automatic variables are available to recipes
    • $@ = Filename of the target causing this to run
    • $< = Name of the first pre-requisite
    • $^ = All of the pre-requisites separated by spaces
    • .... a dozen more of these

Built in functions

Demo

(Wildcards)

We learned

  • Lists of inputs can be generated with (wildcard  ...)
  • Lists of outputs can be generated with (patsubst ...)
  • Good when combined with pattern rules(!!)

Putting it all together

Demo

(Building the web)

We learned

  • The structure of a Makefile
  • Touching placeholder files
  • Automatic parallelism! (on sensible OSs)

Things to consider

  • Self executing make "per widget"
  • Stylus dependencies (not dealt with in this example)
  • Vanilla JS (existing JS files currently ignored)
  • widgets -> node_modules 
  • browserify/etc

Re-use

Demo

(Bootstrapping Makefile)

We learned

  • wget is your friend
  • Variable exports
  • .DEFAULT_GOAL
  • PROJECT CONVENTIONS FOR THE WIN

Don't do this

all: build-js build-css

build-js: 
  browserify -t brfs src/app.js > site/app.js

build-css:
  stylus src/style.styl > site/style.css

etc:
  blah


.PHONY build-js build-css etc

Build systems !== Task Runners

Did you mean...

npm scripts

Build Complete

(I'm probably being glared at for going too slow so I expect we don't have time for questions but I am totes hanging out on a beanbag somewhere and will be drinking beer later if you want to tell me I am wrong about everything or I did "Make" wrong or you're an angular fanboy and you want to organise an angry mob)

@robashton

Got Make?

By Rob Ashton

Got Make?

  • 5,190