xref: /aoo42x/main/oowintool (revision adb6f5d8)
1a7e2c521SPedro Giffuni#!/usr/bin/perl -w
2b31e36b3SAndrew Rist# *************************************************************
3b31e36b3SAndrew Rist#
4b31e36b3SAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
5b31e36b3SAndrew Rist#  or more contributor license agreements.  See the NOTICE file
6b31e36b3SAndrew Rist#  distributed with this work for additional information
7b31e36b3SAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
8b31e36b3SAndrew Rist#  to you under the Apache License, Version 2.0 (the
9b31e36b3SAndrew Rist#  "License"); you may not use this file except in compliance
10b31e36b3SAndrew Rist#  with the License.  You may obtain a copy of the License at
11b31e36b3SAndrew Rist#
12b31e36b3SAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
13b31e36b3SAndrew Rist#
14b31e36b3SAndrew Rist#  Unless required by applicable law or agreed to in writing,
15b31e36b3SAndrew Rist#  software distributed under the License is distributed on an
16b31e36b3SAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17b31e36b3SAndrew Rist#  KIND, either express or implied.  See the License for the
18b31e36b3SAndrew Rist#  specific language governing permissions and limitations
19b31e36b3SAndrew Rist#  under the License.
20b31e36b3SAndrew Rist#
21b31e36b3SAndrew Rist# *************************************************************
22cdf0e10cSrcweir
23cdf0e10cSrcweiruse File::Copy;
24cdf0e10cSrcweir
25cdf0e10cSrcweirmy $output_format = 'u';
26cdf0e10cSrcweir
27cdf0e10cSrcweirsub reg_get_value($)
28cdf0e10cSrcweir{
29cdf0e10cSrcweir    # it is believed that the registry moves keys around
30cdf0e10cSrcweir    # depending on OS version, this will de-mangle that
31cdf0e10cSrcweir    my $key = shift;
32cdf0e10cSrcweir    my $fhandle;
33cdf0e10cSrcweir    my $value;
34cdf0e10cSrcweir
35cdf0e10cSrcweir    open ($fhandle, "/proc/registry/$key") || return;
36cdf0e10cSrcweir    # reg keys have 0x00 0x5c at the end
37cdf0e10cSrcweir    $value = (split /\0/, <$fhandle>)[0];
38cdf0e10cSrcweir    close ($fhandle);
39cdf0e10cSrcweir
40cdf0e10cSrcweir    if ( defined $value ) {
41cdf0e10cSrcweir        chomp ($value);
42cdf0e10cSrcweir        $value =~ s|\r\n||;
43cdf0e10cSrcweir#    print "Value '$value' at '$key'\n";
44cdf0e10cSrcweir    }
45cdf0e10cSrcweir
46cdf0e10cSrcweir    return $value;
47cdf0e10cSrcweir}
48cdf0e10cSrcweir
49cdf0e10cSrcweirsub reg_find_key($)
50cdf0e10cSrcweir{
51cdf0e10cSrcweir    # it is believed that the registry moves keys around
52cdf0e10cSrcweir    # depending on OS version, this will de-mangle that
53cdf0e10cSrcweir    my $key = shift;
54cdf0e10cSrcweir    $key =~ s| |\\ |;
55cdf0e10cSrcweir    $key = `cd /proc/registry/ ; ls $key`;
56cdf0e10cSrcweir
57cdf0e10cSrcweir    return $key;
58cdf0e10cSrcweir}
59cdf0e10cSrcweir
60cdf0e10cSrcweirsub print_syntax()
61cdf0e10cSrcweir{
62cdf0e10cSrcweir    print "oowintool [option] ...\n";
63cdf0e10cSrcweir    print " encoding options\n";
64cdf0e10cSrcweir    print "   -w   - windows form\n";
65cdf0e10cSrcweir    print "   -u   - unix form (default)\n";
66cdf0e10cSrcweir    print " commands:\n";
67cdf0e10cSrcweir    print "   --msvc-ver              - dump version of MSVC eg. 6.0\n";
68cdf0e10cSrcweir    print "   --msvc-copy-dlls <dest> - copy msvc[pr]??.dlls into <dest>/msvcp??/\n";
69cdf0e10cSrcweir    print "   --msvc-productdir       - dump productdir\n";
70cdf0e10cSrcweir    print "   --msvs-productdir       - dump productdir\n";
71cdf0e10cSrcweir    print "   --dotnetsdk-dir         - dump .Net SDK path\n";
72cdf0e10cSrcweir    print "   --csc-compilerdir       - dump .Net SDK compiler path\n";
73cdf0e10cSrcweir    print "   --psdk-home             - dump psdk install dir\n";
74cdf0e10cSrcweir    print "   --jdk-home              - dump the jdk install dir\n";
75cdf0e10cSrcweir    print "   --nsis-dir              - dump NSIS path\n";
76cdf0e10cSrcweir    print "   --help                  - this message\n";
77cdf0e10cSrcweir}
78cdf0e10cSrcweir
79cdf0e10cSrcweirsub cygpath($$$)
80cdf0e10cSrcweir{
81cdf0e10cSrcweir    my ($path, $input_format, $format) = @_;
82cdf0e10cSrcweir
83cdf0e10cSrcweir    return $path if ( ! defined $path );
84cdf0e10cSrcweir    # Strip trailing path separators
85cdf0e10cSrcweir    if ($input_format eq 'u') {
86cdf0e10cSrcweir	$path =~ s|/*\s*$||;
87cdf0e10cSrcweir    } else {
88cdf0e10cSrcweir	$path =~ s|\\*\s*$||;
89cdf0e10cSrcweir    }
90cdf0e10cSrcweir
91cdf0e10cSrcweir    # 'Unterminated quoted string errors' from 'ash' when
92cdf0e10cSrcweir    # forking cygpath  so - reimplement cygpath in perl [ gack ]
93cdf0e10cSrcweir    if ($format eq 'u' && $input_format eq 'w') {
94cdf0e10cSrcweir	$path =~ s|\\|/|g;
95cdf0e10cSrcweir	$path =~ s|([a-zA-Z]):/|/cygdrive/$1/|g;
96cdf0e10cSrcweir    }
97cdf0e10cSrcweir    elsif ($format eq 'w' && $input_format eq 'u') {
98cdf0e10cSrcweir	$path =~ s|/cygdrive/([a-zA-Z])/|/$1/|g;
99cdf0e10cSrcweir	$path =~ s|/|\\|g;
100cdf0e10cSrcweir    }
101cdf0e10cSrcweir
102cdf0e10cSrcweir    return $path;
103cdf0e10cSrcweir}
104cdf0e10cSrcweir
105cdf0e10cSrcweirsub print_path($$)
106cdf0e10cSrcweir{
107cdf0e10cSrcweir    my ($path, $unix) = @_;
108cdf0e10cSrcweir
109cdf0e10cSrcweir    $path = cygpath ($path, $unix, $output_format);
110cdf0e10cSrcweir
111cdf0e10cSrcweir    print $path;
112cdf0e10cSrcweir}
113cdf0e10cSrcweir
114cdf0e10cSrcweirsub print_psdk_home()
115cdf0e10cSrcweir{
116cdf0e10cSrcweir    my ($value, $key);
117cdf0e10cSrcweir    $value = reg_get_value ('HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v6.1/InstallationFolder');
118cdf0e10cSrcweir    if (!defined $value)
119cdf0e10cSrcweir    {
120cdf0e10cSrcweir        $value = reg_get_value ('HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/CurrentInstallFolder');
12101d9dfefSHerbert Dürr    }
122cdf0e10cSrcweir    if (!defined $value)
123cdf0e10cSrcweir    {
124cdf0e10cSrcweir	    $value = reg_get_value ('HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/MicrosoftSDK/Directories/Install Dir');
12501d9dfefSHerbert Dürr    }
126cdf0e10cSrcweir    if (!defined $value)
127cdf0e10cSrcweir    {
128cdf0e10cSrcweir	    $key = reg_find_key ('HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/MicrosoftSDK/InstalledSDKs/*/Install Dir');
129cdf0e10cSrcweir	    $value = reg_get_value ($key);
13001d9dfefSHerbert Dürr    }
131cdf0e10cSrcweir    if (!defined $value)
132cdf0e10cSrcweir    {
133cdf0e10cSrcweir        my $dir = cygpath (find_msvc()->{'product_dir'}, 'w', $output_format);
134cdf0e10cSrcweir		$value = `/bin/find "$dir" -iname platformsdk | head -n 1`;
135cdf0e10cSrcweir    }
136cdf0e10cSrcweir
137cdf0e10cSrcweir    defined $value || die "psdk not found";
138cdf0e10cSrcweir
139cdf0e10cSrcweir    print cygpath ($value, 'w', $output_format);
140cdf0e10cSrcweir}
141cdf0e10cSrcweir
142cdf0e10cSrcweirmy %msvc_net_2003 = (
143cdf0e10cSrcweir    'ver' => '7.1',
144cdf0e10cSrcweir    'key' => 'Microsoft/VisualStudio/7.1/Setup/VC/ProductDir',
145cdf0e10cSrcweir    'dll_path' => '../Visual Studio .NET Professional 2003 - English',
146cdf0e10cSrcweir    'dll_suffix' => '71'
147cdf0e10cSrcweir);
148cdf0e10cSrcweirmy %msvs_net_2003 = (
149cdf0e10cSrcweir    'ver' => '7.1',
150cdf0e10cSrcweir    'key' => 'Microsoft/VisualStudio/7.1/Setup/VS/ProductDir',
151cdf0e10cSrcweir    'dll_path' => 'Visual Studio .NET Professional 2003 - English',
152cdf0e10cSrcweir    'dll_suffix' => '71'
153cdf0e10cSrcweir);
154cdf0e10cSrcweirmy %msvs_net_2003_ea = (
155cdf0e10cSrcweir    'ver' => '7.1',
156cdf0e10cSrcweir    'key' => 'Microsoft/VisualStudio/7.1/Setup/VS/ProductDir',
157cdf0e10cSrcweir    'dll_path' => 'Visual Studio .NET Enterprise Architect 2003 - English', # testme ...
158cdf0e10cSrcweir    'dll_suffix' => '71'
159cdf0e10cSrcweir);
160cdf0e10cSrcweirmy %msvs_express_2005 = (
161cdf0e10cSrcweir    'ver' => '8.0',
162cdf0e10cSrcweir    'key' => 'Microsoft/VCExpress/8.0/Setup/VS/ProductDir',
163cdf0e10cSrcweir    'dll_path' => '../SDK/v2.0/Bin',
164cdf0e10cSrcweir    'dll_suffix' => '80'
165cdf0e10cSrcweir);
166cdf0e10cSrcweirmy %msvc_express_2005 = (
167cdf0e10cSrcweir    'ver' => '8.0',
168cdf0e10cSrcweir    'key' => 'Microsoft/VCExpress/8.0/Setup/VC/ProductDir',
169cdf0e10cSrcweir    'dll_path' => '../SDK/v2.0/Bin',
170cdf0e10cSrcweir    'dll_suffix' => '80'
171cdf0e10cSrcweir);
172cdf0e10cSrcweirmy %msvs_2005 = (
173cdf0e10cSrcweir    'ver' => '8.0',
174cdf0e10cSrcweir    'key' => 'Microsoft/VisualStudio/8.0/Setup/VS/ProductDir',
175cdf0e10cSrcweir    'dll_path' => 'Visual Studio .NET Professional 2005 - English',
176cdf0e10cSrcweir    'dll_suffix' => '80'
177cdf0e10cSrcweir);
178cdf0e10cSrcweirmy %msvc_2005 = (
179cdf0e10cSrcweir    'ver' => '8.0',
180cdf0e10cSrcweir    'key' => 'Microsoft/VisualStudio/8.0/Setup/VC/ProductDir',
181cdf0e10cSrcweir    'dll_path' => '../SDK/v2.0/Bin',
182cdf0e10cSrcweir    'dll_suffix' => '80'
183cdf0e10cSrcweir);
184cdf0e10cSrcweirmy %msvs_2008 = (
185cdf0e10cSrcweir    'ver' => '9.0',
186cdf0e10cSrcweir    'key' => 'Microsoft/VisualStudio/9.0/Setup/VS/ProductDir',
187cdf0e10cSrcweir    'dll_path' => 'VC/redist/x86/Microsoft.VC90.CRT',
188cdf0e10cSrcweir    'dll_suffix' => '90'
189cdf0e10cSrcweir);
190cdf0e10cSrcweirmy %msvc_2008 = (
191cdf0e10cSrcweir    'ver' => '9.0',
192cdf0e10cSrcweir    'key' => 'Microsoft/VisualStudio/9.0/Setup/VC/ProductDir',
193cdf0e10cSrcweir    'dll_path' => 'redist/x86/Microsoft.VC90.CRT',
194cdf0e10cSrcweir    'dll_suffix' => '90'
195cdf0e10cSrcweir);
196cdf0e10cSrcweirmy %msvs_express_2008 = (
197cdf0e10cSrcweir    'ver' => '9.0',
198cdf0e10cSrcweir    'key' => 'Microsoft/VCExpress/9.0/Setup/VS/ProductDir',
199cdf0e10cSrcweir    'dll_path' => 'VC/redist/x86/Microsoft.VC90.CRT',
200cdf0e10cSrcweir    'dll_suffix' => '90'
201cdf0e10cSrcweir);
202cdf0e10cSrcweirmy %msvc_express_2008 = (
203cdf0e10cSrcweir    'ver' => '9.0',
204cdf0e10cSrcweir    'key' => 'Microsoft/VCExpress/9.0/Setup/VC/ProductDir',
205cdf0e10cSrcweir    'dll_path' => 'redist/x86/Microsoft.VC90.CRT',
206cdf0e10cSrcweir    'dll_suffix' => '90'
207cdf0e10cSrcweir);
208cdf0e10cSrcweir
209cdf0e10cSrcweirsub find_msvs()
210cdf0e10cSrcweir{
211cdf0e10cSrcweir    my @ms_versions = ( \%msvs_2008, \%msvs_express_2008, \%msvs_2005, \%msvs_express_2005, \%msvs_net_2003_ea, \%msvs_net_2003 );
212cdf0e10cSrcweir
213cdf0e10cSrcweir    for $ver (@ms_versions)
214cdf0e10cSrcweir    {
215cdf0e10cSrcweir	my $install = reg_get_value ("HKEY_LOCAL_MACHINE/SOFTWARE/" . $ver->{'key'});
216cdf0e10cSrcweir	if (defined $install && $install ne '') {
217cdf0e10cSrcweir	    $ver->{'product_dir'} = $install;
218cdf0e10cSrcweir	    return $ver;
219cdf0e10cSrcweir	}
220*adb6f5d8SDamjan Jovanovic	$install = reg_get_value ("HKEY_LOCAL_MACHINE/SOFTWARE/Wow6432Node/" . $ver->{'key'});
221*adb6f5d8SDamjan Jovanovic	if (defined $install && $install ne '') {
222*adb6f5d8SDamjan Jovanovic	    $ver->{'product_dir'} = $install;
223*adb6f5d8SDamjan Jovanovic	    return $ver;
224*adb6f5d8SDamjan Jovanovic	}
225cdf0e10cSrcweir    }
226cdf0e10cSrcweir    die "Can't find MS Visual Studio / VC++";
227cdf0e10cSrcweir}
228cdf0e10cSrcweir
229cdf0e10cSrcweirsub find_msvc()
230cdf0e10cSrcweir{
231cdf0e10cSrcweir    my @ms_versions = ( \%msvc_2008, \%msvc_express_2008, \%msvc_2005, \%msvc_express_2005, \%msvc_net_2003 );
232cdf0e10cSrcweir
233cdf0e10cSrcweir    for $ver (@ms_versions)
234cdf0e10cSrcweir    {
235cdf0e10cSrcweir	my $install = reg_get_value ("HKEY_LOCAL_MACHINE/SOFTWARE/" . $ver->{'key'});
236cdf0e10cSrcweir	if (defined $install && $install ne '') {
237cdf0e10cSrcweir	    $ver->{'product_dir'} = $install;
238cdf0e10cSrcweir	    return $ver;
239cdf0e10cSrcweir	}
240*adb6f5d8SDamjan Jovanovic	$install = reg_get_value("HKEY_LOCAL_MACHINE/SOFTWARE/Wow6432Node/" . $ver->{'key'});
241*adb6f5d8SDamjan Jovanovic	if (defined $install && $install ne '') {
242*adb6f5d8SDamjan Jovanovic	    $ver->{'product_dir'} = $install;
243*adb6f5d8SDamjan Jovanovic	    return $ver;
244*adb6f5d8SDamjan Jovanovic	}
245cdf0e10cSrcweir    }
246cdf0e10cSrcweir    die "Can't find MS Visual Studio / VC++";
247cdf0e10cSrcweir}
248cdf0e10cSrcweir
249cdf0e10cSrcweirsub print_msvc_ver()
250cdf0e10cSrcweir{
251cdf0e10cSrcweir    my $ver = find_msvc();
252cdf0e10cSrcweir    print $ver->{'ver'};
253cdf0e10cSrcweir}
254cdf0e10cSrcweir
255cdf0e10cSrcweirsub print_msvc_product_dir()
256cdf0e10cSrcweir{
257cdf0e10cSrcweir    my $ver = find_msvc();
258cdf0e10cSrcweir    print cygpath ($ver->{'product_dir'}, 'w', $output_format);
259cdf0e10cSrcweir}
260cdf0e10cSrcweir
261cdf0e10cSrcweirsub print_msvs_productdir()
262cdf0e10cSrcweir{
263cdf0e10cSrcweir    my $ver = find_msvs();
264cdf0e10cSrcweir    print cygpath ($ver->{'product_dir'}, 'w', $output_format);
265cdf0e10cSrcweir}
266cdf0e10cSrcweir
267cdf0e10cSrcweirsub print_csc_compiler_dir()
268cdf0e10cSrcweir{
269cdf0e10cSrcweir    my $dir = cygpath (reg_get_value ("HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/.NETFramework/InstallRoot"), 'w', $output_format);
270cdf0e10cSrcweir    my $csc_exe = `/bin/find "$dir" -iname csc.exe | grep "v2\." | head -n 1`;
271cdf0e10cSrcweir    print `dirname $csc_exe`;
272cdf0e10cSrcweir}
273cdf0e10cSrcweir
274cdf0e10cSrcweirsub print_dotnetsdk_dir()
275cdf0e10cSrcweir{
276cdf0e10cSrcweir    my $dir =
277cdf0e10cSrcweir          reg_get_value ("HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/.NETFramework/sdkInstallRootv1.1") ||
278cdf0e10cSrcweir          reg_get_value ("HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/.NETFramework/sdkInstallRootv2.0");
279668ddc01SDamjan Jovanovic    defined $dir || exit 1;
280cdf0e10cSrcweir    print cygpath ($dir, 'w', $output_format);
281cdf0e10cSrcweir}
282cdf0e10cSrcweir
283cdf0e10cSrcweirsub print_jdk_dir()
284cdf0e10cSrcweir{
285cdf0e10cSrcweir    my $dir =
286668ddc01SDamjan Jovanovic	  reg_get_value ("HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/Java\ Development\ Kit/1.8/JavaHome") ||
28701d9dfefSHerbert Dürr	  reg_get_value ("HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/Java\ Development\ Kit/1.7/JavaHome") ||
28801d9dfefSHerbert Dürr	  reg_get_value ("HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/Java\ Development\ Kit/1.6/JavaHome") ||
289cdf0e10cSrcweir	  reg_get_value ("HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/Java\ Development\ Kit/1.5/JavaHome") ||
290cdf0e10cSrcweir	  reg_get_value ("HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/Java\ Development\ Kit/1.4/JavaHome") ||
291cdf0e10cSrcweir	  reg_get_value ("HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/Java\ Development\ Kit/1.3/JavaHome");
292668ddc01SDamjan Jovanovic    defined $dir || exit 1;
293cdf0e10cSrcweir    print cygpath($dir, 'w', $output_format);
294cdf0e10cSrcweir}
295cdf0e10cSrcweir
296cdf0e10cSrcweirsub print_nsis_dir()
297cdf0e10cSrcweir{
298cdf0e10cSrcweir    my $dir = reg_get_value ("HKEY_LOCAL_MACHINE/SOFTWARE/NSIS/@");
299cdf0e10cSrcweir    print cygpath ($dir, 'w', $output_format) if defined $dir;
300cdf0e10cSrcweir}
301cdf0e10cSrcweir
302cdf0e10cSrcweirsub copy_dll($$$)
303cdf0e10cSrcweir{
304cdf0e10cSrcweir    my ($src, $fname, $dest) = @_;
305cdf0e10cSrcweir
306cdf0e10cSrcweir    -f "$src/$fname" || die "can't find $src";
307cdf0e10cSrcweir    -d $dest || die "no directory $dest";
308cdf0e10cSrcweir
309cdf0e10cSrcweir	print STDERR "Copying $src/$fname to $dest\n";
310cdf0e10cSrcweir    copy ("$src/$fname", $dest) || die "copy failed: $!";
311cdf0e10cSrcweir    chmod (0755, "$dest/$fname") || die "failed to set dll executable: $!";
312cdf0e10cSrcweir}
313cdf0e10cSrcweir
314cdf0e10cSrcweirsub msvc_find_version($)
315cdf0e10cSrcweir{
316cdf0e10cSrcweir    my $checkpath = shift;
317cdf0e10cSrcweir    my $ver = find_msvc();
318cdf0e10cSrcweir    my $srcdir = (cygpath ($ver->{'product_dir'}, 'w', 'u') . '/' .
319cdf0e10cSrcweir		  $ver->{$checkpath});
320cdf0e10cSrcweir    -d $srcdir && return $ver;
321cdf0e10cSrcweir    $ver = find_msvs();
322cdf0e10cSrcweir    $srcdir = (cygpath ($ver->{'product_dir'}, 'w', 'u') . '/' .
323cdf0e10cSrcweir		  $ver->{$checkpath});
324cdf0e10cSrcweir    -d $srcdir && return $ver;
325cdf0e10cSrcweir    return undef;
326cdf0e10cSrcweir}
327cdf0e10cSrcweir
328cdf0e10cSrcweirsub msvc_copy_dlls($)
329cdf0e10cSrcweir{
330cdf0e10cSrcweir    my $dest = shift;
331cdf0e10cSrcweir    my $ver = msvc_find_version('dll_path');
332cdf0e10cSrcweir    defined $ver || return;
333cdf0e10cSrcweir    my $srcdir = (cygpath ($ver->{'product_dir'}, 'w', 'u') . '/' .
334cdf0e10cSrcweir		  $ver->{'dll_path'});
335cdf0e10cSrcweir
336cdf0e10cSrcweir    copy_dll ($srcdir, "msvcp" . $ver->{'dll_suffix'} . ".dll",
337cdf0e10cSrcweir	      $dest . $ver->{'dll_suffix'});
338cdf0e10cSrcweir    copy_dll ($srcdir, "msvcr" . $ver->{'dll_suffix'} . ".dll",
339cdf0e10cSrcweir	      $dest . $ver->{'dll_suffix'});
340cdf0e10cSrcweir    if ($ver->{'dll_suffix'} >= 90) {
341cdf0e10cSrcweir        copy_dll ($srcdir, "msvcm" . $ver->{'dll_suffix'} . ".dll",
342cdf0e10cSrcweir                  $dest . $ver->{'dll_suffix'});
343cdf0e10cSrcweir        copy_dll ($srcdir, "Microsoft.VC90.CRT.manifest", $dest . $ver->{'dll_suffix'});
344cdf0e10cSrcweir    }
345cdf0e10cSrcweir}
346cdf0e10cSrcweir
347cdf0e10cSrcweirif (!@ARGV) {
348cdf0e10cSrcweir    print_syntax();
349cdf0e10cSrcweir    exit 1;
350cdf0e10cSrcweir}
351cdf0e10cSrcweir
352cdf0e10cSrcweirmy @commands = ();
353cdf0e10cSrcweirmy $opt;
354cdf0e10cSrcweirwhile (@ARGV) {
355cdf0e10cSrcweir    $opt = shift @ARGV;
356cdf0e10cSrcweir
357cdf0e10cSrcweir    if ($opt eq '-w' || $opt eq '-u') {
358cdf0e10cSrcweir	$output_format = substr($opt, 1, 1);
359cdf0e10cSrcweir    } else {
360cdf0e10cSrcweir	push @commands, $opt;
361cdf0e10cSrcweir    }
362cdf0e10cSrcweir}
363cdf0e10cSrcweir
364cdf0e10cSrcweirwhile (@commands) {
365cdf0e10cSrcweir    $opt = shift @commands;
366cdf0e10cSrcweir
367cdf0e10cSrcweir    if (0) {
368cdf0e10cSrcweir    } elsif ($opt eq '--msvc-ver') {
369cdf0e10cSrcweir	print_msvc_ver();
370cdf0e10cSrcweir    } elsif ($opt eq '--msvc-copy-dlls') {
371cdf0e10cSrcweir	my $dest = shift @commands;
372cdf0e10cSrcweir	defined $dest || die "copy-dlls requires a destination directory";
373cdf0e10cSrcweir	msvc_copy_dlls( $dest );
374cdf0e10cSrcweir    } elsif ($opt eq '--msvs-productdir') {
375cdf0e10cSrcweir	print_msvs_productdir();
376cdf0e10cSrcweir    } elsif ($opt eq '--msvc-productdir') {
377cdf0e10cSrcweir	print_msvc_product_dir();
378cdf0e10cSrcweir    } elsif ($opt eq '--dotnetsdk-dir') {
379cdf0e10cSrcweir	print_dotnetsdk_dir();
380cdf0e10cSrcweir    } elsif ($opt eq '--csc-compilerdir') {
381cdf0e10cSrcweir	print_csc_compiler_dir();
382cdf0e10cSrcweir    } elsif ($opt eq '--psdk-home') {
383cdf0e10cSrcweir	print_psdk_home();
384cdf0e10cSrcweir    } elsif ($opt eq '--jdk-home') {
385cdf0e10cSrcweir	print_jdk_dir();
386cdf0e10cSrcweir    } elsif ($opt eq '--nsis-dir') {
387cdf0e10cSrcweir	print_nsis_dir();
388cdf0e10cSrcweir    } elsif ($opt eq '--help' || $opt eq '/?') {
389cdf0e10cSrcweir	print_syntax();
390cdf0e10cSrcweir    } else {
391cdf0e10cSrcweir	print "Unknown option '$opt'\n";
392cdf0e10cSrcweir	print_syntax();
393cdf0e10cSrcweir	exit 1;
394cdf0e10cSrcweir    }
395cdf0e10cSrcweir}
396cdf0e10cSrcweir
397