Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.misc > #2199

Re: Using Make for workflow control

From despen@verizon.net (Dan.Espen)
Newsgroups comp.misc
Subject Re: Using Make for workflow control
Date 2014-04-01 20:00 -0400
Organization A noiseless patient Spider
Message-ID <ick3b8vbv6.fsf@home.home> (permalink)
References <lh99me$fsm$1@solani.org> <Fij*qaTZu@news.chiark.greenend.org.uk>

Show all headers | View raw


Theo Markettos <theom+news@chiark.greenend.org.uk> writes:

> RS Wood <rsw@therandymon.com> wrote:
>> Interesting article, linked to from Hacker News, about using Make for
>> workflows that don't necessarily involve building binaries or libraries.
>> 
>> http://bost.ocks.org/mike/make/
>> 
>> I'll have to look into it - seems like a lot of work to learn, but
>> potentially worth it.  Automation of processes is good for sanity.
>
> One situation I found to be troublesome is make assumes files are processed
> by taking file A and running it through a rule to make file B.  This doesn't
> work if A and B are the same file.  For example:
>
> sed -i s/example/example2/g somefile

somefile.ok: somefile
        sed -i s/example/example2/g somefile
        grep example2 somefile && echo 'somefile is okay' > somefile.ok

(not tested)

> will replace 'example' in somefile with 'example2'.  If it runs twice
> it makes 'example22', which isn't what you want.

I think you need a better example.
One that actually does something useful.
When I tried to make your example useful,
I came to a solution.

> Obviously this is a contrived example, but the general problem is Make uses
> the file dates to work out whether to run a process or not.  In the above
> case Make won't run the rule because it compares the timestamps of
> 'somefile' and 'somefile' and discovers they're the same.  The output
> 'somefile' isn't out of date with respect to the input 'somefile' so the
> step never happens.

Yes, but if you check that you did what you wanted to the file,
a solution appears.

> If you force the step to happen by not declaring the dependency there is a
> risk it'll happen twice.  Even if that isn't a problem, make has no way of
> knowing that the step doesn't need doing - so it will do it every time.
> This is bad, especially if it'll cause lots of things downstream to rerun.
>
> While this is fine if you can make sure your tools use a file A -> file B
> paradigm, some tools don't work like that.  The workarounds get messy.

I don't think particularly messy.
In the real world, I'd have the .ok (above) filed away in a sub-directory.

-- 
Dan Espen

Back to comp.misc | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Using Make for workflow control RS Wood <rsw@therandymon.com> - 2014-03-30 14:28 +0000
  Re: Using Make for workflow control despen@verizon.net (Dan.Espen) - 2014-03-30 13:39 -0400
  Re: Using Make for workflow control Rich <rich@example.com> - 2014-03-30 21:54 +0000
  Re: Using Make for workflow control Huge <Huge@nowhere.much.invalid> - 2014-03-31 08:40 +0000
  Re: Using Make for workflow control scott@alfter.diespammersdie.us (Scott Alfter) - 2014-03-31 17:43 +0000
  Re: Using Make for workflow control Theo Markettos <theom+news@chiark.greenend.org.uk> - 2014-04-01 23:40 +0100
    Re: Using Make for workflow control despen@verizon.net (Dan.Espen) - 2014-04-01 20:00 -0400

csiph-web