1 package Generators::Vcproj;
8 our(@ISA, @EXPORT, @EXPORT_OK, @AVAILABLE);
12 push @EXPORT_OK, qw(generate);
17 "{E07B9989-2BF7-4F21-8918-BE22BA467AC3}",
18 "{278FFB51-0296-4A44-A81A-22B87B7C3592}",
19 "{7346A2C4-F0FD-444F-9EBE-1AF23B2B5650}",
20 "{67F421AC-EB34-4D49-820B-3196807B423F}",
21 "{385DCFE1-CC8C-4211-A451-80FCFC31CA51}",
22 "{97CC46C5-D2CC-4D26-B634-E75792B79916}",
23 "{C7CE21FE-6EF8-4012-A5C7-A22BCEDFBA11}",
24 "{51575134-3FDF-42D1-BABD-3FB12669C6C9}",
25 "{0AE195E4-9823-4B87-8E6F-20C5614AF2FF}",
26 "{4B918255-67CA-43BB-A46C-26704B666E6B}",
27 "{18CCFEEF-C8EE-4CC1-A265-26F95C9F4649}",
28 "{5D5D90FA-01B7-4973-AFE5-CA88C53AC197}",
29 "{1F054320-036D-49E1-B384-FB5DF0BC8AC0}",
30 "{7CED65EE-F2D9-4171-825B-C7D561FE5786}",
31 "{8D341679-0F07-4664-9A56-3BA0DE88B9BC}",
32 "{C189FEDC-2957-4BD7-9FA4-7622241EA145}",
33 "{66844203-1B9F-4C53-9274-164FFF95B847}",
34 "{E4FEA145-DECC-440D-AEEA-598CF381FD43}",
35 "{73300A8E-C8AC-41B0-B555-4F596B681BA7}",
36 "{873FDEB1-D01D-40BF-A1BF-8BBC58EC0F51}",
37 "{7922C8BE-76C5-4AC6-8BF7-885C0F93B782}",
38 "{E245D370-308B-4A49-BFC1-1E527827975F}",
39 "{F6FA957B-66FC-4ED7-B260-E59BBE4FE813}",
40 "{E6055070-0198-431A-BC49-8DB6CEE770AE}",
41 "{54159234-C3EB-43DA-906B-CE5DA5C74654}",
42 "{594CFC35-0B60-46F6-B8EF-9983ACC1187D}",
43 "{D93FCAB7-1F01-48D2-B832-F761B83231A5}",
44 "{DBA5E6AC-E7BE-42D3-8703-4E787141526E}",
45 "{6171953F-DD26-44C7-A3BE-CC45F86FC11F}",
46 "{9E19DDBE-F5E4-4A26-A2FE-0616E04879B8}",
47 "{AE81A615-99E3-4885-9CE0-D9CAA193E867}",
48 "{FBF4067E-1855-4F6C-8BCD-4D62E801A04D}",
49 "{17007948-6593-4AEB-8106-F7884B4F2C19}",
50 "{199D4C8D-8639-4DA6-82EF-08668C35DEE0}",
51 "{E085E50E-C140-4CF3-BE4B-094B14F0DDD6}",
52 "{00785268-A9CC-4E40-AC29-BAC0019159CE}",
53 "{4C06F56A-DCDB-46A6-B67C-02339935CF12}",
54 "{3A62D3FD-519E-4EC9-8171-D2C1BFEA022F}",
55 "{3A62D3FD-519E-4EC9-8171-D2C1BFEA022F}",
56 "{9392EB58-D7BA-410B-B1F0-B2FAA6BC89A7}",
57 "{2ACAB2D5-E0CE-4027-BCA0-D78B2D7A6C66}",
58 "{86E216C3-43CE-481A-BCB2-BE5E62850635}",
59 "{FB631291-7923-4B91-9A57-7B18FDBB7A42}",
60 "{0A176EC9-E934-45B8-B87F-16C7F4C80039}",
61 "{DF55CA80-46E8-4C53-B65B-4990A23DD444}",
62 "{3A0F9895-55D2-4710-BE5E-AD7498B5BF44}",
63 "{294BDC5A-F448-48B6-8110-DD0A81820F8C}",
64 "{4B9F66E9-FAC9-47AB-B1EF-C16756FBFD06}",
65 "{72EA49C6-2806-48BD-B81B-D4905102E19C}",
66 "{5728EB7E-8929-486C-8CD5-3238D060E768}"
70 my ($git_dir, $out_dir, $rel_dir, %build_structure) = @_;
71 my @libs = @{$build_structure{"LIBS"}};
73 createLibProject($_, $git_dir, $out_dir, $rel_dir, \%build_structure);
76 my @apps = @{$build_structure{"APPS"}};
78 createAppProject($_, $git_dir, $out_dir, $rel_dir, \%build_structure);
81 createGlueProject($git_dir, $out_dir, $rel_dir, %build_structure);
85 sub createLibProject {
86 my ($libname, $git_dir, $out_dir, $rel_dir, $build_structure) = @_;
87 print "Generate $libname vcproj lib project\n";
88 $rel_dir = "..\\$rel_dir";
89 $rel_dir =~ s/\//\\/g;
91 my $target = $libname;
95 my $uuid = $GUIDS[$guid_index];
96 $$build_structure{"LIBS_${target}_GUID"} = $uuid;
99 my @srcs = sort(map("$rel_dir\\$_", @{$$build_structure{"LIBS_${libname}_SOURCES"}}));
105 my $defines = join(",", sort(@{$$build_structure{"LIBS_${libname}_DEFINES"}}));
106 my $includes= join(";", sort(map(""$rel_dir\\$_"", @{$$build_structure{"LIBS_${libname}_INCLUDES"}})));
107 my $cflags = join(" ", sort(@{$$build_structure{"LIBS_${libname}_CFLAGS"}}));
108 $cflags =~ s/\"/"/g;
110 my $cflags_debug = $cflags;
111 $cflags_debug =~ s/-MT/-MTd/;
112 $cflags_debug =~ s/-O.//;
114 my $cflags_release = $cflags;
115 $cflags_release =~ s/-MTd/-MT/;
117 my @tmp = @{$$build_structure{"LIBS_${libname}_LFLAGS"}};
122 $_ =~ s/^-L/-LIBPATH:$rel_dir\//;
126 my $lflags = join(" ", sort(@tmp));
129 $defines =~ s/\"/\\"/g;
131 $includes =~ s/-I//g;
132 mkdir "$target" || die "Could not create the directory $target for lib project!\n";
133 open F, ">$target/$target.vcproj" || die "Could not open $target/$target.pro for writing!\n";
135 <?xml version="1.0" encoding = "Windows-1252"?>
137 ProjectType="Visual C++"
150 OutputDirectory="$rel_dir"
151 ConfigurationType="4"
153 IntermediateDirectory="\$(ProjectDir)\$(ConfigurationName)"
156 Name="VCPreBuildEventTool"
159 Name="VCCustomBuildTool"
162 Name="VCXMLDataGeneratorTool"
165 Name="VCWebServiceProxyGeneratorTool"
171 Name="VCCLCompilerTool"
172 AdditionalOptions="$cflags_debug"
174 InlineFunctionExpansion="1"
175 AdditionalIncludeDirectories="$includes"
176 PreprocessorDefinitions="UNICODE,WIN32,_DEBUG,$defines"
177 MinimalRebuild="true"
179 UsePrecompiledHeader="0"
181 DebugInformationFormat="3"
184 Name="VCManagedResourceCompilerTool"
187 Name="VCResourceCompilerTool"
190 Name="VCPreLinkEventTool"
193 Name="VCLibrarianTool"
194 SuppressStartupBanner="true"
209 Name="VCPostBuildEventTool"
214 OutputDirectory="$rel_dir"
215 ConfigurationType="4"
217 WholeProgramOptimization="1"
218 IntermediateDirectory="\$(ProjectDir)\$(ConfigurationName)"
221 Name="VCPreBuildEventTool"
224 Name="VCCustomBuildTool"
227 Name="VCXMLDataGeneratorTool"
230 Name="VCWebServiceProxyGeneratorTool"
236 Name="VCCLCompilerTool"
237 AdditionalOptions="$cflags_release"
239 InlineFunctionExpansion="1"
240 EnableIntrinsicFunctions="true"
241 AdditionalIncludeDirectories="$includes"
242 PreprocessorDefinitions="UNICODE,WIN32,NDEBUG,$defines"
244 EnableFunctionLevelLinking="true"
245 UsePrecompiledHeader="0"
247 DebugInformationFormat="3"
250 Name="VCManagedResourceCompilerTool"
253 Name="VCResourceCompilerTool"
256 Name="VCPreLinkEventTool"
259 Name="VCLibrarianTool"
260 SuppressStartupBanner="true"
275 Name="VCPostBuildEventTool"
282 Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
283 UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
296 </VisualStudioProject>
301 sub createAppProject {
302 my ($appname, $git_dir, $out_dir, $rel_dir, $build_structure) = @_;
303 print "Generate $appname vcproj app project\n";
304 $rel_dir = "..\\$rel_dir";
305 $rel_dir =~ s/\//\\/g;
307 my $target = $appname;
309 $target =~ s/\.exe//;
311 my $uuid = $GUIDS[$guid_index];
312 $$build_structure{"APPS_${target}_GUID"} = $uuid;
315 my @srcs = sort(map("$rel_dir\\$_", @{$$build_structure{"APPS_${appname}_SOURCES"}}));
321 my $defines = join(",", sort(@{$$build_structure{"APPS_${appname}_DEFINES"}}));
322 my $includes= join(";", sort(map(""$rel_dir\\$_"", @{$$build_structure{"APPS_${appname}_INCLUDES"}})));
323 my $cflags = join(" ", sort(@{$$build_structure{"APPS_${appname}_CFLAGS"}}));
324 $cflags =~ s/\"/"/g;
326 my $cflags_debug = $cflags;
327 $cflags_debug =~ s/-MT/-MTd/;
328 $cflags_debug =~ s/-O.//;
330 my $cflags_release = $cflags;
331 $cflags_release =~ s/-MTd/-MT/;
334 foreach (sort(@{$$build_structure{"APPS_${appname}_LIBS"}})) {
338 my @tmp = @{$$build_structure{"APPS_${appname}_LFLAGS"}};
343 $_ =~ s/^-L/-LIBPATH:$rel_dir\//;
347 my $lflags = join(" ", sort(@tmp)) . " -LIBPATH:$rel_dir";
350 $defines =~ s/\"/\\"/g;
352 $defines =~ s/\\\\/\\/g;
353 $includes =~ s/-I//g;
354 mkdir "$target" || die "Could not create the directory $target for lib project!\n";
355 open F, ">$target/$target.vcproj" || die "Could not open $target/$target.pro for writing!\n";
357 <?xml version="1.0" encoding = "Windows-1252"?>
359 ProjectType="Visual C++"
372 OutputDirectory="$rel_dir"
373 ConfigurationType="1"
375 IntermediateDirectory="\$(ProjectDir)\$(ConfigurationName)"
378 Name="VCPreBuildEventTool"
381 Name="VCCustomBuildTool"
384 Name="VCXMLDataGeneratorTool"
387 Name="VCWebServiceProxyGeneratorTool"
393 Name="VCCLCompilerTool"
394 AdditionalOptions="$cflags_debug"
396 InlineFunctionExpansion="1"
397 AdditionalIncludeDirectories="$includes"
398 PreprocessorDefinitions="UNICODE,WIN32,_DEBUG,$defines"
399 MinimalRebuild="true"
401 UsePrecompiledHeader="0"
403 DebugInformationFormat="3"
406 Name="VCManagedResourceCompilerTool"
409 Name="VCResourceCompilerTool"
412 Name="VCPreLinkEventTool"
416 AdditionalDependencies="$libs"
417 AdditionalOptions="$lflags"
419 GenerateDebugInformation="true"
436 Name="VCPostBuildEventTool"
441 OutputDirectory="$rel_dir"
442 ConfigurationType="1"
444 WholeProgramOptimization="1"
445 IntermediateDirectory="\$(ProjectDir)\$(ConfigurationName)"
448 Name="VCPreBuildEventTool"
451 Name="VCCustomBuildTool"
454 Name="VCXMLDataGeneratorTool"
457 Name="VCWebServiceProxyGeneratorTool"
463 Name="VCCLCompilerTool"
464 AdditionalOptions="$cflags_release"
466 InlineFunctionExpansion="1"
467 EnableIntrinsicFunctions="true"
468 AdditionalIncludeDirectories="$includes"
469 PreprocessorDefinitions="UNICODE,WIN32,NDEBUG,$defines"
471 EnableFunctionLevelLinking="true"
472 UsePrecompiledHeader="0"
474 DebugInformationFormat="3"
477 Name="VCManagedResourceCompilerTool"
480 Name="VCResourceCompilerTool"
483 Name="VCPreLinkEventTool"
487 AdditionalDependencies="$libs"
488 AdditionalOptions="$lflags"
490 GenerateDebugInformation="true"
493 OptimizeReferences="2"
494 EnableCOMDATFolding="2"
509 Name="VCPostBuildEventTool"
516 Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
517 UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
530 </VisualStudioProject>
535 sub createGlueProject {
536 my ($git_dir, $out_dir, $rel_dir, %build_structure) = @_;
537 print "Generate solutions file\n";
538 $rel_dir = "..\\$rel_dir";
539 $rel_dir =~ s/\//\\/g;
540 my $SLN_HEAD = "Microsoft Visual Studio Solution File, Format Version 10.00\n";
541 my $SLN_PRE = "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = ";
542 my $SLN_POST = "\nEndProject\n";
544 my @libs = @{$build_structure{"LIBS"}};
553 my @apps = @{$build_structure{"APPS"}};
562 open F, ">git.sln" || die "Could not open git.sln for writing!\n";
566 my $uuid = $build_structure{"LIBS_${libname}_GUID"};
568 print F "\"${libname}\", \"${libname}\\${libname}.vcproj\", \"${uuid}\"";
573 my $uuid = $build_structure{"APPS_${appname}_GUID"};
575 print F "\"${appname}\", \"${appname}\\${appname}.vcproj\", \"${uuid}\"";
581 GlobalSection(SolutionConfiguration) = preSolution
582 ConfigName.0 = Debug|Win32
583 ConfigName.1 = Release|Win32
585 GlobalSection(ProjectDependencies) = postSolution
587 foreach (@{$build_structure{"APPS"}}) {
589 my $appname_clean = $_;
590 $appname_clean =~ s/\//_/g;
591 $appname_clean =~ s/\.exe//;
593 my $uuid = $build_structure{"APPS_${appname_clean}_GUID"};
595 foreach(@{$build_structure{"APPS_${appname}_LIBS"}}) {
597 $libname =~ s/\//_/g;
598 $libname =~ s/\.(a|lib)//;
599 my $libuuid = $build_structure{"LIBS_${libname}_GUID"};
600 if (defined $libuuid) {
601 print F "\t\t${uuid}.${dep_index} = ${libuuid}\n";
609 GlobalSection(ProjectConfiguration) = postSolution
613 my $uuid = $build_structure{"LIBS_${libname}_GUID"};
614 print F "\t\t${uuid}.Debug|Win32.ActiveCfg = Debug|Win32\n";
615 print F "\t\t${uuid}.Debug|Win32.Build.0 = Debug|Win32\n";
616 print F "\t\t${uuid}.Release|Win32.ActiveCfg = Release|Win32\n";
617 print F "\t\t${uuid}.Release|Win32.Build.0 = Release|Win32\n";
621 my $uuid = $build_structure{"APPS_${appname}_GUID"};
622 print F "\t\t${uuid}.Debug|Win32.ActiveCfg = Debug|Win32\n";
623 print F "\t\t${uuid}.Debug|Win32.Build.0 = Debug|Win32\n";
624 print F "\t\t${uuid}.Release|Win32.ActiveCfg = Release|Win32\n";
625 print F "\t\t${uuid}.Release|Win32.Build.0 = Release|Win32\n";
630 GlobalSection(ExtensibilityGlobals) = postSolution
632 GlobalSection(ExtensibilityAddIns) = postSolution