Fix bug #531926
authorAnkit Jain <radical@corewars.org>
Thu, 20 Aug 2009 20:04:01 +0000 (20:04 -0000)
committerAnkit Jain <radical@corewars.org>
Thu, 20 Aug 2009 20:04:01 +0000 (20:04 -0000)
* xbuild/Microsoft.Common.targets: Add $(ConfigurationName)
and $(PlatformName) default values.
Move CoreCompile to a Compile target with corresponding
Before/After hooks and *DependsOn.
Add Pre/PostBuildEvents handling.

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

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

index 7627f47d62ef2929e0b8fe0b7d54d3abe9c06ea3..146ecb42a45c67d3b1aede1480b8d199182539dc 100644 (file)
@@ -1,3 +1,12 @@
+2009-08-21  Ankit Jain  <jankit@novell.com>
+
+       Fix bug #531926
+       * xbuild/Microsoft.Common.targets: Add $(ConfigurationName)
+       and $(PlatformName) default values.
+       Move CoreCompile to a Compile target with corresponding
+       Before/After hooks and *DependsOn.
+       Add Pre/PostBuildEvents handling.
+
 2009-08-20  Ankit Jain  <jankit@novell.com>
 
        Fix bug #532264.
index 3082fc31d7c59dedcdda5bbed570d7222bdfef70..4f476b8930670c21f1e5399b3c80ff3decff9aec 100644 (file)
        <PropertyGroup>
                <OutDir Condition="'$(OutDir)' == ''">$(OutputPath)</OutDir>
                <OutDir Condition="'$(OutDir)' != '' and !HasTrailingSlash('$(OutDir)')">$(OutDir)\</OutDir>
+
+               <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+               <ConfigurationName Condition="'$(ConfigurationName)' == ''">$(Configuration)</ConfigurationName>
+
+               <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+               <PlatformName Condition="'$(PlatformName)' == ''">$(Platform)</PlatformName>
        </PropertyGroup>
 
        <PropertyGroup>
        <PropertyGroup>
                <CoreBuildDependsOn>
                        PrepareForBuild;
+                       PreBuildEvent;
                        ResolveReferences;
                        CopyFilesMarkedCopyLocal;
                        BuildResources;
-                       CoreCompile;
+                       Compile;
                        DeployOutputFiles;
-                       _RecordCleanFile
+                       _RecordCleanFile;
+                       PostBuildEvent
                </CoreBuildDependsOn>
        </PropertyGroup>
 
        <Target
                Name="CoreBuild"
                DependsOnTargets="$(CoreBuildDependsOn)"
-               Outputs="$(OutDir)$(AssemblyName)$(TargetExt)"
-       />
+               Outputs="$(OutDir)$(AssemblyName)$(TargetExt)">
+
+               <OnError ExecuteTargets="_TimestampAfterCompile;PostBuildEvent"
+                       Condition=" '$(RunPostBuildEvent)' == 'Always' or '$(RunPostBuildEvent)' == 'OnOutputUpdated'"/>
+       </Target>
+
+       <PropertyGroup>
+               <CompileDependsOn>
+                       ResolveReferences;
+                       BeforeCompile;
+                       _TimestampBeforeCompile;
+                       CoreCompile;
+                       _TimestampAfterCompile;
+                       AfterCompile
+               </CompileDependsOn>
+       </PropertyGroup>
+
+       <Target Name="BeforeCompile" />
+       <Target Name="AfterCompile" />
+
+       <Target Name="Compile" DependsOnTargets="$(CompileDependsOn)"/>
 
        <Target Name="BuildResources"
                DependsOnTargets="AssignTargetPaths;SplitResourcesByCulture;CreateManifestResourceNames;CopyNonResxEmbeddedResources;GenerateResources;GenerateSatelliteAssemblies">
 
        </Target>
 
+       <!-- Pre/Post BuildEvents -->
+       <PropertyGroup>
+               <PreBuildEventDependsOn />
+       </PropertyGroup>
+
+       <Target Name="PreBuildEvent"
+               Condition="'$(PreBuildEvent)' != ''"
+               DependsOnTargets="$(PreBuildEventDependsOn)">
+
+               <Exec WorkingDirectory="$(OutDir)" Command="$(PreBuildEvent)" />
+       </Target>
+
+       <!-- PostBuildEvent depends on $(RunPostBuildEvent)
+
+               Default: OnBuildSuccess
+               OnBuildSuccess: Run after a successful build
+               OnOutputUpdated: Run only if the output assembly got updates
+               Always: Run always
+       -->
+       <PropertyGroup>
+               <PostBuildEventDependsOn />
+       </PropertyGroup>
+
+       <!-- this gets invoked in two cases, from CoreBuildDependsOn, if the build completes
+            successfully, OR from OnError in CoreBuild, if the build failed and $(RunPostBuildEvent)
+            is 'Always' or 'OnOutputUpdated' -->
+       <Target Name="PostBuildEvent"
+               Condition="'$(PostBuildEvent)' != '' and
+                       ('$(RunPostBuildEvent)' == 'Always' or '$(RunPostBuildEvent)' == 'OnBuildSuccess' or
+                         ('$(RunPostBuildEvent)' == 'OnOutputUpdated' and
+                           '$(_AssemblyModifiedTimeBeforeCompile)' != '$(_AssemblyModifiedTimeAfterCompile)')
+                       )"
+               DependsOnTargets="$(PostBuildEventDependsOn)">
+
+               <Exec WorkingDirectory="$(OutDir)" Command="$(PostBuildEvent)" />
+       </Target>
+
+       <!-- Timestamp the output assemblies, required for PostBuildEvent -->
+       <Target Name="_TimestampBeforeCompile" Condition="'$(RunPostBuildEvent)' == 'OnOutputUpdated'">
+               <CreateItem Include="%(IntermediateAssembly.ModifiedTime)">
+                       <Output TaskParameter="Include" PropertyName="_AssemblyModifiedTimeBeforeCompile" />
+               </CreateItem>
+       </Target>
+       <Target Name="_TimestampAfterCompile" Condition="'$(RunPostBuildEvent)' == 'OnOutputUpdated'">
+               <CreateItem Include="%(IntermediateAssembly.ModifiedTime)">
+                       <Output TaskParameter="Include" PropertyName="_AssemblyModifiedTimeAfterCompile" />
+               </CreateItem>
+       </Target>
+
+
+       <!-- Clean -->
        <Target Name="_RecordCleanFile"
                DependsOnTargets="_GetCompileOutputsForClean">
                <WriteLinesToFile