Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xeng/native/build-commons.sh479
-rw-r--r--eng/native/configureplatform.cmake182
-rw-r--r--eng/native/functions.cmake (renamed from src/coreclr/functions.cmake)0
-rwxr-xr-xeng/native/gen-buildsys.sh97
-rw-r--r--[-rwxr-xr-x]eng/native/init-distro-rid.sh (renamed from src/coreclr/init-distro-rid.sh)0
-rw-r--r--eng/pipelines/installer/jobs/base-job.yml2
-rw-r--r--eng/pipelines/libraries/base-job.yml6
-rw-r--r--eng/pipelines/libraries/build-job.yml2
-rw-r--r--src/coreclr/CMakeLists.txt2
-rwxr-xr-xsrc/coreclr/_build-commons.sh331
-rwxr-xr-xsrc/coreclr/build-packages.sh4
-rwxr-xr-xsrc/coreclr/build-test.sh350
-rw-r--r--src/coreclr/build.cmd5
-rwxr-xr-xsrc/coreclr/build.sh361
-rw-r--r--src/coreclr/configurecompiler.cmake184
-rwxr-xr-xsrc/coreclr/tests/setup-stress-dependencies.sh16
-rw-r--r--src/installer/corehost/CMakeLists.txt3
-rw-r--r--src/installer/corehost/Windows/gen-buildsys-win.bat20
-rw-r--r--src/installer/corehost/build.proj9
-rwxr-xr-xsrc/installer/corehost/build.sh326
-rw-r--r--src/installer/corehost/cli/apphost/CMakeLists.txt12
-rw-r--r--src/installer/corehost/cli/comhost/CMakeLists.txt2
-rw-r--r--src/installer/corehost/cli/common.cmake2
-rw-r--r--src/installer/corehost/cli/ijwhost/CMakeLists.txt8
-rw-r--r--src/installer/corehost/cli/test/nativehost/CMakeLists.txt2
-rw-r--r--src/installer/corehost/cli/test_fx_ver/CMakeLists.txt2
-rw-r--r--src/installer/corehost/cli/winrthost/CMakeLists.txt4
-rw-r--r--src/installer/functions.cmake8
-rw-r--r--src/installer/settings.cmake62
-rw-r--r--src/libraries/Native/Unix/CMakeLists.txt2
-rw-r--r--src/libraries/Native/build-native.cmd5
-rw-r--r--src/libraries/Native/build-native.proj21
-rwxr-xr-xsrc/libraries/Native/build-native.sh423
33 files changed, 1159 insertions, 1773 deletions
diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh
new file mode 100755
index 00000000000..4728876c0db
--- /dev/null
+++ b/eng/native/build-commons.sh
@@ -0,0 +1,479 @@
+#!/usr/bin/env bash
+
+initTargetDistroRid()
+{
+ source "$__RepoRootDir/eng/native/init-distro-rid.sh"
+
+ local passedRootfsDir=""
+
+ # Only pass ROOTFS_DIR if cross is specified.
+ if [[ "$__CrossBuild" == 1 ]]; then
+ passedRootfsDir="$ROOTFS_DIR"
+ fi
+
+ initDistroRidGlobal "$__BuildOS" "$__BuildArch" "$__PortableBuild" "$passedRootfsDir"
+}
+
+isMSBuildOnNETCoreSupported()
+{
+ __IsMSBuildOnNETCoreSupported="$__msbuildonunsupportedplatform"
+
+ if [[ "$__IsMSBuildOnNETCoreSupported" == 1 ]]; then
+ return
+ fi
+
+ if [[ "$__SkipManaged" == 1 ]]; then
+ __IsMSBuildOnNETCoreSupported=0
+ return
+ fi
+
+ if [[ ( "$__HostOS" == "Linux" ) && ( "$__HostArch" == "x64" || "$__HostArch" == "arm" || "$__HostArch" == "arm64" ) ]]; then
+ __IsMSBuildOnNETCoreSupported=1
+ elif [[ "$__HostArch" == "x64" && ( "$__HostOS" == "OSX" || "$__HostOS" == "FreeBSD" ) ]]; then
+ __IsMSBuildOnNETCoreSupported=1
+ fi
+}
+
+setup_dirs()
+{
+ echo Setting up directories for build
+
+ mkdir -p "$__RootBinDir"
+ mkdir -p "$__BinDir"
+ mkdir -p "$__IntermediatesDir"
+}
+
+# Check the system to ensure the right prereqs are in place
+check_prereqs()
+{
+ echo "Checking prerequisites..."
+
+ # Check presence of CMake on the path
+ command -v cmake 2>/dev/null || { echo >&2 "Please install cmake before running this script"; exit 1; }
+
+ function version { echo "$@" | awk -F. '{ printf("%d%02d%02d\n", $1,$2,$3); }'; }
+
+ local cmake_version="$(cmake --version | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+")"
+
+ if [[ "$(version "$cmake_version")" -lt "$(version 3.14.2)" ]]; then
+ echo "Please install CMake 3.14.2 or newer from http://www.cmake.org/download/ or https://apt.kitware.com and ensure it is on your path."; exit 1;
+ fi
+
+ if [[ "$__UseNinja" == 1 ]]; then
+ command -v ninja 2>/dev/null || command -v ninja-build 2>/dev/null || { echo "Unable to locate ninja!"; exit 1; }
+ fi
+}
+
+build_native()
+{
+ platformArch="$1"
+ cmakeDir="$2"
+ tryrunDir="$3"
+ intermediatesDir="$4"
+ message="$5"
+
+ # All set to commence the build
+ echo "Commencing build of \"$message\" for $__BuildOS.$__BuildArch.$__BuildType in $intermediatesDir"
+
+ if [[ "$__UseNinja" == 1 ]]; then
+ generator="ninja"
+ buildTool="$(command -v ninja || command -v ninja-build)"
+ else
+ buildTool="make"
+ fi
+
+ if [[ "$__SkipConfigure" == 0 ]]; then
+ # if msbuild is not supported, then set __SkipGenerateVersion to 1
+ if [[ "$__IsMSBuildOnNETCoreSupported" == 0 ]]; then __SkipGenerateVersion=1; fi
+ # Drop version.c file
+ __versionSourceFile="$intermediatesDir/version.c"
+ if [[ "$__SkipGenerateVersion" == 0 ]]; then
+ "$__RepoRootDir/eng/common/msbuild.sh" /clp:nosummary "$__ArcadeScriptArgs" "$__RepoRootDir"/eng/empty.csproj \
+ /p:NativeVersionFile="$__versionSourceFile" \
+ /t:GenerateNativeVersionFile /restore \
+ $__CommonMSBuildArgs $__UnprocessedBuildArgs
+ local exit_code="$?"
+ if [[ "$exit_code" != 0 ]]; then
+ echo "${__ErrMsgPrefix}Failed to generate native version file."
+ 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
+ __versionSourceLine="static char sccsid[] __attribute__((used)) = \"@(#)No version information produced\";"
+ if [[ -e "$__versionSourceFile" ]]; then
+ read existingVersionSourceLine < "$__versionSourceFile"
+ fi
+ if [[ "$__versionSourceLine" != "$existingVersionSourceLine" ]]; then
+ echo "$__versionSourceLine" > "$__versionSourceFile"
+ fi
+ fi
+
+ if [[ "$__StaticAnalyzer" == 1 ]]; then
+ scan_build=scan-build
+ fi
+
+ engNativeDir="$__RepoRootDir/eng/native"
+ __CMakeArgs="-DCLR_ENG_NATIVE_DIR=\"$engNativeDir\" $__CMakeArgs"
+ nextCommand="\"$engNativeDir/gen-buildsys.sh\" \"$cmakeDir\" \"$tryrunDir\" \"$intermediatesDir\" $platformArch $__Compiler \"$__CompilerMajorVersion\" \"$__CompilerMinorVersion\" $__BuildType \"$generator\" $scan_build $__CMakeArgs"
+ echo "Invoking $nextCommand"
+ eval $nextCommand
+
+ local exit_code="$?"
+ if [[ "$exit_code" != 0 ]]; then
+ echo "${__ErrMsgPrefix}Failed to generate \"$message\" build project!"
+ exit "$exit_code"
+ fi
+ fi
+
+ # Check that the makefiles were created.
+ if [[ ! -f "$intermediatesDir/CMakeCache.txt" ]]; then
+ echo "${__ErrMsgPrefix}Unable to find generated build files for \"$message\" project!"
+ exit 1
+ fi
+
+ # Build
+ if [[ "$__ConfigureOnly" == 1 ]]; then
+ echo "Finish configuration & skipping \"$message\" build."
+ return
+ fi
+
+ if [[ "$__StaticAnalyzer" == 1 ]]; then
+ pushd "$intermediatesDir"
+
+ buildTool="$SCAN_BUILD_COMMAND -o $__BinDir/scan-build-log $buildTool"
+ echo "Executing $buildTool install -j $__NumProc"
+ "$buildTool" install -j "$__NumProc"
+
+ popd
+ else
+ echo "Executing cmake --build \"$intermediatesDir\" --target install -j $__NumProc"
+ cmake --build "$intermediatesDir" --target install -j "$__NumProc"
+ fi
+
+ local exit_code="$?"
+ if [[ "$exit_code" != 0 ]]; then
+ echo "${__ErrMsgPrefix}Failed to build \"$message\"."
+ exit "$exit_code"
+ fi
+}
+
+usage()
+{
+ echo "Usage: $0 <options>"
+ echo ""
+ echo "Common Options:"
+ echo ""
+ echo "BuildArch can be: -arm, -armel, -arm64, -armel, x64, x86, -wasm"
+ echo "BuildType can be: -debug, -checked, -release"
+ echo "-bindir: output directory (defaults to $__ProjectRoot/artifacts)"
+ echo "-ci: indicates if this is a CI build."
+ echo "-clang: optional argument to build using clang in PATH (default)."
+ echo "-clangx.y: optional argument to build using clang version x.y."
+ echo "-cmakeargs: user-settable additional arguments passed to CMake."
+ echo "-configureonly: do not perform any builds; just configure the build."
+ echo "-cross: optional argument to signify cross compilation,"
+ echo " will use ROOTFS_DIR environment variable if set."
+ echo "-gcc: optional argument to build using gcc in PATH."
+ echo "-gccx.y: optional argument to build using gcc version x.y."
+ echo "-msbuildonunsupportedplatform: build managed binaries even if distro is not officially supported."
+ echo "-ninja: target ninja instead of GNU make"
+ echo "-numproc: set the number of build processes."
+ echo "-portablebuild: pass -portablebuild=false to force a non-portable build."
+ echo "-skipconfigure: skip build configuration."
+ echo "-skipgenerateversion: disable version generation even if MSBuild is supported."
+ echo "-stripsymbols: skip native image generation."
+ echo "-verbose: optional argument to enable verbose build output."
+ echo ""
+ echo "Additional Options:"
+ echo ""
+ for i in "${!usage_list[@]}"; do
+ echo "${usage_list[${i}]}"
+ done
+ echo ""
+ exit 1
+}
+
+# Use uname to determine what the CPU is.
+CPUName=$(uname -p)
+
+# Some Linux platforms report unknown for platform, but the arch for machine.
+if [[ "$CPUName" == "unknown" ]]; then
+ CPUName=$(uname -m)
+fi
+
+case "$CPUName" in
+ aarch64)
+ __BuildArch=arm64
+ __HostArch=arm64
+ ;;
+
+ amd64)
+ __BuildArch=x64
+ __HostArch=x64
+ ;;
+
+ armv7l)
+ echo "Unsupported CPU $CPUName detected, build might not succeed!"
+ __BuildArch=arm
+ __HostArch=arm
+ ;;
+
+ i686)
+ echo "Unsupported CPU $CPUName detected, build might not succeed!"
+ __BuildArch=x86
+ __HostArch=x86
+ ;;
+
+ x86_64)
+ __BuildArch=x64
+ __HostArch=x64
+ ;;
+
+ *)
+ echo "Unknown CPU $CPUName detected, configuring as if for x64"
+ __BuildArch=x64
+ __HostArch=x64
+ ;;
+esac
+
+# Use uname to determine what the OS is.
+OSName=$(uname -s)
+case "$OSName" in
+ Darwin)
+ __BuildOS=OSX
+ __HostOS=OSX
+ ;;
+
+ FreeBSD)
+ __BuildOS=FreeBSD
+ __HostOS=FreeBSD
+ ;;
+
+ Linux)
+ __BuildOS=Linux
+ __HostOS=Linux
+ ;;
+
+ NetBSD)
+ __BuildOS=NetBSD
+ __HostOS=NetBSD
+ ;;
+
+ OpenBSD)
+ __BuildOS=OpenBSD
+ __HostOS=OpenBSD
+ ;;
+
+ SunOS)
+ __BuildOS=SunOS
+ __HostOS=SunOS
+ ;;
+
+ *)
+ echo "Unsupported OS $OSName detected, configuring as if for Linux"
+ __BuildOS=Linux
+ __HostOS=Linux
+ ;;
+esac
+
+__msbuildonunsupportedplatform=0
+
+while :; do
+ if [[ "$#" -le 0 ]]; then
+ break
+ fi
+
+ lowerI="$(echo "$1" | awk '{print tolower($0)}')"
+ case "$lowerI" in
+ -\?|-h|--help)
+ usage
+ exit 1
+ ;;
+
+ arm|-arm)
+ __BuildArch=arm
+ ;;
+
+ arm64|-arm64)
+ __BuildArch=arm64
+ ;;
+
+ armel|-armel)
+ __BuildArch=armel
+ ;;
+
+ bindir|-bindir)
+ if [[ -n "$2" ]]; then
+ __RootBinDir="$2"
+ if [[ ! -d "$__RootBinDir" ]]; then
+ mkdir "$__RootBinDir"
+ fi
+ __RootBinParent=$(dirname "$__RootBinDir")
+ __RootBinName="${__RootBinDir##*/}"
+ __RootBinDir="$(cd "$__RootBinParent" &>/dev/null && printf %s/%s "$PWD" "$__RootBinName")"
+ shift
+ else
+ echo "ERROR: 'bindir' requires a non-empty option argument"
+ exit 1
+ fi
+ ;;
+
+ checked|-checked)
+ __BuildType=Checked
+ ;;
+
+ ci|-ci)
+ __ArcadeScriptArgs="--ci"
+ __ErrMsgPrefix="##vso[task.logissue type=error]"
+ ;;
+
+ clang*|-clang*)
+ __Compiler=clang
+ # clangx.y or clang-x.y
+ version="$(echo "$lowerI" | tr -d '[:alpha:]-=')"
+ parts=(${version//./ })
+ __CompilerMajorVersion="${parts[0]}"
+ __CompilerMinorVersion="${parts[1]}"
+ if [[ -z "$__CompilerMinorVersion" && "$__CompilerMajorVersion" -le 6 ]]; then
+ __CompilerMinorVersion=0;
+ fi
+ ;;
+
+ cmakeargs|-cmakeargs)
+ if [[ -n "$2" ]]; then
+ __CMakeArgs="$2 $__CMakeArgs"
+ shift
+ else
+ echo "ERROR: 'cmakeargs' requires a non-empty option argument"
+ exit 1
+ fi
+ ;;
+
+ configureonly|-configureonly)
+ __ConfigureOnly=1
+ __SkipMSCorLib=1
+ __SkipNuget=1
+ ;;
+
+ cross|-cross)
+ __CrossBuild=1
+ ;;
+
+ debug|-debug)
+ __BuildType=Debug
+ ;;
+
+ gcc*|-gcc*)
+ __Compiler=gcc
+ # gccx.y or gcc-x.y
+ version="$(echo "$lowerI" | tr -d '[:alpha:]-=')"
+ parts=(${version//./ })
+ __CompilerMajorVersion="${parts[0]}"
+ __CompilerMinorVersion="${parts[1]}"
+ ;;
+
+ msbuildonunsupportedplatform|-msbuildonunsupportedplatform)
+ __msbuildonunsupportedplatform=1
+ ;;
+
+ ninja|-ninja)
+ __UseNinja=1
+ ;;
+
+ numproc|-numproc)
+ if [[ -n "$2" ]]; then
+ __NumProc="$2"
+ shift
+ else
+ echo "ERROR: 'numproc' requires a non-empty option argument"
+ exit 1
+ fi
+ ;;
+
+ portablebuild=false|-portablebuild=false)
+ __PortableBuild=0
+ ;;
+
+ release|-release)
+ __BuildType=Release
+ ;;
+
+ skipconfigure|-skipconfigure)
+ __SkipConfigure=1
+ ;;
+
+ skipgenerateversion|-skipgenerateversion)
+ __SkipGenerateVersion=1
+ ;;
+
+ stripsymbols|-stripsymbols)
+ __CMakeArgs="-DSTRIP_SYMBOLS=true $__CMakeArgs"
+ ;;
+
+ verbose|-verbose)
+ __VerboseBuild=1
+ ;;
+
+ x86|-x86)
+ __BuildArch=x86
+ ;;
+
+ x64|-x64)
+ __BuildArch=x64
+ ;;
+
+ wasm|-wasm)
+ __BuildArch=wasm
+ ;;
+
+ *)
+ handle_arguments "$1" "$2"
+ if [[ "$__ShiftArgs" == 1 ]]; then
+ shift
+ __ShiftArgs=0
+ fi
+ ;;
+ esac
+
+ shift
+done
+
+# Get the number of processors available to the scheduler
+# Other techniques such as `nproc` only get the number of
+# processors available to a single process.
+platform=$(uname)
+if [[ "$platform" == "FreeBSD" ]]; then
+ __NumProc=$(sysctl hw.ncpu | awk '{ print $2+1 }')
+elif [[ "$platform" == "NetBSD" ]]; then
+ __NumProc=$(($(getconf NPROCESSORS_ONLN)+1))
+elif [[ "$platform" == "Darwin" ]]; then
+ __NumProc=$(($(getconf _NPROCESSORS_ONLN)+1))
+else
+ __NumProc=$(nproc --all)
+fi
+
+__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
+ export VERBOSE=1
+ __CommonMSBuildArgs="$__CommonMSBuildArgs /v:detailed"
+fi
+
+if [[ "$__PortableBuild" == 0 ]]; then
+ __CommonMSBuildArgs="$__CommonMSBuildArgs /p:PortableBuild=false"
+fi
+
+# Configure environment if we are doing a cross compile.
+if [[ "$__CrossBuild" == 1 ]]; then
+ export CROSSCOMPILE=1
+ if [[ ! -n "$ROOTFS_DIR" ]]; then
+ export ROOTFS_DIR="$__RepoRootDir/.tools/rootfs/$__BuildArch"
+ fi
+fi
+
+# init the target distro name
+initTargetDistroRid
+
+# Init if MSBuild for .NET Core is supported for this platform
+isMSBuildOnNETCoreSupported
diff --git a/eng/native/configureplatform.cmake b/eng/native/configureplatform.cmake
new file mode 100644
index 00000000000..f529f7ed5e3
--- /dev/null
+++ b/eng/native/configureplatform.cmake
@@ -0,0 +1,182 @@
+include(CheckPIESupported)
+
+# All code we build should be compiled as position independent
+check_pie_supported(OUTPUT_VARIABLE PIE_SUPPORT_OUTPUT LANGUAGES CXX)
+if(NOT MSVC AND NOT CMAKE_CXX_LINK_PIE_SUPPORTED)
+ message(WARNING "PIE is not supported at link time: ${PIE_SUPPORT_OUTPUT}.\n"
+ "PIE link options will not be passed to linker.")
+endif()
+set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+
+#----------------------------------------
+# Detect and set platform variable names
+# - for non-windows build platform & architecture is detected using inbuilt CMAKE variables and cross target component configure
+# - for windows we use the passed in parameter to CMAKE to determine build arch
+#----------------------------------------
+if(CMAKE_SYSTEM_NAME STREQUAL Linux)
+ set(CLR_CMAKE_HOST_UNIX 1)
+ if(CLR_CROSS_COMPONENTS_BUILD)
+ # CMAKE_HOST_SYSTEM_PROCESSOR returns the value of `uname -p` on host.
+ if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL amd64)
+ if(CLR_CMAKE_TARGET_ARCH STREQUAL "arm" OR CLR_CMAKE_TARGET_ARCH STREQUAL "armel")
+ if(CMAKE_CROSSCOMPILING)
+ set(CLR_CMAKE_HOST_UNIX_X86 1)
+ else()
+ set(CLR_CMAKE_HOST_UNIX_AMD64 1)
+ endif()
+ else()
+ set(CLR_CMAKE_HOST_UNIX_AMD64 1)
+ endif()
+ elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL i686)
+ set(CLR_CMAKE_HOST_UNIX_X86 1)
+ else()
+ clr_unknown_arch()
+ endif()
+ else()
+ # CMAKE_SYSTEM_PROCESSOR returns the value of `uname -p` on target.
+ # For the AMD/Intel 64bit architecture two different strings are common.
+ # Linux and Darwin identify it as "x86_64" while FreeBSD and netbsd uses the
+ # "amd64" string. Accept either of the two here.
+ if(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL amd64)
+ set(CLR_CMAKE_HOST_UNIX_AMD64 1)
+ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l)
+ set(CLR_CMAKE_HOST_UNIX_ARM 1)
+ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL arm)
+ set(CLR_CMAKE_HOST_UNIX_ARM 1)
+ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64)
+ set(CLR_CMAKE_HOST_UNIX_ARM64 1)
+ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL i686)
+ set(CLR_CMAKE_HOST_UNIX_X86 1)
+ else()
+ clr_unknown_arch()
+ endif()
+ endif()
+ set(CLR_CMAKE_HOST_LINUX 1)
+
+ # Detect Linux ID
+ set(LINUX_ID_FILE "/etc/os-release")
+ if(CMAKE_CROSSCOMPILING)
+ set(LINUX_ID_FILE "${CMAKE_SYSROOT}${LINUX_ID_FILE}")
+ endif()
+
+ execute_process(
+ COMMAND bash -c "source ${LINUX_ID_FILE} && echo \$ID"
+ OUTPUT_VARIABLE CLR_CMAKE_LINUX_ID
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ if(DEFINED CLR_CMAKE_LINUX_ID)
+ if(CLR_CMAKE_LINUX_ID STREQUAL tizen)
+ set(CLR_CMAKE_TARGET_TIZEN_LINUX 1)
+ elseif(CLR_CMAKE_LINUX_ID STREQUAL alpine)
+ set(CLR_CMAKE_HOST_ALPINE_LINUX 1)
+ endif()
+ endif(DEFINED CLR_CMAKE_LINUX_ID)
+endif(CMAKE_SYSTEM_NAME STREQUAL Linux)
+
+if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
+ set(CLR_CMAKE_HOST_UNIX 1)
+ set(CLR_CMAKE_HOST_UNIX_AMD64 1)
+ set(CLR_CMAKE_HOST_DARWIN 1)
+ set(CMAKE_ASM_COMPILE_OBJECT "${CMAKE_C_COMPILER} <FLAGS> <DEFINES> <INCLUDES> -o <OBJECT> -c <SOURCE>")
+endif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
+
+if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
+ set(CLR_CMAKE_HOST_UNIX 1)
+ set(CLR_CMAKE_HOST_UNIX_AMD64 1)
+ set(CLR_CMAKE_HOST_FREEBSD 1)
+endif(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
+
+if(CMAKE_SYSTEM_NAME STREQUAL OpenBSD)
+ set(CLR_CMAKE_HOST_UNIX 1)
+ set(CLR_CMAKE_HOST_UNIX_AMD64 1)
+ set(CLR_CMAKE_HOST_OPENBSD 1)
+endif(CMAKE_SYSTEM_NAME STREQUAL OpenBSD)
+
+if(CMAKE_SYSTEM_NAME STREQUAL NetBSD)
+ set(CLR_CMAKE_HOST_UNIX 1)
+ set(CLR_CMAKE_HOST_UNIX_AMD64 1)
+ set(CLR_CMAKE_HOST_NETBSD 1)
+endif(CMAKE_SYSTEM_NAME STREQUAL NetBSD)
+
+if(CMAKE_SYSTEM_NAME STREQUAL SunOS)
+ set(CLR_CMAKE_HOST_UNIX 1)
+ EXECUTE_PROCESS(
+ COMMAND isainfo -n
+ OUTPUT_VARIABLE SUNOS_NATIVE_INSTRUCTION_SET
+ )
+ if(SUNOS_NATIVE_INSTRUCTION_SET MATCHES "amd64")
+ set(CLR_CMAKE_HOST_UNIX_AMD64 1)
+ set(CMAKE_SYSTEM_PROCESSOR "amd64")
+ else()
+ clr_unknown_arch()
+ endif()
+ set(CLR_CMAKE_HOST_SUNOS 1)
+endif(CMAKE_SYSTEM_NAME STREQUAL SunOS)
+
+#--------------------------------------------
+# This repo builds two set of binaries
+# 1. binaries which execute on target arch machine
+# - for such binaries host architecture & target architecture are same
+# - eg. coreclr.dll
+# 2. binaries which execute on host machine but target another architecture
+# - host architecture is different from target architecture
+# - eg. crossgen.exe - runs on x64 machine and generates nis targeting arm64
+# - for complete list of such binaries refer to file crosscomponents.cmake
+#-------------------------------------------------------------
+# Set HOST architecture variables
+if(CLR_CMAKE_HOST_UNIX_ARM)
+ set(CLR_CMAKE_HOST_ARCH_ARM 1)
+ set(CLR_CMAKE_HOST_ARCH "arm")
+elseif(CLR_CMAKE_HOST_UNIX_ARM64)
+ set(CLR_CMAKE_HOST_ARCH_ARM64 1)
+ set(CLR_CMAKE_HOST_ARCH "arm64")
+elseif(CLR_CMAKE_HOST_UNIX_AMD64)
+ set(CLR_CMAKE_HOST_ARCH_AMD64 1)
+ set(CLR_CMAKE_HOST_ARCH "x64")
+elseif(CLR_CMAKE_HOST_UNIX_X86)
+ set(CLR_CMAKE_HOST_ARCH_I386 1)
+ set(CLR_CMAKE_HOST_ARCH "x86")
+elseif(WIN32)
+ # CLR_CMAKE_HOST_ARCH is passed in as param to cmake
+ if (CLR_CMAKE_HOST_ARCH STREQUAL x64)
+ set(CLR_CMAKE_HOST_ARCH_AMD64 1)
+ elseif(CLR_CMAKE_HOST_ARCH STREQUAL x86)
+ set(CLR_CMAKE_HOST_ARCH_I386 1)
+ elseif(CLR_CMAKE_HOST_ARCH STREQUAL arm)
+ set(CLR_CMAKE_HOST_ARCH_ARM 1)
+ elseif(CLR_CMAKE_HOST_ARCH STREQUAL arm64)
+ set(CLR_CMAKE_HOST_ARCH_ARM64 1)
+ else()
+ clr_unknown_arch()
+ endif()
+endif()
+
+# Set TARGET architecture variables
+# Target arch will be a cmake param (optional) for both windows as well as non-windows build
+# if target arch is not specified then host & target are same
+if(NOT DEFINED CLR_CMAKE_TARGET_ARCH OR CLR_CMAKE_TARGET_ARCH STREQUAL "" )
+ set(CLR_CMAKE_TARGET_ARCH ${CLR_CMAKE_HOST_ARCH})
+endif()
+
+# Set target architecture variables
+if (CLR_CMAKE_TARGET_ARCH STREQUAL x64)
+ set(CLR_CMAKE_TARGET_ARCH_AMD64 1)
+ elseif(CLR_CMAKE_TARGET_ARCH STREQUAL x86)
+ set(CLR_CMAKE_TARGET_ARCH_I386 1)
+ elseif(CLR_CMAKE_TARGET_ARCH STREQUAL arm64)
+ set(CLR_CMAKE_TARGET_ARCH_ARM64 1)
+ elseif(CLR_CMAKE_TARGET_ARCH STREQUAL arm)
+ set(CLR_CMAKE_TARGET_ARCH_ARM 1)
+ elseif(CLR_CMAKE_TARGET_ARCH STREQUAL armel)
+ set(CLR_CMAKE_TARGET_ARCH_ARM 1)
+ set(ARM_SOFTFP 1)
+ else()
+ clr_unknown_arch()
+endif()
+
+# check if host & target arch combination are valid
+if(NOT(CLR_CMAKE_TARGET_ARCH STREQUAL CLR_CMAKE_HOST_ARCH))
+ if(NOT((CLR_CMAKE_HOST_ARCH_AMD64 AND CLR_CMAKE_TARGET_ARCH_ARM64) OR (CLR_CMAKE_HOST_ARCH_I386 AND CLR_CMAKE_TARGET_ARCH_ARM) OR (CLR_CMAKE_HOST_ARCH_AMD64 AND CLR_CMAKE_TARGET_ARCH_ARM)))
+ message(FATAL_ERROR "Invalid host and target arch combination")
+ endif()
+endif()
diff --git a/src/coreclr/functions.cmake b/eng/native/functions.cmake
index f11c56c8283..f11c56c8283 100644
--- a/src/coreclr/functions.cmake
+++ b/eng/native/functions.cmake
diff --git a/eng/native/gen-buildsys.sh b/eng/native/gen-buildsys.sh
index 32e82f2fd05..ae2e0eb2d0b 100755
--- a/eng/native/gen-buildsys.sh
+++ b/eng/native/gen-buildsys.sh
@@ -3,26 +3,14 @@
# This file invokes cmake and generates the build system for Clang.
#
-source="${BASH_SOURCE[0]}"
+scriptroot="$( cd -P "$( dirname "$0" )" && pwd )"
-# resolve $SOURCE until the file is no longer a symlink
-while [[ -h $source ]]; do
- scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
- source="$(readlink "$source")"
-
- # if $source was a relative symlink, we need to resolve it relative to the path where the
- # symlink file was located
- [[ $source != /* ]] && source="$scriptroot/$source"
-done
-scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
-
-if [ $# -lt 4 ]
-then
+if [[ "$#" -lt 4 ]]; then
echo "Usage..."
- echo "gen-buildsys.sh <path to top level CMakeLists.txt> <path to intermediate directory> <path to tryrun.cmake directory> <Architecture> <compiler> <compiler major version> <compiler minor version> [build flavor] [ninja] [scan-build] [cmakeargs]"
+ echo "gen-buildsys.sh <path to top level CMakeLists.txt> <path to tryrun.cmake directory> <path to intermediate directory> <Architecture> <compiler> <compiler major version> <compiler minor version> [build flavor] [ninja] [scan-build] [cmakeargs]"
echo "Specify the path to the top level CMake file."
- echo "Specify the path to the directory with tryrun.cmake file."
echo "Specify the path that the build system files are generated in."
+ echo "Specify the path to the directory with tryrun.cmake file."
echo "Specify the target architecture."
echo "Specify the name of compiler (clang or gcc)."
echo "Specify the major version of compiler."
@@ -41,7 +29,7 @@ cxxCompiler="$compiler++"
majorVersion="$6"
minorVersion="$7"
-if [ "$compiler" = "gcc" ]; then cxxCompiler="g++"; fi
+if [[ "$compiler" == "gcc" ]]; then cxxCompiler="g++"; fi
check_version_exists() {
desired_version=-1
@@ -58,38 +46,38 @@ check_version_exists() {
echo "$desired_version"
}
-if [ -z "$CLR_CC" ]; then
+if [[ -z "$CLR_CC" ]]; then
# Set default versions
- if [ -z "$majorVersion" ]; then
+ if [[ -z "$majorVersion" ]]; then
# note: gcc (all versions) and clang versions higher than 6 do not have minor version in file name, if it is zero.
- if [ "$compiler" = "clang" ]; then versions=( 9 8 7 6.0 5.0 4.0 3.9 3.8 3.7 3.6 3.5 )
- elif [ "$compiler" = "gcc" ]; then versions=( 9 8 7 6 5 4.9 ); fi
+ if [[ "$compiler" == "clang" ]]; then versions=( 9 8 7 6.0 5.0 4.0 3.9 3.8 3.7 3.6 3.5 )
+ elif [[ "$compiler" == "gcc" ]]; then versions=( 9 8 7 6 5 4.9 ); fi
for version in "${versions[@]}"; do
parts=(${version//./ })
desired_version="$(check_version_exists "${parts[0]}" "${parts[1]}")"
- if [ "$desired_version" != "-1" ]; then majorVersion="${parts[0]}"; break; fi
+ if [[ "$desired_version" != "-1" ]]; then majorVersion="${parts[0]}"; break; fi
done
- if [ -z "$majorVersion" ]; then
+ if [[ -z "$majorVersion" ]]; then
if command -v "$compiler" > /dev/null; then
- if [ "$(uname)" != "Darwin" ]; then
+ if [[ "$(uname)" != "Darwin" ]]; then
echo "WARN: Specific version of $compiler not found, falling back to use the one in PATH."
fi
- export CC="$(command -v "$compiler")"
- export CXX="$(command -v "$cxxCompiler")"
+ CC="$(command -v "$compiler")"
+ CXX="$(command -v "$cxxCompiler")"
else
echo "ERROR: No usable version of $compiler found."
exit 1
fi
else
- if [ "$compiler" = "clang" ] && [ "$majorVersion" -lt 5 ]; then
- if [ "$build_arch" = "arm" ] || [ "$build_arch" = "armel" ]; then
+ if [[ "$compiler" == "clang" && "$majorVersion" -lt 5 ]]; then
+ if [[ "$build_arch" == "arm" || "$build_arch" == "armel" ]]; then
if command -v "$compiler" > /dev/null; then
echo "WARN: Found clang version $majorVersion which is not supported on arm/armel architectures, falling back to use clang from PATH."
- export CC="$(command -v "$compiler")"
- export CXX="$(command -v "$cxxCompiler")"
+ CC="$(command -v "$compiler")"
+ CXX="$(command -v "$cxxCompiler")"
else
echo "ERROR: Found clang version $majorVersion which is not supported on arm/armel architectures, and there is no clang in PATH."
exit 1
@@ -99,34 +87,36 @@ if [ -z "$CLR_CC" ]; then
fi
else
desired_version="$(check_version_exists "$majorVersion" "$minorVersion")"
- if [ "$desired_version" = "-1" ]; then
+ if [[ "$desired_version" == "-1" ]]; then
echo "ERROR: Could not find specific version of $compiler: $majorVersion $minorVersion."
exit 1
fi
fi
- if [ -z "$CC" ]; then
- export CC="$(command -v "$compiler$desired_version")"
- export CXX="$(command -v "$cxxCompiler$desired_version")"
- if [ -z "$CXX" ]; then export CXX="$(command -v "$cxxCompiler")"; fi
+ if [[ -z "$CC" ]]; then
+ CC="$(command -v "$compiler$desired_version")"
+ CXX="$(command -v "$cxxCompiler$desired_version")"
+ if [[ -z "$CXX" ]]; then CXX="$(command -v "$cxxCompiler")"; fi
fi
else
- if [ ! -f "$CLR_CC" ]; then
+ if [[ ! -f "$CLR_CC" ]]; then
echo "ERROR: CLR_CC is set but path '$CLR_CC' does not exist"
exit 1
fi
- export CC="$CLR_CC"
- export CXX="$CLR_CXX"
+ CC="$CLR_CC"
+ CXX="$CLR_CXX"
fi
-if [ -z "$CC" ]; then
+if [[ -z "$CC" ]]; then
echo "ERROR: Unable to find $compiler."
exit 1
fi
-export CCC_CC="$CC"
-export CCC_CXX="$CXX"
-export SCAN_BUILD_COMMAND="$(command -v "scan-build$desired_version")"
+CCC_CC="$CC"
+CCC_CXX="$CXX"
+SCAN_BUILD_COMMAND="$(command -v "scan-build$desired_version")"
+
+export CC CCC_CC CXX CCC_CXX SCAN_BUILD_COMMAND
buildtype=DEBUG
code_coverage=OFF
@@ -136,11 +126,11 @@ generator="Unix Makefiles"
__UnprocessedCMakeArgs=""
for i in "${@:8}"; do
- upperI="$(echo $i | awk '{print toupper($0)}')"
- case $upperI in
+ upperI="$(echo "$i" | awk '{print toupper($0)}')"
+ case "$upperI" in
# Possible build types are DEBUG, CHECKED, RELEASE, RELWITHDEBINFO.
DEBUG | CHECKED | RELEASE | RELWITHDEBINFO)
- buildtype=$upperI
+ buildtype="$upperI"
;;
NINJA)
generator=Ninja
@@ -154,26 +144,29 @@ for i in "${@:8}"; do
esac
done
-OS=`uname`
-
cmake_extra_defines=
-if [ "$CROSSCOMPILE" == "1" ]; then
+if [[ "$CROSSCOMPILE" == "1" ]]; then
if ! [[ -n "$ROOTFS_DIR" ]]; then
echo "ROOTFS_DIR not set for crosscompile"
exit 1
fi
- export TARGET_BUILD_ARCH=$build_arch
- cmake_extra_defines="$cmake_extra_defines -C $tryrun_dir/tryrun.cmake"
+
+ TARGET_BUILD_ARCH="$build_arch"
+ export TARGET_BUILD_ARCH
+
+ if [[ -n "$tryrun_dir" ]]; then
+ cmake_extra_defines="$cmake_extra_defines -C $tryrun_dir/tryrun.cmake"
+ fi
cmake_extra_defines="$cmake_extra_defines -DCMAKE_TOOLCHAIN_FILE=$scriptroot/../common/cross/toolchain.cmake"
fi
-if [ "$build_arch" == "armel" ]; then
+if [[ "$build_arch" == "armel" ]]; then
cmake_extra_defines="$cmake_extra_defines -DARM_SOFTFP=1"
fi
cmake_command=$(command -v cmake)
-if [[ "$scan_build" == "ON" && "$SCAN_BUILD_COMMAND" != "" ]]; then
+if [[ "$scan_build" == "ON" && -n "$SCAN_BUILD_COMMAND" ]]; then
cmake_command="$SCAN_BUILD_COMMAND $cmake_command"
fi
diff --git a/src/coreclr/init-distro-rid.sh b/eng/native/init-distro-rid.sh
index 8868c9b3663..8868c9b3663 100755..100644
--- a/src/coreclr/init-distro-rid.sh
+++ b/eng/native/init-distro-rid.sh
diff --git a/eng/pipelines/installer/jobs/base-job.yml b/eng/pipelines/installer/jobs/base-job.yml
index 385762a03cf..18675962bc2 100644
--- a/eng/pipelines/installer/jobs/base-job.yml
+++ b/eng/pipelines/installer/jobs/base-job.yml
@@ -183,6 +183,8 @@ jobs:
# lowercase for RID format. (Detection normally converts, but we're preventing it.)
- name: OutputRidArg
value: /p:OutputRid=linux-musl-${{ parameters.archType }}
+ - name: _PortableBuild
+ value: true
- name: BuildArguments
value: >-
diff --git a/eng/pipelines/libraries/base-job.yml b/eng/pipelines/libraries/base-job.yml
index e9ac1f42911..a08275e2a38 100644
--- a/eng/pipelines/libraries/base-job.yml
+++ b/eng/pipelines/libraries/base-job.yml
@@ -3,6 +3,7 @@ parameters:
osGroup: ''
archType: ''
osSubgroup: ''
+ crossrootfsDir: ''
framework: ''
isOfficialBuild: false
isOfficialAllConfigurations: false
@@ -50,6 +51,9 @@ jobs:
- ${{ if ne(parameters.testScope, '') }}:
- _testScopeArg: -testscope ${{ parameters.testScope }}
+ - ${{ if eq(parameters.osGroup, 'Linux') }}:
+ - _crossBuildPropertyArg: /p:CrossBuild=${{ ne(parameters.crossrootfsDir, '') }}
+
- ${{ if and(eq(parameters.osGroup, 'Linux'), eq(parameters.osSubGroup, '_musl')) }}:
- _runtimeOSArg: /p:RuntimeOS=linux-musl
@@ -98,7 +102,7 @@ jobs:
- ${{ if eq(parameters.isOfficialBuild, 'true') }}:
- _stripSymbolsArg: -stripSymbols
- - _buildArguments: -configuration ${{ parameters.buildConfig }} -ci -arch ${{ parameters.archType }} $(_finalFrameworkArg) $(_stripSymbolsArg) $(_testScopeArg) $(_warnAsErrorArg) $(_runtimeOSArg) $(_msbuildCommonParameters) $(_runtimeArtifactsPathArg)
+ - _buildArguments: -configuration ${{ parameters.buildConfig }} -ci -arch ${{ parameters.archType }} $(_finalFrameworkArg) $(_stripSymbolsArg) $(_testScopeArg) $(_warnAsErrorArg) $(_runtimeOSArg) $(_msbuildCommonParameters) $(_runtimeArtifactsPathArg) $(_crossBuildPropertyArg)
- ${{ parameters.variables }}
dependsOn:
diff --git a/eng/pipelines/libraries/build-job.yml b/eng/pipelines/libraries/build-job.yml
index 0e3e3b8cfb3..7fdc4e7c868 100644
--- a/eng/pipelines/libraries/build-job.yml
+++ b/eng/pipelines/libraries/build-job.yml
@@ -3,6 +3,7 @@ parameters:
osGroup: ''
osSubgroup: ''
archType: ''
+ crossrootfsDir: ''
framework: netcoreapp
isOfficialBuild: false
isOfficialAllConfigurations: false
@@ -31,6 +32,7 @@ jobs:
osGroup: ${{ parameters.osGroup }}
osSubgroup: ${{ parameters.osSubgroup }}
archType: ${{ parameters.archType }}
+ crossrootfsDir: ${{ parameters.crossrootfsDir }}
framework: ${{ parameters.framework }}
isOfficialBuild: ${{ parameters.isOfficialBuild }}
isOfficialAllConfigurations: ${{ parameters.isOfficialAllConfigurations }}
diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt
index 8b83a03c5b4..30c01e5ac24 100644
--- a/src/coreclr/CMakeLists.txt
+++ b/src/coreclr/CMakeLists.txt
@@ -6,7 +6,7 @@ cmake_policy(SET CMP0042 NEW)
project(CoreCLR)
# Include cmake functions
-include(functions.cmake)
+include(${CLR_ENG_NATIVE_DIR}/functions.cmake)
if (WIN32)
message(STATUS "VS_PLATFORM_TOOLSET is ${CMAKE_VS_PLATFORM_TOOLSET}")
diff --git a/src/coreclr/_build-commons.sh b/src/coreclr/_build-commons.sh
index b6011844488..8bac206f28f 100755
--- a/src/coreclr/_build-commons.sh
+++ b/src/coreclr/_build-commons.sh
@@ -1,293 +1,14 @@
#!/usr/bin/env bash
-initTargetDistroRid()
-{
- source "${__ProjectDir}/init-distro-rid.sh"
+usage_list+=("-coverage: optional argument to enable code coverage build (currently supported only for Linux and OSX).")
+usage_list+=("-skipmanaged: do not build managed components.")
+usage_list+=("-skipnative: do not build native components.")
- local passedRootfsDir=""
-
- # Only pass ROOTFS_DIR if cross is specified.
- if [ "$__CrossBuild" = 1 ]; then
- passedRootfsDir="${ROOTFS_DIR}"
- fi
-
- initDistroRidGlobal "$__BuildOS" "$__BuildArch" "$__PortableBuild" "$passedRootfsDir"
-}
-
-isMSBuildOnNETCoreSupported()
-{
- __isMSBuildOnNETCoreSupported="$__msbuildonunsupportedplatform"
-
- if [ "$__isMSBuildOnNETCoreSupported" = 1 ]; then
- return
- fi
-
- if [ "$__SkipManaged" = 1 ]; then
- __isMSBuildOnNETCoreSupported=0
- return
- fi
-
- if [ "$__HostOS" = "Linux" ] && { [ "$__HostArch" = "x64" ] || [ "$__HostArch" = "arm" ] || [ "$__HostArch" = "arm64" ]; }; then
- __isMSBuildOnNETCoreSupported=1
- elif [ "$__HostArch" = "x64" ] && { [ "$__HostOS" = "OSX" ] || [ "$__HostOS" = "FreeBSD" ]; }; then
- __isMSBuildOnNETCoreSupported=1
- fi
-}
-
-usage()
-{
- echo "Usage: $0 <options>"
- echo ""
- echo "Common Options:"
- echo ""
- echo "BuildArch can be: -x64, -x86, -arm, -armel, -arm64"
- echo "BuildType can be: -debug, -checked, -release"
- echo "-bindir - output directory (defaults to $__ProjectRoot/artifacts)"
- echo "-clang - optional argument to build using clang in PATH (default)."
- echo "-clangx.y - optional argument to build using clang version x.y."
- echo "-cmakeargs - user-settable additional arguments passed to CMake."
- echo "-configureonly - do not perform any builds; just configure the build."
- echo "-coverage - optional argument to enable code coverage build (currently supported only for Linux and OSX)."
- echo "-cross - optional argument to signify cross compilation,"
- echo " - will use ROOTFS_DIR environment variable if set."
- echo "-gcc - optional argument to build using gcc in PATH."
- echo "-gccx.y - optional argument to build using gcc version x.y."
- echo "-msbuildonunsupportedplatform - build managed binaries even if distro is not officially supported."
- echo "-ninja - target ninja instead of GNU make"
- echo "-numproc - set the number of build processes."
- echo "-portablebuild - pass -portablebuild=false to force a non-portable build."
- echo "-skipconfigure - skip build configuration."
- echo "-skipmanaged - do not build managed components."
- echo "-skipnative - do not build native components."
- echo "-skipgenerateversion - disable version generation even if MSBuild is supported."
- echo "-verbose - optional argument to enable verbose build output."
- echo ""
- echo "Additional Options:"
- echo ""
- for i in "${!usage_list[@]}"; do
- echo "${usage_list[${i}]}"
- done
- echo ""
- exit 1
-}
-
-# Use uname to determine what the CPU is.
-CPUName=$(uname -p)
-
-# Some Linux platforms report unknown for platform, but the arch for machine.
-if [ "$CPUName" = "unknown" ]; then
- CPUName=$(uname -m)
-fi
-
-case "$CPUName" in
- aarch64)
- __BuildArch=arm64
- __HostArch=arm64
- ;;
-
- amd64)
- __BuildArch=x64
- __HostArch=x64
- ;;
-
- armv7l)
- echo "Unsupported CPU $CPUName detected, build might not succeed!"
- __BuildArch=arm
- __HostArch=arm
- ;;
-
- i686)
- echo "Unsupported CPU $CPUName detected, build might not succeed!"
- __BuildArch=x86
- __HostArch=x86
- ;;
-
- x86_64)
- __BuildArch=x64
- __HostArch=x64
- ;;
-
- *)
- echo "Unknown CPU $CPUName detected, configuring as if for x64"
- __BuildArch=x64
- __HostArch=x64
- ;;
-esac
-
-# Use uname to determine what the OS is.
-OSName=$(uname -s)
-case "$OSName" in
- Darwin)
- __BuildOS=OSX
- __HostOS=OSX
- ;;
-
- FreeBSD)
- __BuildOS=FreeBSD
- __HostOS=FreeBSD
- ;;
-
- Linux)
- __BuildOS=Linux
- __HostOS=Linux
- ;;
-
- NetBSD)
- __BuildOS=NetBSD
- __HostOS=NetBSD
- ;;
-
- OpenBSD)
- __BuildOS=OpenBSD
- __HostOS=OpenBSD
- ;;
-
- SunOS)
- __BuildOS=SunOS
- __HostOS=SunOS
- ;;
-
- *)
- echo "Unsupported OS $OSName detected, configuring as if for Linux"
- __BuildOS=Linux
- __HostOS=Linux
- ;;
-esac
-
-while :; do
- if [ "$#" -le 0 ]; then
- break
- fi
-
- lowerI="$(echo "$1" | awk '{print tolower($0)}')"
- case "$lowerI" in
- -\?|-h|--help)
- usage
- exit 1
- ;;
-
- arm|-arm)
- __BuildArch=arm
- ;;
-
- arm64|-arm64)
- __BuildArch=arm64
- ;;
-
- armel|-armel)
- __BuildArch=armel
- ;;
-
- bindir|-bindir)
- if [ -n "$2" ]; then
- __RootBinDir="$2"
- if [ ! -d "$__RootBinDir" ]; then
- mkdir "$__RootBinDir"
- fi
- __RootBinParent=$(dirname "$__RootBinDir")
- __RootBinName="${__RootBinDir##*/}"
- __RootBinDir="$(cd "$__RootBinParent" &>/dev/null && printf %s/%s "$PWD" "$__RootBinName")"
- shift
- else
- echo "ERROR: 'bindir' requires a non-empty option argument"
- exit 1
- fi
- ;;
-
- checked|-checked)
- __BuildType=Checked
- ;;
-
- ci|-ci)
- __ArcadeScriptArgs="--ci"
- __ErrMsgPrefix="##vso[task.logissue type=error]"
- ;;
-
- clang*|-clang*)
- __Compiler=clang
- # clangx.y or clang-x.y
- version="$(echo "$lowerI" | tr -d '[:alpha:]-=')"
- parts=(${version//./ })
- __CompilerMajorVersion="${parts[0]}"
- __CompilerMinorVersion="${parts[1]}"
- if [ -z "$__CompilerMinorVersion" ] && [ "$__CompilerMajorVersion" -le 6 ]; then
- __CompilerMinorVersion=0;
- fi
- ;;
-
- cmakeargs|-cmakeargs)
- if [ -n "$2" ]; then
- __cmakeargs="$__cmakeargs $2"
- shift
- else
- echo "ERROR: 'cmakeargs' requires a non-empty option argument"
- exit 1
- fi
- ;;
-
- configureonly|-configureonly)
- __ConfigureOnly=1
- __SkipMSCorLib=1
- __SkipNuget=1
- ;;
+handle_arguments() {
+ case "$1" in
coverage|-coverage)
- __CodeCoverage=Coverage
- ;;
-
- cross|-cross)
- __CrossBuild=1
- ;;
-
- debug|-debug)
- __BuildType=Debug
- ;;
-
- gcc*|-gcc*)
- __Compiler=gcc
- # gccx.y or gcc-x.y
- version="$(echo "$lowerI" | tr -d '[:alpha:]-=')"
- parts=(${version//./ })
- __CompilerMajorVersion="${parts[0]}"
- __CompilerMinorVersion="${parts[1]}"
- ;;
-
- msbuildonunsupportedplatform|-msbuildonunsupportedplatform)
- __msbuildonunsupportedplatform=1
- ;;
-
- ninja|-ninja)
- __UseNinja=1
- ;;
-
- numproc|-numproc)
- if [ -n "$2" ]; then
- __NumProc="$2"
- shift
- else
- echo "ERROR: 'numproc' requires a non-empty option argument"
- exit 1
- fi
- ;;
-
- portablebuild=false|-portablebuild=false)
- __PortableBuild=0
- ;;
-
- rebuild|-rebuild)
- __RebuildTests=1
- ;;
-
- release|-release)
- __BuildType=Release
- ;;
-
- skipconfigure|-skipconfigure)
- __SkipConfigure=1
- ;;
-
- skipgenerateversion|-skipgenerateversion)
- __SkipGenerateVersion=1
+ __CodeCoverage=1
;;
skipmanaged|-skipmanaged)
@@ -301,44 +22,10 @@ while :; do
__CopyNativeProjectsAfterCombinedTestBuild=false
;;
- verbose|-verbose)
- __VerboseBuild=1
- ;;
-
- x86|-x86)
- __BuildArch=x86
- ;;
-
- x64|-x64)
- __BuildArch=x64
- ;;
-
*)
- handle_arguments "$1"
+ handle_arguments_local "$1"
;;
esac
+}
- shift
-done
-
-# Get the number of processors available to the scheduler
-# Other techniques such as `nproc` only get the number of
-# processors available to a single process.
-platform=$(uname)
-if [ "$platform" = "FreeBSD" ]; then
- __NumProc=$(sysctl hw.ncpu | awk '{ print $2+1 }')
-elif [ "$platform" = "NetBSD" ]; then
- __NumProc=$(($(getconf NPROCESSORS_ONLN)+1))
-elif [ "$platform" = "Darwin" ]; then
- __NumProc=$(($(getconf _NPROCESSORS_ONLN)+1))
-else
- __NumProc=$(nproc --all)
-fi
-
-__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
- export VERBOSE=1
- __CommonMSBuildArgs="$__CommonMSBuildArgs /v:detailed"
-fi
+source "$__RepoRootDir"/eng/native/build-commons.sh
diff --git a/src/coreclr/build-packages.sh b/src/coreclr/build-packages.sh
index a0c7b1fce00..9617440e44b 100755
--- a/src/coreclr/build-packages.sh
+++ b/src/coreclr/build-packages.sh
@@ -12,12 +12,12 @@ usage()
initDistroRid()
{
- source ${__ProjectRoot}/init-distro-rid.sh
+ source $__RepoRootDir/eng/native/init-distro-rid.sh
local passedRootfsDir=""
# Only pass ROOTFS_DIR if __DoCrossArchBuild is specified.
- if (( ${__CrossBuild} == 1 )); then
+ if (( __CrossBuild == 1 )); then
passedRootfsDir=${ROOTFS_DIR}
fi
diff --git a/src/coreclr/build-test.sh b/src/coreclr/build-test.sh
index 274995f11c8..1898c16d5f0 100755
--- a/src/coreclr/build-test.sh
+++ b/src/coreclr/build-test.sh
@@ -2,7 +2,7 @@
build_test_wrappers()
{
- if [ $__BuildTestWrappers -ne -0 ]; then
+ if [[ "$__BuildTestWrappers" -ne -0 ]]; then
echo "${__MsgPrefix}Creating test wrappers..."
export __Exclude="${__ProjectDir}/tests/issues.targets"
@@ -10,12 +10,12 @@ build_test_wrappers()
buildVerbosity="Summary"
- if [ $__VerboseBuild == 1 ]; then
+ if [[ "$__VerboseBuild" == 1 ]]; then
buildVerbosity="Diag"
fi
# Set up directories and file names
- __BuildLogRootName=$subDirectoryName
+ __BuildLogRootName="$subDirectoryName"
__BuildLog="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.log"
__BuildWrn="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.wrn"
__BuildErr="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.err"
@@ -27,9 +27,10 @@ build_test_wrappers()
nextCommand="\"${__DotNetCli}\" msbuild \"${__ProjectDir}/tests/src/runtest.proj\" /nodereuse:false /p:BuildWrappers=true /p:TargetsWindows=false $__Logging /p:__BuildOS=$__BuildOS /p:__BuildType=$__BuildType /p:__BuildArch=$__BuildArch"
eval $nextCommand
- if [ $? -ne 0 ]; then
+ local exitCode="$?"
+ if [[ "$exitCode" -ne 0 ]]; then
echo "${__ErrMsgPrefix}${__MsgPrefix}Error: XUnit wrapper build failed. Refer to the build log files for details (above)"
- exit 1
+ exit "$exitCode"
else
echo "XUnit Wrappers have been built."
echo { "\"build_os\"": "\"${__BuildOS}\"", "\"build_arch\"": "\"${__BuildArch}\"", "\"build_type\"": "\"${__BuildType}\"" } > "${__TestWorkingDir}/build_info.json"
@@ -42,20 +43,20 @@ generate_layout()
{
echo "${__MsgPrefix}Creating test overlay..."
- __TestDir=$__ProjectDir/tests
- __ProjectFilesDir=$__TestDir
- __TestBinDir=$__TestWorkingDir
+ __TestDir="$__ProjectDir"/tests
+ __ProjectFilesDir="$__TestDir"
+ __TestBinDir="$__TestWorkingDir"
- if [ $__RebuildTests -ne 0 ]; then
- if [ -d "${__TestBinDir}" ]; then
+ if [[ "$__RebuildTests" -ne 0 ]]; then
+ if [[ -d "${__TestBinDir}" ]]; then
echo "Removing tests build dir: ${__TestBinDir}"
- rm -rf $__TestBinDir
+ rm -rf "$__TestBinDir"
fi
fi
__CMakeBinDir="${__TestBinDir}"
- if [ -z "$__TestIntermediateDir" ]; then
+ if [[ -z "$__TestIntermediateDir" ]]; then
__TestIntermediateDir="tests/obj/${__BuildOS}.${__BuildArch}.${__BuildType}"
fi
@@ -64,17 +65,17 @@ generate_layout()
echo "__BuildType: ${__BuildType}"
echo "__TestIntermediateDir: ${__TestIntermediateDir}"
- if [ ! -f "$__TestBinDir" ]; then
+ if [[ ! -f "$__TestBinDir" ]]; then
echo "Creating TestBinDir: ${__TestBinDir}"
- mkdir -p $__TestBinDir
+ mkdir -p "$__TestBinDir"
fi
- if [ ! -f "$__LogsDir" ]; then
+ if [[ ! -f "$__LogsDir" ]]; then
echo "Creating LogsDir: ${__LogsDir}"
- mkdir -p $__LogsDir
+ mkdir -p "$__LogsDir"
fi
- if [ ! -f "$__MsbuildDebugLogsDir" ]; then
+ if [[ ! -f "$__MsbuildDebugLogsDir" ]]; then
echo "Creating MsbuildDebugLogsDir: ${__MsbuildDebugLogsDir}"
- mkdir -p $__MsbuildDebugLogsDir
+ mkdir -p "$__MsbuildDebugLogsDir"
fi
# Set up the directory for MSBuild debug logs.
@@ -90,51 +91,53 @@ generate_layout()
build_MSBuild_projects "Restore_Packages" "${__ProjectDir}/tests/build.proj" "Restore product binaries (build tests)" "/t:BatchRestorePackages"
- if [ -n "$__UpdateInvalidPackagesArg" ]; then
+ if [[ -n "$__UpdateInvalidPackagesArg" ]]; then
__up="/t:UpdateInvalidPackageVersions"
fi
echo "${__MsgPrefix}Creating test overlay..."
- if [ -z "$xUnitTestBinBase" ]; then
- xUnitTestBinBase=$__TestWorkingDir
+ if [[ -z "$xUnitTestBinBase" ]]; then
+ xUnitTestBinBase="$__TestWorkingDir"
fi
- export CORE_ROOT=$xUnitTestBinBase/Tests/Core_Root
+ export CORE_ROOT="$xUnitTestBinBase"/Tests/Core_Root
- if [ -d "${CORE_ROOT}" ]; then
- rm -rf $CORE_ROOT
+ if [[ -d "${CORE_ROOT}" ]]; then
+ rm -rf "$CORE_ROOT"
fi
- mkdir -p $CORE_ROOT
+ mkdir -p "$CORE_ROOT"
build_MSBuild_projects "Tests_Overlay_Managed" "${__ProjectDir}/tests/src/runtest.proj" "Creating test overlay" "/t:CreateTestOverlay"
- chmod +x $__BinDir/corerun
- chmod +x $__CrossgenExe
+ chmod +x "$__BinDir"/corerun
+ chmod +x "$__CrossgenExe"
# Make sure to copy over the pulled down packages
- cp -r $__BinDir/* $CORE_ROOT/ > /dev/null
+ cp -r "$__BinDir"/* "$CORE_ROOT/" > /dev/null
- if [ "$__BuildOS" != "OSX" ]; then
+ if [[ "$__BuildOS" != "OSX" ]]; then
nextCommand="\"$__TestDir/setup-stress-dependencies.sh\" --arch=$__BuildArch --outputDir=$CORE_ROOT"
echo "Resolve runtime dependences via $nextCommand"
eval $nextCommand
- if [ $? != 0 ]; then
+
+ local exitCode="$?"
+ if [[ "$exitCode" != 0 ]]; then
echo "${__ErrMsgPrefix}${__MsgPrefix}Error: setup-stress-dependencies failed."
- exit 1
+ exit "$exitCode"
fi
fi
# Precompile framework assemblies with crossgen if required
- if [[ $__DoCrossgen != 0 || $__DoCrossgen2 != 0 ]]; then
+ if [[ "$__DoCrossgen" != 0 || "$__DoCrossgen2" != 0 ]]; then
precompile_coreroot_fx
fi
}
precompile_coreroot_fx()
{
- local overlayDir=$CORE_ROOT
+ local overlayDir="$CORE_ROOT"
local compilerName=Crossgen
# Read the exclusion file for this platform
@@ -142,24 +145,24 @@ precompile_coreroot_fx()
skipCrossGenFiles+=('System.Runtime.WindowsRuntime.dll')
# Temporary output folder for Crossgen2-compiled assemblies
- local outputDir=${overlayDir}/out
+ local outputDir="$overlayDir"/out
# Delete previously crossgened assemblies
- rm ${overlayDir}/*.ni.dll
+ rm "$overlayDir"/*.ni.dll
# Collect reference assemblies for Crossgen2
local crossgen2References=""
- if [[ $__DoCrossgen2 != 0 ]]; then
+ if [[ "$__DoCrossgen2" != 0 ]]; then
compilerName=Crossgen2
- mkdir ${outputDir}
+ mkdir "$outputDir"
skipCrossGenFiles+=('Microsoft.CodeAnalysis.CSharp.dll')
skipCrossGenFiles+=('Microsoft.CodeAnalysis.dll')
skipCrossGenFiles+=('Microsoft.CodeAnalysis.VisualBasic.dll')
- for reference in ${overlayDir}/*.dll; do
+ for reference in "$overlayDir"/*.dll; do
crossgen2References+=" -r:${reference}"
done
fi
@@ -170,49 +173,49 @@ precompile_coreroot_fx()
local failedToPrecompile=0
declare -a failedAssemblies
- filesToPrecompile=$(find -L $overlayDir -maxdepth 1 -iname Microsoft.\*.dll -o -iname System.\*.dll -type f)
+ filesToPrecompile=$(find -L "$overlayDir" -maxdepth 1 -iname Microsoft.\*.dll -o -iname System.\*.dll -type f)
for fileToPrecompile in ${filesToPrecompile}; do
- local filename=${fileToPrecompile}
+ local filename="$fileToPrecompile"
if is_skip_crossgen_test "$(basename $filename)"; then
continue
fi
- echo Precompiling $filename
+ echo Precompiling "$filename"
- if [[ $__DoCrossgen != 0 ]]; then
- $__CrossgenExe /Platform_Assemblies_Paths $overlayDir $filename 1> $filename.stdout 2>$filename.stderr
+ if [[ "$__DoCrossgen" != 0 ]]; then
+ "$__CrossgenExe" /Platform_Assemblies_Paths "$overlayDir" "$filename" 1> "$filename".stdout 2> "$filename".stderr
fi
- if [[ $__DoCrossgen2 != 0 ]]; then
- ${overlayDir}/crossgen2/crossgen2 ${crossgen2References} -O --inputbubble --out ${outputDir}/$(basename $filename) $filename 1>$filename.stdout 2>$filename.stderr
+ if [[ "$__DoCrossgen2" != 0 ]]; then
+ "$overlayDir"/crossgen2/crossgen2 "$crossgen2References" -O --inputbubble --out "$outputDir"/"$(basename $filename)" "$filename" 1> "$filename".stdout 2> "$filename".stderr
fi
- local exitCode=$?
- if [[ $exitCode != 0 ]]; then
- if grep -q -e '0x80131018' $filename.stderr; then
+ local exitCode="$?"
+ if [[ "$exitCode" != 0 ]]; then
+ if grep -q -e '0x80131018' "$filename".stderr; then
printf "\n\t$filename is not a managed assembly.\n\n"
else
- echo Unable to precompile $filename, exit code is $exitCode.
- cat $filename.stdout
- cat $filename.stderr
+ echo Unable to precompile "$filename", exit code is "$exitCode".
+ cat "$filename".stdout
+ cat "$filename".stderr
failedAssemblies+=($(basename -- "$filename"))
failedToPrecompile=$((failedToPrecompile+1))
fi
else
- rm $filename.{stdout,stderr}
+ rm "$filename".{stdout,stderr}
fi
totalPrecompiled=$((totalPrecompiled+1))
- echo Processed: $totalPrecompiled, failed $failedToPrecompile
+ echo "Processed: $totalPrecompiled, failed $failedToPrecompile"
done
- if [[ $__DoCrossgen2 != 0 ]]; then
+ if [[ "$__DoCrossgen2" != 0 ]]; then
# Copy the Crossgen-compiled assemblies back to CORE_ROOT
- mv -f ${outputDir}/* ${overlayDir}/
- rm -r ${outputDir}
+ mv -f "$outputDir"/* "$overlayDir"/
+ rm -r "$outputDir"
fi
- if [[ $failedToPrecompile != 0 ]]; then
+ if [[ "$failedToPrecompile" != 0 ]]; then
echo Failed assemblies:
for assembly in "${failedAssemblies[@]}"; do
echo " $assembly"
@@ -226,7 +229,7 @@ declare -a skipCrossGenFiles
function is_skip_crossgen_test {
for skip in "${skipCrossGenFiles[@]}"; do
- if [ "$1" == "$skip" ]; then
+ if [[ "$1" == "$skip" ]]; then
return 0
fi
done
@@ -237,34 +240,34 @@ build_Tests()
{
echo "${__MsgPrefix}Building Tests..."
- __TestDir=$__ProjectDir/tests
- __ProjectFilesDir=$__TestDir
- __TestBinDir=$__TestWorkingDir
+ __TestDir="$__ProjectDir"/tests
+ __ProjectFilesDir="$__TestDir"
+ __TestBinDir="$__TestWorkingDir"
- if [ -f "${__TestWorkingDir}/build_info.json" ]; then
+ if [[ -f "${__TestWorkingDir}/build_info.json" ]]; then
rm "${__TestWorkingDir}/build_info.json"
fi
- if [ $__RebuildTests -ne 0 ]; then
- if [ -d "${__TestBinDir}" ]; then
+ if [[ "$__RebuildTests" -ne 0 ]]; then
+ if [[ -d "$__TestBinDir" ]]; then
echo "Removing tests build dir: ${__TestBinDir}"
- rm -rf $__TestBinDir
+ rm -rf "$__TestBinDir"
fi
fi
- export __CMakeBinDir="${__TestBinDir}"
- if [ ! -d "${__TestIntermediatesDir}" ]; then
- mkdir -p ${__TestIntermediatesDir}
+ export __CMakeBinDir="$__TestBinDir"
+ if [[ ! -d "$__TestIntermediatesDir" ]]; then
+ mkdir -p "$__TestIntermediatesDir"
fi
__NativeTestIntermediatesDir="${__TestIntermediatesDir}/Native"
- if [ ! -d "${__NativeTestIntermediatesDir}" ]; then
- mkdir -p ${__NativeTestIntermediatesDir}
+ if [[ ! -d "${__NativeTestIntermediatesDir}" ]]; then
+ mkdir -p "${__NativeTestIntermediatesDir}"
fi
__ManagedTestIntermediatesDir="${__TestIntermediatesDir}/Managed"
- if [ ! -d "${__ManagedTestIntermediatesDir}" ]; then
- mkdir -p ${__ManagedTestIntermediatesDir}
+ if [[ ! -d "${__ManagedTestIntermediatesDir}" ]]; then
+ mkdir -p "${__ManagedTestIntermediatesDir}"
fi
echo "__BuildOS: ${__BuildOS}"
@@ -274,17 +277,17 @@ build_Tests()
echo "__NativeTestIntermediatesDir: ${__NativeTestIntermediatesDir}"
echo "__ManagedTestIntermediatesDir: ${__ManagedTestIntermediatesDir}"
- if [ ! -f "$__TestBinDir" ]; then
+ if [[ ! -f "$__TestBinDir" ]]; then
echo "Creating TestBinDir: ${__TestBinDir}"
- mkdir -p $__TestBinDir
+ mkdir -p "$__TestBinDir"
fi
- if [ ! -f "$__LogsDir" ]; then
+ if [[ ! -f "$__LogsDir" ]]; then
echo "Creating LogsDir: ${__LogsDir}"
- mkdir -p $__LogsDir
+ mkdir -p "$__LogsDir"
fi
- if [ ! -f "$__MsbuildDebugLogsDir" ]; then
+ if [[ ! -f "$__MsbuildDebugLogsDir" ]]; then
echo "Creating MsbuildDebugLogsDir: ${__MsbuildDebugLogsDir}"
- mkdir -p $__MsbuildDebugLogsDir
+ mkdir -p "$__MsbuildDebugLogsDir"
fi
# Set up the directory for MSBuild debug logs.
@@ -298,30 +301,30 @@ build_Tests()
# ===
# =========================================================================================
- if [ ${__SkipRestorePackages} != 1 ]; then
+ if [[ "${__SkipRestorePackages}" != 1 ]]; then
build_MSBuild_projects "Restore_Product" "${__ProjectDir}/tests/build.proj" "Restore product binaries (build tests)" "/t:BatchRestorePackages"
- if [ $? -ne 0 ]; then
+ if [[ "$?" -ne 0 ]]; then
echo "${__ErrMsgPrefix}${__MsgPrefix}Error: package restoration failed. Refer to the build log files for details (above)"
exit 1
fi
fi
- if [ $__SkipNative != 1 ]; then
- build_native_projects "$__BuildArch" "${__NativeTestIntermediatesDir}"
+ if [[ "$__SkipNative" != 1 ]]; then
+ build_native "$__BuildArch" "$__TestDir" "$__ProjectRoot" "$__NativeTestIntermediatesDir" "CoreCLR test component"
- if [ $? -ne 0 ]; then
+ if [[ "$?" -ne 0 ]]; then
echo "${__ErrMsgPrefix}${__MsgPrefix}Error: native test build failed. Refer to the build log files for details (above)"
exit 1
fi
fi
- if [ $__SkipManaged != 1 ]; then
+ if [[ "$__SkipManaged" != 1 ]]; then
echo "Starting the Managed Tests Build..."
build_MSBuild_projects "Tests_Managed" "$__ProjectDir/tests/build.proj" "Managed tests build (build tests)" "$__up"
- if [ $? -ne 0 ]; then
+ if [[ "$?" -ne 0 ]]; then
echo "${__ErrMsgPrefix}${__MsgPrefix}Error: managed test build failed. Refer to the build log files for details (above)"
exit 1
else
@@ -329,7 +332,7 @@ build_Tests()
build_MSBuild_projects "Check_Test_Build" "${__ProjectDir}/tests/src/runtest.proj" "Check Test Build" "/t:CheckTestBuild"
- if [ $? -ne 0 ]; then
+ if [[ "$?" -ne 0 ]]; then
echo "${__ErrMsgPrefix}${__MsgPrefix}Error: Check Test Build failed."
exit 1
fi
@@ -340,38 +343,38 @@ build_Tests()
build_test_wrappers
fi
- if [ $__CopyNativeTestBinaries == 1 ]; then
+ if [[ "$__CopyNativeTestBinaries" == 1 ]]; then
echo "Copying native test binaries to output..."
build_MSBuild_projects "Tests_Managed" "$__ProjectDir/tests/build.proj" "Managed tests build (build tests)" "/t:CopyAllNativeProjectReferenceBinaries"
- if [ $? -ne 0 ]; then
+ if [[ "$?" -ne 0 ]]; then
echo "${__ErrMsgPrefix}${__MsgPrefix}Error: copying native test binaries failed. Refer to the build log files for details (above)"
exit 1
fi
fi
- if [ -n "$__UpdateInvalidPackagesArg" ]; then
+ if [[ -n "$__UpdateInvalidPackagesArg" ]]; then
__up="/t:UpdateInvalidPackageVersions"
fi
- if [ $__SkipGenerateLayout != 1 ]; then
+ if [[ "$__SkipGenerateLayout" != 1 ]]; then
generate_layout
fi
}
build_MSBuild_projects()
{
- subDirectoryName=$1
+ subDirectoryName="$1"
shift
- projectName=$1
+ projectName="$1"
shift
stepName="$1"
shift
extraBuildParameters=("$@")
# Set up directories and file names
- __BuildLogRootName=$subDirectoryName
+ __BuildLogRootName="$subDirectoryName"
__BuildLog="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.log"
__BuildWrn="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.wrn"
__BuildErr="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.err"
@@ -387,7 +390,7 @@ build_MSBuild_projects()
__AppendToLog=false
- if [ -n "$__priority1" ]; then
+ if [[ -n "$__priority1" ]]; then
export __NumberOfTestGroups=10
fi
@@ -397,7 +400,7 @@ build_MSBuild_projects()
__msbuildWrn="\"/flp1:WarningsOnly;LogFile=${__BuildWrn};Append=${__AppendToLog}\""
__msbuildErr="\"/flp2:ErrorsOnly;LogFile=${__BuildErr};Append=${__AppendToLog}\""
- export __TestGroupToBuild=$testGroupToBuild
+ export __TestGroupToBuild="$testGroupToBuild"
# Generate build command
buildArgs=("$projectName")
@@ -417,7 +420,7 @@ build_MSBuild_projects()
eval $nextCommand
# Make sure everything is OK
- if [ $? -ne 0 ]; then
+ if [[ "$?" -ne 0 ]]; then
echo "${__ErrMsgPrefix}${__MsgPrefix}Failed to build $stepName. See the build logs:"
echo " $__BuildLog"
echo " $__BuildWrn"
@@ -449,7 +452,7 @@ build_MSBuild_projects()
eval $nextCommand
# Make sure everything is OK
- if [ $? -ne 0 ]; then
+ if [[ "$?" -ne 0 ]]; then
echo "${__ErrMsgPrefix}${__MsgPrefix}Failed to build $stepName. See the build logs:"
echo " $__BuildLog"
echo " $__BuildWrn"
@@ -459,107 +462,22 @@ build_MSBuild_projects()
fi
}
-build_native_projects()
-{
- platformArch="$1"
- intermediatesForBuild="$2"
-
- extraCmakeArguments=""
- message="native tests assets"
-
- # All set to commence the build
- echo "Commencing build of $message for $__BuildOS.$__BuildArch.$__BuildType in $intermediatesForBuild"
-
- generator=""
- if [ $__UseNinja == 1 ]; then
- generator="ninja"
- if ! buildTool=$(command -v ninja || command -v ninja-build); then
- echo "Unable to locate ninja!" 1>&2
- exit 1
- fi
- fi
-
- if [ $__SkipConfigure == 0 ]; then
- # if msbuild is not supported, then set __SkipGenerateVersion to 1
- if [ $__isMSBuildOnNETCoreSupported == 0 ]; then __SkipGenerateVersion=1; fi
- # Drop version.c file
- __versionSourceFile="$intermediatesForBuild/version.c"
- if [ $__SkipGenerateVersion == 0 ]; then
- pwd
- $__RepoRootDir/eng/common/msbuild.sh $__RepoRootDir/eng/empty.csproj \
- /p:NativeVersionFile=$__versionSourceFile \
- /t:GenerateNativeVersionFile /restore \
- $__CommonMSBuildArgs $__UnprocessedBuildArgs
- if [ $? -ne 0 ]; then
- echo "${__ErrMsgPrefix}Failed to generate native version file."
- exit $?
- fi
- else
- # Generate the dummy version.c, but only if it 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
- echo $__versionSourceLine > $__versionSourceFile
- fi
- fi
-
- if [[ -n "$__CodeCoverage" ]]; then
- extraCmakeArguments="$extraCmakeArguments -DCLR_CMAKE_ENABLE_CODE_COVERAGE=1"
- fi
-
- engNativeDir="$__RepoRootDir/eng/native"
- __cmakeargs="$__cmakeargs -DCLR_ENG_NATIVE_DIR=\"$engNativeDir\""
- nextCommand="\"$engNativeDir/gen-buildsys.sh\" \"$__TestDir\" \"$__ProjectRoot\" \"$intermediatesForBuild\" $platformArch $__Compiler \"$__CompilerMajorVersion\" \"$__CompilerMinorVersion\" $__BuildType $generator $extraCmakeArguments $__cmakeargs"
- echo "Invoking $nextCommand"
- eval $nextCommand
-
- if [ $? != 0 ]; then
- echo "${__ErrMsgPrefix}Failed to generate $message build project!"
- exit 1
- fi
- fi
-
- if [ ! -f "$intermediatesForBuild/CMakeCache.txt" ]; then
- echo "${__ErrMsgPrefix}Unable to find generated build files for $message project!"
- exit 1
- fi
-
- # Build
- if [ $__ConfigureOnly == 1 ]; then
- echo "Finish configuration & skipping $message build."
- return
- fi
-
- echo "Executing cmake --build \"$intermediatesForBuild\" --target install -j $__NumProc"
-
- cmake --build "$intermediatesForBuild" --target install -j $__NumProc
-
- local exit_code=$?
- if [ $exit_code != 0 ]; then
- echo "${__ErrMsgPrefix}Failed to build $message."
- exit $exit_code
- fi
-
- echo "Native tests build success!"
-}
-
-usage_list=("-buildtestwrappersonly - only build the test wrappers.")
+usage_list=("-buildtestwrappersonly: only build the test wrappers.")
usage_list+=("-copynativeonly: Only copy the native test binaries to the managed output. Do not build the native or managed tests.")
-usage_list+=("-crossgen - Precompiles the framework managed assemblies in coreroot.")
-usage_list+=("-generatelayoutonly - only pull down dependencies and build coreroot.")
-usage_list+=("-priority1 - include priority=1 tests in the build.")
-usage_list+=("-runtests - run tests after building them.")
+usage_list+=("-crossgen: Precompiles the framework managed assemblies in coreroot.")
+usage_list+=("-generatelayoutonly: only pull down dependencies and build coreroot.")
+usage_list+=("-priority1: include priority=1 tests in the build.")
+usage_list+=("-rebuild: if tests have already been built - rebuild them.")
+usage_list+=("-runtests: run tests after building them.")
usage_list+=("-skipgeneratelayout: Do not generate the Core_Root layout.")
-usage_list+=("-skiprestorepackages - skip package restore.")
+usage_list+=("-skiprestorepackages: skip package restore.")
# Obtain the location of the bash script to figure out where the root of the repo is.
-__ProjectRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-__RepoRootDir=${__ProjectRoot}/../..
+__ProjectRoot="$(cd "$(dirname "$0")"; pwd -P)"
+__RepoRootDir="$(cd "$__ProjectRoot"/../..; pwd -P)"
-handle_arguments() {
- case $1 in
+handle_arguments_local() {
+ case "$1" in
buildtestwrappersonly|-buildtestwrappersonly)
__BuildTestWrappersOnly=1
;;
@@ -592,6 +510,10 @@ handle_arguments() {
__UnprocessedBuildArgs+=("/p:CLRTestPriorityToBuild=1")
;;
+ rebuild|-rebuild)
+ __RebuildTests=1
+ ;;
+
runtests|-runtests)
__RunTests=1
;;
@@ -633,6 +555,7 @@ __DoCrossgen2=0
__DotNetCli="$__RepoRootDir/dotnet.sh"
__GenerateLayoutOnly=
__GenerateTestHostOnly=
+__IsMSBuildOnNETCoreSupported=0
__MSBCleanBuildArgs=
__NativeTestIntermediatesDir=
__PortableBuild=1
@@ -651,14 +574,13 @@ __UnprocessedBuildArgs=
__LocalCoreFXConfig=${__BuildType}
__UseNinja=0
__VerboseBuild=0
-__cmakeargs=""
-__msbuildonunsupportedplatform=0
+__CMakeArgs=""
__priority1=
CORE_ROOT=
source "$__ProjectRoot"/_build-commons.sh
-if [ "${__BuildArch}" != "${__HostArch}" ]; then
+if [[ "${__BuildArch}" != "${__HostArch}" ]]; then
__CrossBuild=1
fi
@@ -673,53 +595,37 @@ __TestDir="$__ProjectDir/tests"
__TestWorkingDir="$__RootBinDir/tests/coreclr/$__BuildOS.$__BuildArch.$__BuildType"
__IntermediatesDir="$__RootBinDir/obj/coreclr/$__BuildOS.$__BuildArch.$__BuildType"
__TestIntermediatesDir="$__RootBinDir/tests/coreclr/obj/$__BuildOS.$__BuildArch.$__BuildType"
-__isMSBuildOnNETCoreSupported=0
__CrossComponentBinDir="$__BinDir"
__CrossCompIntermediatesDir="$__IntermediatesDir/crossgen"
__CrossArch="$__HostArch"
-if [ $__CrossBuild == 1 ]; then
+if [[ "$__CrossBuild" == 1 ]]; then
__CrossComponentBinDir="$__CrossComponentBinDir/$__CrossArch"
fi
__CrossgenCoreLibLog="$__LogsDir/CrossgenCoreLib_$__BuildOS.$BuildArch.$__BuildType.log"
__CrossgenExe="$__CrossComponentBinDir/crossgen"
-isMSBuildOnNETCoreSupported
-
# CI_SPECIFIC - On CI machines, $HOME may not be set. In such a case, create a subfolder and set the variable to it.
# This is needed by CLI to function.
-if [ -z "$HOME" ]; then
- if [ ! -d "$__ProjectDir/temp_home" ]; then
+if [[ -z "$HOME" ]]; then
+ if [[ ! -d "$__ProjectDir/temp_home" ]]; then
mkdir temp_home
fi
- export HOME=$__ProjectDir/temp_home
- echo "HOME not defined; setting it to $HOME"
-fi
-# Configure environment if we are doing a cross compile.
-if [ $__CrossBuild == 1 ]; then
- export CROSSCOMPILE=1
- if ! [[ -n "$ROOTFS_DIR" ]]; then
- export ROOTFS_DIR="$__RepoRootDir/.tools/rootfs/$__BuildArch"
- fi
-fi
-
-# init the target distro name
-initTargetDistroRid
-
-if [ $__PortableBuild == 0 ]; then
- __CommonMSBuildArgs="$__CommonMSBuildArgs /p:PortableBuild=false"
+ HOME="$__ProjectDir"/temp_home
+ export HOME
+ echo "HOME not defined; setting it to $HOME"
fi
if [[ (-z "$__GenerateLayoutOnly") && (-z "$__GenerateTestHostOnly") && (-z "$__BuildTestWrappersOnly") ]]; then
build_Tests
-elif [ ! -z "$__BuildTestWrappersOnly" ]; then
+elif [[ ! -z "$__BuildTestWrappersOnly" ]]; then
build_test_wrappers
else
generate_layout
fi
-if [ $? -ne 0 ]; then
+if [[ "$?" -ne 0 ]]; then
echo "Failed to build tests"
exit 1
fi
@@ -727,9 +633,9 @@ fi
echo "${__MsgPrefix}Test build successful."
echo "${__MsgPrefix}Test binaries are available at ${__TestBinDir}"
-__testNativeBinDir=$__IntermediatesDir/tests
+__testNativeBinDir="$__IntermediatesDir"/tests
-if [ $__RunTests -ne 0 ]; then
+if [[ "$__RunTests" -ne 0 ]]; then
echo "Run Tests..."
diff --git a/src/coreclr/build.cmd b/src/coreclr/build.cmd
index 698d2683e9f..a668f9fe154 100644
--- a/src/coreclr/build.cmd
+++ b/src/coreclr/build.cmd
@@ -23,11 +23,6 @@ if defined VS160COMNTOOLS (
set __VSVersion=vs2017
)
-:: Work around Jenkins CI + msbuild problem: Jenkins sometimes creates very large environment
-:: variables, and msbuild can't handle environment blocks with such large variables. So clear
-:: out the variables that might be too large.
-set ghprbCommentBody=
-
:: Note that the msbuild project files (specifically, dir.proj) will use the following variables, if set:
:: __BuildArch -- default: x64
:: __BuildType -- default: Debug
diff --git a/src/coreclr/build.sh b/src/coreclr/build.sh
index 11caf9bbc6e..6c54d81b115 100755
--- a/src/coreclr/build.sh
+++ b/src/coreclr/build.sh
@@ -1,12 +1,7 @@
#!/usr/bin/env bash
-# Work around Jenkins CI + msbuild problem: Jenkins sometimes creates very large environment
-# variables, and msbuild can't handle environment blocks with such large variables. So clear
-# out the variables that might be too large.
-export ghprbCommentBody=
-
# resolve python-version to use
-if [ "$PYTHON" == "" ] ; then
+if [[ -z "$PYTHON" ]]; then
if ! PYTHON=$(command -v python3 || command -v python2 || command -v python || command -v py)
then
echo "Unable to locate build-dependency python!" 1>&2
@@ -15,7 +10,7 @@ if [ "$PYTHON" == "" ] ; then
fi
# validate python-dependency
# useful in case of explicitly set option.
-if ! command -v $PYTHON > /dev/null
+if ! command -v "$PYTHON" > /dev/null
then
echo "Unable to locate build-dependency python ($PYTHON)!" 1>&2
exit 1
@@ -38,78 +33,56 @@ usage_list+=("-skipnuget: skip NuGet package generation.")
usage_list+=("-skiprestore: specify the official build ID to be used by this build.")
usage_list+=("-skiprestoreoptdata: build CoreLib as PartialNGen.")
usage_list+=("-staticanalyzer: skip native image generation.")
-usage_list+=("-stripSymbols: skip native image generation.")
-setup_dirs()
+setup_dirs_local()
{
- echo Setting up directories for build
+ setup_dirs
- mkdir -p "$__RootBinDir"
- mkdir -p "$__BinDir"
mkdir -p "$__LogsDir"
mkdir -p "$__MsbuildDebugLogsDir"
- mkdir -p "$__IntermediatesDir"
- if [ $__CrossBuild == 1 ]; then
+ if [[ "$__CrossBuild" == 1 ]]; then
mkdir -p "$__CrossComponentBinDir"
fi
}
-# Check the system to ensure the right prereqs are in place
-
-check_prereqs()
-{
- echo "Checking prerequisites..."
-
- # Check presence of CMake on the path
- hash cmake 2>/dev/null || { echo >&2 "Please install cmake before running this script"; exit 1; }
-
- function version { echo "$@" | awk -F. '{ printf("%d%02d%02d\n", $1,$2,$3); }'; }
-
- local cmake_version=$(cmake --version | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+")
-
- if [[ $(version $cmake_version) -lt $(version 3.14.0) ]]; then
- echo "Please install CMake 3.14 or newer from http://www.cmake.org/download/ or https://apt.kitware.com and ensure it is on your path."; exit 1;
- fi
-}
-
restore_optdata()
{
local OptDataProjectFilePath="$__ProjectRoot/src/.nuget/optdata/optdata.csproj"
- if [[ ( $__SkipRestoreOptData == 0 ) && ( $__isMSBuildOnNETCoreSupported == 1 ) ]]; then
+ if [[ "$__SkipRestoreOptData" == 0 && "$__IsMSBuildOnNETCoreSupported" == 1 ]]; then
echo "Restoring the OptimizationData package"
"$__RepoRootDir/eng/common/msbuild.sh" /clp:nosummary $__ArcadeScriptArgs \
$OptDataProjectFilePath /t:Restore /m \
$__CommonMSBuildArgs $__UnprocessedBuildArgs
- local exit_code=$?
- if [ $exit_code != 0 ]; then
+ local exit_code="$?"
+ if [[ "$exit_code" != 0 ]]; then
echo "${__ErrMsgPrefix}Failed to restore the optimization data package."
- exit $exit_code
+ exit "$exit_code"
fi
fi
- if [ $__isMSBuildOnNETCoreSupported == 1 ]; then
+ if [[ "$__IsMSBuildOnNETCoreSupported" == 1 ]]; then
# Parse the optdata package versions out of msbuild so that we can pass them on to CMake
local PgoDataPackagePathOutputFile="${__IntermediatesDir}/optdatapath.txt"
local IbcDataPackagePathOutputFile="${__IntermediatesDir}/ibcoptdatapath.txt"
# Writes into ${PgoDataPackagePathOutputFile}
- "$__RepoRootDir/eng/common/msbuild.sh" /clp:nosummary $__ArcadeScriptArgs $OptDataProjectFilePath /t:DumpPgoDataPackagePath ${__CommonMSBuildArgs} /p:PgoDataPackagePathOutputFile=${PgoDataPackagePathOutputFile} 2>&1 > /dev/null
- local exit_code=$?
- if [ $exit_code != 0 ] || [ ! -f "${PgoDataPackagePathOutputFile}" ]; then
+ "$__RepoRootDir/eng/common/msbuild.sh" /clp:nosummary $__ArcadeScriptArgs $OptDataProjectFilePath /t:DumpPgoDataPackagePath ${__CommonMSBuildArgs} /p:PgoDataPackagePathOutputFile=${PgoDataPackagePathOutputFile} > /dev/null 2>&1
+ local exit_code="$?"
+ if [[ "$exit_code" != 0 || ! -f "${PgoDataPackagePathOutputFile}" ]]; then
echo "${__ErrMsgPrefix}Failed to get PGO data package path."
- exit $exit_code
+ exit "$exit_code"
fi
__PgoOptDataPath=$(<"${PgoDataPackagePathOutputFile}")
# Writes into ${IbcDataPackagePathOutputFile}
- "$__RepoRootDir/eng/common/msbuild.sh" /clp:nosummary $__ArcadeScriptArgs $OptDataProjectFilePath /t:DumpIbcDataPackagePath ${__CommonMSBuildArgs} /p:IbcDataPackagePathOutputFile=${IbcDataPackagePathOutputFile} 2>&1 > /dev/null
- local exit_code=$?
- if [ $exit_code != 0 ] || [ ! -f "${IbcDataPackagePathOutputFile}" ]; then
+ "$__RepoRootDir/eng/common/msbuild.sh" /clp:nosummary $__ArcadeScriptArgs $OptDataProjectFilePath /t:DumpIbcDataPackagePath ${__CommonMSBuildArgs} /p:IbcDataPackagePathOutputFile=${IbcDataPackagePathOutputFile} > /dev/null 2>&1
+ local exit_code="$?"
+ if [[ "$exit_code" != 0 || ! -f "${IbcDataPackagePathOutputFile}" ]]; then
echo "${__ErrMsgPrefix}Failed to get IBC data package path."
- exit $exit_code
+ exit "$exit_code"
fi
__IbcOptDataPath=$(<"${IbcDataPackagePathOutputFile}")
@@ -118,134 +91,25 @@ restore_optdata()
generate_event_logging_sources()
{
- __OutputEventingDir=$1
+ __OutputEventingDir="$1"
__PythonWarningFlags="-Wall"
- if [[ $__IgnoreWarnings == 0 ]]; then
+ if [[ "$__IgnoreWarnings" == 0 ]]; then
__PythonWarningFlags="$__PythonWarningFlags -Werror"
fi
echo "Laying out dynamically generated EventSource classes"
- $PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genRuntimeEventSources.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --intermediate "$__OutputEventingDir"
+ "$PYTHON" -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genRuntimeEventSources.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --intermediate "$__OutputEventingDir"
}
generate_event_logging()
{
# Event Logging Infrastructure
- if [[ $__SkipMSCorLib == 0 ]]; then
+ if [[ "$__SkipMSCorLib" == 0 ]]; then
generate_event_logging_sources "$__ArtifactsIntermediatesDir/Eventing/$__BuildArch/$__BuildType"
fi
}
-build_native()
-{
- skipCondition=$1
- platformArch="$2"
- intermediatesForBuild="$3"
- extraCmakeArguments="$4"
- message="$5"
-
- if [ $skipCondition == 1 ]; then
- echo "Skipping $message build."
- return
- fi
-
- # All set to commence the build
- echo "Commencing build of $message for $__BuildOS.$__BuildArch.$__BuildType in $intermediatesForBuild"
-
- generator=""
- buildTool="make"
- if [ $__UseNinja == 1 ]; then
- generator="ninja"
- if ! buildTool=$(command -v ninja || command -v ninja-build); then
- echo "Unable to locate ninja!" 1>&2
- exit 1
- fi
- fi
-
- if [ $__SkipConfigure == 0 ]; then
- # if msbuild is not supported, then set __SkipGenerateVersion to 1
- if [ $__isMSBuildOnNETCoreSupported == 0 ]; then __SkipGenerateVersion=1; fi
- # Drop version.c file
- __versionSourceFile="$intermediatesForBuild/version.c"
- if [ $__SkipGenerateVersion == 0 ]; then
- pwd
- "$__RepoRootDir/eng/common/msbuild.sh" /clp:nosummary $__ArcadeScriptArgs $__RepoRootDir/eng/empty.csproj \
- /p:NativeVersionFile=$__versionSourceFile \
- /t:GenerateNativeVersionFile /restore \
- $__CommonMSBuildArgs $__UnprocessedBuildArgs
- local exit_code=$?
- if [ $exit_code != 0 ]; then
- echo "${__ErrMsgPrefix}Failed to generate native version file."
- 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
- __versionSourceLine="static char sccsid[] __attribute__((used)) = \"@(#)No version information produced\";"
- if [ -e $__versionSourceFile ]; then
- read existingVersionSourceLine < $__versionSourceFile
- fi
- if [ "$__versionSourceLine" != "$existingVersionSourceLine" ]; then
- echo $__versionSourceLine > $__versionSourceFile
- fi
- fi
-
- # Regenerate the CMake solution
-
- if [ "$__StaticAnalyzer" = 1 ]; then
- scan_build=scan-build
- fi
- if [[ -n "$__CodeCoverage" ]]; then
- extraCmakeArguments="$extraCmakeArguments -DCLR_CMAKE_ENABLE_CODE_COVERAGE=1"
- fi
-
- engNativeDir="$__RepoRootDir/eng/native"
- __cmakeargs="$__cmakeargs -DCLR_ENG_NATIVE_DIR=\"$engNativeDir\""
- nextCommand="\"$engNativeDir/gen-buildsys.sh\" \"$__ProjectRoot\" \"$__ProjectRoot\" \"$intermediatesForBuild\" $platformArch $__Compiler \"$__CompilerMajorVersion\" \"$__CompilerMinorVersion\" $__BuildType $generator $scan_build $extraCmakeArguments $__cmakeargs"
- echo "Invoking $nextCommand"
- eval $nextCommand
-
- if [ $? != 0 ]; then
- echo "${__ErrMsgPrefix}Failed to generate $message build project!"
- exit 1
- fi
- fi
-
- if [ ! -f "$intermediatesForBuild/CMakeCache.txt" ]; then
- echo "${__ErrMsgPrefix}Unable to find generated build files for $message project!"
- exit 1
- fi
-
- # Build
- if [ $__ConfigureOnly == 1 ]; then
- echo "Finish configuration & skipping $message build."
- return
- fi
-
- # Check that the makefiles were created.
-
- if [ $__StaticAnalyzer == 1 ]; then
- pushd "$intermediatesForBuild"
-
- buildTool="$SCAN_BUILD_COMMAND -o $__BinDir/scan-build-log $buildTool"
- echo "Executing $buildTool install -j $__NumProc"
- $buildTool install -j $__NumProc
-
- popd
- else
- echo "Executing cmake --build \"$intermediatesForBuild\" --target install -j $__NumProc"
-
- cmake --build "$intermediatesForBuild" --target install -j $__NumProc
- fi
-
- local exit_code=$?
- if [ $exit_code != 0 ]; then
- echo "${__ErrMsgPrefix}Failed to build $message."
- exit $exit_code
- fi
-
-}
-
build_cross_architecture_components()
{
local intermediatesForBuild="$__IntermediatesDir/Host$__CrossArch/crossgen"
@@ -270,8 +134,8 @@ build_cross_architecture_components()
export __CMakeBinDir="$crossArchBinDir"
export CROSSCOMPILE=0
- __ExtraCmakeArgs="-DCLR_CMAKE_TARGET_ARCH=$__BuildArch -DCLR_CMAKE_PGO_INSTRUMENT=$__PgoInstrument -DCLR_CMAKE_OPTDATA_PATH=$__PgoOptDataPath -DCLR_CMAKE_PGO_OPTIMIZE=$__PgoOptimize -DCLR_CROSS_COMPONENTS_BUILD=1"
- build_native $__SkipCrossArchBuild "$__CrossArch" "$intermediatesForBuild" "$__ExtraCmakeArgs" "cross-architecture components"
+ __CMakeArgs="-DCLR_CMAKE_TARGET_ARCH=$__BuildArch -DCLR_CROSS_COMPONENTS_BUILD=1 $__CMakeArgs"
+ build_native "$__CrossArch" "$__ProjectRoot" "$__ProjectRoot" "$intermediatesForBuild" "cross-architecture components"
export CROSSCOMPILE=1
}
@@ -281,42 +145,42 @@ build_CoreLib_ni()
local __CrossGenExec=$1
local __CoreLibILDir=$2
- if [ $__PartialNgen == 1 ]; then
+ if [[ "$__PartialNgen" == 1 ]]; then
export COMPlus_PartialNGen=1
fi
- if [ -e $__CrossGenCoreLibLog ]; then
- rm $__CrossGenCoreLibLog
+ if [[ -e "$__CrossGenCoreLibLog" ]]; then
+ rm "$__CrossGenCoreLibLog"
fi
echo "Generating native image of System.Private.CoreLib.dll for $__BuildOS.$__BuildArch.$__BuildType. Logging to \"$__CrossGenCoreLibLog\"."
echo "$__CrossGenExec /Platform_Assemblies_Paths $__CoreLibILDir $__IbcTuning /out $__BinDir/System.Private.CoreLib.dll $__CoreLibILDir/System.Private.CoreLib.dll"
- $__CrossGenExec /nologo /Platform_Assemblies_Paths $__CoreLibILDir $__IbcTuning /out $__BinDir/System.Private.CoreLib.dll $__CoreLibILDir/System.Private.CoreLib.dll >> $__CrossGenCoreLibLog 2>&1
- local exit_code=$?
- if [ $exit_code != 0 ]; then
+ "$__CrossGenExec" /nologo /Platform_Assemblies_Paths $__CoreLibILDir $__IbcTuning /out $__BinDir/System.Private.CoreLib.dll $__CoreLibILDir/System.Private.CoreLib.dll >> $__CrossGenCoreLibLog 2>&1
+ local exit_code="$?"
+ if [[ "$exit_code" != 0 ]]; then
echo "${__ErrMsgPrefix}Failed to generate native image for System.Private.CoreLib. Refer to $__CrossGenCoreLibLog"
- exit $exit_code
+ exit "$exit_code"
fi
- if [ "$__BuildOS" == "Linux" ]; then
+ if [[ "$__BuildOS" == "Linux" ]]; then
echo "Generating symbol file for System.Private.CoreLib.dll"
echo "$__CrossGenExec /Platform_Assemblies_Paths $__BinDir /CreatePerfMap $__BinDir $__BinDir/System.Private.CoreLib.dll"
- $__CrossGenExec /nologo /Platform_Assemblies_Paths $__BinDir /CreatePerfMap $__BinDir $__BinDir/System.Private.CoreLib.dll >> $__CrossGenCoreLibLog 2>&1
- local exit_code=$?
- if [ $exit_code != 0 ]; then
+ "$__CrossGenExec" /nologo /Platform_Assemblies_Paths $__BinDir /CreatePerfMap $__BinDir $__BinDir/System.Private.CoreLib.dll >> $__CrossGenCoreLibLog 2>&1
+ local exit_code="$?"
+ if [[ "$exit_code" != 0 ]]; then
echo "${__ErrMsgPrefix}Failed to generate symbol file for System.Private.CoreLib. Refer to $__CrossGenCoreLibLog"
- exit $exit_code
+ exit "$exit_code"
fi
fi
}
build_CoreLib()
{
- if [ $__isMSBuildOnNETCoreSupported == 0 ]; then
+ if [[ "$__IsMSBuildOnNETCoreSupported" == 0 ]]; then
echo "System.Private.CoreLib.dll build unsupported."
return
fi
- if [ $__SkipMSCorLib == 1 ]; then
+ if [[ "$__SkipMSCorLib" == 1 ]]; then
echo "Skipping building System.Private.CoreLib."
return
fi
@@ -325,7 +189,7 @@ build_CoreLib()
# Invoke MSBuild
__ExtraBuildArgs=""
- if [[ "$__IbcTuning" == "" ]]; then
+ if [[ -z "$__IbcTuning" ]]; then
__ExtraBuildArgs="$__ExtraBuildArgs /p:OptimizationDataDir=\"$__IbcOptDataPath/data\""
__ExtraBuildArgs="$__ExtraBuildArgs /p:EnableProfileGuidedOptimization=true"
fi
@@ -341,10 +205,10 @@ build_CoreLib()
/p:__IntermediatesDir=$__IntermediatesDir /p:__RootBinDir=$__RootBinDir \
$__CommonMSBuildArgs $__ExtraBuildArgs $__UnprocessedBuildArgs
- local exit_code=$?
- if [ $exit_code != 0 ]; then
+ local exit_code="$?"
+ if [[ "$exit_code" != 0 ]]; then
echo "${__ErrMsgPrefix}Failed to restore managed components."
- exit $exit_code
+ exit "$exit_code"
fi
"$__RepoRootDir/eng/common/msbuild.sh" /clp:nosummary $__ArcadeScriptArgs \
@@ -354,23 +218,23 @@ build_CoreLib()
/p:__IntermediatesDir=$__IntermediatesDir /p:__RootBinDir=$__RootBinDir \
$__CommonMSBuildArgs $__ExtraBuildArgs $__UnprocessedBuildArgs
- local exit_code=$?
- if [ $exit_code != 0 ]; then
+ local exit_code="$?"
+ if [[ "$exit_code" != 0 ]]; then
echo "${__ErrMsgPrefix}Failed to build managed components."
- exit $exit_code
+ exit "$exit_code"
fi
if [[ "$__BuildManagedTools" -eq "1" ]]; then
echo "Publishing crossgen2 for $__DistroRid"
"$__RepoRootDir/dotnet.sh" publish --self-contained -r $__DistroRid -c $__BuildType -o "$__BinDir/crossgen2" "$__ProjectRoot/src/tools/crossgen2/crossgen2/crossgen2.csproj" /nologo /p:BuildArch=$__BuildArch
- local exit_code=$?
- if [ $exit_code != 0 ]; then
+ local exit_code="$?"
+ if [[ "$exit_code" != 0 ]]; then
echo "${__ErrMsgPrefix}Failed to build crossgen2."
- exit $exit_code
+ exit "$exit_code"
fi
- if [ "$__HostOS" == "OSX" ]; then
+ if [[ "$__HostOS" == "OSX" ]]; then
cp "$__BinDir/libclrjit.dylib" "$__BinDir/crossgen2/libclrjitilc.dylib"
cp "$__BinDir/libjitinterface.dylib" "$__BinDir/crossgen2/libjitinterface.dylib"
else
@@ -379,45 +243,45 @@ build_CoreLib()
fi
fi
- local __CoreLibILDir=$__BinDir/IL
+ local __CoreLibILDir="$__BinDir"/IL
- if [ $__SkipCrossgen == 1 ]; then
+ if [[ "$__SkipCrossgen" == 1 ]]; then
echo "Skipping generating native image"
- if [ $__CrossBuild == 1 ]; then
+ 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
+ cp "$__CoreLibILDir"/System.Private.CoreLib.dll "$__BinDir"/System.Private.CoreLib.dll
fi
return
fi
# The cross build generates a crossgen with the target architecture.
- if [ $__CrossBuild == 0 ]; then
- if [ $__SkipCoreCLR == 1 ]; then
+ if [[ "$__CrossBuild" == 0 ]]; then
+ if [[ "$__SkipCoreCLR" == 1 ]]; then
return
fi
# The architecture of host pc must be same architecture with target.
- if [[ ( "$__HostArch" == "$__BuildArch" ) ]]; then
- build_CoreLib_ni "$__BinDir/crossgen" $__CoreLibILDir
+ if [[ "$__HostArch" == "$__BuildArch" ]]; then
+ build_CoreLib_ni "$__BinDir/crossgen" "$__CoreLibILDir"
elif [[ ( "$__HostArch" == "x64" ) && ( "$__BuildArch" == "x86" ) ]]; then
- build_CoreLib_ni "$__BinDir/crossgen" $__CoreLibILDir
+ build_CoreLib_ni "$__BinDir/crossgen" "$__CoreLibILDir"
elif [[ ( "$__HostArch" == "arm64" ) && ( "$__BuildArch" == "arm" ) ]]; then
- build_CoreLib_ni "$__BinDir/crossgen" $__CoreLibILDir
+ build_CoreLib_ni "$__BinDir/crossgen" "$__CoreLibILDir"
else
exit 1
fi
else
if [[ ( "$__CrossArch" == "x86" ) && ( "$__BuildArch" == "arm" ) ]]; then
- build_CoreLib_ni "$__CrossComponentBinDir/crossgen" $__CoreLibILDir
+ build_CoreLib_ni "$__CrossComponentBinDir/crossgen" "$__CoreLibILDir"
elif [[ ( "$__CrossArch" == "x64" ) && ( "$__BuildArch" == "arm" ) ]]; then
- build_CoreLib_ni "$__CrossComponentBinDir/crossgen" $__CoreLibILDir
+ build_CoreLib_ni "$__CrossComponentBinDir/crossgen" "$__CoreLibILDir"
elif [[ ( "$__HostArch" == "x64" ) && ( "$__BuildArch" == "arm64" ) ]]; then
- build_CoreLib_ni "$__CrossComponentBinDir/crossgen" $__CoreLibILDir
+ build_CoreLib_ni "$__CrossComponentBinDir/crossgen" "$__CoreLibILDir"
else
# Crossgen not performed, so treat the IL version as the final version
- cp $__CoreLibILDir/System.Private.CoreLib.dll $__BinDir/System.Private.CoreLib.dll
+ cp "$__CoreLibILDir"/System.Private.CoreLib.dll "$__BinDir"/System.Private.CoreLib.dll
fi
fi
}
@@ -425,37 +289,37 @@ build_CoreLib()
generate_NugetPackages()
{
# We can only generate nuget package if we also support building mscorlib as part of this build.
- if [ $__isMSBuildOnNETCoreSupported == 0 ]; then
+ if [[ "$__IsMSBuildOnNETCoreSupported" == 0 ]]; then
echo "Nuget package generation unsupported."
return
fi
# Since we can build mscorlib for this OS, did we build the native components as well?
- if [[ $__SkipCoreCLR == 1 && $__CrossgenOnly == 0 ]]; then
+ if [[ "$__SkipCoreCLR" == 1 && "$__CrossgenOnly" == 0 ]]; then
echo "Unable to generate nuget packages since native components were not built."
return
fi
- echo "Generating nuget packages for "$__BuildOS
- echo "DistroRid is "$__DistroRid
- echo "ROOTFS_DIR is "$ROOTFS_DIR
+ echo "Generating nuget packages for $__BuildOS"
+ echo "DistroRid is $__DistroRid"
+ echo "ROOTFS_DIR is $ROOTFS_DIR"
# Build the packages
# Package build uses the Arcade system and scripts, relying on it to restore required toolsets as part of build
- $__RepoRootDir/eng/common/build.sh -r -b -projects $__SourceDir/.nuget/packages.builds \
- -verbosity minimal -bl:$__LogsDir/Nuget_$__BuildOS__$__BuildArch__$__BuildType.binlog \
+ "$__RepoRootDir"/eng/common/build.sh -r -b -projects "$__SourceDir"/.nuget/packages.builds \
+ -verbosity minimal -bl:"$__LogsDir/Nuget_$__BuildOS__$__BuildArch__$__BuildType.binlog" \
/p:PortableBuild=true \
- /p:__IntermediatesDir=$__IntermediatesDir /p:__RootBinDir=$__RootBinDir /p:__DoCrossArchBuild=$__CrossBuild \
+ /p:"__IntermediatesDir=$__IntermediatesDir" /p:"__RootBinDir=$__RootBinDir" /p:"__DoCrossArchBuild=$__CrossBuild" \
$__CommonMSBuildArgs $__UnprocessedBuildArgs
- local exit_code=$?
- if [ $exit_code != 0 ]; then
+ local exit_code="$?"
+ if [[ "$exit_code" != 0 ]]; then
echo "${__ErrMsgPrefix}Failed to generate Nuget packages."
- exit $exit_code
+ exit "$exit_code"
fi
}
-handle_arguments() {
- case $1 in
+handle_arguments_local() {
+ case "$1" in
crossgenonly|-crossgenonly)
__SkipMSCorLib=1
__SkipCoreCLR=1
@@ -472,7 +336,7 @@ handle_arguments() {
ignorewarnings|-ignorewarnings)
__IgnoreWarnings=1
- __cmakeargs="$__cmakeargs -DCLR_CMAKE_WARNINGS_ARE_ERRORS=OFF"
+ __CMakeArgs="-DCLR_CMAKE_WARNINGS_ARE_ERRORS=OFF $__CMakeArgs"
;;
nopgooptimize|-nopgooptimize)
@@ -526,12 +390,8 @@ handle_arguments() {
__StaticAnalyzer=1
;;
- stripsymbols|-stripsymbols)
- __cmakeargs="$__cmakeargs -DSTRIP_SYMBOLS=true"
- ;;
-
*)
- __UnprocessedBuildArgs+=("$1")
+ __UnprocessedBuildArgs="$__UnprocessedBuildArgs $1"
;;
esac
}
@@ -545,15 +405,13 @@ echo "Commencing CoreCLR Repo build"
#
# Set the default arguments for build
-# Obtain the location of the bash script to figure out where the root of the subrepo is.
-__ProjectRoot="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-
-# Some paths are relative to the main repo root
-__RepoRootDir="${__ProjectRoot}/../.."
+# Obtain the location of the bash script to figure out where the root of the repo is.
+__ProjectRoot="$(cd "$(dirname "$0")"; pwd -P)"
+__RepoRootDir="$(cd "$__ProjectRoot"/../..; pwd -P)"
__BuildArch=
__BuildType=Debug
-__CodeCoverage=
+__CodeCoverage=0
__IgnoreWarnings=0
# Set the various build properties here so that CMake and MSBuild can pick them up
@@ -568,6 +426,7 @@ __CrossgenOnly=0
__DistroRid=""
__IbcOptDataPath=""
__IbcTuning=""
+__IsMSBuildOnNETCoreSupported=0
__MSBCleanBuildArgs=
__OfficialBuildIdArg=""
__PartialNgen=0
@@ -595,12 +454,11 @@ __UnprocessedBuildArgs=
__UseNinja=0
__VerboseBuild=0
__ValidateCrossArg=1
-__cmakeargs=""
-__msbuildonunsupportedplatform=0
+__CMakeArgs=""
source "$__ProjectRoot"/_build-commons.sh
-if [ "${__BuildArch}" != "${__HostArch}" ]; then
+if [[ "${__BuildArch}" != "${__HostArch}" ]]; then
__CrossBuild=1
fi
@@ -613,40 +471,21 @@ __BinDir="$__RootBinDir/bin/coreclr/$__BuildOS.$__BuildArch.$__BuildType"
__PackagesBinDir="$__BinDir/.nuget"
export __IntermediatesDir="$__RootBinDir/obj/coreclr/$__BuildOS.$__BuildArch.$__BuildType"
export __ArtifactsIntermediatesDir="$__RepoRootDir/artifacts/obj/coreclr"
-__isMSBuildOnNETCoreSupported=0
__CrossComponentBinDir="$__BinDir"
__CrossArch="$__HostArch"
-if [ $__CrossBuild == 1 ]; then
+if [[ "$__CrossBuild" == 1 ]]; then
__CrossComponentBinDir="$__CrossComponentBinDir/$__CrossArch"
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="$__RepoRootDir/.tools/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
-
# CI_SPECIFIC - On CI machines, $HOME may not be set. In such a case, create a subfolder and set the variable to set.
# This is needed by CLI to function.
-if [ -z "$HOME" ]; then
- if [ ! -d "$__ProjectDir/temp_home" ]; then
+if [[ -z "$HOME" ]]; then
+ if [[ ! -d "$__ProjectDir/temp_home" ]]; then
mkdir temp_home
fi
- export HOME=$__ProjectDir/temp_home
+ export HOME="$__ProjectDir"/temp_home
echo "HOME not defined; setting it to $HOME"
fi
@@ -655,7 +494,7 @@ fi
export __CMakeBinDir="$__BinDir"
# Make the directories necessary for build if they don't exist
-setup_dirs
+setup_dirs_local
# Set up the directory for MSBuild debug logs.
export MSBUILDDEBUGPATH="${__MsbuildDebugLogsDir}"
@@ -670,13 +509,21 @@ restore_optdata
generate_event_logging
# Build the coreclr (native) components.
-__ExtraCmakeArgs="-DCLR_CMAKE_PGO_INSTRUMENT=$__PgoInstrument -DCLR_CMAKE_OPTDATA_PATH=$__PgoOptDataPath -DCLR_CMAKE_PGO_OPTIMIZE=$__PgoOptimize"
+__CMakeArgs="-DCLR_CMAKE_PGO_INSTRUMENT=$__PgoInstrument -DCLR_CMAKE_OPTDATA_PATH=$__PgoOptDataPath -DCLR_CMAKE_PGO_OPTIMIZE=$__PgoOptimize $__CMakeArgs"
-build_native $__SkipCoreCLR "$__BuildArch" "$__IntermediatesDir" "$__ExtraCmakeArgs" "CoreCLR component"
+if [[ "$__SkipConfigure" == 0 && "$__CodeCoverage" == 1 ]]; then
+ __CMakeArgs="-DCLR_CMAKE_ENABLE_CODE_COVERAGE=1 $__CMakeArgs"
+fi
+
+if [[ "$__SkipCoreCLR" == 1 ]]; then
+ echo "Skipping CoreCLR component build."
+else
+ build_native "$__BuildArch" "$__ProjectRoot" "$__ProjectRoot" "$__IntermediatesDir" "CoreCLR component"
+fi
# Build cross-architecture components
-if [ $__SkipCrossArchNative != 1 ]; then
- if [[ $__CrossBuild == 1 ]]; then
+if [[ "$__SkipCrossArchNative" != 1 ]]; then
+ if [[ "$__CrossBuild" == 1 ]]; then
build_cross_architecture_components
fi
fi
@@ -685,12 +532,12 @@ fi
build_CoreLib
-if [ $__CrossgenOnly == 1 ]; then
+if [[ "$__CrossgenOnly" == 1 ]]; then
build_CoreLib_ni "$__BinDir/crossgen"
fi
# Generate nuget packages
-if [ $__SkipNuget != 1 ]; then
+if [[ "$__SkipNuget" != 1 ]]; then
generate_NugetPackages
fi
diff --git a/src/coreclr/configurecompiler.cmake b/src/coreclr/configurecompiler.cmake
index e52c7e79551..f301d715aa6 100644
--- a/src/coreclr/configurecompiler.cmake
+++ b/src/coreclr/configurecompiler.cmake
@@ -8,194 +8,12 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
cmake_policy(SET CMP0083 NEW)
-include(CheckPIESupported)
include(CheckCXXCompilerFlag)
-
-# All code we build should be compiled as position independent
-check_pie_supported(OUTPUT_VARIABLE PIE_SUPPORT_OUTPUT LANGUAGES CXX)
-if(NOT MSVC AND NOT CMAKE_CXX_LINK_PIE_SUPPORTED)
- message(WARNING "PIE is not supported at link time: ${PIE_SUPPORT_OUTPUT}.\n"
- "PIE link options will not be passed to linker.")
-endif()
-set(CMAKE_POSITION_INDEPENDENT_CODE ON)
-
-#----------------------------------------
-# Detect and set platform variable names
-# - for non-windows build platform & architecture is detected using inbuilt CMAKE variables and cross target component configure
-# - for windows we use the passed in parameter to CMAKE to determine build arch
-#----------------------------------------
-if(CMAKE_SYSTEM_NAME STREQUAL Linux)
- set(CLR_CMAKE_HOST_UNIX 1)
- if(CLR_CROSS_COMPONENTS_BUILD)
- # CMAKE_HOST_SYSTEM_PROCESSOR returns the value of `uname -p` on host.
- if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL amd64)
- if(CLR_CMAKE_TARGET_ARCH STREQUAL "arm" OR CLR_CMAKE_TARGET_ARCH STREQUAL "armel")
- if(CMAKE_CROSSCOMPILING)
- set(CLR_CMAKE_HOST_UNIX_X86 1)
- else()
- set(CLR_CMAKE_HOST_UNIX_AMD64 1)
- endif()
- else()
- set(CLR_CMAKE_HOST_UNIX_AMD64 1)
- endif()
- elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL i686)
- set(CLR_CMAKE_HOST_UNIX_X86 1)
- else()
- clr_unknown_arch()
- endif()
- else()
- # CMAKE_SYSTEM_PROCESSOR returns the value of `uname -p` on target.
- # For the AMD/Intel 64bit architecture two different strings are common.
- # Linux and Darwin identify it as "x86_64" while FreeBSD and netbsd uses the
- # "amd64" string. Accept either of the two here.
- if(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL amd64)
- set(CLR_CMAKE_HOST_UNIX_AMD64 1)
- elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l)
- set(CLR_CMAKE_HOST_UNIX_ARM 1)
- elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL arm)
- set(CLR_CMAKE_HOST_UNIX_ARM 1)
- elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64)
- set(CLR_CMAKE_HOST_UNIX_ARM64 1)
- elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL i686)
- set(CLR_CMAKE_HOST_UNIX_X86 1)
- else()
- clr_unknown_arch()
- endif()
- endif()
- set(CLR_CMAKE_HOST_LINUX 1)
-
- # Detect Linux ID
- set(LINUX_ID_FILE "/etc/os-release")
- if(CMAKE_CROSSCOMPILING)
- set(LINUX_ID_FILE "${CMAKE_SYSROOT}${LINUX_ID_FILE}")
- endif()
-
- execute_process(
- COMMAND bash -c "source ${LINUX_ID_FILE} && echo \$ID"
- OUTPUT_VARIABLE CLR_CMAKE_LINUX_ID
- OUTPUT_STRIP_TRAILING_WHITESPACE)
-
- if(DEFINED CLR_CMAKE_LINUX_ID)
- if(CLR_CMAKE_LINUX_ID STREQUAL tizen)
- set(CLR_CMAKE_TARGET_TIZEN_LINUX 1)
- elseif(CLR_CMAKE_LINUX_ID STREQUAL alpine)
- set(CLR_CMAKE_HOST_ALPINE_LINUX 1)
- endif()
- endif(DEFINED CLR_CMAKE_LINUX_ID)
-endif(CMAKE_SYSTEM_NAME STREQUAL Linux)
-
-if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
- set(CLR_CMAKE_HOST_UNIX 1)
- set(CLR_CMAKE_HOST_UNIX_AMD64 1)
- set(CLR_CMAKE_HOST_DARWIN 1)
- set(CMAKE_ASM_COMPILE_OBJECT "${CMAKE_C_COMPILER} <FLAGS> <DEFINES> <INCLUDES> -o <OBJECT> -c <SOURCE>")
-endif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
-
-if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
- set(CLR_CMAKE_HOST_UNIX 1)
- set(CLR_CMAKE_HOST_UNIX_AMD64 1)
- set(CLR_CMAKE_HOST_FREEBSD 1)
-endif(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
-
-if(CMAKE_SYSTEM_NAME STREQUAL OpenBSD)
- set(CLR_CMAKE_HOST_UNIX 1)
- set(CLR_CMAKE_HOST_UNIX_AMD64 1)
- set(CLR_CMAKE_HOST_OPENBSD 1)
-endif(CMAKE_SYSTEM_NAME STREQUAL OpenBSD)
-
-if(CMAKE_SYSTEM_NAME STREQUAL NetBSD)
- set(CLR_CMAKE_HOST_UNIX 1)
- set(CLR_CMAKE_HOST_UNIX_AMD64 1)
- set(CLR_CMAKE_HOST_NETBSD 1)
-endif(CMAKE_SYSTEM_NAME STREQUAL NetBSD)
-
-if(CMAKE_SYSTEM_NAME STREQUAL SunOS)
- set(CLR_CMAKE_HOST_UNIX 1)
- EXECUTE_PROCESS(
- COMMAND isainfo -n
- OUTPUT_VARIABLE SUNOS_NATIVE_INSTRUCTION_SET
- )
- if(SUNOS_NATIVE_INSTRUCTION_SET MATCHES "amd64")
- set(CLR_CMAKE_HOST_UNIX_AMD64 1)
- set(CMAKE_SYSTEM_PROCESSOR "amd64")
- else()
- clr_unknown_arch()
- endif()
- set(CLR_CMAKE_HOST_SUNOS 1)
-endif(CMAKE_SYSTEM_NAME STREQUAL SunOS)
-
+include(${CLR_ENG_NATIVE_DIR}/configureplatform.cmake)
# "configureoptimization.cmake" must be included after CLR_CMAKE_HOST_UNIX has been set.
include(${CMAKE_CURRENT_LIST_DIR}/configureoptimization.cmake)
-#--------------------------------------------
-# This repo builds two set of binaries
-# 1. binaries which execute on target arch machine
-# - for such binaries host architecture & target architecture are same
-# - eg. coreclr.dll
-# 2. binaries which execute on host machine but target another architecture
-# - host architecture is different from target architecture
-# - eg. crossgen.exe - runs on x64 machine and generates nis targeting arm64
-# - for complete list of such binaries refer to file crosscomponents.cmake
-#-------------------------------------------------------------
-# Set HOST architecture variables
-if(CLR_CMAKE_HOST_UNIX_ARM)
- set(CLR_CMAKE_HOST_ARCH_ARM 1)
- set(CLR_CMAKE_HOST_ARCH "arm")
-elseif(CLR_CMAKE_HOST_UNIX_ARM64)
- set(CLR_CMAKE_HOST_ARCH_ARM64 1)
- set(CLR_CMAKE_HOST_ARCH "arm64")
-elseif(CLR_CMAKE_HOST_UNIX_AMD64)
- set(CLR_CMAKE_HOST_ARCH_AMD64 1)
- set(CLR_CMAKE_HOST_ARCH "x64")
-elseif(CLR_CMAKE_HOST_UNIX_X86)
- set(CLR_CMAKE_HOST_ARCH_I386 1)
- set(CLR_CMAKE_HOST_ARCH "x86")
-elseif(WIN32)
- # CLR_CMAKE_HOST_ARCH is passed in as param to cmake
- if (CLR_CMAKE_HOST_ARCH STREQUAL x64)
- set(CLR_CMAKE_HOST_ARCH_AMD64 1)
- elseif(CLR_CMAKE_HOST_ARCH STREQUAL x86)
- set(CLR_CMAKE_HOST_ARCH_I386 1)
- elseif(CLR_CMAKE_HOST_ARCH STREQUAL arm)
- set(CLR_CMAKE_HOST_ARCH_ARM 1)
- elseif(CLR_CMAKE_HOST_ARCH STREQUAL arm64)
- set(CLR_CMAKE_HOST_ARCH_ARM64 1)
- else()
- clr_unknown_arch()
- endif()
-endif()
-
-# Set TARGET architecture variables
-# Target arch will be a cmake param (optional) for both windows as well as non-windows build
-# if target arch is not specified then host & target are same
-if(NOT DEFINED CLR_CMAKE_TARGET_ARCH OR CLR_CMAKE_TARGET_ARCH STREQUAL "" )
- set(CLR_CMAKE_TARGET_ARCH ${CLR_CMAKE_HOST_ARCH})
-endif()
-
-# Set target architecture variables
-if (CLR_CMAKE_TARGET_ARCH STREQUAL x64)
- set(CLR_CMAKE_TARGET_ARCH_AMD64 1)
- elseif(CLR_CMAKE_TARGET_ARCH STREQUAL x86)
- set(CLR_CMAKE_TARGET_ARCH_I386 1)
- elseif(CLR_CMAKE_TARGET_ARCH STREQUAL arm64)
- set(CLR_CMAKE_TARGET_ARCH_ARM64 1)
- elseif(CLR_CMAKE_TARGET_ARCH STREQUAL arm)
- set(CLR_CMAKE_TARGET_ARCH_ARM 1)
- elseif(CLR_CMAKE_TARGET_ARCH STREQUAL armel)
- set(CLR_CMAKE_TARGET_ARCH_ARM 1)
- set(ARM_SOFTFP 1)
- else()
- clr_unknown_arch()
-endif()
-
-# check if host & target arch combination are valid
-if(NOT(CLR_CMAKE_TARGET_ARCH STREQUAL CLR_CMAKE_HOST_ARCH))
- if(NOT((CLR_CMAKE_HOST_ARCH_AMD64 AND CLR_CMAKE_TARGET_ARCH_ARM64) OR (CLR_CMAKE_HOST_ARCH_I386 AND CLR_CMAKE_TARGET_ARCH_ARM) OR (CLR_CMAKE_HOST_ARCH_AMD64 AND CLR_CMAKE_TARGET_ARCH_ARM)))
- message(FATAL_ERROR "Invalid host and target arch combination")
- endif()
-endif()
-
#-----------------------------------------------------
# Initialize Cmake compiler flags and other variables
#-----------------------------------------------------
diff --git a/src/coreclr/tests/setup-stress-dependencies.sh b/src/coreclr/tests/setup-stress-dependencies.sh
index 9ab4170e3fa..8141123fc63 100755
--- a/src/coreclr/tests/setup-stress-dependencies.sh
+++ b/src/coreclr/tests/setup-stress-dependencies.sh
@@ -104,7 +104,7 @@ fi
# Use uname to determine what the OS is.
OSName=$(uname -s)
-case $OSName in
+case "$OSName" in
Linux)
__BuildOS=Linux
__HostOS=Linux
@@ -144,8 +144,8 @@ esac
isPortable=0
-source "${scriptDir}"/../init-distro-rid.sh
-initDistroRidGlobal ${__BuildOS} x64 ${isPortable}
+source "${scriptDir}"/../../../eng/native/init-distro-rid.sh
+initDistroRidGlobal "$__BuildOS" x64 "$isPortable"
# Hack, replace the rid to ubuntu.14.04 which has a valid non-portable
# package.
@@ -153,22 +153,22 @@ initDistroRidGlobal ${__BuildOS} x64 ${isPortable}
# The CoreDisTools package is currently manually packaged and we only have
# 14.04 and 16.04 packages. Use the oldest package which will work on newer
# platforms.
-if [[ ${__BuildOS} == "Linux" ]]; then
- if [[ ${__BuildArch} == "x64" ]]; then
+if [ "$__BuildOS" = "Linux" ]; then
+ if [ "$__BuildArch" = "x64" ]; then
__DistroRid=ubuntu.14.04-x64
- elif [[ ${__BuildArch} == "x86" ]]; then
+ elif [ "$__BuildArch" = "x86" ]; then
__DistroRid=ubuntu.14.04-x86
fi
fi
# Query runtime Id
-rid=${__DistroRid}
+rid="$__DistroRid"
echo "Rid to be used: ${rid}"
if [ -z "$rid" ]; then
exit_with_error 1 "Failed to query runtime Id"
-fi
+fi
# Download the package
echo Downloading CoreDisTools package
diff --git a/src/installer/corehost/CMakeLists.txt b/src/installer/corehost/CMakeLists.txt
index eccefce32ad..ca3a9bed66b 100644
--- a/src/installer/corehost/CMakeLists.txt
+++ b/src/installer/corehost/CMakeLists.txt
@@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 3.14.2)
project(corehost)
+include(${CLR_ENG_NATIVE_DIR}/functions.cmake)
+include(${CLR_ENG_NATIVE_DIR}/configuretools.cmake)
+include(${CLR_ENG_NATIVE_DIR}/configureplatform.cmake)
include(../settings.cmake)
include(../functions.cmake)
add_subdirectory(cli)
diff --git a/src/installer/corehost/Windows/gen-buildsys-win.bat b/src/installer/corehost/Windows/gen-buildsys-win.bat
index d2404e5797a..e5935d75901 100644
--- a/src/installer/corehost/Windows/gen-buildsys-win.bat
+++ b/src/installer/corehost/Windows/gen-buildsys-win.bat
@@ -16,11 +16,11 @@ set __VSString=%__VSString:"=%
set __ExtraCmakeParams=
:: Set the target architecture to a format cmake understands. ANYCPU defaults to x64
-set __RIDArch=%3
-if /i "%3" == "x64" (set cm_BaseRid=win7&&set cm_Arch=AMD64&&set __ExtraCmakeParams=%__ExtraCmakeParams% -A x64)
-if /i "%3" == "x86" (set cm_BaseRid=win7&&set cm_Arch=I386&&set __ExtraCmakeParams=%__ExtraCmakeParams% -A Win32)
-if /i "%3" == "arm" (set cm_BaseRid=win8&&set cm_Arch=ARM&&set __ExtraCmakeParams=%__ExtraCmakeParams% -A ARM)
-if /i "%3" == "arm64" (set cm_BaseRid=win10&&set cm_Arch=ARM64&&set __ExtraCmakeParams=%__ExtraCmakeParams% -A ARM64)
+set __Arch=%3
+if /i "%__Arch%" == "x64" (set cm_BaseRid=win7&&set __ExtraCmakeParams=%__ExtraCmakeParams% -A x64)
+if /i "%__Arch%" == "x86" (set cm_BaseRid=win7&&set __ExtraCmakeParams=%__ExtraCmakeParams% -A Win32)
+if /i "%__Arch%" == "arm" (set cm_BaseRid=win8&&set __ExtraCmakeParams=%__ExtraCmakeParams% -A ARM)
+if /i "%__Arch%" == "arm64" (set cm_BaseRid=win10&&set __ExtraCmakeParams=%__ExtraCmakeParams% -A ARM64)
set __LatestCommit=%4
set __HostVersion=%5
@@ -30,7 +30,7 @@ set __HostPolicyVersion=%8
:: Form the base RID to be used if we are doing a portable build
if /i "%9" == "1" (set cm_BaseRid=win)
-set cm_BaseRid=%cm_BaseRid%-%__RIDArch%
+set cm_BaseRid=%cm_BaseRid%-%__Arch%
echo "Computed RID for native build is %cm_BaseRid%"
if defined CMakePath goto DoGen
@@ -41,8 +41,12 @@ for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy ByPass "& .\Win
popd
:DoGen
-echo "%CMakePath%" %__sourceDir% "-DCMAKE_SYSTEM_VERSION=10.0" "-DCLI_CMAKE_HOST_VER=%__HostVersion%" "-DCLI_CMAKE_COMMON_HOST_VER=%__AppHostVersion%" "-DCLI_CMAKE_HOST_FXR_VER=%__HostFxrVersion%" "-DCLI_CMAKE_HOST_POLICY_VER=%__HostPolicyVersion%" "-DCLI_CMAKE_PKG_RID=%cm_BaseRid%" "-DCLI_CMAKE_COMMIT_HASH=%__LatestCommit%" "-DCLI_CMAKE_PLATFORM_ARCH_%cm_Arch%=1" "-DCMAKE_INSTALL_PREFIX=%__CMakeBinDir%" "-DCLI_CMAKE_RESOURCE_DIR=%__ResourcesDir%" -G "Visual Studio %__VSString%" %__ExtraCmakeParams%
-"%CMakePath%" %__sourceDir% "-DCMAKE_SYSTEM_VERSION=10.0" "-DCLI_CMAKE_HOST_VER=%__HostVersion%" "-DCLI_CMAKE_COMMON_HOST_VER=%__AppHostVersion%" "-DCLI_CMAKE_HOST_FXR_VER=%__HostFxrVersion%" "-DCLI_CMAKE_HOST_POLICY_VER=%__HostPolicyVersion%" "-DCLI_CMAKE_PKG_RID=%cm_BaseRid%" "-DCLI_CMAKE_COMMIT_HASH=%__LatestCommit%" "-DCLI_CMAKE_PLATFORM_ARCH_%cm_Arch%=1" "-DCMAKE_INSTALL_PREFIX=%__CMakeBinDir%" "-DCLI_CMAKE_RESOURCE_DIR=%__ResourcesDir%" -G "Visual Studio %__VSString%" %__ExtraCmakeParams%
+set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCMAKE_SYSTEM_VERSION=10.0" "-DCLI_CMAKE_HOST_VER=%__HostVersion%" "-DCLI_CMAKE_COMMON_HOST_VER=%__AppHostVersion%" "-DCLI_CMAKE_HOST_FXR_VER=%__HostFxrVersion%"
+set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCLI_CMAKE_HOST_POLICY_VER=%__HostPolicyVersion%" "-DCLI_CMAKE_PKG_RID=%cm_BaseRid%" "-DCLI_CMAKE_COMMIT_HASH=%__LatestCommit%" "-DCLR_CMAKE_HOST_ARCH=%__Arch%"
+set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCMAKE_INSTALL_PREFIX=%__CMakeBinDir%" "-DCLI_CMAKE_RESOURCE_DIR=%__ResourcesDir%" "-DCLR_ENG_NATIVE_DIR="%__sourceDir%\..\..\..\eng\native"
+
+echo "%CMakePath%" %__sourceDir% -G "Visual Studio %__VSString%" %__ExtraCmakeParams%
+"%CMakePath%" %__sourceDir% -G "Visual Studio %__VSString%" %__ExtraCmakeParams%
endlocal
GOTO :DONE
diff --git a/src/installer/corehost/build.proj b/src/installer/corehost/build.proj
index a666f704f85..12c6909e73f 100644
--- a/src/installer/corehost/build.proj
+++ b/src/installer/corehost/build.proj
@@ -27,11 +27,10 @@
<PropertyGroup>
<CMakeBuildDir>$(IntermediateOutputRootPath)corehost\cmake\</CMakeBuildDir>
- <BuildArgs>--configuration $(ConfigurationGroup) --arch $(TargetArchitecture) --apphostver $(AppHostVersion) --hostver $(HostVersion) --fxrver $(HostResolverVersion) --policyver $(HostPolicyVersion) --commithash $(LatestCommit)</BuildArgs>
- <BuildArgs Condition="'$(PortableBuild)' == 'true'">$(BuildArgs) -portable</BuildArgs>
- <BuildArgs Condition="'$(CrossBuild)' == 'true'">$(BuildArgs) --cross</BuildArgs>
- <BuildArgs Condition="'$(StripSymbols)' == 'true'">$(BuildArgs) --stripsymbols</BuildArgs>
- <BuildArgs>$(BuildArgs) --rootdir $(RepoRoot)</BuildArgs>
+ <BuildArgs>$(ConfigurationGroup) $(TargetArchitecture) -apphostver "$(AppHostVersion)" -hostver "$(HostVersion)" -fxrver "$(HostResolverVersion)" -policyver "$(HostPolicyVersion)" -commithash "$(LatestCommit)"</BuildArgs>
+ <BuildArgs Condition="'$(PortableBuild)' != 'true'">$(BuildArgs) -portablebuild=false</BuildArgs>
+ <BuildArgs Condition="'$(CrossBuild)' == 'true'">$(BuildArgs) -cross</BuildArgs>
+ <BuildArgs Condition="'$(StripSymbols)' == 'true'">$(BuildArgs) -stripsymbols</BuildArgs>
</PropertyGroup>
<!--
diff --git a/src/installer/corehost/build.sh b/src/installer/corehost/build.sh
index e1fba6b35a3..5cd97ec0ded 100755
--- a/src/installer/corehost/build.sh
+++ b/src/installer/corehost/build.sh
@@ -1,282 +1,102 @@
#!/usr/bin/env bash
-init_rid_plat()
-{
- # Detect Distro
- if [ $__CrossBuild == 1 ]; then
- if [ -z $ROOTFS_DIR ]; then
- echo "ROOTFS_DIR is not defined."
- exit -1
- else
- if [ -e $ROOTFS_DIR/etc/os-release ]; then
- source $ROOTFS_DIR/etc/os-release
- __rid_plat="$ID.$VERSION_ID"
- if [[ "$ID" == "alpine" ]]; then
- __rid_plat="linux-musl"
- fi
- fi
- echo "__rid_plat is $__rid_plat"
- fi
- else
- __rid_plat=""
- if [ -e /etc/os-release ]; then
- source /etc/os-release
- if [[ "$ID" == "rhel" ]]; then
- # remove the last version number
- VERSION_ID=${VERSION_ID%.*}
- fi
- __rid_plat="$ID${VERSION_ID:+.$VERSION_ID}"
- if [[ "$ID" == "alpine" ]]; then
- __rid_plat="linux-musl"
- fi
- fi
- fi
-
- if [ "$(uname -s)" == "Darwin" ]; then
- __rid_plat=osx.10.12
- fi
- if [ "$(uname -s)" == "FreeBSD" ]; then
- major_ver=`uname -U | cut -b1-2`
- __rid_plat=freebsd.$major_ver
- fi
-
- if [ $__linkPortable == 1 ]; then
- if [ "$(uname -s)" == "Darwin" ]; then
- __rid_plat="osx"
- elif [ "$(uname -s)" == "FreeBSD" ]; then
- __rid_plat="freebsd"
- else
- __rid_plat="linux"
- fi
- fi
-}
-
-usage()
-{
- echo "Usage: $0 --rootdir <path> --configuration <configuration> --arch <Architecture> --hostver <Dotnet exe version> --apphostver <app host exe version> --fxrver <HostFxr library version> --policyver <HostPolicy library version> --commithash <Git commit hash> [--xcompiler <Cross C++ Compiler>]"
- echo ""
- echo "Options:"
- echo " --rootdir <path> Path to the root of the repository. Required."
- echo " --configuration <configuration> Build configuration (Debug, Release)"
- echo " --arch <Architecture> Target Architecture (x64, x86, arm, arm64, armel)"
- echo " --hostver <Dotnet host version> Version of the dotnet executable"
- echo " --apphostver <app host version> Version of the apphost executable"
- echo " --fxrver <HostFxr version> Version of the hostfxr library"
- echo " --policyver <HostPolicy version> Version of the hostpolicy library"
- echo " --commithash <Git commit hash> Current commit hash of the repo at build time"
- echo " -portable Optional argument to build portable platform packages."
- echo " --cross Optional argument to signify cross compilation,"
- echo " and use ROOTFS_DIR environment variable to find rootfs."
- echo " --stripsymbols Optional argument to strip native symbols during the build"
-
- exit 1
-}
+usage_list=("-hostver <Dotnet host version>: Version of the dotnet executable.")
+usage_list+=("-apphostver <app host version>: Version of the apphost executable.")
+usage_list+=("-fxrver <HostFxr version>: Version of the hostfxr library.")
+usage_list+=("-policyver <HostPolicy version>: Version of the hostpolicy library.")
+usage_list+=("-commithash <Git commit hash>: Current commit hash of the repo at build time.")
set -e
-SOURCE="${BASH_SOURCE[0]}"
-while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
- DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
- SOURCE="$(readlink "$SOURCE")"
- [[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
-done
-DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
-__build_arch=
+__scriptpath="$(cd "$(dirname "$0")"; pwd -P)"
+__RepoRootDir="$(cd "$__scriptpath"/../../..; pwd -P)"
+
+__BuildArch=x64
+__BuildOS=Linux
+__BuildType=Debug
+__CMakeArgs=""
+__Compiler=clang
+__CompilerMajorVersion=
+__CompilerMinorVersion=
+__CrossBuild=0
+__IsMSBuildOnNETCoreSupported=0
+__PortableBuild=1
+__RootBinDir="$__RepoRootDir/artifacts"
+__SkipConfigure=0
+__SkipGenerateVersion=0
+__StaticLibLink=0
+__UnprocessedBuildArgs=
+__VerboseBuild=false
__host_ver=
__apphost_ver=
__policy_ver=
__fxr_ver=
-__CrossBuild=0
__commit_hash=
-__portableBuildArgs=
-__configuration=Debug
-__linkPortable=0
-__cmake_defines=
-__cmake_bin_prefix=
-while [ "$1" != "" ]; do
- lowerI="$(echo $1 | awk '{print tolower($0)}')"
- case $lowerI in
- -h|--help)
- usage
- exit 1
- ;;
- --arch)
- shift
- __build_arch=$1
- ;;
- --configuration)
- shift
- __configuration=$1
- ;;
- --hostver)
- shift
- __host_ver=$1
- ;;
- --apphostver)
- shift
- __apphost_ver=$1
- ;;
- --fxrver)
- shift
- __fxr_ver=$1
- ;;
- --policyver)
- shift
- __policy_ver=$1
+handle_arguments() {
+
+ case "$1" in
+ hostver|-hostver)
+ __host_ver="$2"
+ __ShiftArgs=1
;;
- --commithash)
- shift
- __commit_hash=$1
+
+ apphostver|-apphostver)
+ __apphost_ver="$2"
+ __ShiftArgs=1
;;
- -portable)
- __portableBuildArgs="-DCLI_CMAKE_PORTABLE_BUILD=1"
- __linkPortable=1
+
+ fxrver|-fxrver)
+ __fxr_ver="$2"
+ __ShiftArgs=1
;;
- --cross)
- __CrossBuild=1
+
+ policyver|-policyver)
+ __policy_ver="$2"
+ __ShiftArgs=1
;;
- --stripsymbols)
- __cmake_defines="${__cmake_defines} -DSTRIP_SYMBOLS=true"
+
+ commithash|-commithash)
+ __commit_hash="$2"
+ __ShiftArgs=1
;;
- --rootdir)
- shift
- RootRepo=$1
- ;;
+
*)
- echo "Unknown argument to build.sh $1"; usage; exit 1
+ __UnprocessedBuildArgs="$__UnprocessedBuildArgs $1"
esac
- shift
-done
-
-if [ "$RootRepo" == "" ]; then
- usage
-fi
-
-__bin_dir="$RootRepo/artifacts/bin"
-__baseIntermediateOutputPath="$RootRepo/artifacts/obj"
-__versionSourceFile="$__baseIntermediateOutputPath/_version.c"
-
-__cmake_defines="${__cmake_defines} -DCMAKE_BUILD_TYPE=${__configuration} ${__portableBuildArgs}"
-
-mkdir -p "$__baseIntermediateOutputPath"
-
-case $__build_arch in
- amd64|x64)
- __arch_define=-DCLI_CMAKE_PLATFORM_ARCH_AMD64=1
- ;;
- x86)
- __arch_define=-DCLI_CMAKE_PLATFORM_ARCH_I386=1
- ;;
- arm|armel)
- __arch_define=-DCLI_CMAKE_PLATFORM_ARCH_ARM=1
- ;;
- arm64)
- __arch_define=-DCLI_CMAKE_PLATFORM_ARCH_ARM64=1
- ;;
- *)
- echo "Unknown architecture $__build_arch"; usage; exit 1
- ;;
-esac
-__cmake_defines="${__cmake_defines} ${__arch_define}"
-
-# Configure environment if we are doing a cross compile.
-if [ "$__CrossBuild" == 1 ]; then
- if ! [[ -n $ROOTFS_DIR ]]; then
- export ROOTFS_DIR="$RootRepo/.tools/rootfs/$__build_arch"
- fi
-fi
+}
-# __base_rid is the base RID that corehost is shipped for, effectively, the name of the folder in "runtimes/{__base_rid}/native/" inside the nupkgs.
-# __rid_plat is the OS portion of the RID.
-__rid_plat=
-init_rid_plat
+source "$__RepoRootDir"/eng/native/build-commons.sh
-if [ -z $__rid_plat ]; then
- echo "Unknown base rid (eg.: osx.10.12, ubuntu.14.04) being targeted"
- exit -1
-fi
+# Set dependent variables
+__LogsDir="$__RootBinDir/log"
+__MsbuildDebugLogsDir="$__LogsDir/MsbuildDebugLogs"
-if [ -z $__commit_hash ]; then
- echo "Commit hash was not specified"
- exit -1
-fi
+# Set the remaining variables based upon the determined build configuration
+__DistroRidLower="$(echo $__DistroRid | tr '[:upper:]' '[:lower:]')"
+__BinDir="$__RootBinDir/bin/$__DistroRidLower.$__BuildType"
+__IntermediatesDir="$__RootBinDir/obj/$__DistroRidLower.$__BuildType"
-__build_arch_lowcase=$(echo "$__build_arch" | tr '[:upper:]' '[:lower:]')
-__base_rid=$__rid_plat-$__build_arch_lowcase
-echo "Computed RID for native build is $__base_rid"
-__cmake_bin_prefix="$__bin_dir/$__base_rid.$__configuration"
-__intermediateOutputPath="$__baseIntermediateOutputPath/$__base_rid.$__configuration/corehost"
-export __CrossToolChainTargetRID=$__base_rid
+export __BinDir __IntermediatesDir
-# Set up the environment to be used for building with clang.
-if command -v "clang-3.5" > /dev/null 2>&1; then
- export CC="$(command -v clang-3.5)"
- export CXX="$(command -v clang++-3.5)"
-elif command -v "clang-3.6" > /dev/null 2>&1; then
- export CC="$(command -v clang-3.6)"
- export CXX="$(command -v clang++-3.6)"
-elif command -v "clang-3.9" > /dev/null 2>&1; then
- export CC="$(command -v clang-3.9)"
- export CXX="$(command -v clang++-3.9)"
-elif command -v "clang-5.0" > /dev/null 2>&1; then
- export CC="$(command -v clang-5.0)"
- export CXX="$(command -v clang++-5.0)"
-elif command -v "clang-9" > /dev/null 2>&1; then
- export CC="$(command -v clang-9)"
- export CXX="$(command -v clang++-9)"
-elif command -v clang > /dev/null 2>&1; then
- export CC="$(command -v clang)"
- export CXX="$(command -v clang++)"
-else
- echo "Unable to find Clang Compiler"
- echo "Install clang-3.5 or clang3.6 or clang3.9 or clang5.0 or clang9"
- exit 1
-fi
+__CMakeArgs="-DCLI_CMAKE_HOST_VER=\"$__host_ver\" -DCLI_CMAKE_COMMON_HOST_VER=\"$__apphost_ver\" -DCLI_CMAKE_HOST_FXR_VER=\"$__fxr_ver\""
+__CMakeArgs="-DCLI_CMAKE_HOST_POLICY_VER=\"$__policy_ver\" -DCLI_CMAKE_PKG_RID=\"$__DistroRid\" -DCLI_CMAKE_COMMIT_HASH=\"$__commit_hash\" $__CMakeArgs"
-if [ ! -f $__versionSourceFile ]; then
- __versionSourceLine="static char sccsid[] __attribute__((used)) = \"@(#)No version information produced\";"
- echo $__versionSourceLine > $__versionSourceFile
+if [[ "$__PortableBuild" == 1 ]]; then
+ __CMakeArgs="-DCLI_CMAKE_PORTABLE_BUILD=1 $__CMakeArgs"
fi
-__cmake_defines="${__cmake_defines} -DVERSION_FILE_PATH=${__versionSourceFile}"
+# Specify path to be set for CMAKE_INSTALL_PREFIX.
+# This is where all built CoreClr libraries will copied to.
+__CMakeBinDir="$__BinDir"
+export __CMakeBinDir
-mkdir -p $__intermediateOutputPath
-pushd $__intermediateOutputPath
+# Make the directories necessary for build if they don't exist
+setup_dirs
-echo "Building Corehost from $DIR to $(pwd)"
-set -x # turn on trace
-if [ $__CrossBuild == 1 ]; then
- # clang-3.9 or clang-9 are default compilers for cross compilation
- if [[ "$__build_arch" != "arm" && "$__build_arch" != "armel" ]]; then
- if command -v "clang-3.9" > /dev/null 2>&1; then
- export CC="$(command -v clang-3.9)"
- export CXX="$(command -v clang++-3.9)"
- elif command -v "clang-9" > /dev/null 2>&1; then
- export CC="$(command -v clang-9)"
- export CXX="$(command -v clang++-9)"
- fi
- elif command -v "clang-4.0" > /dev/null 2>&1; then
- export CC="$(command -v clang-4.0)"
- export CXX="$(command -v clang++-4.0)"
- elif command -v "clang-5.0" > /dev/null 2>&1; then
- export CC="$(command -v clang-5.0)"
- export CXX="$(command -v clang++-5.0)"
- elif command -v "clang-9" > /dev/null 2>&1; then
- export CC="$(command -v clang-9)"
- export CXX="$(command -v clang++-9)"
- else
- echo "Unable to find Clang 3.9 or Clang 4.0 or Clang 5.0 or Clang 9 Compiler"
- echo "Install clang-3.9 or clang-4.0 or clang-5.0 or clang-9 for cross compilation"
- exit 1
- fi
- export TARGET_BUILD_ARCH=$__build_arch_lowcase
- export __DistroRid=$__rid_plat
- cmake "$DIR" -G "Unix Makefiles" $__cmake_defines -DCLI_CMAKE_HOST_VER=$__host_ver -DCLI_CMAKE_COMMON_HOST_VER=$__apphost_ver -DCLI_CMAKE_HOST_FXR_VER=$__fxr_ver -DCLI_CMAKE_HOST_POLICY_VER=$__policy_ver -DCLI_CMAKE_PKG_RID=$__base_rid -DCLI_CMAKE_COMMIT_HASH=$__commit_hash -DCMAKE_INSTALL_PREFIX=$__cmake_bin_prefix -DCMAKE_TOOLCHAIN_FILE=$RootRepo/eng/common/cross/toolchain.cmake
-else
- cmake "$DIR" -G "Unix Makefiles" $__cmake_defines -DCLI_CMAKE_HOST_VER=$__host_ver -DCLI_CMAKE_COMMON_HOST_VER=$__apphost_ver -DCLI_CMAKE_HOST_FXR_VER=$__fxr_ver -DCLI_CMAKE_HOST_POLICY_VER=$__policy_ver -DCLI_CMAKE_PKG_RID=$__base_rid -DCLI_CMAKE_COMMIT_HASH=$__commit_hash -DCMAKE_INSTALL_PREFIX=$__cmake_bin_prefix
-fi
-popd
+# Check prereqs.
+check_prereqs
-set +x # turn off trace
-cmake --build $__intermediateOutputPath --target install --config $__configuration
+# Build the installer native components.
+# note the third argument, tryrun_dir is empty for installers
+build_native "$__BuildArch" "$__scriptpath" "" "$__IntermediatesDir" "installer component"
diff --git a/src/installer/corehost/cli/apphost/CMakeLists.txt b/src/installer/corehost/cli/apphost/CMakeLists.txt
index 241c994f436..10ac01f5c09 100644
--- a/src/installer/corehost/cli/apphost/CMakeLists.txt
+++ b/src/installer/corehost/cli/apphost/CMakeLists.txt
@@ -2,11 +2,11 @@
# The .NET Foundation licenses this file to you under the MIT license.
# See the LICENSE file in the project root for more information.
-project(apphost)
+project(apphost)
set(DOTNET_PROJECT_NAME "apphost")
# Add RPATH to the apphost binary that allows using local copies of shared libraries
-# dotnet core depends on for special scenarios when system wide installation of such
+# dotnet core depends on for special scenarios when system wide installation of such
# dependencies is not possible for some reason.
# This cannot be enabled for MacOS (Darwin) since its RPATH works in a different way,
# doesn't apply to libraries loaded via dlopen and most importantly, it is not transitive.
@@ -56,12 +56,12 @@ add_definitions(-DFEATURE_APPHOST=1)
# Disable manifest generation into the file .exe on Windows
if(WIN32)
- set_property(TARGET ${PROJECT_NAME} PROPERTY
- LINK_FLAGS "/MANIFEST:NO"
- )
+ set_property(TARGET ${PROJECT_NAME} PROPERTY
+ LINK_FLAGS "/MANIFEST:NO"
+ )
endif()
# Specify non-default Windows libs to be used for Arm/Arm64 builds
-if (WIN32 AND (CLI_CMAKE_PLATFORM_ARCH_ARM OR CLI_CMAKE_PLATFORM_ARCH_ARM64))
+if (WIN32 AND (CLR_CMAKE_HOST_ARCH_ARM OR CLR_CMAKE_HOST_ARCH_ARM64))
target_link_libraries(apphost Advapi32.lib shell32.lib)
endif()
diff --git a/src/installer/corehost/cli/comhost/CMakeLists.txt b/src/installer/corehost/cli/comhost/CMakeLists.txt
index 6be26bb349e..576000ff4fc 100644
--- a/src/installer/corehost/cli/comhost/CMakeLists.txt
+++ b/src/installer/corehost/cli/comhost/CMakeLists.txt
@@ -39,7 +39,7 @@ if (WIN32)
set(WINLIBS wintrust.lib)
# Specify non-default Windows libs to be used for Arm/Arm64 builds
- if (CLI_CMAKE_PLATFORM_ARCH_ARM OR CLI_CMAKE_PLATFORM_ARCH_ARM64)
+ if (CLR_CMAKE_HOST_ARCH_ARM OR CLR_CMAKE_HOST_ARCH_ARM64)
list(APPEND WINLIBS Advapi32.lib Ole32.lib OleAut32.lib)
endif()
diff --git a/src/installer/corehost/cli/common.cmake b/src/installer/corehost/cli/common.cmake
index 63e7306df31..fef6fb88c7c 100644
--- a/src/installer/corehost/cli/common.cmake
+++ b/src/installer/corehost/cli/common.cmake
@@ -68,7 +68,7 @@ function(set_common_libs TargetType)
endif()
# Specify the import library to link against for Arm32 build since the default set is minimal
- if (CLI_CMAKE_PLATFORM_ARCH_ARM)
+ if (CLR_CMAKE_HOST_ARCH_ARM)
if (WIN32)
target_link_libraries(${DOTNET_PROJECT_NAME} shell32.lib)
else()
diff --git a/src/installer/corehost/cli/ijwhost/CMakeLists.txt b/src/installer/corehost/cli/ijwhost/CMakeLists.txt
index e4be42a6d19..dee3347b977 100644
--- a/src/installer/corehost/cli/ijwhost/CMakeLists.txt
+++ b/src/installer/corehost/cli/ijwhost/CMakeLists.txt
@@ -36,12 +36,12 @@ add_definitions(-DFEATURE_LIBHOST=1)
convert_to_absolute_path(SOURCES ${SOURCES})
convert_to_absolute_path(ASM_HELPERS_SOURCES ${ASM_HELPERS_SOURCES})
-if (WIN32 AND (CLI_CMAKE_PLATFORM_ARCH_ARM OR CLI_CMAKE_PLATFORM_ARCH_ARM64))
+if (WIN32 AND (CLR_CMAKE_HOST_ARCH_ARM OR CLR_CMAKE_HOST_ARCH_ARM64))
preprocess_compile_asm(ASM_FILES ${ASM_HELPERS_SOURCES} OUTPUT_OBJECTS ASM_HELPERS_OBJECTS)
list(APPEND ASM_HELPERS_SOURCES ${ASM_HELPERS_OBJECTS})
endif ()
-if (WIN32 AND CLI_CMAKE_PLATFORM_ARCH_I386)
+if (WIN32 AND CLR_CMAKE_HOST_ARCH_I386)
set_source_files_properties(${ASM_HELPERS_SOURCES} PROPERTIES COMPILE_FLAGS "/safeseh")
endif ()
@@ -50,9 +50,9 @@ list(APPEND SOURCES ${ASM_HELPERS_SOURCES})
include(../lib.cmake)
# Specify non-default Windows libs to be used for Arm/Arm64 builds
-if (WIN32 AND (CLI_CMAKE_PLATFORM_ARCH_ARM OR CLI_CMAKE_PLATFORM_ARCH_ARM64))
+if (WIN32 AND (CLR_CMAKE_HOST_ARCH_ARM OR CLR_CMAKE_HOST_ARCH_ARM64))
target_link_libraries(ijwhost Advapi32.lib Ole32.lib)
endif()
install(TARGETS ijwhost DESTINATION corehost)
-install_symbols (ijwhost corehost) \ No newline at end of file
+install_symbols (ijwhost corehost)
diff --git a/src/installer/corehost/cli/test/nativehost/CMakeLists.txt b/src/installer/corehost/cli/test/nativehost/CMakeLists.txt
index ef0de0dd3f8..6d688b5eb6e 100644
--- a/src/installer/corehost/cli/test/nativehost/CMakeLists.txt
+++ b/src/installer/corehost/cli/test/nativehost/CMakeLists.txt
@@ -50,6 +50,6 @@ include(../testexe.cmake)
target_link_libraries(${DOTNET_PROJECT_NAME} nethost)
# Specify non-default Windows libs to be used for Arm/Arm64 builds
-if (WIN32 AND (CLI_CMAKE_PLATFORM_ARCH_ARM OR CLI_CMAKE_PLATFORM_ARCH_ARM64))
+if (WIN32 AND (CLR_CMAKE_HOST_ARCH_ARM OR CLR_CMAKE_HOST_ARCH_ARM64))
target_link_libraries(${DOTNET_PROJECT_NAME} Advapi32.lib Ole32.lib OleAut32.lib)
endif()
diff --git a/src/installer/corehost/cli/test_fx_ver/CMakeLists.txt b/src/installer/corehost/cli/test_fx_ver/CMakeLists.txt
index d7d8db0171d..8590b9d3c30 100644
--- a/src/installer/corehost/cli/test_fx_ver/CMakeLists.txt
+++ b/src/installer/corehost/cli/test_fx_ver/CMakeLists.txt
@@ -39,6 +39,6 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
target_link_libraries (${EXE_NAME} "dl")
endif()
-if((${CMAKE_SYSTEM_NAME} MATCHES "Linux") AND CLI_CMAKE_PLATFORM_ARCH_ARM)
+if((${CMAKE_SYSTEM_NAME} MATCHES "Linux") AND CLR_CMAKE_HOST_ARCH_ARM)
target_link_libraries (${EXE_NAME} "atomic")
endif()
diff --git a/src/installer/corehost/cli/winrthost/CMakeLists.txt b/src/installer/corehost/cli/winrthost/CMakeLists.txt
index 0ef36ddba12..2c93d6082cd 100644
--- a/src/installer/corehost/cli/winrthost/CMakeLists.txt
+++ b/src/installer/corehost/cli/winrthost/CMakeLists.txt
@@ -29,11 +29,11 @@ include(../lib.cmake)
add_definitions(-DFEATURE_LIBHOST=1)
# Specify non-default Windows libs to be used for Arm/Arm64 builds
-if (WIN32 AND (CLI_CMAKE_PLATFORM_ARCH_ARM OR CLI_CMAKE_PLATFORM_ARCH_ARM64))
+if (WIN32 AND (CLR_CMAKE_HOST_ARCH_ARM OR CLR_CMAKE_HOST_ARCH_ARM64))
target_link_libraries(winrthost Advapi32.lib Ole32.lib OleAut32.lib)
endif()
target_link_libraries(winrthost RuntimeObject.lib)
install(TARGETS winrthost DESTINATION corehost)
-install_symbols(winrthost corehost) \ No newline at end of file
+install_symbols(winrthost corehost)
diff --git a/src/installer/functions.cmake b/src/installer/functions.cmake
index 0da68c7424f..78aeea246e2 100644
--- a/src/installer/functions.cmake
+++ b/src/installer/functions.cmake
@@ -45,11 +45,11 @@ function(get_include_directories IncludeDirectories)
get_directory_property(dirs INCLUDE_DIRECTORIES)
foreach(dir IN LISTS dirs)
- if (CLR_CMAKE_PLATFORM_ARCH_ARM AND WIN32)
+ if (CLR_CMAKE_HOST_ARCH_ARM AND WIN32)
list(APPEND INC_DIRECTORIES /I${dir})
else()
list(APPEND INC_DIRECTORIES -I${dir})
- endif(CLR_CMAKE_PLATFORM_ARCH_ARM AND WIN32)
+ endif(CLR_CMAKE_HOST_ARCH_ARM AND WIN32)
endforeach()
set(${IncludeDirectories} ${INC_DIRECTORIES} PARENT_SCOPE)
@@ -127,12 +127,12 @@ endfunction()
function(get_include_directories_asm IncludeDirectories)
get_directory_property(dirs INCLUDE_DIRECTORIES)
- if (CLI_CMAKE_PLATFORM_ARCH_ARM AND WIN32)
+ if (CLR_CMAKE_HOST_ARCH_ARM AND WIN32)
list(APPEND INC_DIRECTORIES "-I ")
endif()
foreach(dir IN LISTS dirs)
- if (CLI_CMAKE_PLATFORM_ARCH_ARM AND WIN32)
+ if (CLR_CMAKE_HOST_ARCH_ARM AND WIN32)
list(APPEND INC_DIRECTORIES ${dir};)
else()
list(APPEND INC_DIRECTORIES -I${dir})
diff --git a/src/installer/settings.cmake b/src/installer/settings.cmake
index efec063dc81..3bfe8105509 100644
--- a/src/installer/settings.cmake
+++ b/src/installer/settings.cmake
@@ -4,48 +4,6 @@
set (CMAKE_CXX_STANDARD 11)
-include(CheckPIESupported)
-
-# All code we build should be compiled as position independent
-check_pie_supported(OUTPUT_VARIABLE PIE_SUPPORT_OUTPUT LANGUAGES CXX)
-if(NOT MSVC AND NOT CMAKE_CXX_LINK_PIE_SUPPORTED)
- message(WARNING "PIE is not supported at link time: ${PIE_SUPPORT_OUTPUT}.\n"
- "PIE link options will not be passed to linker.")
-endif()
-
-set(CMAKE_POSITION_INDEPENDENT_CODE ON)
-
-if(CMAKE_SYSTEM_NAME STREQUAL Linux)
- set(CLR_CMAKE_PLATFORM_UNIX 1)
- message("System name Linux")
-endif(CMAKE_SYSTEM_NAME STREQUAL Linux)
-
-if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
- set(CLR_CMAKE_PLATFORM_UNIX 1)
- message("System name Darwin")
-endif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
-
-if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
- set(CLR_CMAKE_PLATFORM_UNIX 1)
- add_definitions(-D_BSD_SOURCE) # required for getline
- message("System name FreeBSD")
-endif(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
-
-if(CMAKE_SYSTEM_NAME STREQUAL OpenBSD)
- set(CLR_CMAKE_PLATFORM_UNIX 1)
- message("System name OpenBSD")
-endif(CMAKE_SYSTEM_NAME STREQUAL OpenBSD)
-
-if(CMAKE_SYSTEM_NAME STREQUAL NetBSD)
- set(CLR_CMAKE_PLATFORM_UNIX 1)
- message("System name NetBSD")
-endif(CMAKE_SYSTEM_NAME STREQUAL NetBSD)
-
-if(CMAKE_SYSTEM_NAME STREQUAL SunOS)
- set(CLR_CMAKE_PLATFORM_UNIX 1)
- message("System name SunOS")
-endif(CMAKE_SYSTEM_NAME STREQUAL SunOS)
-
if (NOT WIN32)
# Try to locate the paxctl tool. Failure to find it is not fatal,
# but the generated executables won't work on a system where PAX is set
@@ -81,7 +39,7 @@ if (NOT WIN32)
endif ()
function(strip_symbols targetName outputFilename)
- if(CLR_CMAKE_PLATFORM_UNIX)
+ if(CLR_CMAKE_HOST_UNIX)
if(STRIP_SYMBOLS)
# On the older version of cmake (2.8.12) used on Ubuntu 14.04 the TARGET_FILE
@@ -120,7 +78,7 @@ function(strip_symbols targetName outputFilename)
set(${outputFilename} ${strip_destination_file} PARENT_SCOPE)
endif(STRIP_SYMBOLS)
- endif(CLR_CMAKE_PLATFORM_UNIX)
+ endif(CLR_CMAKE_HOST_UNIX)
endfunction()
function(install_symbols targetName destination_path)
@@ -242,24 +200,24 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
add_definitions(-D__LINUX__)
endif()
-if(CLI_CMAKE_PLATFORM_ARCH_I386)
+if(CLR_CMAKE_HOST_ARCH_I386)
add_definitions(-D_TARGET_X86_=1)
set(ARCH_SPECIFIC_FOLDER_NAME "i386")
-elseif(CLI_CMAKE_PLATFORM_ARCH_AMD64)
+elseif(CLR_CMAKE_HOST_ARCH_AMD64)
add_definitions(-D_TARGET_AMD64_=1)
set(ARCH_SPECIFIC_FOLDER_NAME "AMD64")
-elseif(CLI_CMAKE_PLATFORM_ARCH_ARM)
+elseif(CLR_CMAKE_HOST_ARCH_ARM)
add_definitions(-D_TARGET_ARM_=1)
set(ARCH_SPECIFIC_FOLDER_NAME "arm")
-elseif(CLI_CMAKE_PLATFORM_ARCH_ARM64)
- add_definitions(-D_TARGET_ARM64_=1)
+elseif(CLR_CMAKE_HOST_ARCH_ARM64)
+ add_definitions(-D_TARGET_ARM64_=1)
set(ARCH_SPECIFIC_FOLDER_NAME "arm64")
else()
message(FATAL_ERROR "Unknown target architecture")
endif()
# Specify the Windows SDK to be used for Arm builds
-if (WIN32 AND (CLI_CMAKE_PLATFORM_ARCH_ARM OR CLI_CMAKE_PLATFORM_ARCH_ARM64))
+if (WIN32 AND (CLR_CMAKE_HOST_ARCH_ARM OR CLR_CMAKE_HOST_ARCH_ARM64))
if(NOT DEFINED CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION OR CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION STREQUAL "" )
message(FATAL_ERROR "Windows SDK is required for the Arm32 or Arm64 build.")
else()
@@ -268,7 +226,7 @@ if (WIN32 AND (CLI_CMAKE_PLATFORM_ARCH_ARM OR CLI_CMAKE_PLATFORM_ARCH_ARM64))
endif ()
if (WIN32)
- if(CLI_CMAKE_PLATFORM_ARCH_ARM)
+ if(CLR_CMAKE_HOST_ARCH_ARM)
# Explicitly specify the assembler to be used for Arm32 compile
file(TO_CMAKE_PATH "$ENV{VCToolsInstallDir}\\bin\\HostX86\\arm\\armasm.exe" CMAKE_ASM_COMPILER)
@@ -278,7 +236,7 @@ if (WIN32)
# Enable generic assembly compilation to avoid CMake generate VS proj files that explicitly
# use ml[64].exe as the assembler.
enable_language(ASM)
- elseif(CLI_CMAKE_PLATFORM_ARCH_ARM64)
+ elseif(CLR_CMAKE_HOST_ARCH_ARM64)
# Explicitly specify the assembler to be used for Arm64 compile
file(TO_CMAKE_PATH "$ENV{VCToolsInstallDir}\\bin\\HostX86\\arm64\\armasm64.exe" CMAKE_ASM_COMPILER)
diff --git a/src/libraries/Native/Unix/CMakeLists.txt b/src/libraries/Native/Unix/CMakeLists.txt
index ae80db3fd96..1ec346cd092 100644
--- a/src/libraries/Native/Unix/CMakeLists.txt
+++ b/src/libraries/Native/Unix/CMakeLists.txt
@@ -22,7 +22,7 @@ set(CMAKE_INSTALL_PREFIX $ENV{__CMakeBinDir})
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
set(CMAKE_SHARED_LIBRARY_PREFIX "")
-set(VERSION_FILE_PATH "${CMAKE_BINARY_DIR}/../../_version.c")
+set(VERSION_FILE_PATH "${CMAKE_BINARY_DIR}/version.c")
# We mark the function which needs exporting with DLLEXPORT
add_compile_options(-fvisibility=hidden)
diff --git a/src/libraries/Native/build-native.cmd b/src/libraries/Native/build-native.cmd
index cefa656dd1c..5325a165f5a 100644
--- a/src/libraries/Native/build-native.cmd
+++ b/src/libraries/Native/build-native.cmd
@@ -127,6 +127,11 @@ may help to copy its "DIA SDK" folder into "%VSINSTALLDIR%" manually, then try a
exit /b 1
:GenVSSolution
+:: generate version file
+powershell -NoProfile -ExecutionPolicy ByPass -NoLogo -File "%__repoRoot%\eng\common\msbuild.ps1" /clp:nosummary %__ArcadeScriptArgs%^
+ %__repoRoot%\eng\empty.csproj /p:NativeVersionFile="%__artifactsDir%\obj\_version.h"^
+ /t:GenerateNativeVersionFile /restore
+
:: Regenerate the VS solution
pushd "%__IntermediatesDir%"
diff --git a/src/libraries/Native/build-native.proj b/src/libraries/Native/build-native.proj
index 75fab11e50b..99f5e238dc0 100644
--- a/src/libraries/Native/build-native.proj
+++ b/src/libraries/Native/build-native.proj
@@ -2,13 +2,10 @@
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props))" />
<!-- Target that builds all the native binaries in the Native folder -->
- <Target Name="Build" DependsOnTargets="GenerateNativeVersionFile;BuildNativeUnix;BuildNativeWindows" />
+ <Target Name="Build" DependsOnTargets="BuildNativeUnix;BuildNativeWindows" />
<PropertyGroup>
- <!-- Hardcode version paths in a global location. -->
- <NativeVersionFile Condition="'$(OS)' == 'Windows_NT'">$(ArtifactsObjDir)_version.h</NativeVersionFile>
- <NativeVersionFile Condition="'$(OS)' != 'Windows_NT'">$(ArtifactsObjDir)_version.c</NativeVersionFile>
- <_BuildNativeArgs>$(ArchGroup) $(ConfigurationGroup) $(OSGroup) outconfig $(Configuration)</_BuildNativeArgs>
+ <_BuildNativeArgs>$(ArchGroup) $(ConfigurationGroup) outconfig $(Configuration)</_BuildNativeArgs>
</PropertyGroup>
<Target Name="BuildNativeUnix"
@@ -19,17 +16,17 @@
MSBuildNodeCount should a good approximation for how many procs to use for native build, if we find that doesn't work
then we should consider calling Environment.ProcessorCount
-->
- <_ProcessorCountArg> --numproc $(MSBuildNodeCount)</_ProcessorCountArg>
- <_StripSymbolsArg Condition="'$(BuildNativeStripSymbols)' == 'true' and '$(OSGroup)' != 'WebAssembly'"> stripsymbols</_StripSymbolsArg>
- <_PortableBuildArg Condition="'$(PortableBuild)' == 'true'"> -portable</_PortableBuildArg>
+ <_ProcessorCountArg> -numproc $(MSBuildNodeCount)</_ProcessorCountArg>
+ <_StripSymbolsArg Condition="'$(BuildNativeStripSymbols)' == 'true' and '$(OSGroup)' != 'WebAssembly'"> -stripsymbols</_StripSymbolsArg>
+ <_PortableBuildArg Condition="'$(PortableBuild)' != 'true'"> -portablebuild=false</_PortableBuildArg>
+ <_CrossBuildArg Condition="'$(CrossBuild)' == 'true'"> -cross</_CrossBuildArg>
<!--
BuildNativeCompiler is a pass-through argument, to pass an argument to build-native.sh. It is intended to be
used to force a specific compiler toolset.
-->
<_BuildNativeCompilerArg Condition="'$(BuildNativeCompiler)' != ''"> $(BuildNativeCompiler)</_BuildNativeCompilerArg>
-
- <_BuildNativeUnixArgs>$(_BuildNativeArgs)$(_ProcessCountArg)$(_StripSymbolsArg)$(_PortableBuildArg)$(_BuildNativeCompilerArg)</_BuildNativeUnixArgs>
+ <_BuildNativeUnixArgs>$(_BuildNativeArgs)$(_ProcessCountArg)$(_StripSymbolsArg)$(_PortableBuildArg)$(_CrossBuildArg)$(_BuildNativeCompilerArg)</_BuildNativeUnixArgs>
</PropertyGroup>
<Message Text="$(MSBuildProjectDirectory)/build-native.sh $(_BuildNativeUnixArgs)" Importance="High"/>
@@ -41,10 +38,6 @@
<Target Name="BuildNativeWindows"
Condition="'$(OS)' == 'Windows_NT' and '$(TargetsNetFx)' != 'true'">
- <PropertyGroup>
- <_BuildNativeWindowsArgs>$(_BuildNativeArgs)</_BuildNativeWindowsArgs>
- </PropertyGroup>
-
<!-- Run script that invokes Cmake to create VS files, and then calls msbuild to compile them -->
<Message Text="&quot;$(MSBuildProjectDirectory)\build-native.cmd&quot; $(_BuildNativeArgs)" Importance="High"/>
<Exec Command="&quot;$(MSBuildProjectDirectory)\build-native.cmd&quot; $(_BuildNativeArgs)" />
diff --git a/src/libraries/Native/build-native.sh b/src/libraries/Native/build-native.sh
index 5247d468b38..9f0031031e8 100755
--- a/src/libraries/Native/build-native.sh
+++ b/src/libraries/Native/build-native.sh
@@ -1,398 +1,87 @@
#!/usr/bin/env bash
-usage()
-{
- echo "Our parameters changed! The parameters: buildArch, buildType, buildOS, numProc"
- echo "are passed by the Run Command Tool."
- echo "If you plan to only run this script, be sure to pass those parameters."
- echo "For more information type build-native.sh -? at the root of the repo."
- echo
- echo "Usage: $0 [runParameters][-verbose] [-clangx.y] [-gccx.y] [-cross] [-staticLibLink] [-cmakeargs] [-makeargs]"
- echo "runParameters: buildArch, buildType, buildOS, -numProc <numproc value>"
- echo "BuildArch can be: -x64, -x86, -arm, -armel, -arm64"
- echo "BuildType can be: -debug, -checked, -release"
- echo "-verbose - optional argument to enable verbose build output."
- echo "-clangx.y - optional argument to build using clang version x.y."
- echo "-gccx.y - optional argument to build using gcc version x.y."
- echo "-cross - optional argument to signify cross compilation,"
- echo " - will use ROOTFS_DIR environment variable if set."
- echo "-staticLibLink - Optional argument to statically link any native library."
- echo "-portable - Optional argument to build native libraries portable over GLIBC based Linux distros."
- echo "-stripSymbols - Optional argument to strip native symbols during the build."
- echo "-skipgenerateversion - Pass this in to skip getting a version on the build output."
- echo "-cmakeargs - user-settable additional arguments passed to CMake."
- exit 1
-}
-
-__scriptpath=$(cd "$(dirname "$0")"; pwd -P)
-__nativeroot=$__scriptpath/Unix
-__rootRepo=$(cd "$__scriptpath/../../.."; pwd -P)
-__artifactsDir="$__rootRepo/artifacts"
-
-initHostDistroRid()
-{
- __HostDistroRid=""
- if [ "$__HostOS" == "Linux" ]; then
- if [ -e /etc/os-release ]; then
- source /etc/os-release
- if [[ $ID == "alpine" ]]; then
- # remove the last version digit
- VERSION_ID=${VERSION_ID%.*}
- fi
- __HostDistroRid="$ID.$VERSION_ID-$__HostArch"
- fi
- elif [ "$__HostOS" == "OSX" ]; then
- _osx_version=`sw_vers -productVersion | cut -f1-2 -d'.'`
- __HostDistroRid="osx.$_osx_version-x64"
- elif [ "$__HostOS" == "FreeBSD" ]; then
- __freebsd_version=`sysctl -n kern.osrelease | cut -f1 -d'-'`
- __HostDistroRid="freebsd.$__freebsd_version-x64"
- fi
-
-
- if [ "$__HostDistroRid" == "" ]; then
- echo "WARNING: Can not determine runtime id for current distro."
- fi
-}
-
-initTargetDistroRid()
-{
- if [ $__CrossBuild == 1 ]; then
- if [ "$__BuildOS" == "Linux" ]; then
- if [ ! -e $ROOTFS_DIR/etc/os-release ]; then
- echo "WARNING: Can not determine runtime id for current distro."
- export __DistroRid=""
- else
- source $ROOTFS_DIR/etc/os-release
- export __DistroRid="$ID.$VERSION_ID-$__BuildArch"
- fi
- fi
- else
- export __DistroRid="$__HostDistroRid"
- fi
-}
-
-setup_dirs()
-{
- echo Setting up directories for build
-
- mkdir -p "$__BinDir"
- mkdir -p "$__IntermediatesDir"
-}
+usage_list=("-outconfig: Configuration, typically a quadruplet such as 'netcoreapp5.0-Linux-Release-x64', used to name output directory.")
+usage_list+=("-staticLibLink: Optional argument to statically link any native library.")
-# Check the system to ensure the right pre-reqs are in place
-check_native_prereqs()
-{
- echo "Checking pre-requisites..."
+__scriptpath="$(cd "$(dirname "$0")"; pwd -P)"
+__nativeroot="$__scriptpath"/Unix
+__RepoRootDir="$(cd "$__scriptpath"/../../..; pwd -P)"
+__artifactsDir="$__RepoRootDir/artifacts"
- # Check presence of CMake on the path
- hash cmake 2>/dev/null || { echo >&2 "Please install cmake before running this script"; exit 1; }
-}
-
-prepare_native_build()
-{
- # Specify path to be set for CMAKE_INSTALL_PREFIX.
- # This is where all built CoreClr libraries will copied to.
- export __CMakeBinDir="$__BinDir"
-
- # Configure environment if we are doing a verbose build
- if [ $__VerboseBuild == 1 ]; then
- export VERBOSE=1
- fi
-
- # Generate version.c if specified, else have an empty one.
- __versionSourceFile=$__artifactsDir/obj/_version.c
- if [ ! -e "${__versionSourceFile}" ]; then
- __versionSourceLine="static char sccsid[] __attribute__((used)) = \"@(#)No version information produced\";"
- echo "${__versionSourceLine}" > ${__versionSourceFile}
- fi
-}
+handle_arguments() {
-build_native()
-{
- # All set to commence the build
-
- echo "Commencing build of corefx native components for $__BuildOS.$__BuildArch.$__BuildType"
- cd "$__IntermediatesDir"
-
- if [ "$__BuildArch" == "wasm" ]; then
- if [ "$EMSDK_PATH" == "" ]; then
- echo "Error: Should set EMSDK_PATH environment variable pointing to emsdk root."
- exit 1
- fi
- source $EMSDK_PATH/emsdk_env.sh
- fi
-
- # Regenerate the CMake solution
- engNativeDir="$__rootRepo/eng/native"
- __CMakeExtraArgs="$__CMakeExtraArgs -DCLR_ENG_NATIVE_DIR=\"$engNativeDir\""
- nextCommand="\"$engNativeDir/gen-buildsys.sh\" \"$__nativeroot\" \"$__nativeroot\" \"$__IntermediatesDir\" $__BuildArch $__Compiler \"$__CompilerMajorVersion\" \"$__CompilerMinorVersion\" $__BuildType $__CMakeArgs $__CMakeExtraArgs"
- echo "Invoking $nextCommand"
- eval "$nextCommand"
-
- if [ $? != 0 ]; then
- echo "Failed to generate $message build project!"
- exit 1
- fi
-
- # Check that the makefiles were created.
-
- if [ ! -f "$__IntermediatesDir/CMakeCache.txt" ]; then
- echo "Unable to find generated build files for native component project!"
- exit 1
- fi
-
- # Build
+ case "$1" in
+ outconfig|-outconfig)
+ __outConfig="$2"
+ __ShiftArgs=1
+ ;;
- echo "Executing make install -j $__NumProc $__MakeExtraArgs"
+ staticliblink|-staticliblink)
+ __StaticLibLink=1
+ ;;
- make install -j $__NumProc $__MakeExtraArgs
- if [ $? != 0 ]; then
- echo "Failed to build corefx native components."
- exit 1
- fi
+ *)
+ __UnprocessedBuildArgs="$__UnprocessedBuildArgs $1"
+ esac
}
# Set the various build properties here so that CMake and MSBuild can pick them up
-__CMakeExtraArgs=""
-__MakeExtraArgs=""
__BuildArch=x64
-__BuildType=Debug
-__CMakeArgs=DEBUG
__BuildOS=Linux
-__NumProc=1
-__UnprocessedBuildArgs=
-__CrossBuild=0
-__ServerGC=0
-__VerboseBuild=false
+__BuildType=Debug
+__CMakeArgs=""
__Compiler=clang
__CompilerMajorVersion=
__CompilerMinorVersion=
+__CrossBuild=0
+__IsMSBuildOnNETCoreSupported=0
+__PortableBuild=1
+__RootBinDir="$__RepoRootDir/artifacts"
+__SkipConfigure=0
+__SkipGenerateVersion=0
__StaticLibLink=0
-__PortableBuild=0
-
-CPUName=$(uname -m)
-if [ "$CPUName" == "i686" ]; then
- __BuildArch=x86
-fi
-
-# Use uname to determine what the OS is.
-OSName=$(uname -s)
-case $OSName in
- Linux)
- __BuildOS=Linux
- __HostOS=Linux
- ;;
-
- Darwin)
- __BuildOS=OSX
- __HostOS=OSX
- ;;
-
- FreeBSD)
- __BuildOS=FreeBSD
- __HostOS=FreeBSD
- ;;
-
- OpenBSD)
- __BuildOS=OpenBSD
- __HostOS=OpenBSD
- ;;
-
- NetBSD)
- __BuildOS=NetBSD
- __HostOS=NetBSD
- ;;
-
- SunOS)
- __BuildOS=SunOS
- __HostOS=SunOS
- ;;
-
- *)
- echo "Unsupported OS $OSName detected, configuring as if for Linux"
- __BuildOS=Linux
- __HostOS=Linux
- ;;
-esac
-
-while :; do
- if [ $# -le 0 ]; then
- break
- fi
-
- lowerI="$(echo $1 | awk '{print tolower($0)}')"
- case $lowerI in
- -\?|-h|--help)
- usage
- exit 1
- ;;
- x86|-x86)
- __BuildArch=x86
- ;;
- x64|-x64)
- __BuildArch=x64
- ;;
- arm|-arm)
- __BuildArch=arm
- ;;
- armel|-armel)
- __BuildArch=armel
- ;;
- arm64|-arm64)
- __BuildArch=arm64
- ;;
- wasm|-wasm)
- __BuildArch=wasm
- ;;
- debug|-debug)
- __BuildType=Debug
- ;;
- release|-release)
- __BuildType=Release
- __CMakeArgs=RELEASE
- ;;
- outconfig|-outconfig)
- __outConfig=$2
- shift
- ;;
- freebsd|FreeBSD|-freebsd|-FreeBSD)
- __BuildOS=FreeBSD
- ;;
- linux|-linux)
- __BuildOS=Linux
- ;;
- netbsd|-netbsd)
- __BuildOS=NetBSD
- ;;
- osx|-osx)
- __BuildOS=OSX
- ;;
- stripsymbols|-stripsymbols)
- __CMakeExtraArgs="$__CMakeExtraArgs -DSTRIP_SYMBOLS=true"
- ;;
- numproc|-numproc|--numproc)
- shift
- __NumProc=$1
- ;;
- verbose|-verbose)
- __VerboseBuild=1
- ;;
- staticliblink|-staticliblink)
- __StaticLibLink=1
- ;;
- portable|-portable)
- # Portable native components are only supported on Linux
- if [ "$__HostOS" == "Linux" ]; then
- __PortableBuild=1
- fi
- ;;
- clang*|-clang*|--clang*)
- __Compiler=clang
- # clangx.y or clang-x.y
- version="$(echo "$lowerI" | tr -d '[:alpha:]-=')"
- parts=(${version//./ })
- __CompilerMajorVersion="${parts[0]}"
- __CompilerMinorVersion="${parts[1]}"
- if [ -z "$__CompilerMinorVersion" ] && [ "$__CompilerMajorVersion" -le 6 ]; then
- __CompilerMinorVersion=0;
- fi
- ;;
- gcc*|-gcc*)
- __Compiler=gcc
- # gccx.y or gcc-x.y
- version="$(echo "$lowerI" | tr -d '[:alpha:]-=')"
- parts=(${version//./ })
- __CompilerMajorVersion="${parts[0]}"
- __CompilerMinorVersion="${parts[1]}"
- ;;
- cross|-cross)
- __CrossBuild=1
- ;;
- cmakeargs|-cmakeargs)
- if [ -n "$2" ]; then
- __CMakeExtraArgs="$__CMakeExtraArgs $2"
- shift
- else
- echo "ERROR: 'cmakeargs' requires a non-empty option argument"
- exit 1
- fi
- ;;
- makeargs|-makeargs)
- if [ -n "$2" ]; then
- __MakeExtraArgs="$__MakeExtraArgs $2"
- shift
- else
- echo "ERROR: 'makeargs' requires a non-empty option argument"
- exit 1
- fi
- ;;
- useservergc|-useservergc)
- __ServerGC=1
- ;;
- *)
- __UnprocessedBuildArgs="$__UnprocessedBuildArgs $1"
- esac
+__UnprocessedBuildArgs=
+__VerboseBuild=false
- shift
-done
+source "$__RepoRootDir"/eng/native/build-commons.sh
# Set cross build
-if [ $__BuildArch != wasm ]; then
- __CMakeExtraArgs="$__CMakeExtraArgs -DFEATURE_DISTRO_AGNOSTIC_SSL=$__PortableBuild"
- __CMakeExtraArgs="$__CMakeExtraArgs -DCMAKE_STATIC_LIB_LINK=$__StaticLibLink"
+if [[ "$__BuildArch" != wasm ]]; then
+ __CMakeArgs="-DFEATURE_DISTRO_AGNOSTIC_SSL=$__PortableBuild $__CMakeArgs"
+ __CMakeArgs="-DCMAKE_STATIC_LIB_LINK=$__StaticLibLink $__CMakeArgs"
- case $CPUName in
- i686)
- if [ $__BuildArch != x86 ]; then
- __CrossBuild=1
- echo "Set CrossBuild for $__BuildArch build"
- fi
- ;;
- x86_64)
- if [ $__BuildArch != x64 ]; then
- __CrossBuild=1
- echo "Set CrossBuild for $__BuildArch build"
- fi
- ;;
- esac
+ if [[ "$__BuildArch" != x86 && "$__BuildArch" != x64 ]]; then
+ __CrossBuild=1
+ echo "Set CrossBuild for $__BuildArch build"
+ fi
+else
+ if [[ -z "$EMSDK_PATH" ]]; then
+ echo "Error: Should set EMSDK_PATH environment variable pointing to emsdk root."
+ exit 1
+ fi
+ source "$EMSDK_PATH"/emsdk_env.sh
fi
# set default OSX deployment target
-if [[ $__BuildOS == OSX ]]; then
- __CMakeExtraArgs="$__CMakeExtraArgs -DCMAKE_OSX_DEPLOYMENT_TARGET=10.13"
+if [[ "$__BuildOS" == OSX ]]; then
+ __CMakeArgs="-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13 $__CMakeArgs"
fi
# Set the remaining variables based upon the determined build configuration
-__outConfig=${__outConfig:-"$__BuildOS-$__BuildArch-$__BuildType"}
-__IntermediatesDir="$__artifactsDir/obj/native/$__outConfig"
-__BinDir="$__artifactsDir/bin/native/$__outConfig"
+__outConfig="${__outConfig:-"$__BuildOS-$__BuildArch-$__BuildType"}"
+__IntermediatesDir="$__RootBinDir/obj/native/$__outConfig"
+__BinDir="$__RootBinDir/bin/native/$__outConfig"
+
+# Specify path to be set for CMAKE_INSTALL_PREFIX.
+# This is where all built CoreClr libraries will copied to.
+__CMakeBinDir="$__BinDir"
+export __CMakeBinDir
# Make the directories necessary for build if they don't exist
setup_dirs
-# Configure environment if we are doing a cross compile.
-if [ "$__CrossBuild" == 1 ]; then
- export CROSSCOMPILE=1
- if ! [[ -n "$ROOTFS_DIR" ]]; then
- export ROOTFS_DIR="$__rootRepo/.tools/rootfs/$__BuildArch"
- fi
-fi
-
-# init the host distro name
-initHostDistroRid
-
-# init the target distro name
-initTargetDistroRid
-
- # Check prereqs.
-
- check_native_prereqs
-
- # Prepare the system
-
- prepare_native_build
-
- # Build the corefx native components.
+# Check prereqs.
+check_prereqs
- build_native
+# Build the corefx native components.
+build_native "$__BuildArch" "$__nativeroot" "$__nativeroot" "$__IntermediatesDir" "native libraries component"