5 my $output_format = 'u';
9 # it is believed that the registry moves keys around
10 # depending on OS version, this will de-mangle that
15 open ($fhandle, "/proc/registry/$key") || return;
16 # reg keys have 0x00 0x5c at the end
17 $value = (split /\0/, <$fhandle>)[0];
20 if ( defined $value ) {
23 # print "Value '$value' at '$key'\n";
31 # it is believed that the registry moves keys around
32 # depending on OS version, this will de-mangle that
35 $key = `cd /proc/registry/ ; ls $key`;
42 print "oowintool [option] ...\n";
43 print " encoding options\n";
44 print " -w - windows form\n";
45 print " -u - unix form (default)\n";
47 print " --msvc-ver - dump version of MSVC eg. 6.0\n";
48 print " --msvc-copy-dlls <dest> - copy msvc[pr]??.dlls into <dest>/msvcp??/\n";
49 print " --msvc-copy-instmsi <dest> - copy instmsia.exe, insmsiw.exe into <dest>\n";
50 print " --msvc-productdir - dump productdir\n";
51 print " --msvs-productdir - dump productdir\n";
52 print " --dotnetsdk-dir - dump .Net SDK path\n";
53 print " --csc-compilerdir - dump .Net SDK compiler path\n";
54 print " --psdk-home - dump psdk install dir\n";
55 print " --jdk-home - dump the jdk install dir\n";
56 print " --nsis-dir - dump NSIS path\n";
57 print " --help - this message\n";
62 my ($path, $input_format, $format) = @_;
64 return $path if ( ! defined $path );
65 # Strip trailing path separators
66 if ($input_format eq 'u') {
72 # 'Unterminated quoted string errors' from 'ash' when
73 # forking cygpath so - reimplement cygpath in perl [ gack ]
74 if ($format eq 'u' && $input_format eq 'w') {
76 $path =~ s
|([a
-zA
-Z
]):/|/cygdrive
/$1/|g
;
78 elsif ($format eq 'w' && $input_format eq 'u') {
79 $path =~ s
|/cygdrive/([a
-zA
-Z
])/|/$1/|g
;
88 my ($path, $unix) = @_;
90 $path = cygpath
($path, $unix, $output_format);
98 $value = reg_get_value
('HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v6.1/InstallationFolder');
101 $value = reg_get_value
('HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/CurrentInstallFolder');
105 $value = reg_get_value
('HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/MicrosoftSDK/Directories/Install Dir');
109 $key = reg_find_key
('HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/MicrosoftSDK/InstalledSDKs/*/Install Dir');
110 $value = reg_get_value
($key);
114 my $dir = cygpath
(find_msvc
()->{'product_dir'}, 'w', $output_format);
115 $value = `/bin/find "$dir" -iname platformsdk | head -n 1`;
118 defined $value || die "psdk not found";
120 print cygpath
($value, 'w', $output_format);
125 'key' => 'Microsoft/VisualStudio/9.0/Setup/VS/ProductDir',
126 'instmsi_path' => '?',
127 'dll_path' => 'VC/redist/x86/Microsoft.VC90.CRT',
132 'key' => 'Microsoft/VisualStudio/9.0/Setup/VC/ProductDir',
133 'instmsi_path' => '?',
134 'dll_path' => 'redist/x86/Microsoft.VC90.CRT',
137 my %msvs_express_2008 = (
139 'key' => 'Microsoft/VCExpress/9.0/Setup/VS/ProductDir',
140 'instmsi_path' => '?',
141 'dll_path' => 'VC/redist/x86/Microsoft.VC90.CRT',
144 my %msvc_express_2008 = (
146 'key' => 'Microsoft/VCExpress/9.0/Setup/VC/ProductDir',
147 'instmsi_path' => '?',
148 'dll_path' => 'redist/x86/Microsoft.VC90.CRT',
153 'key' => 'Microsoft/VisualStudio/10.0/Setup/VS/ProductDir',
154 'instmsi_path' => '?',
155 'dll_path' => 'VC/redist/x86/Microsoft.VC100.CRT',
156 'dll_suffix' => '100'
160 'key' => 'Microsoft/VisualStudio/10.0/Setup/VC/ProductDir',
161 'instmsi_path' => '?',
162 'dll_path' => 'redist/x86/Microsoft.VC100.CRT',
163 'dll_suffix' => '100'
168 my @ms_versions = ( \
%msvs_2008, \
%msvs_express_2008, \
%msvs_2010 );
170 for $ver (@ms_versions)
172 my $install = reg_get_value
("HKEY_LOCAL_MACHINE/SOFTWARE/" . $ver->{'key'});
173 if (defined $install && $install ne '') {
174 $ver->{'product_dir'} = $install;
178 die "Can't find MS Visual Studio / VC++";
183 my @ms_versions = ( \
%msvc_2008, \
%msvc_express_2008, \
%msvc_2010 );
185 for $ver (@ms_versions)
187 my $install = reg_get_value
("HKEY_LOCAL_MACHINE/SOFTWARE/" . $ver->{'key'});
188 if (defined $install && $install ne '') {
189 $ver->{'product_dir'} = $install;
193 die "Can't find MS Visual Studio / VC++";
198 my $ver = find_msvc
();
202 sub print_msvc_product_dir
()
204 my $ver = find_msvc
();
205 print cygpath
($ver->{'product_dir'}, 'w', $output_format);
208 sub print_msvs_productdir
()
210 my $ver = find_msvs
();
211 print cygpath
($ver->{'product_dir'}, 'w', $output_format);
214 sub print_csc_compiler_dir
()
216 my $dir = cygpath
(reg_get_value
("HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/.NETFramework/InstallRoot"), 'w', $output_format);
217 my $csc_exe = `/bin/find "$dir" -iname csc.exe | grep "v3\.5\." | head -n 1` ||
218 `/bin/find "$dir" -iname csc.exe | grep "v4\." | head -n 1` ||
219 `/bin/find "$dir" -iname csc.exe | grep "v2\." | head -n 1`;
220 print `dirname $csc_exe`;
223 sub print_dotnetsdk_dir
()
226 reg_get_value
("HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/.NETFramework/sdkInstallRootv1.1") ||
227 reg_get_value
("HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/.NETFramework/sdkInstallRootv2.0");
229 print cygpath
($dir, 'w', $output_format);
236 reg_get_value
("HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/Java\ Development\ Kit/1.5/JavaHome") ||
237 reg_get_value
("HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/Java\ Development\ Kit/1.6/JavaHome") ||
238 reg_get_value
("HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/Java\ Development\ Kit/1.4/JavaHome") ||
239 reg_get_value
("HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/Java\ Development\ Kit/1.3/JavaHome");
240 print cygpath
($dir, 'w', $output_format);
245 my $dir = reg_get_value
("HKEY_LOCAL_MACHINE/SOFTWARE/NSIS/@");
246 print cygpath
($dir, 'w', $output_format) if defined $dir;
251 my ($src, $fname, $dest) = @_;
253 -f
"$src/$fname" || die "can't find $src";
254 -d
$dest || die "no directory $dest";
256 print STDERR
"Copying $src/$fname to $dest\n";
257 copy
("$src/$fname", $dest) || die "copy failed: $!";
258 chmod (0755, "$dest/$fname") || die "failed to set dll executable: $!";
261 sub msvc_find_version
($)
263 my $checkpath = shift;
264 my $ver = find_msvc
();
265 my $srcdir = (cygpath
($ver->{'product_dir'}, 'w', 'u') . '/' .
267 -d
$srcdir && return $ver;
269 $srcdir = (cygpath
($ver->{'product_dir'}, 'w', 'u') . '/' .
271 -d
$srcdir && return $ver;
275 sub msvc_copy_dlls
($)
278 my $ver = msvc_find_version
('dll_path');
279 defined $ver || return;
280 my $srcdir = (cygpath
($ver->{'product_dir'}, 'w', 'u') . '/' .
283 copy_dll
($srcdir, "msvcp" . $ver->{'dll_suffix'} . ".dll",
284 $dest . $ver->{'dll_suffix'});
285 copy_dll
($srcdir, "msvcr" . $ver->{'dll_suffix'} . ".dll",
286 $dest . $ver->{'dll_suffix'});
287 if ($ver->{'dll_suffix'} == 90) {
288 copy_dll
($srcdir, "msvcm" . $ver->{'dll_suffix'} . ".dll",
289 $dest . $ver->{'dll_suffix'});
290 copy_dll
($srcdir, "Microsoft.VC90.CRT.manifest", $dest . $ver->{'dll_suffix'});
294 sub msvc_copy_instmsi
($)
297 my $ver = msvc_find_version
('instmsi_path');
298 defined $ver || return;
299 my $srcdir = (cygpath
($ver->{'product_dir'}, 'w', 'u') . '/' .
300 $ver->{'instmsi_path'});
302 copy_dll
($srcdir, "instmsia.exe",
304 copy_dll
($srcdir, "instmsiw.exe",
318 if ($opt eq '-w' || $opt eq '-u') {
319 $output_format = substr($opt, 1, 1);
321 push @commands, $opt;
326 $opt = shift @commands;
329 } elsif ($opt eq '--msvc-ver') {
331 } elsif ($opt eq '--msvc-copy-dlls') {
332 my $dest = shift @commands;
333 defined $dest || die "copy-dlls requires a destination directory";
334 msvc_copy_dlls
( $dest );
335 } elsif ($opt eq '--msvc-copy-instmsi') {
336 my $dest = shift @commands;
337 defined $dest || die "copy-instmsi requires a destination directory";
338 msvc_copy_instmsi
( $dest );
339 } elsif ($opt eq '--msvs-productdir') {
340 print_msvs_productdir
();
341 } elsif ($opt eq '--msvc-productdir') {
342 print_msvc_product_dir
();
343 } elsif ($opt eq '--dotnetsdk-dir') {
344 print_dotnetsdk_dir
();
345 } elsif ($opt eq '--csc-compilerdir') {
346 print_csc_compiler_dir
();
347 } elsif ($opt eq '--psdk-home') {
349 } elsif ($opt eq '--jdk-home') {
351 } elsif ($opt eq '--nsis-dir') {
353 } elsif ($opt eq '--help' || $opt eq '/?') {
356 print "Unknown option '$opt'\n";