sbsv1/abld/genutil/modload.pm
changeset 607 378360dbbdba
parent 599 fa7a3cc6effd
equal deleted inserted replaced
591:22486c9c7b15 607:378360dbbdba
       
     1 # Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 # All rights reserved.
       
     3 # This component and the accompanying materials are made available
       
     4 # under the terms of "Eclipse Public License v1.0"
       
     5 # which accompanies this distribution, and is available
       
     6 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 #
       
     8 # Initial Contributors:
       
     9 # Nokia Corporation - initial contribution.
       
    10 #
       
    11 # Contributors:
       
    12 #
       
    13 # Description:
       
    14 # Runtime module-loading routine for loading e32tools modules into 'main' module
       
    15 # 
       
    16 #
       
    17 
       
    18 
       
    19 package Modload;
       
    20 
       
    21 require Exporter;
       
    22 @ISA=qw(Exporter);
       
    23 
       
    24 @EXPORT=qw(
       
    25 	Load_SetVerbose
       
    26 	Load_SetModulePath
       
    27 	Load_ModuleL
       
    28 );
       
    29 
       
    30 
       
    31 use Pathutl;
       
    32 
       
    33 my %Mode=(
       
    34 	Verbose=>0
       
    35 );
       
    36 my $ModulePath;
       
    37 
       
    38 sub Load_SetVerbose () {
       
    39 	$Mode{Verbose}=1;
       
    40 }
       
    41 
       
    42 sub Load_SetModulePath ($) {
       
    43 	$ModulePath=$_[0];
       
    44 }
       
    45 
       
    46 sub Load_ModuleL (@) {
       
    47 # Loads a module into the 'main' package, including all the functions the module defines for export
       
    48 
       
    49 	my @ModBaseList=@_;
       
    50 	my $ModBase;
       
    51 	foreach $ModBase (@ModBaseList) {
       
    52 		$ModBase=uc $ModBase;
       
    53 		die "ERROR: Can't load \"$ModulePath$ModBase.PM\"\n" unless -e "$ModulePath$ModBase.PM";
       
    54 		if ($Mode{Verbose}) {
       
    55 			print "Loading Module: \"",$ModBase,".PM\"\n";
       
    56 		}
       
    57 		package main;
       
    58 		require $ModBase.".PM" or die "ERROR: Can't load function from \"$ModulePath$ModBase.PM\"\n";
       
    59 		my $Package=ucfirst lc $ModBase;
       
    60 		$Package->import;
       
    61 	}
       
    62 }
       
    63 
       
    64 1;