sbsv1/abld/e32util/set-rvct.bat
changeset 599 fa7a3cc6effd
equal deleted inserted replaced
596:9f25be3da657 599:fa7a3cc6effd
       
     1 @rem
       
     2 @rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 @rem All rights reserved.
       
     4 @rem This component and the accompanying materials are made available
       
     5 @rem under the terms of "Eclipse Public License v1.0"
       
     6 @rem which accompanies this distribution, and is available
       
     7 @rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 @rem
       
     9 @rem Initial Contributors:
       
    10 @rem Nokia Corporation - initial contribution.
       
    11 @rem
       
    12 @rem Contributors:
       
    13 @rem
       
    14 @rem Description:
       
    15 @rem
       
    16 @rem = '--*-Perl-*--
       
    17 @echo off
       
    18 if "%OS%" == "Windows_NT" goto WinNT
       
    19 perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
       
    20 goto endofperl
       
    21 :WinNT
       
    22 perl -x -S %0 %*
       
    23 if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl
       
    24 if %errorlevel% == 9009 echo You do not have Perl in your PATH.
       
    25 if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul
       
    26 goto endofperl
       
    27 @rem ';
       
    28 #!perl
       
    29 #line 15
       
    30 use FindBin;
       
    31 
       
    32 my $SELF_NAME = "set-rvct";
       
    33 
       
    34 my $self_path;
       
    35 
       
    36 BEGIN
       
    37 {
       
    38     $self_path = $FindBin::Bin;
       
    39 }
       
    40 
       
    41 use lib $self_path;
       
    42 
       
    43 use RVCT_ver2set;
       
    44 
       
    45 
       
    46 # Some internal helper functions.
       
    47 sub _usage_and_die(@);
       
    48 sub _err_and_die(@);
       
    49 sub _warning(@);
       
    50 sub _fixup_path($$);
       
    51 
       
    52 
       
    53 sub main(@)
       
    54 {
       
    55     my @available = RVCT_ver2set::get_versions();
       
    56 
       
    57     _err_and_die("no RVCT versions found; check that ABLD_RVCT_INI is set.")
       
    58         unless(@available);
       
    59 
       
    60     my ($vers, @junk) = @_;
       
    61 
       
    62     _usage_and_die(@available)
       
    63         if ( !$vers || @junk || !RVCT_ver2set::compiler_exists($vers) );
       
    64 
       
    65     if ($ENV{ABLD_PLAT_INI})
       
    66     {
       
    67         _warning("ABLD_PLAT_INI is set; the build system might clobber your settings.");
       
    68     }
       
    69 
       
    70     my $path = _fixup_path( $ENV{PATH}, RVCT_ver2set::get_bin_path($vers) );
       
    71 
       
    72     # Create the batch file.
       
    73     {
       
    74         my $fname = "..__.bat";
       
    75 
       
    76         open (my $file,  ">",  $fname)
       
    77             or _err_and_die("couldn't create $fname.");
       
    78 
       
    79         print $file "set PATH=$path\n";
       
    80 
       
    81         my ($n, $p);
       
    82 
       
    83         $n = RVCT_ver2set::get_bin_name($vers);
       
    84         $p = RVCT_ver2set::get_bin_path($vers);
       
    85         print $file "set $n=$p\n";
       
    86 
       
    87         $n = RVCT_ver2set::get_inc_name($vers);
       
    88         $p = RVCT_ver2set::get_inc_path($vers);
       
    89         print $file "set $n=$p\n";
       
    90 
       
    91         $n = RVCT_ver2set::get_lib_name($vers);
       
    92         $p = RVCT_ver2set::get_lib_path($vers);
       
    93         print $file "set $n=$p\n";
       
    94 
       
    95         print $file "echo.\n";
       
    96         print $file "armcc --vsn\n";
       
    97 
       
    98         close $file or _err_and_die("couldn't close $fname.");
       
    99     }
       
   100 }
       
   101 
       
   102 sub _usage_and_die(@)
       
   103 {
       
   104     for (@_)
       
   105     {
       
   106         print STDERR "    $SELF_NAME $_\n";
       
   107     }
       
   108 
       
   109     exit 1;
       
   110 }
       
   111 
       
   112 sub _err_and_die(@)
       
   113 {
       
   114     print STDERR "error: @_\n";
       
   115     exit 1;
       
   116 }
       
   117 
       
   118 sub _warning(@)
       
   119 {
       
   120     print STDERR "warning: @_\n";
       
   121 }
       
   122 
       
   123 sub _fixup_path($$)
       
   124 {
       
   125     my @path = split(/;/, shift);
       
   126     my $bin  = shift;
       
   127 
       
   128     my @result = ();
       
   129 
       
   130     foreach (@path)
       
   131     {
       
   132         push @result, ($_) unless ($_ eq $bin);
       
   133     }
       
   134 
       
   135     return join(";", $bin, @result);
       
   136 }
       
   137 
       
   138 
       
   139 main(@ARGV);
       
   140 
       
   141 
       
   142 
       
   143 __END__
       
   144 :endofperl
       
   145 
       
   146 if "%errorlevel%" == "0" (if exist ..__.bat call ..__.bat & del ..__.bat)
       
   147 
       
   148 :: vim:ft=perl
       
   149