[jamming] How to search in directories
Alen Ladavac
alenl-ml at croteam.com
Mon May 22 03:43:49 PDT 2006
Hi Klaus,
In the "switch" part, add another case that skips ".svn". Just like it
does for "." and "..":
case */.svn : _dummy = "" ; # is there some no-op statement?
HTH,
Alen
Klaus wrote:
> Hello Alen,
> thanks for the Reply.
> I took the snippet and adapted the ListDir rule.
> Now the rules checks recursively in all subdirectories and returns all
> directories.
> But I've another problem:
> In the main directory there's a ".svn" folder with information for the
> Subversion control-system.
> How can I prevent the program to search recursively in this ".svn"-folder?
> Here's my code-snippet:
> rule ListDirs
> {
> local _result = ; # start with empty list
> local _subdir = ;
> local _dirlist = [ GLOB $(1) : * ] ; # for each file in the directory
> for _subdir in $(_dirlist)
> {
> switch $(_subdir) # store if it is not . or ..
> {
> case */. : _dummy = "" ; # is there some no-op statement?
> case */.. : _dummy = "" ; # is there some no-op statement?
> case * :
> {
> if $(_subdir:BS) != . && $(_subdir:BS) != .. && [ GLOB $(_subdir) : * ]
> {
> # add it to the list
> _result += $(_subdir) ;
> # recurse into it
> _result += [ ListDirs $(_subdir) ] ;
> }
> }
> }
> }
> return $(_result) ; # return resulting list
> }
> subdirs = [ ListDirs . ] ;
> ECHO "Subdirectories = " $(subdirs) ;
> for (_tempdir) in $(subdirs)
> {
> _matched = [ MATCH "[.][\][^.]" : $(_tempdir) ] ;
> ECHO "Match = " $(_matched) ;
> }
> ECHO "List:" $(list) ;
> Best Reagards,
> Winston
>>From: Alen Ladavac <alenl-ml at croteam.com>
>>Reply-To: Alen Ladavac <alenl-ml at croteam.com>
>>To: "Klaus Meier" <winstonkl at hotmail.com>
>>CC: jamming at perforce.com
>>Subject: Re: [jamming] How to search in directories
>>Date: Thu, 18 May 2006 17:08:41 +0200
>>
>>Hi Klaus,
>>
>>The GLOB rule will get you a list of all files (and subdirectories) in
>>a directory, but it will not recurse. So you have to write your
>>recursive function for this. For example you could glob for all lib_*
>>and exe_*, then glob within them.
>>
>>Below is an example RGLOB rule that finds all files with given
>>patterns in all subdirectories of the specified dir. It's a bit messy,
>>but you get the picture.
>>
>>HTH,
>>Alen
>>
>>--8<-------------------
>>
>># list all files in a directory, except ., .. and Sys
>># [ ListDir dirname skipdirs ]
>>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, except system specific
>>rule RGLOB {
>>
>> # initially use the files in the current directory
>> local _files = [ GLOB $(1) : $(2) ] ;
>>
>> # filter so that only real files are included (skip current dir, parent
>>dir and all other dirs)
>> local _f = ;
>> local _result = ;
>> for _f in $(_files) {
>> if $(_f:BS) != . && $(_f:BS) != .. && ! [ GLOB $(_f) : * ] {
>> _result += $(_f) ;
>> }
>> }
>>
>>
>> # 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) ;
>>}
>>
>>--8<-------------------
>>
>>
>>Klaus wrote:
>>
>> > Hello,
>>
>> > I new in workin with Jam and the Jamfiles.
>> > I've got project with the following subdirectories:
>> > \lib_1
>> > \lib_2
>> > \lib_3
>> > \exe_1
>> > \exe_2
>> > \exe_3
>>
>> > Inside each of these subdirectories ae two directories with a source and
>>a
>> > debug directory.
>> > How can I get a variable filled with a list of directories beginning
>>with
>> > lib and one variable with directories beginning with exe?
>> > So I want to compile the files inside each of these subdirectories.
>>
>> > Best regards,
>>
>> > Winston
>>
>> > _________________________________________________________________
>> > Sie suchen E-Mails, Dokumente oder Fotos? Die neue MSN Suche Toolbar mit
>> > Windows-Desktopsuche liefert in sekundenschnelle Ergebnisse. Jetzt neu!
>> > http://desktop.msn.de/ Jetzt gratis downloaden!
>> > _______________________________________________
>> > jamming mailing list - jamming at perforce.com
>> > http://maillist.perforce.com/mailman/listinfo/jamming
>>
>>
>>--
>>Alen
>>
> _________________________________________________________________
> Sie suchen E-Mails, Dokumente oder Fotos? Die neue MSN Suche Toolbar mit
> Windows-Desktopsuche liefert in sekundenschnelle Ergebnisse. Jetzt neu!
> http://desktop.msn.de/ Jetzt gratis downloaden!
> _______________________________________________
> jamming mailing list - jamming at perforce.com
> http://maillist.perforce.com/mailman/listinfo/jamming
--
Alen
More information about the jamming
mailing list