From 4ae690e4eeb9297ed59ff932cc4184d23896234d Mon Sep 17 00:00:00 2001 From: Stephen Cprek Date: Mon, 27 Apr 2015 15:02:25 -0500 Subject: Generalize env vars, env setup, and copyright scripts Methods ported over from code in EKB. Change-Id: I26b6f2326314936b0316f64272230730ecd3f9ee RTC: 126634 Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/17465 Tested-by: Jenkins Server Tested-by: Jenkins OP Build CI Tested-by: Jenkins OP HW Tested-by: FSP CI Jenkins Reviewed-by: A. Patrick Williams III --- src/build/tools/addCopyright.pl | 79 ++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 45 deletions(-) (limited to 'src/build/tools/addCopyright.pl') diff --git a/src/build/tools/addCopyright.pl b/src/build/tools/addCopyright.pl index 604fa9807..c89ddbf5f 100755 --- a/src/build/tools/addCopyright.pl +++ b/src/build/tools/addCopyright.pl @@ -52,7 +52,6 @@ # and run the file to update all # ############################################################################### - use strict; use warnings; use POSIX; @@ -60,21 +59,35 @@ use Getopt::Long; use File::Basename; use lib dirname (__FILE__); - #------------------------------------------------------------------------------ # Project-specific settings. #------------------------------------------------------------------------------ my $ReleaseYear = `date +%Y`; chomp( $ReleaseYear ); - $ReleaseYear = $ENV{'DATE_OVERRIDE'} if defined $ENV{'DATE_OVERRIDE'}; my $copyrightSymbol = ""; # my $copyrightSymbol = "(C)"; # Uncomment if unable to use  character. -my $projectName = "HostBoot"; +# set by environment variable in project env.bash +my $projectName = $ENV{'PROJECT_NAME'}; my $copyrightStr = "Contributors Listed Below - COPYRIGHT"; +## note that these use single ticks so that the escape chars are NOT evaluated yet. +my $OLD_DELIMITER_END = 'IBM_PROLOG_END'; +my $DELIMITER_END = 'IBM_PROLOG_END_TAG'; +my $DELIMITER_BEGIN = 'IBM_PROLOG_BEGIN_TAG'; + +my $SOURCE_BEGIN_TAG = "\$Source:"; +my $SOURCE_END_TAG = "\$"; + +# Desired License, set by environment variable in project env.bash +my $LicenseFile = $ENV{'LICENSE'}; + +#------------------------------------------------------------------------------ +# Contributer info +#------------------------------------------------------------------------------ + # Constants for company's copyright # When adding a new company add constant here and to %fileContributorsCompany use constant IBM => 'International Business Machines Corp.'; @@ -88,16 +101,6 @@ my %fileContributorsCompany = ( "Google Shared Technology" => GOOGLE, ); -## note that these use single ticks so that the escape chars are NOT evaluated yet. -my $OLD_DELIMITER_END = 'IBM_PROLOG_END'; -my $DELIMITER_END = 'IBM_PROLOG_END_TAG'; -my $DELIMITER_BEGIN = 'IBM_PROLOG_BEGIN_TAG'; - -my $SOURCE_BEGIN_TAG = "\$Source:"; -my $SOURCE_END_TAG = "\$"; - -# End Project-specific settings - #------------------------------------------------------------------------------ # Constants #------------------------------------------------------------------------------ @@ -107,7 +110,7 @@ use constant RC_NO_COPYRIGHT_BLOCK => 3; use constant RC_INVALID_SOURCE_LINE => 4; use constant RC_INVALID_YEAR => 5; use constant RC_OLD_DELIMITER_END => 6; -use constant RC_NOT_HOSTBOOT_BLOCK => 7; +use constant RC_PROJECT_DOES_NOT_MATCH => 7; use constant RC_BAD_CONTRIBUTORS_BLOCK => 8; use constant RC_NO_COPYRIGHT_STRING => 9; use constant RC_INVALID_FILETYPE => 10; @@ -342,9 +345,6 @@ foreach ( @Files ) } # end foreach - - - if ( $opt_logfile ne "" ) { close( LOGFH ); @@ -648,11 +648,11 @@ sub checkCopyrightBlock( $$ ) return RC_NO_COPYRIGHT_STRING; } - ## Check to see if this is a HostBoot Copyright notice - if ( !( $block =~ m/OpenPOWER $projectName Project/ ) ) + ## Check to see if this matches the project it lives in + if ( !( $block =~ m/$projectName Project/ ) ) { - print STDOUT "WARNING: Not a $projectName copyright block\n"; - return RC_NOT_HOSTBOOT_BLOCK; + print STDOUT "WARNING: Copyright block does not reference project $projectName\n"; + return RC_PROJECT_DOES_NOT_MATCH; } ## split into lines and check for specific things @@ -1026,7 +1026,7 @@ sub addPrologComments($$$) # NOTE: CMVC prologs with inline comments will have a single trailing # space at the end of the line. This is undesirable for most - # hostboot developers so it will not be added. + # developers so it will not be added. if ( $line =~ m/$DELIMITER_BEGIN/ ) { @@ -1083,30 +1083,20 @@ sub fillinEmptyCopyrightBlock( $$ ) $copyright_Contributors .= "[+] ".$key."\n"; } + ## Get desired license + my $LicenseContent = ""; + open(LICENSE, "< $LicenseFile") or die " $? can't open $LicenseFile: $!" ; + while (my $line = ) + { + my $evalLine = eval "qq($line)"; + $LicenseContent .= $evalLine; + } + close(LICENSE); + ## define the final copyright block template here. my $IBMCopyrightBlock = <