19 messages in com.perforce.jamming[jamming] Automatic inclusion of sour...
FromSent OnAttachments
Peter Björklund13 Sep 2003 15:40 
Peter Björklund14 Sep 2003 02:11 
Alen Ladavac14 Sep 2003 04:30 
Peter Björklund14 Sep 2003 05:57 
Matt Armstrong14 Sep 2003 07:51 
Alen Ladavac14 Sep 2003 09:00 
Alen Ladavac14 Sep 2003 09:40 
Alen Ladavac14 Sep 2003 11:00 
Matt Armstrong14 Sep 2003 13:35 
Alen Ladavac14 Sep 2003 14:02 
Matt Armstrong15 Sep 2003 09:41 
Wallace, Richard17 Sep 2003 17:13 
Paul Forgey18 Sep 2003 11:17 
Wallace, Richard19 Sep 2003 13:43 
Paul Forgey19 Sep 2003 14:53 
Wallace, Richard19 Sep 2003 15:13 
Paul Forgey19 Sep 2003 15:30 
Wallace, Richard19 Sep 2003 16:01 
Ingo Weinhold20 Sep 2003 02:56 
Subject:[jamming] Automatic inclusion of source files
From:Alen Ladavac (al@croteam.com)
Date:09/14/2003 04:30:53 AM
List:com.perforce.jamming

I don't understand how could include dependencies between .cpp files be
determined automatically? You don't #include .cpp files, do you?

We also build for multiple platforms here, but we solve that problem in a
specific way (we used that even before Jam, to improve readability and keep our sanity :)). We put all
platform-specific parts of each library in subdirectory of a Sys subdir. Like SomeLibrary/Sys/Win32,
SomeLibrary/Sys/XBox, SomeLibrary/Sys/SDL, etc. My original version of RGLOB has additional case in
ListDir to skip */Sys when searching directories. Then I can manually add needed per-platform subdirs,
like this:

FILES = [ RGLOB $(PRJDIR) : *.cpp *.c ] ;

if $(CONFIG) = Win32 { FILES += [ RGLOB $(PRJDIR)\\Sys\\Win32 : *.cpp ] ; } else # .... etc.

Main MyApp : $(FILES) ;

Cheers, Alen

----- Original Message ----- From: "Peter Björklund" <pi@hotmail.com> To: "Alen Ladavac" <al@croteam.com>; <jamm@perforce.com> Sent: Sunday, September 14, 2003 9:11 AM Subject: Re: [jamming] Automatic inclusion of source files

Thanks Alen!

Your code solved most of my jam problems!

However, I have a couple óf libraries (again with several hundred source files in subdirectories) that doesn't come with any jam or make files. The problem with those are that they are muilti platform (e.g. GameCube, Playstation, Palm, MacOS etc) and those obviously fails to compile on the "wrong" platform.

So therefore I am interested in only having those .cpp files that have been determined that there is an include dependency with. Jam must be able to correctly parse "#ifdef" and "#if defined(xxx)" macro statements.

The solution for me now is that everytime I get a new version of the library sources, I delete the directories and source files that contain code for the "wrong" platform. This is *very* time consuming.

Maybe there is a program which can correctly parse the dependencies and then feed that list to jam?

Any help would be much appreciated!

Best regards, Peter Bjorklund

----- Original Message ----- From: "Alen Ladavac" <al@croteam.com> To: "Peter Björklund" <pi@hotmail.com> Sent: Sunday, September 14, 2003 12:13 PM Subject: Re: [jamming] Automatic inclusion of source files

Hi,

Interesting enough, I just solved that exact problem two days ago. :)

Anyway....

1) Using GLOB builtin rule you can add files in one directory. Something like this:

Main MyApp : [ GLOB . : *.cpp ] ;

(That is grossly simplified, you'd probably want to use "$(SUBDIR)" instead of "." etc, but you get the point.)

2) But, GLOB doesn't handle subdirectories. So I wrote my custom rule RGLOB. A simplified version is pasted below. You can use it instead of GLOB.

Note that in this way you will get relative paths to sources as that relative path will be inside the names of target so if you are writing some more complex rules and actions, take that in account. I arrange it all so that all paths for files in all projects are always relative to one base path for the entire workspace. This saves you the problems with header files with same base name from different directories causing problems with dependency searching.

I hope this helps.

Note that I am new to Jam, so if anybody more proficient can check out the code below and see if there are some errors (it works for me, but you never know), or if there is possibility for optimization (although it works pretty fast with a relatively large-ish tree I have here), please do let me know. I'd especially like to know how would you people handle the inverse cases in the switch statement.

Oh, and yes, I used some Win32-isms here. You might want to use $(DOT) and $(SLASH) instead of "." and "\\" in the code.

Cheers, Alen

--------- Code --------

# list all files in a directory, except ., .. # [ ListDir dirname ] rule ListDir {

# start with empty list local _result = ;

# for each file in the directory local _dirlist = [ GLOB $(1) : * ] ; for _subdir in $(_dirlist) {

# if it is not . or .. switch $(_subdir) { case *\\. : _dummy = "" ; # is there some no-op statement? case *\\.. : _dummy = "" ; # is there some no-op statement? case * : # add it to the list _result += $(_subdir) ; } }

# return resulting list return $(_result) ; }

# same as glob, but recurses into subdirs rule RGLOB {

# initially use the files in the current directory local _result = [ GLOB $(1) : $(2) ] ;

# list all subdirectories (and files, but it doesn't hurt) local _subdirlist = [ ListDir $(1) ] ;

# for each subdir/file for _subdir in $(_subdirlist) { # recurse into it _result += [ RGLOB $(_subdir) : $(2) ] ; }

# return the resulting list return $(_result) ; }

-------------

----- Original Message ----- From: "Peter Björklund" <pi@hotmail.com> To: <jamm@perforce.com> Sent: Saturday, September 13, 2003 10:40 PM Subject: [jamming] Automatic inclusion of source files

Hi!

Since Jam automatically parses the dependencies of the header files, how can I get it to automatically include add the source files as dependencies? I have a lot of source files (several hundred) in sub directories. Now, I obviously don't want to add them all in my jamfile. How can I tell Jam to do it for me?

Best regards, Peter Bjorklund