1 package VC7WorkspaceCreator
;
3 # ************************************************************
4 # Description : A VC7 Workspace Creator
5 # Author : Chad Elliott
6 # Create Date : 5/14/2002
7 # ************************************************************
9 # ************************************************************
11 # ************************************************************
15 use VC7ProjectCreator
;
21 @ISA = qw(VCPropertyBase WinWorkspaceBase WorkspaceCreator);
23 # ************************************************************
25 # ************************************************************
27 ## NOTE: We call the constant as a function to support Perl 5.6.
28 my %guids = (Creator
::cplusplus
() => '8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942',
29 Creator
::csharp
() => 'FAE04EC0-301F-11D3-BF4B-00C04F79EFBC',
30 Creator
::java
() => 'E6FDF86B-F3D1-11D4-8576-0002A516ECE8',
31 Creator
::vb
() => 'F184B08F-C81C-45F6-A57F-5ABD9991F28F',
32 Creator
::website
() => 'E24C65DC-7377-472B-9ABA-BC803B73C61A',
35 # ************************************************************
37 # ************************************************************
45 sub workspace_file_extension
{
53 my $crlf = $self->crlf();
55 ## This identifies it as a Visual Studio file
56 print $fh 'Microsoft Visual Studio Solution File, Format Version 7.00', $crlf;
58 ## Optionally print the workspace comment
59 $self->print_workspace_comment($fh,
61 '# This file was generated by MPC. Any changes made directly to', $crlf,
62 '# this file will be lost the next time it is generated.', $crlf,
64 '# MPC Command:', $crlf,
65 '# ', $self->create_command_line_string($0, @ARGV), $crlf);
69 sub print_inner_project
{
76 #my $name_to_guid_map = shift;
77 #my $proj_language = shift;
84 my($self, $fh, $configs) = @_;
85 my $crlf = $self->crlf();
88 ## Print out the configurations for the solution
89 foreach my $key (sort keys %$configs) {
90 print $fh "\t\tConfigName.$count = $key$crlf";
96 sub print_dependencies
{
97 my($self, $fh, $gen, $list, $pjs) = @_;
98 my $crlf = $self->crlf();
100 ## I hate to add yet another loop through all the projects, but
101 ## we must have some way to map plain project names to guids.
102 my %name_to_guid_map;
103 foreach my $project (@
$list) {
104 my($name, $guid) = $gen->access_pi_values($pjs, $project,
105 ProjectCreator
::PROJECT_NAME
,
106 ProjectCreator
::PROJECT_GUID
);
107 $name_to_guid_map{$name} = $guid;
110 ## Project Dependencies
111 print $fh "\tGlobalSection(ProjectDependencies) = postSolution$crlf";
112 foreach my $project (@
$list) {
113 my($name, $project_guid) = $gen->access_pi_values(
115 ProjectCreator
::PROJECT_NAME
,
116 ProjectCreator
::PROJECT_GUID
);
117 my $deps = $self->get_validated_ordering($project);
118 if (defined $$deps[0]) {
120 foreach my $dep (@
$deps) {
121 my $guid = $name_to_guid_map{$dep};
123 print $fh "\t\t{$project_guid}.$i = {$guid}$crlf";
129 print $fh "\tEndGlobalSection$crlf";
134 my($self, $fh, $gen) = @_;
135 my $projects = $self->get_projects();
136 my $pjs = $self->get_project_info();
137 my @list = sort @
$projects;
138 my $crlf = $self->crlf();
140 ## I hate to add yet another loop through all the projects, but
141 ## we must have some way to map plain project names to guids.
142 my %name_to_guid_map;
143 foreach my $project (@list) {
144 my($name, $guid) = $gen->access_pi_values($pjs, $project,
145 ProjectCreator
::PROJECT_NAME
,
146 ProjectCreator
::PROJECT_GUID
);
147 $name_to_guid_map{$name} = $guid;
150 ## Project Information
151 foreach my $project (@list) {
152 my($pname, $guid, $language, @cfgs) =
153 $gen->access_pi_values($pjs, $project,
154 ProjectCreator
::PROJECT_NAME
,
155 ProjectCreator
::PROJECT_GUID
,
156 ProjectCreator
::LANGUAGE
,
157 ProjectCreator
::CONFIGURATIONS
);
158 my $pguid = $guids{$language};
159 my $deps = $self->get_validated_ordering($project);
160 my($name, $proj) = $self->adjust_names($pname, $project, $language);
161 print $fh "Project(\"{$pguid}\") = \"$name\", \"$proj\", \"{$guid}\"$crlf";
162 $self->print_inner_project($fh, $gen, $guid, $deps,
163 $name, \
%name_to_guid_map,
165 print $fh "EndProject$crlf";
168 ## This block creates the different possible configurations for this
170 print $fh "Global$crlf",
172 $self->get_solution_config_section_name(),
173 ") = preSolution$crlf";
175 foreach my $project (@list) {
176 my @cfgs = $gen->access_pi_values($pjs, $project,
177 ProjectCreator
::CONFIGURATIONS
);
178 foreach my $cfg (@cfgs) {
179 $configs{$self->get_short_config_name($cfg)} = $cfg;
182 $self->print_configs($fh, \
%configs);
183 print $fh "\tEndGlobalSection$crlf";
185 ## Print dependencies if there are any
186 $self->print_dependencies($fh, $gen, \
@list, $pjs);
188 ## Project Configuration Names
189 print $fh "\tGlobalSection(",
190 $self->get_project_config_section_name(),
191 ") = postSolution$crlf";
193 ## See if there is an 'Any CPU' or '.NET' configuration
195 foreach my $key (keys %configs) {
196 if (index($key, 'Any CPU') >= 0 || index($key, '.NET') >= 0) {
202 ## Go through each project and print out the settings per GUID
203 foreach my $project (@list) {
204 my($pguid, $custom_only, $nocross, @cfgs) =
205 $gen->access_pi_values($pjs, $project,
206 ProjectCreator
::PROJECT_GUID
,
207 ProjectCreator
::CUSTOM_ONLY
,
208 ProjectCreator
::NO_CROSS_COMPILE
,
209 ProjectCreator
::CONFIGURATIONS
);
210 my %all_configs = %configs;
211 foreach my $cfg (sort @cfgs) {
212 my $c = $self->get_short_config_name($cfg);
213 my $deployable = !$nocross && !$custom_only;
214 my $buildable = !$nocross;
216 ## I don't like this hard-coded configuration information.
218 if (index($cfg, 'Win32') >= 0 || index($cfg, 'x64') >= 0) {
223 if (defined $anycpu) {
224 ## There is a non-C++ project; there is no need to explicitly
225 ## enable building of the configurations for this project. So, we
226 ## get rid of the configuration settings from the copy of the
228 delete $all_configs{$c};
231 print $fh "\t\t{$pguid}.$c.ActiveCfg = $cfg$crlf";
232 print $fh "\t\t{$pguid}.$c.Build.0 = $cfg$crlf" if ($buildable);
233 print $fh "\t\t{$pguid}.$c.Deploy.0 = $cfg$crlf" if ($deployable);
237 ## If this is a mixed language workspace, we need to explicitly
238 ## enable the building of the non-C++ projects when any platform
239 ## other than Any CPU/.NET is selected.
240 if (defined $anycpu) {
242 foreach my $c (sort @cfgs) {
243 if ($c =~ /(.+\|)/) {
245 foreach my $remainder (sort keys %all_configs) {
246 if (index($remainder, $cfg) == 0) {
247 if (!$printed{$pguid.$remainder}) {
248 print $fh "\t\t{$pguid}.$remainder.ActiveCfg = $c$crlf",
249 "\t\t{$pguid}.$remainder.Build.0 = $c$crlf";
250 $printed{$pguid.$remainder} = 1;
255 print $fh "\t\t{$pguid}.$c.ActiveCfg = $c$crlf",
256 "\t\t{$pguid}.$c.Build.0 = $c$crlf";
260 ## Non-C++ projects have no configurations
261 if (!defined $cfgs[0]) {
262 foreach my $c (sort keys %configs) {
263 my $cfg = $c . '|.NET';
264 print $fh "\t\t{$pguid}.$c.ActiveCfg = $cfg$crlf",
265 "\t\t{$pguid}.$c.Build.0 = $cfg$crlf";
270 print $fh "\tEndGlobalSection$crlf";
272 $self->print_additional_sections($fh);
274 print $fh "EndGlobal$crlf";
279 my($self, $name, $proj, $lang) = @_;
285 sub get_short_config_name
{
286 my($self, $cfg) = @_;
292 sub get_solution_config_section_name
{
294 return 'SolutionConfiguration';
298 sub get_project_config_section_name
{
300 return 'ProjectConfiguration';
304 sub print_additional_sections
{
306 my $crlf = $self->crlf();
308 print $fh "\tGlobalSection(ExtensibilityGlobals) = postSolution$crlf",
309 "\tEndGlobalSection$crlf",
310 "\tGlobalSection(ExtensibilityAddIns) = postSolution$crlf",
311 "\tEndGlobalSection$crlf";