Fix bug #533903.
authorAnkit Jain <radical@corewars.org>
Tue, 25 Aug 2009 23:53:01 +0000 (23:53 -0000)
committerAnkit Jain <radical@corewars.org>
Tue, 25 Aug 2009 23:53:01 +0000 (23:53 -0000)
* xbuild/Microsoft.Common.targets: Support building projects
directly from command line. Builds referenced projects. Honors
$(BuildingSolutionFile) and $(BuildingInsideVisualStudio) now.
Also, clean referenced projects.

svn path=/trunk/mcs/; revision=140679

mcs/tools/xbuild/ChangeLog
mcs/tools/xbuild/xbuild/Microsoft.Common.targets

index 146ecb42a45c67d3b1aede1480b8d199182539dc..538bb4c130c1e41d777f20ed05c89007aaaa50e3 100644 (file)
@@ -1,3 +1,11 @@
+2009-08-26  Ankit Jain  <jankit@novell.com>
+
+       Fix bug #533903.
+       * xbuild/Microsoft.Common.targets: Support building projects
+       directly from command line. Builds referenced projects. Honors
+       $(BuildingSolutionFile) and $(BuildingInsideVisualStudio) now.
+       Also, clean referenced projects.
+
 2009-08-21  Ankit Jain  <jankit@novell.com>
 
        Fix bug #531926
index 4f476b8930670c21f1e5399b3c80ff3decff9aec..105024ac4152ae1c5a6b64babe322f4a030513c0 100644 (file)
 
        <ItemGroup>
                <IntermediateAssembly Include="$(IntermediateOutputPath)$(AssemblyName)$(TargetExt)" />
-       </ItemGroup>
 
-       <ItemGroup>
-               <TargetPath Include="$(OutDir)" />
+               <!-- creating this as a item to use FullPath on it, to build TargetPath -->
+               <_OutDirItem Include="$(OutDir)"/>
+               <_TargetPathItem Include="@(_OutDirItem->'%(FullPath)\$(AssemblyName)$(TargetExt)')" />
        </ItemGroup>
 
+       <PropertyGroup>
+               <TargetPath>@(_TargetPathItem)</TargetPath>
+       </PropertyGroup>
+
        <Target Name="PrepareForBuild">
                <Message Importance="High" Text="Configuration: $(Configuration) Platform: $(Platform)"/>
-               
+
                <MakeDir 
                        Directories="$(OutDir);$(IntermediateOutputPath)"
                />
                Name="AssignProjectConfigurations"
                Condition="'@(ProjectReference)' != ''">
 
+               <!-- assign configs if building a solution file -->
                <AssignProjectConfiguration
                        ProjectReferences = "@(ProjectReference)"
-                       SolutionConfigurationContents = "$(CurrentSolutionConfigurationContents)">
+                       SolutionConfigurationContents = "$(CurrentSolutionConfigurationContents)"
+                       Condition="'$(BuildingSolutionFile)' == 'true'">
 
                        <Output TaskParameter = "AssignedProjects" ItemName = "ProjectReferenceWithConfiguration"/>
                </AssignProjectConfiguration>
 
+               <!-- Else, just -->
+               <CreateItem Include="@(ProjectReference)" Condition="'$(BuildingSolutionFile)' != 'true'">
+                       <Output TaskParameter="Include" ItemName="ProjectReferenceWithConfiguration"/>
+               </CreateItem>
+
        </Target>
 
 
                Name="ResolveProjectReferences"
                DependsOnTargets="AssignProjectConfigurations"
        >
-               <!-- FIXME: don't build if building a .sln, since project ref would already have been built -->
+               <!-- If building from a .sln.proj or from IDE, then referenced projects have already
+                    been built, so just get the target paths -->
                <MSBuild
                        Projects="@(ProjectReferenceWithConfiguration)"
                        Targets="GetTargetPath"
                        Properties="%(ProjectReferenceWithConfiguration.SetConfiguration); %(ProjectReferenceWithConfiguration.SetPlatform)"
-                       Condition="'@(ProjectReferenceWithConfiguration)' != ''">
+                       Condition="'@(ProjectReferenceWithConfiguration)' != '' and ('$(BuildingSolutionFile)' == 'true' or '$(BuildingInsideVisualStudio)' == 'true')">
+
+                       <Output TaskParameter="TargetOutputs" ItemName="ChildProjectReferences" />
+               </MSBuild>
+
+               <!-- Building a project directly, build the referenced the projects also -->
+               <MSBuild
+                       Projects="@(ProjectReferenceWithConfiguration)"
+                       Properties="%(ProjectReferenceWithConfiguration.SetConfiguration); %(ProjectReferenceWithConfiguration.SetPlatform)"
+                       Condition="'@(ProjectReferenceWithConfiguration)' != '' and '$(BuildingSolutionFile)' != 'true' and '$(BuildingInsideVisualStudio)' != 'true' ">
 
                        <Output TaskParameter="TargetOutputs" ItemName="ChildProjectReferences" />
                </MSBuild>
                </Copy>
        </Target>
 
-       <Target Name="GetTargetPath" Outputs="@(TargetPath->'%(FullPath)\$(AssemblyName)$(TargetExt)')"/>
+       <Target Name="GetTargetPath" Outputs="$(TargetPath)"/>
 
        <Target Name="GetCopyToOutputDirectoryItems"
                Outputs="@(AllItemsFullPathWithTargetPath)"
        <PropertyGroup>
                <CleanDependsOn>
                        BeforeClean;
+                       CleanReferencedProjects;
                        CoreClean;
                        AfterClean
                </CleanDependsOn>
                </ReadLinesFromFile>
        </Target>
 
+       <Target Name="CleanReferencedProjects"
+               DependsOnTargets="AssignProjectConfigurations">
+
+               <!-- If building from .sln.proj or from IDE, clean will get handled by them,
+                    else we are building a project directly, from the command line, so
+                    clean the referenced projects -->
+               <MSBuild Projects="@(ProjectReferenceWithConfiguration)"
+                       Targets="Clean"
+                       Condition=" '$(BuildingSolutionFile)' != 'true' and '$(BuildingInsideVisualStudio)' != 'true' and '@(ProjectReferenceWithConfiguration)' != ''" />
+
+       </Target>
+
        <Target Name="Clean" DependsOnTargets="$(CleanDependsOn)"/>
 
        <!-- Override in project to run before/after clean tasks -->