[jamming] Checking variable on a target

Alen Ladavac alenl-ml at croteam.com
Mon Nov 22 03:04:14 PST 2004


Erm, how about, this?

if not $(LINKLIBS)=="" echo $(LINKLIBS) >> $(<:S=.rsp)

It's not a jam-side solution, but it should fix the problem.

On the other hand, why not put all linking flags into one action? Then the
problem would not exist, as long as there is at least one flag (which is
usually true).

HTH,
Alen

----- Original Message -----
From: "Dean Ashton" <dean.ashton at ntlworld.com>
To: <jamming at perforce.com>
Sent: Monday, November 22, 2004 09:53
Subject: [jamming] Checking variable on a target


> Hi,
> As part of our link handling (where we may have many items in the NEEDLIBS
and LINKLIBS variables), I have a Link rule that looks like this:
>
> rule Link
> {
> MODE on $(<) = $(EXEMODE) ;
> Chmod $(<) ;
>
> StartLink $(<) : $(>) ;
> WriteLinkObjs $(<) : $(>) ;
> WriteNeedLibs $(<) : $(>) ;
> WriteLinkLibs $(<) : $(>) ;
> FinishLink $(<) : $(>) ;
> }
>
> The actions used above are as follows:
>
> actions quietly ignore StartLink
> {
> $(RM) $(<:S=.rsp) 2>nul
> echo $(LINKFLAGS) /out:$(<) $(UNDEFS) /pdb:$(<:S=$(SUFPDB)) > $(<:S=.rsp)
> }
>
> actions together piecemeal quietly WriteLinkObjs
> {
> echo $(>) >> $(<:S=.rsp)
> }
>
> actions together piecemeal quietly WriteNeedLibs bind NEEDLIBS
> {
> echo $(NEEDLIBS) >> $(<:S=.rsp)
> }
>
> actions together piecemeal quietly WriteLinkLibs
> {
> echo $(LINKLIBS) >> $(<:S=.rsp)
> }
>
> actions FinishLink bind NEEDLIBS
> {
> $(LINK) @$(<:S=.rsp)
> }
>
> My problem is that our Jamrules file needs to handle the case where our
.exe has NEEDLIBS set (as you get when you use the standard LinkLibraries
rule on an executable), and also where the .exe can get away without any
additional libraries.
>
> The problem I have (on Windows, naturally), is that if NEEDLIBS is not set
(ie: I haven't needed to call LinkLibraries in my Jamfile), then the action
'WriteNeedLibs' fails.. $(NEEDLIBS) expands to an empty string, and
Windows/DOS 'echo' just outputs 'ECHO is on'. Which causes my link to fail
(as you would expect, I don't have a file called 'ECHO is on.obj' :))
>
> How can I make sure that the action 'WriteNeedLibs' is only called when
there's something in $(NEEDLIBS). NEEDLIBS is defined on the .executable
(rather than being global), but I can't seem to use 'NEEDLIBS on (my target
name)' in a conditional expression in my Link rule.
>
> I've also tried adding an additional latch-style variable to LinkLibraries
(formed from the executable name and a suffix eg: 'Main.exe-has-needlibs'),
and checking that, but to no avail.
>
> If anyone has any ideas how I can get this conditional behaviour to work,
I'd be really happy to hear them!
>
> Many thanks,
>
> Dean
>
> --
> Dean Ashton, Senior Programmer
> Sony Computer Entertainment Europe (Cambridge)
>
> -----------------------------------------
> Email provided by http://www.ntlhome.com/
>
>
> _______________________________________________
> jamming mailing list  -  jamming at perforce.com
> http://maillist.perforce.com/mailman/listinfo/jamming
>




More information about the jamming mailing list