Changeset 69 in ProjectBuilder for devel/pb/lib


Ignore:
Timestamp:
Aug 31, 2007, 3:20:15 PM (17 years ago)
Author:
Bruno Cornec
Message:

Rework interfaces of pb_init, conf files content and management to ease usage

Location:
devel/pb/lib/ProjectBuilder
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/lib/ProjectBuilder/common.pm

    r68 r69  
    3232    $proj = $ENV{'PBPROJ'};
    3333}
     34
     35#
     36# We get the pbrc file for that project
     37# and use its content
     38#
     39$pbrc = pb_init("$ENV{'PBETC'}","pbrc");
     40
     41my %pbrc = %$pbrc;
     42if (not defined $proj) {
     43    # Take the first as the default project
     44    $proj = (keys %pbrc)[0];
     45    print $LOG "Using $proj as default project as none has been specified\n" if (($debug >= 0) and (defined $proj));
     46}
     47die "No project defined - use env var PBPROJ or -p proj" if (not (defined $proj));
     48
     49#
     50# Set delivery directory
     51#
     52my $topdir=basename($pbrc{$proj});
     53chdir $topdir || die "Unable to change directory to $topdir";
     54$ENV{'PBDESTDIR'}=$topdir."/delivery";
     55
    3456#
    3557# Use project configuration file if needed
    3658#
    3759if (not defined $ENV{'PBROOT'}) {
    38     pb_init("$ENV{'PBETC'}");
    39 
    40     if (not defined $proj) {
    41         # Take the first as the default project
    42         $proj = (keys %pbroot)[0];
    43     print $LOG "Using $proj as default project as none has been specified\n" if (($debug >= 0) and (defined $proj));
     60    if (-f $pbrc{$proj}) {
     61        $pbroot = pb_init($pbrc{$proj},"pbroot");
     62        # There is normaly only one line in it
     63        $ENV{'PBROOT'} = (values %$pbroot)[0] if (defined $pbroot);
     64        print $LOG "Using $ENV{'PBROOT'} as default pbroot from $pbrc{$proj}\n" if (($debug >= 0) and (defined $ENV{'PBROOT'}));
    4465    }
    45     die "No project defined - use env var PBPROJ or -p proj" if (not (defined $proj));
    46 
    47     $ENV{'PBROOT'} = $pbroot{$proj};
    48 } else {
    49     die "No project defined - use env var PBPROJ or -p proj" if (not (defined $proj));
     66    die "No pbroot defined - use env var PBROOT or -r pbroot " if (not defined $ENV{'PBROOT'});
    5067}
    5168
     
    101118
    102119#
    103 # Adapt to your needs
    104 # Set delivery directory
    105 # Removes all directory existing below as they are temp dir only
     120# Removes all directory existing below the delivery dir
     121# as they are temp dir only
    106122# Files stay and have to be cleaned up manually
    107123#
    108 chdir "$ENV{'PBROOT'}/..";
    109 my $path = `pwd`;
    110 chomp($path);
    111 $ENV{'PBDESTDIR'}=$path."/delivery";
    112124if (-d $ENV{'PBDESTDIR'}) {
    113125    opendir(DIR,$ENV{'PBDESTDIR'}) || die "Unable to open directory $ENV{'PBDESTDIR'}: $!";
  • devel/pb/lib/ProjectBuilder/pb.pm

    r50 r69  
    99use AppConfig qw(ARGCOUNT_HASH ARGCOUNT_ONE);
    1010use Data::Dumper;
    11 use vars qw (%pbroot);
    1211
    1312sub pb_init {
    1413
    1514my $conffile = shift;
     15my $param = shift;
    1616my $trace;
    1717
     
    3333                        });
    3434$config->file($conffile);
    35 my $ptr = $config->get("pbroot") || die "Unable to find pbroot in $conffile";
     35my $ptr = $config->get($param) || die "Unable to find $param in $conffile";
    3636print "DEBUG: pbroot: ".Dumper($ptr)."\n" if ($debug >= 1);
    37 %pbroot = %$ptr;
     37return($ptr);
    3838}
    3939
Note: See TracChangeset for help on using the changeset viewer.