Hacker News new | ask | show | jobs
by skore 2373 days ago
Well, kind of.

I'm using make to build a content graph, part of that is http:// dependencies. The underlying concept is that you can define protocols (https would be one) and then teach my make pre-parser about building them. An example would be:

    myfile.js: https://code.jquery.com/jquery-3.4.1.js local.js
        uglifyjs $^ -o $@
The 'https://' is rewritten to map to a local cache directory (so it's little more than a glorified variable, but still more intuitive since protocols are so familiar from our use of the web), so the above code is actually something like

    myfile.js: cache/https/code.jquery.com/jquery-3.4.1.js local.js
        uglifyjs $^ -o $@
and that in turn invokes a rule that makes a HEAD request to the URL - if that is outdated against the local copy, that gets renewed. So, in regular make code, something like this:

    cache/https/%: cache/https/%.head
        curl -Ls https://$* > $@

    cache/https/%.head: cache/https/%.head.force
        rsync --checksum $< $@

    cache/https/%.head.force: FORCE
        curl -Ls -I https://$* > $@
I could see a way to turn this around, though. The concept of "protocols" is currently only GET in my setup, but I do plan on supporting the idea of POST, eventually. So what you're asking for is that, I guess.

I must say, though, that in my now three years of using (or abusing) make, "just make it another file" is surprisingly often the right next step. In the POST situation, it would simply be a local file that has direct or side-effects attached that do what you're expecting it to do.

2 comments

> "just make it another file" is surprisingly often the right next step

This way it also often turns out that the "fetch"/"cache" part gets naturally separated from the rest, and that's super useful to track down any permanent or transitory issue.

Yes! It's basically a built-in stack trace! Permanently written straight to your disk!

It does get unwieldy after a certain size, but that's what I'm building tooling for.

Perhaps the part I'm missing is how you are rewriting the https:// URLs to the paths. Do you preprocess the Makefile?
Yeah, I'm using a preprocessor to generate the makefiles from what is basically blueprints.