1 package VC8WorkspaceCreator
;
3 # ************************************************************
4 # Description : A VC8 Workspace Creator
5 # Author : Johnny Willemsen
6 # Create Date : 4/21/2004
7 # ************************************************************
9 # ************************************************************
11 # ************************************************************
15 use VC8ProjectCreator
;
16 use VC71WorkspaceCreator
;
19 @ISA = qw(VC71WorkspaceCreator);
21 # ************************************************************
23 # ************************************************************
25 my %lang_map = (Creator
::cplusplus
=> 'Visual C#',
26 Creator
::csharp
=> 'Visual C#',
27 Creator
::vb
=> 'Visual Basic',
28 Creator
::java
=> 'Visual J#');
30 # ************************************************************
32 # ************************************************************
36 my $crlf = $self->crlf();
38 ## This identifies it as a Visual Studio 2005 file
40 'Microsoft Visual Studio Solution File, Format Version 9.00', $crlf;
42 ## Optionally print the workspace comment
43 $self->print_workspace_comment($fh,
44 '# Visual Studio 2005', $crlf,
47 '# This file was generated by MPC. Any changes made directly to', $crlf,
48 '# this file will be lost the next time it is generated.', $crlf,
50 '# MPC Command:', $crlf,
51 '# ', $self->create_command_line_string($0, @ARGV), $crlf);
55 my($self, $fh, $creator) = @_;
56 my $pjs = $self->get_project_info();
57 my @projects = $self->sort_dependencies($self->get_projects(), 0);
60 ## Store a map of the project name to project guid and whether or not
61 ## it is suitable to be referenced. Adding a reference to a
62 ## non-managed c++ library or a "utility" project causes a warning in
63 ## Visual Studio 2008 and higher.
64 foreach my $project (@projects) {
65 my($name, $deps, $guid, $lang, $custom_only, $nocross, $managed) = @
{$$pjs{$project}};
66 $gmap{$name} = [$guid, !$custom_only && ($managed ||
67 $lang ne Creator
::cplusplus
)];
70 ## Now go through the projects and check for the need to add external
72 foreach my $project (@projects) {
73 my $ph = new FileHandle
();
74 my $outdir = $self->get_outdir();
75 $outdir = $self->getcwd() if ($outdir eq '.');
76 if (open($ph, "$outdir/$project")) {
79 my $crlf = $self->crlf();
80 my $cwd = $self->getcwd();
81 my $lang = $$pjs{$project}->[3];
82 my $managed = $$pjs{$project}->[6];
85 ## This is a comment found in vc8.mpd if the project contains the
86 ## 'after' keyword setting and the 'add_references' template
88 if (/^(\s*)<!\-\-\s+MPC\s+ADD\s+DEPENDENCIES/) {
90 my $deps = $self->get_validated_ordering($project);
91 foreach my $dep (@
$deps) {
92 my $relative = $self->get_relative_dep_file($creator,
95 if (defined $relative) {
96 if ($lang eq Creator
::cplusplus
) {
97 ## If the current project is not managed, then we will
98 ## add references (although I doubt that will be useful).
99 ## If the current project is managed, then the reference
100 ## project must be managed or a non-c++ project.
101 if (!$managed || ($managed && $gmap{$dep}->[1])) {
102 ## See if the dependency has an associated attribute.
103 ## If it does, split it into name value pairs for use in
104 ## the resulting generated XML.
106 my $attr = $creator->get_dependency_attribute($dep);
108 foreach my $a (split(',', $attr)) {
109 my @nvp = split('=', $a);
110 $attr{lc($nvp[0])} = $nvp[1]if (defined $nvp[0] &&
115 push(@read, $spc . '<ProjectReference' . $crlf .
116 $spc . "\tReferencedProjectIdentifier=" .
117 "\"\{$gmap{$dep}->[0]\}\"$crlf" .
118 (defined $attr{'copylocal'} ?
$spc .
119 "\tCopyLocal=\"" . $attr{'copylocal'} . "\"$crlf" : '') .
120 $spc . "\tRelativePathToProject=\"$relative\"$crlf" .
121 $spc . '/>' . $crlf);
124 ## This is a non-c++ language. So, it should not reference
125 ## unmanaged c++ libraries. If it's a managed project or
126 ## it's not a c++ project, it's ok to add a reference.
127 elsif ($gmap{$dep}->[1]) {
128 push(@read, $spc . '<ProjectReference Include="' .
129 $relative . '">' . $crlf,
130 $spc . ' <Project>{' . $gmap{$dep}->[0] .
131 '}</Project>' . $crlf,
132 $spc . ' <Name>' . $dep . '</Name>' . $crlf,
133 $spc . '</ProjectReference>' . $crlf);
136 ## Indicate that we need to re-write the file
148 ## If we need to re-write the file, then do so
149 if ($write && open($ph, ">$outdir/$project")) {
150 foreach my $line (@read) {
160 my($self, $name, $proj, $lang) = @_;
162 ## For websites, the project needs to be the directory of the actual
163 ## project file with a trailing slash. The name needs a trailing slash
165 if ($lang eq Creator
::website
) {
166 $proj = $self->mpc_dirname($proj);
171 ## This always needs to be a path with the Windows style directory
177 sub get_short_config_name
{
178 #my($self, $cfg) = @_;
182 sub get_solution_config_section_name
{
184 return 'SolutionConfigurationPlatforms';
187 sub get_project_config_section_name
{
189 return 'ProjectConfigurationPlatforms';
192 sub print_additional_sections
{
194 my $crlf = $self->crlf();
196 print $fh "\tGlobalSection(SolutionProperties) = preSolution$crlf",
197 "\t\tHideSolutionNode = FALSE$crlf",
198 "\tEndGlobalSection$crlf";
201 sub allow_empty_dependencies
{
206 sub print_inner_project
{
207 my($self, $fh, $gen, $currguid, $deps, $name, $name_to_guid_map, $proj_language, $cfgs) = @_;
209 ## We need to perform a lot of work, but only for websites.
210 if ($proj_language eq Creator
::website
) {
211 my $crlf = $self->crlf();
212 my $directory = ($name eq '.\\' ?
213 $self->get_workspace_name() . '\\' : $name);
215 ## We need the directory name with no trailing back-slash for use
217 my $notrail = $directory;
220 # Print the website project.
221 print $fh "\tProjectSection(WebsiteProperties) = preProject", $crlf;
223 ## Print out the references
225 foreach my $dep (@
$deps) {
226 if (defined $$name_to_guid_map{$dep}) {
227 $references = "\t\t" .
228 'ProjectReferences = "' if (!defined $references);
229 $references .= "{$$name_to_guid_map{$dep}}|$dep;";
232 print $fh $references, '"', $crlf if (defined $references);
234 ## And now the configurations
236 foreach my $config (@
$cfgs) {
238 if (!$cfg_seen{$config}) {
239 print $fh "\t\t$config.AspNetCompiler.VirtualPath = \"/$notrail\"", $crlf,
240 "\t\t$config.AspNetCompiler.PhysicalPath = \"$directory\"", $crlf,
241 "\t\t$config.AspNetCompiler.TargetPath = \"PrecompiledWeb\\$directory\"", $crlf,
242 "\t\t$config.AspNetCompiler.Updateable = \"true\"", $crlf,
243 "\t\t$config.AspNetCompiler.ForceOverwrite = \"true\"", $crlf,
244 "\t\t$config.AspNetCompiler.FixedNames = \"true\"", $crlf,
245 "\t\t$config.AspNetCompiler.Debug = \"",
246 ($config =~ /debug/i ?
'True' : 'False'), "\"", $crlf;
247 $cfg_seen{$config} = 1;
250 print $fh "\t\tVWDPort = \"1573\"", $crlf,
251 "\t\tDefaultWebSiteLanguage = \"",
252 $lang_map{$self->get_language()}, "\"", $crlf,
253 "\tEndProjectSection", $crlf;
256 # We can ignore this project and pass it to the
257 # SUPER since it's not a website.
258 $self->SUPER::print_inner_project
($fh, $gen, $currguid, $deps,
259 $name, $name_to_guid_map);