[Tizen] Add method to write coredump of .NET process (#317)
[platform/upstream/coreclr.git] / build.sh
index f9f8bff..97e89be 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -47,6 +47,7 @@ usage()
     echo "-skipnuget - skip building nuget packages."
     echo "-skiprestoreoptdata - skip restoring optimization data used by profile-based optimizations."
     echo "-skipcrossgen - skip native image generation"
+    echo "-skipmanagedtools -- skip build tools such as R2Rdump and RunInContext"
     echo "-crossgenonly - only run native image generation"
     echo "-partialngen - build CoreLib as PartialNGen"
     echo "-verbose - optional argument to enable verbose build output."
@@ -74,9 +75,9 @@ initTargetDistroRid()
     # Only pass ROOTFS_DIR if cross is specified.
     if (( ${__CrossBuild} == 1 )); then
         passedRootfsDir=${ROOTFS_DIR}
-    elif [ "${__BuildArch}" != "${__HostArch}" ]; then
-        echo "Error, you are building a cross scenario without passing -cross."
-        exit 1
+    #elif [ "${__BuildArch}" != "${__HostArch}" ]; then
+    #    echo "Error, you are building a cross scenario without passing -cross."
+    #    exit 1
     fi
 
     initDistroRidGlobal ${__BuildOS} ${__BuildArch} ${__PortableBuild} ${passedRootfsDir}
@@ -150,26 +151,27 @@ restore_optdata()
 
     if [ $__isMSBuildOnNETCoreSupported == 1 ]; then
         # Parse the optdata package versions out of msbuild so that we can pass them on to CMake
-        local DotNetCli="$__ProjectRoot/.dotnet/dotnet"
-        if [ ! -f $DotNetCli ]; then
-            source "$__ProjectRoot/init-dotnet.sh"
-            if [ $? != 0 ]; then
-                echo "Failed to install dotnet."
-                exit 1
-            fi
-        fi
-        __PgoOptDataVersion=$(DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 $DotNetCli msbuild $OptDataProjectFilePath /t:DumpPgoDataPackageVersion /nologo)
-        if [ $? != 0 ]; 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=$(echo $__PgoOptDataVersion | sed 's/^\s*//')
-        __IbcOptDataVersion=$(DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 $DotNetCli msbuild $OptDataProjectFilePath /t:DumpIbcDataPackageVersion /nologo)
-        if [ $? != 0 ]; then
+
+        __PgoOptDataVersion=$(<"${PgoDataPackageVersionOutputFile}")
+
+        # 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=$(echo $__IbcOptDataVersion | sed 's/^[[:blank:]]*//')
+
+        __IbcOptDataVersion=$(<"${IbcDataPackageVersionOutputFile}")
     fi
 }
 
@@ -441,13 +443,19 @@ build_CoreLib()
         exit 1
     fi
 
+    local __CoreLibILDir=$__BinDir/IL
+
     if [ $__SkipCrossgen == 1 ]; then
         echo "Skipping generating native image"
+
+        #if [ $__CrossBuild == 1 ]; then
+            # Crossgen not performed, so treat the IL version as the final version
+            cp $__CoreLibILDir/System.Private.CoreLib.dll $__BinDir/System.Private.CoreLib.dll
+        #fi
+
         return
     fi
 
-    local __CoreLibILDir=$__BinDir/IL
-
     # The cross build generates a crossgen with the target architecture.
     if [ $__CrossBuild == 0 ]; then
        if [ $__SkipCoreCLR == 1 ]; then
@@ -774,6 +782,21 @@ while :; do
             __ClangMinorVersion=
             ;;
 
+        clang8|-clang8)
+            __ClangMajorVersion=8
+            __ClangMinorVersion=
+            ;;
+
+        clang9|-clang9)
+            __ClangMajorVersion=9
+            __ClangMinorVersion=
+            ;;
+
+        clang10|-clang10)
+            __ClangMajorVersion=10
+            __ClangMinorVersion=
+            ;;
+
         gcc5|-gcc5)
             __GccMajorVersion=5
             __GccMinorVersion=
@@ -865,6 +888,10 @@ while :; do
             __SkipCrossgen=1
             ;;
 
+        skipmanagedtools | -skipmanagedtools)
+            __BuildManagedTools=0
+            ;;
+
         crossgenonly|-crossgenonly)
             __SkipMSCorLib=1
             __SkipCoreCLR=1
@@ -967,7 +994,7 @@ while :; do
     shift
 done
 
-__CommonMSBuildArgs="/p:__BuildArch=$__BuildArch /p:__BuildType=$__BuildType /p:__BuildOS=$__BuildOS $__OfficialBuildIdArg $__SignTypeArg $__SkipRestoreArg"
+__CommonMSBuildArgs="/p:__BuildArch=$__BuildArch /p:__BuildType=$__BuildType /p:__BuildOS=$__BuildOS /nodeReuse:false $__OfficialBuildIdArg $__SignTypeArg $__SkipRestoreArg"
 
 # Configure environment if we are doing a verbose build
 if [ $__VerboseBuild == 1 ]; then
@@ -986,15 +1013,6 @@ if [[ $__ClangMajorVersion == 0 && $__ClangMinorVersion == 0 ]]; then
     fi
 fi
 
-if [[ "$__BuildArch" == "armel" ]]; then
-    # Armel cross build is Tizen specific and does not support Portable RID build
-    __PortableBuild=0
-fi
-
-if [ $__PortableBuild == 0 ]; then
-    __CommonMSBuildArgs="$__CommonMSBuildArgs /p:PortableBuild=false"
-fi
-
 # Set dependent variables
 __LogsDir="$__RootBinDir/Logs"
 __MsbuildDebugLogsDir="$__LogsDir/MsbuildDebugLogs"
@@ -1012,9 +1030,21 @@ if [ $__CrossBuild == 1 ]; then
 fi
 __CrossGenCoreLibLog="$__LogsDir/CrossgenCoreLib_$__BuildOS.$__BuildArch.$__BuildType.log"
 
+# Configure environment if we are doing a cross compile.
+if [ $__CrossBuild == 1 ]; then
+    export CROSSCOMPILE=1
+    if ! [[ -n "$ROOTFS_DIR" ]]; then
+        export ROOTFS_DIR="$__ProjectRoot/cross/rootfs/$__BuildArch"
+    fi
+fi
+
 # init the target distro name
 initTargetDistroRid
 
+if [ $__PortableBuild == 0 ]; then
+    __CommonMSBuildArgs="$__CommonMSBuildArgs /p:PortableBuild=false"
+fi
+
 # Init if MSBuild for .NET Core is supported for this platform
 isMSBuildOnNETCoreSupported
 
@@ -1032,14 +1062,6 @@ fi
 # This is where all built CoreClr libraries will copied to.
 export __CMakeBinDir="$__BinDir"
 
-# Configure environment if we are doing a cross compile.
-if [ $__CrossBuild == 1 ]; then
-    export CROSSCOMPILE=1
-    if ! [[ -n "$ROOTFS_DIR" ]]; then
-        export ROOTFS_DIR="$__ProjectRoot/cross/rootfs/$__BuildArch"
-    fi
-fi
-
 # Make the directories necessary for build if they don't exist
 setup_dirs