bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: multi-threaded compiling


From: Mischa Baars
Subject: Re: multi-threaded compiling
Date: Tue, 12 Mar 2024 13:37:31 +0100

On Tue, Mar 12, 2024 at 12:49 PM Greg Wooledge <greg@wooledge.org> wrote:

> On Tue, Mar 12, 2024 at 09:42:22AM +0100, Mischa Baars wrote:
> > Here's the script and the Makefile using "printf '<%s>'":
>
> Sadly, your mail user agent chose to attach "Makefile" with content-type
> application/octet-stream, which my MUA (mutt) refuses to show inline,
> or to include in a reply as quoted text.
>
> Here's the top part of it, inline:
>
>
> STR[0]="one and two"
> STR[1]=one\ and\ two
>
> CFLAGS[0]=-D__STRINGIZED__=0 -D__STRING__=${STR[0]}
> CFLAGS[1]=-D__STRINGIZED__=0 -D__STRING__=${STR[1]}
> CFLAGS[2]=-D__STRINGIZED__=1 -D__STRING__=${STR[0]}
> CFLAGS[3]=-D__STRINGIZED__=1 -D__STRING__=${STR[1]}
>
>
> And here's what Martin said about it:
>
> > On Tue, Mar 12, 2024 at 9:32 AM Martin D Kealey <martin@kurahaupo.gen.nz
> >
> > wrote:
> > > In section two, the problem is that quote removal is done BEFORE
> variables
> > > are expanded, even though it prevents word splitting from being done
> AFTER
> > > variable expansion. Therefore writing VAR=" \"string 1\" \"string 2\" "
> > > absolutely cannot do what you might expect; the embedded quote marks
> will
> > > be used literally, and then (because ${CFLAGS[0]} is not quoted) the
> > > resulting string will be split on any embedded whitespace..
>
>
> As someone said yesterday, you will need eval for this.
>
>
> hobbit:/tmp/x$ cat Makefile
> FOO=-D__x="one two three"
>
> all:
>         @bash -c 'eval '\''CFLAGS=${FOO}'\''; declare -p CFLAGS'
> hobbit:/tmp/x$ make
> declare -- CFLAGS="-D__x=one two three"
>

>
> Of course, using eval presents its own set of challenges, so proceed
> with extreme caution.
>

Indeed it does :) The Makefile was already working :) It is the script that
won't.


>
> I'd still like to hear why you aren't simply using "make -j".
>

That's because I don't want to define static compile and link targets for
every new project I start. The Makefile in question contains only a few
lines of code and some environment variables, but works on every new
project as long as you follow certain guidelines regarding the directory
structure. It scans, compiles and links on the fly.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]