1#!perl
2#
3# This script is only useful if your source is in a SVN working copy!
4#
5# Problem: whenever you add a new wxWidgets version and convert the VC6 projects,
6# they are converted to VC8 XML .vcproj . In the process, a new project GUID is created.
7# When you then open your solution, all GUIDs are updated.
8#
9# To avoid this:
10# 1) Open and close wx.dsw with VS9 to convert to wx.sln (VS10 can't open them)
11# 2) Open and close wx.sln, creating the .vcxproj
12# 3) Run this script. It will replace the new GUIDs in the wx vcxproj by the old ones from the aMule-MSVC10E-ExtLibs.sln .
13# 4) Now load aMule-MSVCE-ExtLibs.sln. It won't be changed anymore.
14#
15
16use strict;
17
18open(sln, 'aMule-MSVC10E-ExtLibs.sln') or die $!;
19#Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wxregex", "..\..\..\..\wxWidgets\build\msw\wx_wxregex.vcxproj", "{A960D0AD-C20E-4FD6-B477-6509232C7D94}"
20#    <ProjectGuid>{B499DD81-BCA2-42D8-986C-E0FBAAC25B13}</ProjectGuid>
21while (<sln>) {
22	if (/^Project.*, \"(.+)\", \"(.+)\"/) {
23		my ($path, $guid) = ($1, $2);
24		next unless $path =~ /\\wxWidgets/;
25		$path =~ s-\\-/-g;
26		print "fix $path\n";
27		open(prj, $path) or die "$path $!";
28		my @content = <prj>;
29		close prj;
30		foreach (@content) {
31			if (/<ProjectGuid>/) {
32				$_ = "    <ProjectGuid>$guid</ProjectGuid>\n";
33				print $_;
34				last;
35			}
36		}
37		open(prj, ">$path") or die;
38		print prj @content;
39		close prj;
40	}
41}
42