Address PR feedback.
authorjashook <jashoo@microsoft.com>
Thu, 13 Jun 2019 20:29:27 +0000 (20:29 +0000)
committerjashook <jashoo@microsoft.com>
Thu, 13 Jun 2019 20:29:27 +0000 (20:29 +0000)
build.cmd
build.sh
dir.common.props
src/.nuget/optdata/ibcmerge.csproj
src/.nuget/optdata/optdata.csproj

index 7bf070f..9bcafec 100644 (file)
--- a/build.cmd
+++ b/build.cmd
@@ -389,24 +389,36 @@ if %__RestoreOptData% EQU 1 (
     )
 )
 
+set PgoDataPackageVersionOutputFile="%__IntermediatesDir%\optdataversion.txt"
+set IbcDataPackageVersionOutputFile="%__IntermediatesDir%\ibcoptdataversion.txt"
+
 REM Parse the optdata package versions out of msbuild so that we can pass them on to CMake
-call "%__ProjectDir%\dotnet.cmd" msbuild "%OptDataProjectFilePath%" /t:DumpPgoDataPackageVersion /nologo %__CommonMSBuildArgs%
+call "%__ProjectDir%\dotnet.cmd" msbuild "%OptDataProjectFilePath%" /t:DumpPgoDataPackageVersion /nologo %__CommonMSBuildArgs% /p:PgoDataPackageVersionOutputFile=%PgoDataPackageVersionOutputFile%
 
-if not exist "%__IntermediatesDir%\optdataversion.txt" (
+ if not not !errorlevel! == 0 (
+    echo "Failed to get PGO data package version."
+    exit /b 1
+)
+if not exist "%PgoDataPackageVersionOutputFile%" (
     echo "Failed to get PGO data package version."
     exit /b !errorlevel!
 )
 
-set /p __PgoOptDataVersion=<"%__IntermediatesDir%\optdataversion.txt"
+set /p __PgoOptDataVersion=<"%PgoDataPackageVersionOutputFile%"
 
-call "%__ProjectDir%\dotnet.cmd" msbuild "%OptDataProjectFilePath%" /t:DumpIbcDataPackageVersion /nologo %__CommonMSBuildArgs%
+call "%__ProjectDir%\dotnet.cmd" msbuild "%OptDataProjectFilePath%" /t:DumpIbcDataPackageVersion /nologo %__CommonMSBuildArgs% /p:IbcDataPackageVersionOutputFile=%IbcDataPackageVersionOutputFile%
 
-if not exist "%__IntermediatesDir%\ibcoptdataversion.txt" (
-    echo "Failed to get PGO data package version."
+ if not not !errorlevel! == 0 (
+    echo "Failed to get IBC data package version."
+    exit /b 1
+)
+
+if not exist "%IbcDataPackageVersionOutputFile%" (
+    echo "Failed to get IBC data package version."
     exit /b !errorlevel!
 )
 
-set /p __IbcOptDataVersion=<"%__IntermediatesDir%\ibcoptdataversion.txt"
+set /p __IbcOptDataVersion=<"%IbcDataPackageVersionOutputFile%"
 
 REM =========================================================================================
 REM ===
@@ -645,14 +657,19 @@ if %__BuildCoreLib% EQU 1 (
     if %__IbcOptimize% EQU 1 (
         echo %__MsgPrefix%Commencing IBCMerge of System.Private.CoreLib for %__BuildOS%.%__BuildArch%.%__BuildType%
         set IbcMergeProjectFilePath=%__ProjectDir%\src\.nuget\optdata\ibcmerge.csproj
-        call "%__ProjectDir%\dotnet.cmd" msbuild "!IbcMergeProjectFilePath!" /t:DumpIbcMergePackageVersion /nologo %__CommonMSBuildArgs%
+        set IbcMergePackageVersionOutputFile="%__IntermediatesDir%\ibcmergeversion.txt"
+        call "%__ProjectDir%\dotnet.cmd" msbuild "!IbcMergeProjectFilePath!" /t:DumpIbcMergePackageVersion /nologo %__CommonMSBuildArgs% /p:IbcMergePackageVersionOutputFile=%IbcMergePackageVersionOutputFile%
 
-        if not exist "%__IntermediatesDir%\ibcmergeversion.txt" (
+        if not not !errorlevel! == 0 (
+            echo "Failed to determine IBC Merge version."
+            exit /b 1
+        )
+        if not exist "%IbcMergePackageVersionOutputFile%" (
             echo "Failed to determine IBC Merge version."
             exit /b 1
         )
         
-        set /p __IbcMergeVersion=<"%__IntermediatesDir%\ibcmergeversion.txt"
+        set /p __IbcMergeVersion=<"%IbcMergePackageVersionOutputFile%"
 
         set IbcMergePath=%__PackagesDir%\microsoft.dotnet.ibcmerge\!__IbcMergeVersion!\tools\netcoreapp2.0\ibcmerge.dll
         if exist !IbcMergePath! (
index 6738cf5..40d59ba 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -151,23 +151,26 @@ restore_optdata()
     if [ $__isMSBuildOnNETCoreSupported == 1 ]; then
         # Parse the optdata package versions out of msbuild so that we can pass them on to CMake
 
-        # Writes into ${__IntermediatesDir}/optdataversion.txt
-        ${__ProjectDir}/dotnet.sh msbuild $OptDataProjectFilePath /t:DumpPgoDataPackageVersion ${__CommonMSBuildArgs} /nologo 2>&1 >/dev/null
-        if [ ! -f "${__IntermediatesDir}/optdataversion.txt" ]; then
+        local PgoDataPackageVersionOutputFile="${__IntermediatesDir}/optdataversion.txt"
+        local IbcDataPackageVersionOutputFile="${__IntermediatesDir}/ibcoptdataversion.txt"
+
+        # Writes into ${PgoDataPackageVersionOutputFile}
+        ${__ProjectDir}/dotnet.sh msbuild $OptDataProjectFilePath /t:DumpPgoDataPackageVersion ${__CommonMSBuildArgs} /p:PgoDataPackageVersionOutputFile=${PgoDataPackageVersionOutputFile} /nologo 2>&1 > /dev/null
+        if [ $? != 0 ] || [ ! -f "${PgoDataPackageVersionOutputFile}" ]; then
             echo "Failed to get PGO data package version."
             exit $?
         fi
 
-        __PgoOptDataVersion=$(<"${__IntermediatesDir}/optdataversion.txt")
+        __PgoOptDataVersion=$(<"${PgoDataPackageVersionOutputFile}")
 
-        # Writes into ${__IntermediatesDir}/ibcoptdataversion.txt
-        ${__ProjectDir}/dotnet.sh msbuild $OptDataProjectFilePath /t:DumpIbcDataPackageVersion ${__CommonMSBuildArgs} /nologo 2>&1 >/dev/null
-        if [ ! -f "${__IntermediatesDir}/ibcoptdataversion.txt" ]; then
+        # Writes into ${IbcDataPackageVersionOutputFile}
+        ${__ProjectDir}/dotnet.sh msbuild $OptDataProjectFilePath /t:DumpIbcDataPackageVersion ${__CommonMSBuildArgs} /p:IbcDataPackageVersionOutputFile=${IbcDataPackageVersionOutputFile} /nologo 2>&1 > /dev/null
+        if [ $? != 0 ] || [ ! -f "${IbcDataPackageVersionOutputFile}" ]; then
             echo "Failed to get IBC data package version."
             exit $?
         fi
 
-        __IbcOptDataVersion=$(<"${__IntermediatesDir}/ibcoptdataversion.txt")
+        __IbcOptDataVersion=$(<"${IbcDataPackageVersionOutputFile}")
     fi
 }
 
index c83f9bb..b44e542 100644 (file)
     <BinDir>$(__BinDir)\</BinDir>
     <BinDir Condition="'$(__BinDir)'==''">$(RootBinDir)Product\$(PlatformConfigPathPart)\</BinDir>
 
-    <!-- Use the envvar __IntermediatesDir to find the location of the obj   -->
-    <!-- dir                                                                 -->
-    <!-- Note that if nmake is used, the obj/ folder is nmakeobj/ therefore  -->
-    <!-- env variable is the only source of truth. This is only done for the -->
-    <!-- windows formatting jobs which use nmake and clang-format to build   -->
-    <!-- the product.                                                        -->
-    <__IntermediatesDir Condition="'$(__IntermediatesDir)' == ''">$(RootBinDir)obj/$(BuildOS).$(BuildArch).$(BuildType)/</__IntermediatesDir>
-
     <!-- We don't append back slash because this path is used by nuget.exe as output directory and it
          fails to write packages to it if the path contains the forward slash.
     -->
index 646fb03..7f1d026 100644 (file)
   <!-- DumpIbcMergePackageVersion is used by build.sh and build.cmd to pass  -->
   <!-- the version information to cmake. The task will write a file to the   -->
   <!-- intermediates directory to be read back by build.cmd/sh. The path for -->
-  <!-- the file is $(__IntermediatesDir)\ibcmergeversion.txt      -->
+  <!-- the file is IbcMergePackageVersionOutputFile                          -->
   <!--                                                                       -->
   <Target Name="DumpIbcMergePackageVersion">
-    <!-- Output the package version to stdout for backcompat -->
-    <Message Importance="high" Text="$(IbcMergePackageVersion)" />
-    <WriteLinesToFile File="$(__IntermediatesDir)\ibcmergeversion.txt" Lines="$(IbcMergePackageVersion)" Overwrite="true"/>
+    <!-- Error if PgoDataPackageVersionOutputFile is not set. -->
+    <Error Condition="'$(IbcMergePackageVersionOutputFile)'==''" />
+
+    <!-- Cleanup old version file -->
+    <Delete Files="$(IbcMergePackageVersionOutputFile)" Condition="Exists('$(IbcMergePackageVersionOutputFile)')" />
+    <Message Text="IbcMergePackageVersion: $(IbcMergePackageVersion) written to: $(IbcMergePackageVersionOutputFile)" Importance="High" />
+    <WriteLinesToFile File="$(IbcMergePackageVersionOutputFile)" Lines="$(optimizationIBCCoreCLRVersion)" Overwrite="true"/>
   </Target>
 
   <PropertyGroup>
index a4f7f1e..400ffa6 100644 (file)
   <!-- DumpPgoDataPackageVersion is used by build.sh and build.cmd to pass   -->
   <!-- the version information to cmake. The task will write a file to the   -->
   <!-- intermediates directory to be read back by build.cmd/sh. The path for -->
-  <!-- the file is $(__IntermediatesDir)\optdataversion.txt       -->
+  <!-- the file is passed as proprty: PgoDataPackageVersionOutputFile        -->
   <!--                                                                       -->
 
   <Target Name="DumpPgoDataPackageVersion">
-    <!-- Keep the old message for backcompat. -->
-    <Message Text="$(optimizationIBCCoreCLRVersion)" Importance="High" />
-    <WriteLinesToFile File="$(__IntermediatesDir)\optdataversion.txt" Lines="$(optimizationIBCCoreCLRVersion)" Overwrite="true"/>
+    <!-- Error if PgoDataPackageVersionOutputFile is not set. -->
+    <Error Condition="'$(PgoDataPackageVersionOutputFile)'==''" />
+
+    <!-- Cleanup old version file -->
+    <Delete Files="$(PgoDataPackageVersionOutputFile)" Condition="Exists('$(PgoDataPackageVersionOutputFile)')" />
+    <Message Text="optimizationPGOCoreCLRVersion: $(optimizationPGOCoreCLRVersion) written to: $(PgoDataPackageVersionOutputFile)" Importance="High" />
+    <WriteLinesToFile File="$(PgoDataPackageVersionOutputFile)" Lines="$(optimizationPGOCoreCLRVersion)" Overwrite="true"/>
   </Target>
 
   <!--                                                                       -->
   <!-- DumpIbcDataPackageVersion is used by build.sh and build.cmd to pass   -->
   <!-- the version information to cmake. The task will write a file to the   -->
   <!-- intermediates directory to be read back by build.cmd/sh. The path for -->
-  <!-- the file is $(__IntermediatesDir)\ibcoptdataversion.txt    -->
+  <!-- the file is IbcDataPackageVersionOutputFile                           -->
   <!--                                                                       -->
   <Target Name="DumpIbcDataPackageVersion">
-    <!-- Keep the old message for backcompat. -->
-    <Message Importance="high" Text="$(optimizationIBCCoreCLRVersion)" />
-    <WriteLinesToFile File="$(__IntermediatesDir)\ibcoptdataversion.txt" Lines="$(optimizationIBCCoreCLRVersion)" Overwrite="true"/>
+    <!-- Error if PgoDataPackageVersionOutputFile is not set. -->
+    <Error Condition="'$(IbcDataPackageVersionOutputFile)'==''" />
+
+    <!-- Cleanup old version file -->
+    <Delete Files="$(IbcDataPackageVersionOutputFile)" Condition="Exists('$(IbcDataPackageVersionOutputFile)')" />
+    <Message Text="optimizationIBCCoreCLRVersion: $(optimizationIBCCoreCLRVersion) written to: $(IbcDataPackageVersionOutputFile)" Importance="High" />
+    <WriteLinesToFile File="$(IbcDataPackageVersionOutputFile)" Lines="$(optimizationIBCCoreCLRVersion)" Overwrite="true"/>
   </Target>
 
 </Project>