1 package WixWorkspaceCreator
;
3 # ************************************************************
4 # Description : A Wix Workspace creator
5 # Author : James H. Hill
6 # Create Date : 6/23/2009
7 # ************************************************************
9 # ************************************************************
11 # ************************************************************
14 use WixProjectCreator
;
20 @ISA = qw(WinWorkspaceBase WorkspaceCreator);
22 # ************************************************************
24 # ************************************************************
27 # ************************************************************
29 # ************************************************************
31 sub workspace_file_extension
{
35 sub workspace_file_name
{
37 return $self->get_modified_workspace_name($self->get_workspace_name(),
43 my $crlf = $self->crlf();
44 my $name = $self->get_workspace_name();
46 ## Begin the project definition for the workspace
47 print $fh '<?xml version="1.0" encoding="utf-8" standalone="yes"?>', $crlf,
53 my $crlf = $self->crlf();
56 # print the target for clean
57 foreach my $project ($self->sort_dependencies($self->get_projects(), 0)) {
58 print $fh " <?include $project ?>", $crlf;
65 $val =~ tr/ \t\/\\\-$()./_
/;
70 my($self, $fh, $gen) = @_;
71 my $info = $self->get_project_info();
72 my $crlf = $self->crlf();
74 # Create a component group consisting of all the projects.
77 ' <ComponentGroup Id="',
78 $self->get_workspace_name(), '">', $crlf;
80 foreach my $project ($self->sort_dependencies($self->get_projects(), 0)) {
81 print $fh ' <ComponentGroupRef Id="ComponentGroup.',
82 $$info{$project}->[ProjectCreator
::PROJECT_NAME
], '" />',
86 print $fh ' </ComponentGroup>', $crlf,
87 ' </Fragment>', $crlf;
93 # For every project marked with "make_group", create a ComponentGroup that references all dependencies
94 my %project_dependencies = ();
95 my $projects = $self->get_projects();
96 my @list = $self->sort_dependencies($projects, 0);
97 foreach my $project (@list) {
98 my $deps = $self->get_validated_ordering($project);
99 $project_dependencies{$project} = [ @
$deps ];
102 # for each project, find all dependencies
103 foreach my $project (keys %project_dependencies) {
104 # foreach my $cfg (@cfgs_main) -> <configuration|platform> could be <Debug|AnyCPU Release|AnyCPU> or <Debug|Win32 Release|Win32 Debug|x64 Release|x64>
105 my($pname_main, $make_group_main, @cfgs_main) =
106 $gen->access_pi_values($info, $project,
107 ProjectCreator
::PROJECT_NAME
,
108 ProjectCreator
::MAKE_GROUP
,
109 ProjectCreator
::CONFIGURATIONS
);
110 # only generate a group if "make_group = 1"
111 if ($make_group_main) {
112 # all dependencies used by any project referenced by $project
114 my @dep_stack = ($project);
115 while (my $top = pop @dep_stack) {
116 # add current project to dependencies (use hash key as set)
118 my $deps = $project_dependencies{$top};
119 foreach my $dep (@
$deps) {
120 # add current project's dependencies to stack for processing, if not already processed
121 push(@dep_stack, $dep) if !exists $all_deps{$dep};
125 # for every config/platform pairing, emit a MainGroup
126 foreach my $cfg (@cfgs_main) {
127 my ($config, $platform) = split('\|', $cfg);
129 print $fh ' <Fragment>', $crlf,
130 ' <ComponentGroup Id="MainGroup.', normalize
($config),
131 '_', normalize
($platform), '_', $pname_main, '">', $crlf;
133 # add main project - pattern is "ComponentGroup.<Debug|Release>_<Win32|x64|AnyCPU>_<projectname>"
134 print $fh ' <ComponentGroupRef Id="ComponentGroup.',
135 normalize
($config), '_', normalize
($platform), '_',
136 $pname_main, '" />', $crlf;
138 # loop over each dependency, and obtain its parameters
139 foreach my $dep (keys %all_deps) {
140 foreach my $p (@
{$self->{'projects'}}) {
141 if ($dep eq $info->{$p}->[ProjectCreator
::PROJECT_NAME
] ||
142 $dep eq $self->mpc_basename($p)) {
143 my($pname_dep, @cfgs_dep) =
144 $gen->access_pi_values($info, $p,
145 ProjectCreator
::PROJECT_NAME
,
146 ProjectCreator
::CONFIGURATIONS
);
148 # add dependency - include AnyCPU if no dependency configuration matches exactly (if the AnyCPU platform exists, that is)
149 my $pform = $platform;
150 if (!exists {map { $_ => 1 } @cfgs_dep}->{$config.'|'.$pform}) {
153 if (exists {map { $_ => 1 } @cfgs_dep}->{$config.'|'.$pform}) {
154 print $fh ' <ComponentGroupRef Id="ComponentGroup.',
155 normalize
($config), '_', normalize
($pform),
156 '_', $pname_dep, '" />', $crlf;
163 print $fh ' </ComponentGroup>', $crlf,
164 ' </Fragment>', $crlf, $crlf;
169 print $fh '</Include>', $crlf;