|
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 strict; |
|
31 use FindBin; |
|
32 |
|
33 my $SELF_NAME = "set-rvct"; |
|
34 |
|
35 my $self_path; |
|
36 |
|
37 BEGIN |
|
38 { |
|
39 $self_path = $FindBin::Bin; |
|
40 } |
|
41 |
|
42 use lib $self_path; |
|
43 |
|
44 use RVCT_ver2set; |
|
45 |
|
46 |
|
47 # Some internal helper functions. |
|
48 sub _usage_and_die(@); |
|
49 sub _err_and_die(@); |
|
50 sub _warning(@); |
|
51 sub _fixup_path($$); |
|
52 |
|
53 |
|
54 sub main(@) |
|
55 { |
|
56 my @available = RVCT_ver2set::get_versions(); |
|
57 |
|
58 _err_and_die("no RVCT versions found; check that ABLD_RVCT_INI is set.") |
|
59 unless(@available); |
|
60 |
|
61 my ($vers, @junk) = @_; |
|
62 |
|
63 _usage_and_die(@available) |
|
64 if ( !$vers || @junk || !RVCT_ver2set::compiler_exists($vers) ); |
|
65 |
|
66 if ($ENV{ABLD_PLAT_INI}) |
|
67 { |
|
68 _warning("ABLD_PLAT_INI is set; the build system might clobber your settings."); |
|
69 } |
|
70 |
|
71 my $path = _fixup_path( $ENV{PATH}, RVCT_ver2set::get_bin_path($vers) ); |
|
72 |
|
73 # Create the batch file. |
|
74 { |
|
75 my $fname = "..__.bat"; |
|
76 |
|
77 open (my $file, ">", $fname) |
|
78 or _err_and_die("couldn't create $fname."); |
|
79 |
|
80 print $file "set PATH=$path\n"; |
|
81 |
|
82 my ($n, $p); |
|
83 |
|
84 $n = RVCT_ver2set::get_bin_name($vers); |
|
85 $p = RVCT_ver2set::get_bin_path($vers); |
|
86 print $file "set $n=$p\n"; |
|
87 |
|
88 $n = RVCT_ver2set::get_inc_name($vers); |
|
89 $p = RVCT_ver2set::get_inc_path($vers); |
|
90 print $file "set $n=$p\n"; |
|
91 |
|
92 $n = RVCT_ver2set::get_lib_name($vers); |
|
93 $p = RVCT_ver2set::get_lib_path($vers); |
|
94 print $file "set $n=$p\n"; |
|
95 |
|
96 print $file "echo.\n"; |
|
97 print $file "armcc --vsn\n"; |
|
98 |
|
99 close $file or _err_and_die("couldn't close $fname."); |
|
100 } |
|
101 } |
|
102 |
|
103 sub _usage_and_die(@) |
|
104 { |
|
105 for (@_) |
|
106 { |
|
107 print STDERR " $SELF_NAME $_\n"; |
|
108 } |
|
109 |
|
110 exit 1; |
|
111 } |
|
112 |
|
113 sub _err_and_die(@) |
|
114 { |
|
115 print STDERR "error: @_\n"; |
|
116 exit 1; |
|
117 } |
|
118 |
|
119 sub _warning(@) |
|
120 { |
|
121 print STDERR "warning: @_\n"; |
|
122 } |
|
123 |
|
124 sub _fixup_path($$) |
|
125 { |
|
126 my @path = split(/;/, shift); |
|
127 my $bin = shift; |
|
128 |
|
129 my @result = (); |
|
130 |
|
131 foreach (@path) |
|
132 { |
|
133 push @result, ($_) unless ($_ eq $bin); |
|
134 } |
|
135 |
|
136 return join(";", $bin, @result); |
|
137 } |
|
138 |
|
139 |
|
140 main(@ARGV); |
|
141 |
|
142 |
|
143 |
|
144 __END__ |
|
145 :endofperl |
|
146 |
|
147 if "%errorlevel%" == "0" (if exist ..__.bat call ..__.bat & del ..__.bat) |
|
148 |
|
149 :: vim:ft=perl |
|
150 |