7 ms·
Did you try searching stack overflow? https://stackoverflow.com/a/43402649 https://stackoverflow.com/a/43402649 If you dedicate a specific directory for all yo
by bigmanwalter 3y ago
Did you try searching stack overflow? https://stackoverflow.com/a/43402649 https://stackoverflow.com/a/43402649
If you dedicate a specific directory for all your JSON, then you can depend on that directory and it will do what you're asking for.
- schemescape 3y agoI did spend quite a bit of time researching approaches, but I didn't come across this particular idea. I'll give it a try. Thanks! Note: in my case, I have a directory structure that's a few levels deep, with an non-prescriptive set of directories (one subdirectory per category, with no limit on the set of categories). Maybe Make handles directories better than I realized (I'd always seen it recommended to use a Makefile in each directory--something I want to avoid).
- mturmon 3y agoHere's one way to do this. I have used this method (directory mod-time triggering, let's say) for a simulation-summarizer which analyzes whatever pile of simulation-output-files happen to be in a given directory. If you run a new simulation, the directory changes and the analysis is re-done by running "make". I used the Gnu make $(wildcard ...) for the template expansion, instead of using shell expansion. This is to take care of the no-file case, so that jsons/*.json will expand to nothing rather than to the literal jsons/*.json (which does not exist). $ cat Makefile file.out: jsons cat $(wildcard jsons/*.json) /dev/null > file.out $ ls -R Makefile jsons/ ./jsons: foo.json $ make cat jsons/foo.json /dev/null > file.out $ make # no file mods => no-op make: `file.out' is up to date. $ touch jsons/bar.json $ make # new file => re-make cat jsons/bar.json jsons/foo.json /dev/null > file.out $ make make: `file.out' is up to date. $ rm jsons/foo.json $ make # deletion => re-make cat jsons/bar.json /dev/null > file.out $ rm jsons/bar.json $ make # nothing there cat /dev/null > file.out $ make make: `file.out' is up to date.
- bigmanwalter 3y agoDefinitely avoid makefiles per directory, see Recursive Make Considered Harmful https://accu.org/journals/overload/14/71/miller_2004/ https://accu.org/journals/overload/14/71/miller_2004/ The approach being recommended in the sibling comment to this is quite nice!