Conditional src files

View: New views
8 Messages — Rating Filter:   Alert me  

Conditional src files

by Anant Rao :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Hi,

 

How is it to handle diff files on diff OSs using bjam?

 

What I mean is – say, file File1.cpp exists only Windows and File2.cpp exists only on Linux.

Using a single Jamfile, is there a way to handle it i.e., conditionally add the files to the build, depending on the OS?

 

Thanks a lot in advance,


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build

Re: Conditional src files

by Steven Watanabe-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

AMDG

Anant Rao wrote:
> How is it to handle diff files on diff OSs using bjam?
>
> What I mean is - say, file File1.cpp exists only Windows and File2.cpp exists only on Linux.
> Using a single Jamfile, is there a way to handle it i.e., conditionally add the files to the build, depending on the OS?
>  

You can use conditional features:

<target-os>windows:<source>File1.cpp
<target-os>linux:<source>File2.cpp

In Christ,
Steven Watanabe

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build

Re: Conditional src files

by Anant Rao :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks Steven!
I'm sorry I didn't give the correct and complete info.

Here's what my Jamfile looks like:


project blah
   : source-location $(OS_SRC) $(OS_LINUX_SRC) $(OS_WIN_SRC)
   ;

lib libblah
:
CommonFile1.cpp
CommonFile2.cpp
WinFile.cpp
LinuxFile.cpp
: <define>$(DEFINES)
: <link>static
;


Now, WinFile.cpp should be included only on Windows and LinuxFile.cpp on Linux. Given this, could you please let me know how I can do it?

Thanks again,


-----Original Message-----
From: boost-build-bounces@... [mailto:boost-build-bounces@...] On Behalf Of Steven Watanabe
Sent: Wednesday, November 04, 2009 6:05 PM
To: Boost.Build developer's and user's list
Subject: Re: [Boost-build] Conditional src files

AMDG

Anant Rao wrote:
> How is it to handle diff files on diff OSs using bjam?
>
> What I mean is - say, file File1.cpp exists only Windows and File2.cpp exists only on Linux.
> Using a single Jamfile, is there a way to handle it i.e., conditionally add the files to the build, depending on the OS?
>  

You can use conditional features:

<target-os>windows:<source>File1.cpp
<target-os>linux:<source>File2.cpp

In Christ,
Steven Watanabe

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build

Re: Conditional src files

by Phillip Seaver :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Anant Rao wrote:

> Thanks Steven!
> I'm sorry I didn't give the correct and complete info.
>
> Here's what my Jamfile looks like:
>
>
> project blah
>    : source-location $(OS_SRC) $(OS_LINUX_SRC) $(OS_WIN_SRC)
>    ;
>
> lib libblah
> :
> CommonFile1.cpp
> CommonFile2.cpp
> WinFile.cpp
> LinuxFile.cpp
> : <define>$(DEFINES)
> : <link>static
> ;
>
>
> Now, WinFile.cpp should be included only on Windows and LinuxFile.cpp on Linux. Given this, could you please let me know how I can do it?
>
> Thanks again,
>
>
> -----Original Message-----
> From: boost-build-bounces@... [mailto:boost-build-bounces@...] On Behalf Of Steven Watanabe
> Sent: Wednesday, November 04, 2009 6:05 PM
> To: Boost.Build developer's and user's list
> Subject: Re: [Boost-build] Conditional src files
>
> AMDG
>
> Anant Rao wrote:
>  
>> How is it to handle diff files on diff OSs using bjam?
>>
>> What I mean is - say, file File1.cpp exists only Windows and File2.cpp exists only on Linux.
>> Using a single Jamfile, is there a way to handle it i.e., conditionally add the files to the build, depending on the OS?
>>  
>>    
>
> You can use conditional features:
>
> <target-os>windows:<source>File1.cpp
> <target-os>linux:<source>File2.cpp
>
> In Christ,
> Steven Watanabe
>  

This should do what you want:

lib libblah
:
CommonFile1.cpp
CommonFile2.cpp
: <define>$(DEFINES)
<target-os>windows:<source>WinFile.cpp
<target-os>linux:<source>LinuxFile.cpp
: <link>static
;

Phillip
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build

Re: Conditional src files

by Rene Rivera-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Anant Rao wrote:

> Thanks Steven! I'm sorry I didn't give the correct and complete info.
>
>
> Here's what my Jamfile looks like:
>
>
> project blah : source-location $(OS_SRC) $(OS_LINUX_SRC)
> $(OS_WIN_SRC) ;
>
> lib libblah : CommonFile1.cpp CommonFile2.cpp WinFile.cpp
> LinuxFile.cpp : <define>$(DEFINES) : <link>static ;
>
>
> Now, WinFile.cpp should be included only on Windows and LinuxFile.cpp
> on Linux. Given this, could you please let me know how I can do it?

It turns out Steven gave you all the info you needed...

project blah
    : source-location $(OS_SRC) $(OS_LINUX_SRC) $(OS_WIN_SRC)
    ;

lib libblah
:
CommonFile1.cpp
CommonFile2.cpp
: <define>$(DEFINES)
<target-os>windows:<source>WinFile.cpp
<target-os>linux:<source>LinuxFile.cpp
: <link>static
;



--
-- Grafik - Don't Assume Anything
-- Redshift Software, Inc. - http://redshift-software.com
-- rrivera/acm.org (msn) - grafik/redshift-software.com
-- 102708583/icq - grafikrobot/aim,yahoo,skype,efnet,gmail
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build

Re: Conditional src files

by Steven Watanabe-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

AMDG

Anant Rao wrote:

> Here's what my Jamfile looks like:
>
>
> project blah
>    : source-location $(OS_SRC) $(OS_LINUX_SRC) $(OS_WIN_SRC)
>    ;
>
> lib libblah
> :
> CommonFile1.cpp
> CommonFile2.cpp
> WinFile.cpp
> LinuxFile.cpp
> : <define>$(DEFINES)
> : <link>static
> ;
>  

Did you really intend <link>static to be in the usage-requirements?
If I remember correctly that isn't allowed.

In Christ,
Steven Watanabe


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build

Re: Conditional src files

by Anant Rao :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Steven, Rene, Philip,
Thanks to you all!
Yes, I wanted 'static' and it works like a charm, doing exactly what I want.

I found out why it was not working, based on Steven's first email.
If I have

Option 1:

  F1.cpp
    : <define>$(DEFINES)
        : <link>static
    : <target-os>windows:<source>winfile.cpp  ;

Winfile.cpp is not compiled.

Option 2:
  F1.cpp
    : <define>$(DEFINES)
    : <target-os>windows:<source>winfile.cpp  
        : <link>static ;

I get a syntax error from bjam.

Option 3:
  F1.cpp
    : <define>$(DEFINES)
     <target-os>windows:<source>winfile.cpp  
        : <link>static ;

Works correctly!!

I think using a ':' before <target-os> is the problem. Am I right?
Thanks a lot again to all of you.
Anant


-----Original Message-----
From: boost-build-bounces@... [mailto:boost-build-bounces@...] On Behalf Of Steven Watanabe
Sent: Wednesday, November 04, 2009 7:23 PM
To: Boost.Build developer's and user's list
Subject: Re: [Boost-build] Conditional src files

AMDG

Anant Rao wrote:

> Here's what my Jamfile looks like:
>
>
> project blah
>    : source-location $(OS_SRC) $(OS_LINUX_SRC) $(OS_WIN_SRC)
>    ;
>
> lib libblah
> :
> CommonFile1.cpp
> CommonFile2.cpp
> WinFile.cpp
> LinuxFile.cpp
> : <define>$(DEFINES)
> : <link>static
> ;
>  

Did you really intend <link>static to be in the usage-requirements?
If I remember correctly that isn't allowed.

In Christ,
Steven Watanabe


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build

Re: Conditional src files

by Vladimir Prus :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thursday 05 November 2009 Anant Rao wrote:

> Hi Steven, Rene, Philip,
> Thanks to you all!
> Yes, I wanted 'static' and it works like a charm, doing exactly what I want.
>
> I found out why it was not working, based on Steven's first email.
> If I have
>
> Option 1:
>
>   F1.cpp
>     : <define>$(DEFINES)
> : <link>static
>     : <target-os>windows:<source>winfile.cpp  ;
>
> Winfile.cpp is not compiled.
>
> Option 2:
>   F1.cpp
>     : <define>$(DEFINES)
>     : <target-os>windows:<source>winfile.cpp  
> : <link>static ;
>
> I get a syntax error from bjam.
>
> Option 3:
>   F1.cpp
>     : <define>$(DEFINES)
>      <target-os>windows:<source>winfile.cpp  
> : <link>static ;
>
> Works correctly!!
>
> I think using a ':' before <target-os> is the problem. Am I right?

Yes. Please recall that things like 'lib' are just function names.
Then:

   lib libblah
         : F1.cpp
     : <define>$(DEFINES)
      <target-os>windows:<source>winfile.cpp  
  : <link>static ;

is a function call. The ":" character separates parameters to that
function. First parameter is the name of the metatarget to create,
second parameter is the list of sources, third parameter is the
requirements and the fourth parameter is the default build. Requirements
are the build properties that must be always present -- so everything
must be in requirements. E.g. the code above has extra ":", and should
be

   lib libblah
         : F1.cpp
     : <define>$(DEFINES)
       <target-os>windows:<source>winfile.cpp  
    <link>static ;

- Volodya




_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build