Remo Dentato | 14 Oct 2008 15:39
Picon
Gravatar

inter directory dependencies (again)

I've just started using jam and I'm trying to set up a project where a
set of executables (stored in the directory "test") depend on a set of
libraries (that I will buld in the directory "src").

I've searched in the archive and I've found a similar question but
I've not been able to follow all the advices given there (create a
custom Jambase, for example).

What I want to do is that each time I compile one of the programs in
"test", the libraries will be rebuilt (if they need to).

So far I created a Jamfile in the root directory that includes the
Jamfiles in the subdirectory so I can build everything correctly from
scratch but I would like to recompile the programs from within their
directory.

Is there any example of how to achive it, that I can look at?
_______________________________________________
jamming mailing list  -  jamming <at> perforce.com
http://maillist.perforce.com/mailman/listinfo/jamming

Craig Allsop | 15 Oct 2008 03:14
Picon

Re: inter directory dependencies (again)

Hi.

Each directory should have it's own jamfile and begin with SubDir, so
for your exe jamfiles place at the bottom a SubIncludeOnce to your
libraries. E.g.

/lib/abc/jamfile:
SubDir TOP lib abc ;
Main abc : $(sources) ;

/exe/prog1/jamfile:
SubDir TOP exe prog1 ;
Main prog1 : $(sources) ;
LinkLibraries prog1 : abc ;
SubIncludeOnce TOP lib abc ;

You should be able to sit in prog1 and build prog1. There is a one
small issue and that is the Win32 lib tool puts paths on your objs so
if you start getting duplicate symbols (from the same objs added from
different directories) when linking for this to work you will need to
fix the Archive actions and make it work from any directory. I think I
posted a solution for this already?

Craig.

If you don't already have this... you can either use it like:
SubIncludeOnce TOP lib : lib1 lib2 lib3 ; or
SubIncludeOnce TOP lib lib1 ;

rule SubIncludeOnce basename : dirlist
(Continue reading)

Craig Allsop | 15 Oct 2008 07:18
Picon

Re: inter directory dependencies (again)

Hi.

Sorry, I missed SubDirName rule: Here is the full example, with a fix
for Archive to make it work from any directory - however it assumes
your LOCATE_TARGET is the same for lib & obj files. If you want to
locate all temp objects in a directory off the root then I suggest
putting the library name in the path so same filenames don't conflict.
e.g. LOCATE_TARGET = [ FDirName $(TOP) obj $(SUBDIR) ] ;

---- /jamrules ---

SPACE = " " ;
MSVCNT = \"$(MSVCNT:J=$(SPACE))\" ;
STDHDRS	= $(MSVCNT)\\include ;
LINKLIBS = $(MSVCNT)\\lib\\kernel32.lib ;

actions updated together piecemeal Archive
{
	cd $(<:P)
	if exist $(<:BS) set _$(<:B)_=$(<:BS)
	$(AR) /out:$(<:BS) %_$(<:B)_% $(>:BS)
}

rule SubDirName path
{
	local g = [ FGrist $(path) ] ;
	local dir = dir ;
	return $(dir:G=$(g)) ;
}

(Continue reading)

Craig Allsop | 16 Oct 2008 03:04
Picon

Re: inter directory dependencies (again)

Hi Remo,

On Wed, Oct 15, 2008 at 6:30 PM, Remo Dentato <rdentato <at> gmail.com> wrote:
> Hi Craig, many thanks!
>  Indeed you already posted an answer to this but I was not able to
> understand how it worked.
>
> This example, instead, it's much more clear to me, I still have to
> study it a little to understand it better but I think I got the
> general scheme.
>
> I will try to make it work for my projects, my current solution uses a
> shell script (or a dos batch) to move back to the top and execute jam
> from there. The net effect is the same but I would prefer a jam-only
> solution as yours.
>
> I have a question, though. At the end of the "program" jamfile:
>
>> --- /exe/prog/jamfile ---
>>
>> SubDir TOP exe prog1 ;
>>
>> Main prog1 : file1.c file2.c file3.c ;
>> LinkLibraries prog1 : abc ;
>>
>> SubIncludeOnce TOP lib abc ;
>
> the "library" jamfile is explicitly included. The SubIncludeOnce is
> there to ensure that everything works both when called from the top
> and from the subdirectory itself, correct?
(Continue reading)

Remo Dentato | 16 Oct 2008 12:19
Picon
Gravatar

Re: inter directory dependencies (again)

On Thu, Oct 16, 2008 at 3:04 AM, Craig Allsop <cjamallsop <at> gmail.com> wrote:
> Hi Remo,
> You don't want much eh? Alright, put your seat belt on...
> [ ... lot of stuff that I'll study carefully ... ]
> That should keep you going for a while...

Many thanks Craig! I will look at the code carefully to understand how it works.

> Jam rocks... but only jam people know this.

I'll try to spread the word as much as I can!

Remo
_______________________________________________
jamming mailing list  -  jamming <at> perforce.com
http://maillist.perforce.com/mailman/listinfo/jamming

Kaspar Schleiser | 30 Oct 2008 16:19
Picon

how to just link objects from subdirectories

Hey,

I'm trying to build an embedded system's firmware which spans multiple 
directories:

root/Jamfile:
---------------
SubDir TOP ;

MainFromObjects arm.bin : $(ALL_OBJECTS) ;

core/Jamfile:
---------------
SubDir TOP core ;

Objects test.c xxx.c ;

I arm.bin to include all .o's from all the subdirectories. How do I do that?

Cheers,
Kaspar
_______________________________________________
jamming mailing list  -  jamming <at> perforce.com
http://maillist.perforce.com/mailman/listinfo/jamming

Kaspar Schleiser | 30 Oct 2008 16:27
Picon

Re: how to just link objects from subdirectories

Hello all,

sorry I made a few mistakes:

Kaspar Schleiser wrote:
> Hey,
> 
> I'm trying to build an embedded system's firmware which spans multiple 
> directories:
> 
> root/Jamfile:
> ---------------
> SubDir TOP ;
> 
> MainFromObjects arm.bin : $(ALL_OBJECTS) ;
SubInclude TOP core ;

> 
> 
> core/Jamfile:
> ---------------
> SubDir TOP core ;
> 
> Objects test.c xxx.c ;
> 
> 
> I arm.bin to include all .o's from all the subdirectories. How do I do that?
That should say "I want arm.bin to ..."

Thanks,
(Continue reading)

Craig Allsop | 31 Oct 2008 00:57
Picon

Re: how to just link objects from subdirectories

Hi Kaspar,

Normally, you would make each a subdirectory a Library but if you
already have .o files but no source, then you could still make
LibraryFromObjects for each subdirectory, OR if you don't want to
build libraries and link everything I suggest you make a rule to
'visit' each subdirectory in the root jamfile...

rule Gather dir
{
  SubDir TOP $(dir) ;
  local files = [ Glob $(SUBDIR) : *.o ] ;
  files = [ FGristFiles $(files:BS) ] ;
  SEARCH on $(files) = $(SEARCH_SOURCE) ;
  OBJS += files ;
}

In the root:

Gather core ;
Gather core part1 ;
Gather core part2 ;
SubDir TOP root ; # required for next line
MainFromObjects arm : $(OBJS) ;

If want to automatically scan all the directories, then just call
Gather inside a loop:

# for ignoring files that look like directories...
FOREACH_IGNORE = . .. jamfile jamrules ;
(Continue reading)


Gmane