[HN Gopher] A stupid simple make wrapper that makes my life easier
       ___________________________________________________________________
        
       A stupid simple make wrapper that makes my life easier
        
       Author : wurosh
       Score  : 65 points
       Date   : 2021-06-03 08:49 UTC (14 hours ago)
        
 (HTM) web link (github.com)
 (TXT) w3m dump (github.com)
        
       | bluehatbrit wrote:
       | Looks interesting! Not to put a dampener on the project but the
       | name clashes with Cake (C# Make) project which could be confusing
       | - https://cakebuild.net/ None the less this looks like a useful
       | tool.
        
         | wurosh wrote:
         | Oh, I didn't know, I spend all of my time working with Linux so
         | I'm a bit out of touch with that space. I'll see if I can come
         | up with a nice short name that doesn't clash
        
         | tgv wrote:
         | I don't mind name clashes: there so many projects, and only a
         | handful of words. Macker could be a good name, though.
        
       | rcarmo wrote:
       | I like the idea, but since I'm so used to using make for
       | everything, I would probably just bake in a Makefile with the
       | shell bits I found most useful for each container instead.
        
       | rurban wrote:
       | on macOs I had to skip the in_docker_group check. And the escape
       | sequences did not work
        
         | wurosh wrote:
         | Interesting. I don't have access to a Mac, so a bit of extra
         | information would be helpful. Could you open an issue on the
         | repo? I know docker desktop uses a virtialized linux kernel on
         | Mac, but I assumed access would still be controlled through
         | user groups. Is there an alternative check I can do? I'd be
         | more than happy to add MacOS specific logic. I'll look into how
         | escape sequences work on Mac as well.
        
       | commachika wrote:
       | Fauci is a fucking genocidal fascist.
       | 
       | Fauci must be executed on live tv!
        
       | [deleted]
        
       | zfrag wrote:
       | KILL FAUCI!
       | 
       | KILL FAUCI!
       | 
       | KILL FAUCI!
       | 
       | KILL FAUCI!
       | 
       | KILL FAUCI!
       | 
       | KILL FAUCI!
       | 
       | KILL FAUCI!
       | 
       | KILL FAUCI!
       | 
       | KILL FAUCI!
       | 
       | KILL FAUCI!
       | 
       | KILL FAUCI!
       | 
       | KILL FAUCI!
       | 
       | KILL FAUCI!
       | 
       | KILL FAUCI!
        
       | florianist wrote:
       | Before releasing a script, it's always a good idea to fix the
       | errors reported by Shellcheck. There are several here. Also the
       | script has a /bin/sh shebang and README says it's POSIX but it
       | has bashims (for example "echo -e" will fail in default /bin/sh
       | in Debian).
        
         | Hello71 wrote:
         | there are more issues after fixing all of those: grep -w is not
         | POSIX, the exit status of type is not clearly defined by POSIX,
         | realpath is not POSIX, basename is POSIX but can be replaced
         | with ${path##*/} for most well-formed paths (gives different
         | results for /, but this script doesn't work properly for /
         | anyways?), inodes are not unique across devices,
         | --directory=dir has ugly handling but seems to work but
         | --directory dir doesn't (i think it silently sets the directory
         | to --directory and then passes dir as a separate argument?)
        
       | BiteCode_dev wrote:
       | A bit of a plug, but if you are using python in your project
       | already, give a try to pydoit (pydoit.org/). It completely
       | replaced make, task runners or build systems for me.
       | 
       | Pydoit is the sweet spot for most of my use cases:
       | 
       | - it scales up (graph of deps, file watcher, etc) but above all,
       | it scales DOWN (simple stuff are dead simple)
       | 
       | - it promotes a declarative task definition
       | 
       | - it embraces the shell yet let you use python if you need to
       | 
       | - it gets out of your way and doesn't try to rule your project.
       | It just runs what you want and disapear.
       | 
       | - the doc is nice
       | 
       | The biggest drawback is that you need to pip install it, which
       | means non python devs will avoid it. I wish it was provided as an
       | stand alone executable
        
         | hprotagonist wrote:
         | a meta-plug is in order for pipx, then:
         | https://pipxproject.github.io/pipx/
         | 
         | which wholly abstracts "pip install this thing that has an
         | entry_point without hating your life."
        
           | mitchbob wrote:
           | Thanks! New URL: https://pypa.github.io/pipx/
        
         | agumonkey wrote:
         | https://pydoit.org/
        
       | wurosh wrote:
       | The README says it all. I kept writing Makefiles that ran build
       | targets in Docker in a shoddy way. I just wrote a slightly less
       | shoddy POSIX sh wrapper that does it for me. It's nothing fancy,
       | but it makes my life easier and it's super simple to use.
        
       | 0xbadcafebee wrote:
       | Mm. I've gone this way before, and eventually it breaks down.
       | _make_ just isn 't that composeable. I have even made fancy
       | Makefiles that allow me to pass command-line arguments to
       | targets. At the end of the day, what you really want is a wrapper
       | program that gives you specific composeable functionality, and
       | Make isn't that.
        
       | Arch-TK wrote:
       | "The Makefile is the single source of truth for dev commands"
       | 
       | This feels like when you set up a club for a hobby you enjoy,
       | let's say it's beer pong, and you go on holiday for a month, you
       | come back to find that your beer pong club is now full of people
       | just chugging lots of beer and completely ignoring the game.
       | 
       | Please, make is a sophisticated tool with lots of good features.
       | It is NOT a repository for "dev commands" whatever the hell that
       | means. Make is a tool which takes targets, dependencies and
       | recipes and turns them into a DAG which it then executes based on
       | a set of criteria. If you want a glorified shell script which
       | runs commands, why not just do a bash script with a switch in it?
       | It's certainly going to behave a lot more like you expect. Why
       | call it cake when it has almost nothing to do with make?
        
         | aequitas wrote:
         | > It is NOT a repository for "dev commands" whatever the hell
         | that means.
         | 
         | What it means is that it doesn't matter if I run `make test`,
         | my coworker runs `make test` or the CI system runs `make test`,
         | we all end up with the same result. Namely that the test suite
         | will be run, after all stuff is done that is needed to setup
         | the dev environment. Basically you codify all actions you as a
         | developer would need, to setup, verify or use a project and all
         | the dependencies between them. This makes your projects
         | portable and when you have multiple projects (in different
         | languages), getting it setup and running the test suite is the
         | same for each one of them.
         | 
         | Why not use a bash script? That's how I started off but once a
         | coworker introduced me to Make I never looked back. Bash scales
         | really badly in terms of readability and maintainability.
        
           | Arch-TK wrote:
           | Right, I wasn't asking what "single source of truth is" I was
           | asking what a "dev command" is. If you have commands and you
           | want to store them so that multiple people can run them then
           | the solution is NOT make, using make to execute commands is
           | really quite like using machine gun to turn your TV on. Make
           | is a very big and complex tool with lots of nuance and lots
           | of different and not-cross-compatible versions. Moreover, it
           | doesn't always use the same shell on every machine you run it
           | on so using it to store bash scripts (for example) isn't
           | really portable either.
           | 
           | I'm sorry to be the one to tell you this but neither you nor
           | your coworker know what make is if all you think it is is a
           | way to store subcommands.
           | 
           | If you want shell scripts write shell scripts. If you want
           | them all to stem from one command (as subcommands), use a
           | switch statement. These solutions will actually likely be far
           | more reliable and portable (if you know what you're doing, I
           | would imagine it's easier with portable shell than portable
           | shell in make since even most of the programmers I know who
           | use make for the purpose it was designed for don't seem to
           | understand it very well).
        
             | aequitas wrote:
             | Take a look at one of my Makefiles[0]. It uses most
             | features Make has to offer (to much so). It doesn't matter
             | what state you start from, fresh clones repo or outdated
             | virtualenv. Running `make run` will do everything needed to
             | run the application instance, `make test` will run the
             | testsuite. Each command is it's own "functional" block of
             | shell script with it's inputs (prerequisites) and outputs
             | (target). All recipies will run in Bash on all system btw,
             | see the first line of the Makefile.
             | 
             | Still, a Makefile with only targets, no prerequisites is
             | less cruft than a Bash script with a switch statement. But
             | eventually your (team) needs will grow and you start to
             | introduce more logic and dependencies. This is where Make
             | shines for me.
             | 
             | [0] https://gitlab.com/internet-cleanup-foundation/web-
             | security-...
        
               | Arch-TK wrote:
               | "Dependencies" in your makefile are literally just
               | functions. This can literally all be done with a bash
               | script and 100% less backslashes to make things run in
               | one shell. I really seriously think that this would be
               | much cleared if written in bash.
               | 
               | That being said, while perusing the original makefile I
               | found multiple issues. The one which stands out the most
               | is that running make with a -j flag (which is entirely
               | likely if your end user aliases that in their bashrc, I
               | know multiple people that do). I am pretty sure fix and
               | test can't run concurrently, at least I can't imagine how
               | in-place fixing of files while running tests would work
               | reliably. There's probably more cases where this would
               | break things. Another issue is using `echo -e` and other
               | bashisms, except that it's not guaranteed make will be
               | running bash.
               | 
               | I really don't understand why your makefile keeps
               | creating files, if it didn't create most of those files
               | it would behave basically identically except for not
               | needing to periodically run clean. In fact, by not
               | providing a full DAG your makefile is just annoying in
               | that there really isn't any option other than deleting
               | random files or redoing all the steps. I don't see how
               | having to delete .make.test and running make test is any
               | better than having ./run-testsuite or ./run testsuite
               | just run the testsuite every time.
               | 
               | Edit: I noticed your makefile sets SHELL. But this will
               | in turn break this line:
               | 
               | https://gitlab.com/internet-cleanup-foundation/web-
               | security-...
        
         | vimax wrote:
         | Your shell file with a switch isn't going to do incremental
         | parallel builds.
         | 
         | If you understand make, your makefile will behave as you expect
         | it to. If you try to read a makefile as a shell script you'll
         | constantly be surprised.
        
           | Arch-TK wrote:
           | The people this tool is aimed for don't use make to do
           | incremental parallel builds. They use it to as a glorified
           | shell wrapper which produces sub commands. That's what the
           | use-case for this tool seems to be at least.
           | 
           | I know what make is and I know how to use it, thanks.
        
         | ataylor32 wrote:
         | > why not just do a bash script with a switch in it?
         | 
         | Here is another alternative:
         | 
         | https://github.com/TekWizely/run
        
       ___________________________________________________________________
       (page generated 2021-06-03 23:02 UTC)