Index: config_office/set_soenv.in =================================================================== RCS file: /cvs/tools/config_office/set_soenv.in,v retrieving revision 1.88 diff -u -r1.88 set_soenv.in --- config_office/set_soenv.in 31 Jan 2006 18:28:58 -0000 1.88 +++ config_office/set_soenv.in 4 Feb 2006 23:27:57 -0000 @@ -23,7 +23,7 @@ # VI. Open the output file. # VII. Writing the data to the output file. # VIII. Closing output file. -# IX. Sourcing the output file. +# IX. Creating importenv.mk. # X. Set up the build environment. # XI. Moving the output file to the build home directory. # @@ -31,6 +31,7 @@ # use strict; # pragma use File::Basename; +use File::Path; # @@ -38,6 +39,15 @@ # IIa. Declaring variables for the system commands, etc. #-------------------------------------------------------- # + +# Used for the importenv.mk generation +my ( $importenvdir, $extraimportfile, $noimportfile); +my %no_import = (); +my @extra_import = (); +my @no_import = (); +my @env_import = (); +my @env_import_tmp = (); + my ( $outfile, $outfile_sh, $outfile_bat, $bootfile, $newline, $comment, $comment4nt, $compiler, $unsetenv, $setenv, $unset, $set, $ds, $ps, $cur_dir, $par_dir, $I, $L, $D, $buildenv, $answer, $tmp, $MINGW, $platform, $cygwinver, $empty, $no_ant, $no_stl, $no_gcc_include, @@ -1922,9 +1932,46 @@ } # #------------------------------ -# IX. Sourcing the output file. +# IX. Creating importenv.mk #------------------------------ # +$importenvdir = $SOLARVERSION.$ds.$INPATH.$INC; +$importenvdir =~ s/(\$\{?\w+\}?)/$1/eeg ; # expand the variables +$extraimportfile = $SOLARENV.$INC.$ds."dmakeextraimport.lst"; +$noimportfile = $SOLARENV.$INC.$ds."dmakenoimport.lst"; +print(":".$importenvdir.":\n"); +mkpath($importenvdir) unless -d $importenvdir; +open( IMPENVOUT, ">$importenvdir".$ds."importenv.mk" ) || + die "Cannot open $importenvdir".$ds."importenv.mk: $!\n"; + +print IMPENVOUT "# Generated import list of environment variables for dmake\n"; +print IMPENVOUT "# Do not edit!\n"; +print IMPENVOUT "#\n"; +print IMPENVOUT ".IMPORT .IGNORE :"; + +readVarList(\@extra_import, $extraimportfile); +readVarList(\@no_import, $noimportfile); +for (@no_import) { + $no_import{$_} = "1"; +} + +for my $ele (@env_import) { + unless( $no_import{$ele} ) { + push @env_import_tmp,$ele; + } +} +for my $ele (@extra_import) { + push @env_import_tmp,$ele; +} +@env_import = sort @env_import_tmp; +for (@env_import) { + print IMPENVOUT " ".$_; +} +print IMPENVOUT "\n"; + +close( IMPENVOUT ) || print "Can't close importenv.mk: $!"; + +# #--------------------------------- # X. Set up the build environment. #--------------------------------- @@ -2101,7 +2148,10 @@ #--------------------------------------------------------- sub ToFile { if ( $_[ 2 ] eq "e" ) - { # Write an environment variable to file. + { # Add variable to dmake import list + push @env_import, $_[ 0 ]; + + # Write an environment variable to file. if (defined $_[ 1 ] && $_[ 1 ] ne "" ) { printf("%-12s %-17s %-10s %s\n", "The variable", $_[ 0 ], "is set to:", $_[ 1 ]) ; # to stdout print OUT "$setenv $_[ 0 ] \"$_[ 1 ]\"$newline"; # to tcsh file @@ -2176,7 +2226,9 @@ print OUT_BAT "$_[ 0 ] $newline" if defined($outfile_bat); } elsif ( $_[ 2 ] eq "j" ) - { + { # Add variable to dmake import list + push @env_import, $_[ 0 ]; + if ((defined $_[ 1 ]) and ( $platform =~ m/cygwin/ )) { printf("%-12s %-17s %-10s %-39s\n", "The variable", $_[ 0 ], "is set to:", $_[ 1 ]) ; # to stdout $win_format_var = WinFormat( $_[ 1 ] ); #Filter for Windows @@ -2446,6 +2498,36 @@ $Warning = $Warning."* - set_soenv: warning: $arg1 $newline"; # add the warning } } + +#--------------------------------------------------------- +# Function name: readVarList +# Description: Read the variable names from a file into an array. +# Arguments: 1. Reference to the target array +# 2. File name +# Return value: void +#--------------------------------------------------------- +sub readVarList +{ + my $ArrayRef = shift; + my $FileName = shift; + my $FileContent; + if (open ($FileContent, $FileName)) { + while (<$FileContent>) { + my $line = $_; + my @vars; + chomp $line; + $line =~ s/#.+$//; + $line =~ s/^\s+//; + $line =~ s/\s+$//; + @vars = split(/\s+/, $line); + for (@vars) { + push @{$ArrayRef}, $_; + } + } + close ($FileContent); + } +} + #------------------- # That's all folks! #-------------------