Provide dummy runtime_version.h when skipped (#35579)
authorAdeel Mujahid <adeelbm@outlook.com>
Wed, 29 Apr 2020 13:17:35 +0000 (16:17 +0300)
committerGitHub <noreply@github.com>
Wed, 29 Apr 2020 13:17:35 +0000 (06:17 -0700)
With `-skipgenerateversion`, all MSBuild invocations are skipped.
In that case, we generate a dummy `version.c` file. Since
`runtime_version.h` is added as a required header, generate its dummy
variant in the same context.

eng/native/build-commons.sh

index 14839cb..3fdb144 100755 (executable)
@@ -82,6 +82,7 @@ build_native()
         buildTool="make"
     fi
 
+    runtimeVersionHeaderFile="$intermediatesDir/../runtime_version.h"
     if [[ "$__SkipConfigure" == 0 ]]; then
         # if msbuild is not supported, then set __SkipGenerateVersion to 1
         if [[ "$__IsMSBuildOnNETCoreSupported" == 0 ]]; then __SkipGenerateVersion=1; fi
@@ -95,7 +96,7 @@ build_native()
         if [[ "$__SkipGenerateVersion" == 0 ]]; then
             "$__RepoRootDir/eng/common/msbuild.sh" /clp:nosummary "$__ArcadeScriptArgs" "$__RepoRootDir"/eng/empty.csproj \
                                                    /p:NativeVersionFile="$__versionSourceFile" \
-                                                   /p:RuntimeVersionFile="$intermediatesDir/../runtime_version.h" \
+                                                   /p:RuntimeVersionFile="$runtimeVersionHeaderFile" \
                                                    /t:GenerateRuntimeVersionFile /restore \
                                                    $__CommonMSBuildArgs $__binlogArg $__UnprocessedBuildArgs
             local exit_code="$?"
@@ -104,12 +105,24 @@ build_native()
                 exit "$exit_code"
             fi
         else
-            # Generate the dummy version.c, but only if it didn't exist to make sure we don't trigger unnecessary rebuild
+            # Generate the dummy version.c and runtime_version.h, but only if they didn't exist to make sure we don't trigger unnecessary rebuild
             __versionSourceLine="static char sccsid[] __attribute__((used)) = \"@(#)No version information produced\";"
             if [[ -e "$__versionSourceFile" ]]; then
                 read existingVersionSourceLine < "$__versionSourceFile"
             fi
             if [[ "$__versionSourceLine" != "$existingVersionSourceLine" ]]; then
+                cat << EOF > $runtimeVersionHeaderFile
+#define RuntimeAssemblyMajorVersion 0
+#define RuntimeAssemblyMinorVersion 0
+#define RuntimeFileMajorVersion 0
+#define RuntimeFileMinorVersion 0
+#define RuntimeFileBuildVersion 0
+#define RuntimeFileRevisionVersion 0
+#define RuntimeProductMajorVersion 0
+#define RuntimeProductMinorVersion 0
+#define RuntimeProductPatchVersion 0
+#define RuntimeProductVersion
+EOF
                 echo "$__versionSourceLine" > "$__versionSourceFile"
             fi
         fi