Generate version.cpp if it doesn't already exist.
authorEric Erhardt <eric.erhardt@microsoft.com>
Tue, 20 Feb 2018 18:45:22 +0000 (12:45 -0600)
committerEric Erhardt <eric.erhardt@microsoft.com>
Tue, 20 Feb 2018 23:46:09 +0000 (17:46 -0600)
This is necessary when bootstrapping a new RID, and we can't run MSBuild to generate the version.cpp file.

Commit migrated from https://github.com/dotnet/core-setup/commit/83f55767876e52aba1372b94fee5f0faf9308aca

src/installer/corehost/CMakeLists.txt
src/installer/corehost/build.sh

index fadadad..fd2dd12 100644 (file)
@@ -1,6 +1,4 @@
 cmake_minimum_required (VERSION 2.6)
 
-set(VERSION_FILE_PATH "${CMAKE_BINARY_DIR}/../../../version.cpp")
-
 include(../settings.cmake)
 add_subdirectory(cli)
index 300a07b..cdd3895 100755 (executable)
@@ -1,9 +1,5 @@
 #!/usr/bin/env bash
 
-# Why is this a separate script? Why not just invoke 'cmake' and 'make' in the C# build scripts themselves?
-# I really don't know, but it doesn't work when I do that. Something about SIGCHLD not getting from clang to cmake or something.
-#       -anurse
-
 init_rid_plat()
 {
     # Detect Distro
@@ -98,6 +94,8 @@ __portableBuildArgs=
 __configuration=Debug
 __linkPortable=0
 __cmake_defines="-DCMAKE_BUILD_TYPE=${__configuration} ${__portableBuildArgs}"
+__baseIntermediateOutputPath="$RootRepo/Bin/obj"
+__versionSourceFile="$__baseIntermediateOutputPath/version.cpp"
 
 while [ "$1" != "" ]; do
         lowerI="$(echo $1 | awk '{print tolower($0)}')"
@@ -150,6 +148,8 @@ while [ "$1" != "" ]; do
     shift
 done
 
+mkdir -p "$__baseIntermediateOutputPath"
+
 case $__build_arch in
     amd64|x64)
         __arch_define=-DCLI_CMAKE_PLATFORM_ARCH_AMD64=1
@@ -214,6 +214,13 @@ else
     exit 1
 fi
 
+if [ ! -f $__versionSourceFile ]; then
+    __versionSourceLine="static char sccsid[] __attribute__((used)) = \"@(#)No version information produced\";"
+    echo $__versionSourceLine > $__versionSourceFile
+fi
+
+__cmake_defines="${__cmake_defines} -DVERSION_FILE_PATH:STRING=${__versionSourceFile}"
+
 echo "Building Corehost from $DIR to $(pwd)"
 set -x # turn on trace
 if [ $__CrossBuild == 1 ]; then