| PerlBuildSystem documentation | view source | Contained in the PerlBuildSystem distribution. |
PBS::SubpbsResult - Support for hierarchical projects
use PBS::SubpbsResult ;
my $subpbs_result = new PBS::SubpbsResult($file_name) ;
my @search_paths = @{ $subpbs_result->GetLibrarySearchPaths()} ;
Pbs strives to let you build hierarchical projects, this module simplifies the task of returning sub module information to the module parent. This module is amainly used in Builders.
This module lets you create files which hold the information. Below are two examples.
Say you have module A which has a link dependency on module B. Module B needs to be linked with and extra library. A and B are build in different project (a subpbs for B exists).
When linking your project, you need to know at the top level what B needs to be linked with. To avoid putting knowledge of B's dependencies in the build of A, we would like the link information to be returned in a generic way to A.
Module B build result, when invoked from A's build is a '.subpbs_result' file.
# make A depend on B's build result
AddRule 'module B', ['A.o' => 'some_A_file.o', 'B.subpbs_result'], \&Build_A ;
# Build B in a subpbs
AddSubpbRule('B.subpbs_result', 'somepbs_file.pl')
sub Build_A
{
use PBS::SubpbsResult ;
...
my @objects_to_link ;
my @libs ;
my @other_specific_information ;
my $very_special_information ;
for my $dependency (@dependencies)
{
if($dependency =~ /\.subpbs_result/)
{
my $subpbs_result = new PBS::SubpbsResult($dependency) ;
push @objects_to_link, GetObjects($subpbs_result) ;
push @libs, GetLibraries($subpbs_result) ;
push @other_specific_information = GetOtherSpecificInformation($subpbs_result) ;
$very_special_information = GetVerySpecialInformation($subpbs_result)[0] ;
}
}
...
}
# in somepbs_file.pl
my @libraries = ('some_lib', 'some_other_lib') ;
my @other_specific_information = ('specific1', 'specific2') ;
my $very_special_information = 1 ;
AddRule 'B.subpbs_result', ['B.subpbs_result' => 'b1.o', 'b2.o', 'C.subpbs_result'], \&BuildSubpbsResult ;
sub BuildSubpbsResult
{
...
use PBS::SubpbsResult ;
my $subpbs_result = new PBS::SubpbsResult() ;
for my $dependency (@dependencies)
{
if($dependency =~ /\.subpbs_result$/)
{
$subpbs_result->Append($dependency) ;
}
else
{
$subpbs_result->AddObjects({NAME =>$dependency, MD5 => $md5}) ;
}
}
$subpbs_result->AddLibraries(@libraries) ;
$subpbs_result->AddWithMd5('other_specific_information', @other_specific_information) ;
$subpbs_result->Add('very_special_information', $very_special_information) ;
$subpbs_result->Write($dependent) ;
}
We (Anders and I) had a project, which had a top-down hierarchy, though of building archives at all the sub levels and merge the archives while going up the levels. We soon find out that 'ar' didn't merge archives so we had to unpack the sub levels archives before archiving them again. That took very long time! We stopped using 'ar' and instead uses a pbs_result file where the archive was replaced with a list of file links.
Nothing.
Khemir Nadim ibn Hamouda. nadim@khemir.net
| PerlBuildSystem documentation | view source | Contained in the PerlBuildSystem distribution. |