summaryrefslogtreecommitdiff
path: root/build.sh
diff options
context:
space:
mode:
authorJiyoung Yun <jy910.yun@samsung.com>2016-12-27 07:46:08 (GMT)
committerJiyoung Yun <jy910.yun@samsung.com>2016-12-27 07:46:08 (GMT)
commitdb20f3f1bb8595633a7e16c8900fd401a453a6b5 (patch)
treee5435159cd1bf0519276363a6fe1663d1721bed3 /build.sh
parent4b4aad7217d3292650e77eec2cf4c198ea9c3b4b (diff)
downloadcoreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.zip
coreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.tar.gz
coreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.tar.bz2
Imported Upstream version 1.0.0.9127upstream/1.0.0.9127
Diffstat (limited to 'build.sh')
-rwxr-xr-xbuild.sh171
1 files changed, 132 insertions, 39 deletions
diff --git a/build.sh b/build.sh
index e639ca0..ca27844 100755
--- a/build.sh
+++ b/build.sh
@@ -42,6 +42,7 @@ usage()
echo "skipmscorlib - do not build mscorlib.dll."
echo "skiptests - skip the tests in the 'tests' subdirectory."
echo "skipnuget - skip building nuget packages."
+ echo "portableLinux - build for Portable Linux Distribution"
echo "verbose - optional argument to enable verbose build output."
echo "-skiprestore: skip restoring packages ^(default: packages are restored during build^)."
echo "-disableoss: Disable Open Source Signing for System.Private.CoreLib."
@@ -56,19 +57,41 @@ usage()
exit 1
}
-initDistroRid()
+initHostDistroRid()
{
- if [ "$__BuildOS" == "Linux" ]; then
+ if [ "$__HostOS" == "Linux" ]; then
if [ ! -e /etc/os-release ]; then
echo "WARNING: Can not determine runtime id for current distro."
- export __DistroRid=""
+ __HostDistroRid=""
else
source /etc/os-release
- export __DistroRid="$ID.$VERSION_ID-$__HostArch"
+ __HostDistroRid="$ID.$VERSION_ID-$__HostArch"
fi
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
+
+ # Portable builds target the base RID only for Linux based platforms
+ if [ $__PortableLinux == 1 ]; then
+ export __DistroRid="linux-$__BuildArch"
+ fi
+}
+
setup_dirs()
{
echo Setting up directories for build
@@ -77,6 +100,11 @@ setup_dirs()
mkdir -p "$__BinDir"
mkdir -p "$__LogsDir"
mkdir -p "$__IntermediatesDir"
+
+ if [ $__CrossBuild == 1 ]; then
+ mkdir -p "$__CrossComponentBinDir"
+ mkdir -p "$__CrossCompIntermediatesDir"
+ fi
}
# Check the system to ensure the right prereqs are in place
@@ -93,11 +121,10 @@ check_prereqs()
}
-build_coreclr()
-{
+generate_event_logging_sources()
+{
if [ $__SkipCoreCLR == 1 ]; then
- echo "Skipping CoreCLR build."
return
fi
@@ -143,10 +170,23 @@ build_coreclr()
fi
rm -rf "$__GeneratedIntermediateEventProvider"
+}
- # All set to commence the build
+build_native()
+{
+ skipCondition=$1
+ platformArch="$2"
+ intermediatesForBuild="$3"
+ extraCmakeArguments="$4"
+ message="$5"
+
+ if [ $skipCondition == 1 ]; then
+ echo "Skipping $message build."
+ return
+ fi
- echo "Commencing build of native components for $__BuildOS.$__BuildArch.$__BuildType in $__IntermediatesDir"
+ # All set to commence the build
+ echo "Commencing build of $message for $__BuildOS.$__BuildArch.$__BuildType in $intermediatesForBuild"
generator=""
buildFile="Makefile"
@@ -167,34 +207,34 @@ build_coreclr()
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.cpp
+ # Drop version.cpp file
+ __versionSourceFile="$intermediatesForBuild/version.cpp"
if [ $__SkipGenerateVersion == 0 ]; then
+ pwd
"$__ProjectRoot/run.sh" build -Project=$__ProjectDir/build.proj -generateHeaderUnix -NativeVersionSourceFile=$__versionSourceFile $__RunArgs $__UnprocessedBuildArgs
else
+ # Generate the dummy version.cpp, 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\";"
- echo $__versionSourceLine > $__versionSourceFile
+ if [ -e $__versionSourceFile ]; then
+ read existingVersionSourceLine < $__versionSourceFile
+ fi
+ if [ "$__versionSourceLine" != "$existingVersionSourceLine" ]; then
+ echo $__versionSourceLine > $__versionSourceFile
+ fi
fi
- echo "Restoring the OptimizationData package"
- "$__ProjectRoot/run.sh" sync -optdata
-
- pushd "$__IntermediatesDir"
+ pushd "$intermediatesForBuild"
# Regenerate the CMake solution
- __ExtraCmakeArgs="-DCLR_CMAKE_TARGET_OS=$__BuildOS -DCLR_CMAKE_PACKAGES_DIR=$__PackagesDir -DCLR_CMAKE_PGO_INSTRUMENT=$__PgoInstrument"
- echo "Invoking \"$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh\" \"$__ProjectRoot\" $__ClangMajorVersion $__ClangMinorVersion $__BuildArch $__BuildType $__CodeCoverage $__IncludeTests $generator $__ExtraCmakeArgs $__cmakeargs"
- "$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh" "$__ProjectRoot" $__ClangMajorVersion $__ClangMinorVersion $__BuildArch $__BuildType $__CodeCoverage $__IncludeTests $generator "$__ExtraCmakeArgs" "$__cmakeargs"
+ echo "Invoking \"$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh\" \"$__ProjectRoot\" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $__IncludeTests $generator $extraCmakeArguments $__cmakeargs"
+ "$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh" "$__ProjectRoot" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $__IncludeTests $generator "$extraCmakeArguments" "$__cmakeargs"
popd
fi
- # Check that the makefiles were created.
- pushd "$__IntermediatesDir"
-
- if [ ! -f "$__IntermediatesDir/$buildFile" ]; then
- echo "Failed to generate native component build project!"
+ if [ ! -f "$intermediatesForBuild/$buildFile" ]; then
+ echo "Failed to generate $message build project!"
exit 1
fi
-
+
# 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.
@@ -206,21 +246,24 @@ build_coreclr()
NumProc=$(($(getconf _NPROCESSORS_ONLN)+1))
fi
- # Build CoreCLR
-
+ # Build
if [ $__ConfigureOnly == 1 ]; then
- echo "Skipping CoreCLR build."
+ echo "Finish configuration & skipping $message build."
return
fi
+ # Check that the makefiles were created.
+ pushd "$intermediatesForBuild"
+
echo "Executing $buildTool install -j $NumProc"
$buildTool install -j $NumProc
if [ $? != 0 ]; then
- echo "Failed to build coreclr components."
+ echo "Failed to build $message."
exit 1
fi
- popd
+
+ popd
}
isMSBuildOnNETCoreSupported()
@@ -230,7 +273,7 @@ isMSBuildOnNETCoreSupported()
if [ "$__HostArch" == "x64" ]; then
if [ "$__HostOS" == "Linux" ]; then
- case "$__DistroRid" in
+ case "$__HostDistroRid" in
"centos.7-x64")
__isMSBuildOnNETCoreSupported=1
;;
@@ -261,6 +304,9 @@ isMSBuildOnNETCoreSupported()
"ubuntu.16.10-x64")
__isMSBuildOnNETCoreSupported=1
;;
+ "alpine.3.4.3-x64")
+ __isMSBuildOnNETCoreSupported=1
+ ;;
*)
esac
elif [ "$__HostOS" == "OSX" ]; then
@@ -475,9 +521,12 @@ __CrossBuild=0
__ClangMajorVersion=0
__ClangMinorVersion=0
__NuGetPath="$__PackagesDir/NuGet.exe"
+__HostDistroRid=""
__DistroRid=""
__cmakeargs=""
__SkipGenerateVersion=0
+__DoCrossArchBuild=0
+__PortableLinux=0
while :; do
if [ $# -le 0 ]; then
@@ -530,8 +579,17 @@ while :; do
cross)
__CrossBuild=1
;;
-
- verbose)
+
+ portablelinux)
+ if [ "$__BuildOS" == "Linux" ]; then
+ __PortableLinux=1
+ else
+ echo "ERROR: portableLinux not supported for non-Linux platforms."
+ exit 1
+ fi
+ ;;
+
+ verbose)
__VerboseBuild=1
;;
@@ -572,7 +630,6 @@ while :; do
__ConfigureOnly=1
__SkipMSCorLib=1
__SkipNuget=1
- __IncludeTests=
;;
skipconfigure)
@@ -589,6 +646,10 @@ while :; do
__SkipCoreCLR=1
;;
+ crosscomponent)
+ __DoCrossArchBuild=1
+ ;;
+
skipmscorlib)
__SkipMSCorLib=1
;;
@@ -664,8 +725,8 @@ fi
# Set dependent variables
__LogsDir="$__RootBinDir/Logs"
-# init the distro name
-initDistroRid
+# init the host distro name
+initHostDistroRid
# Set the remaining variables based upon the determined build configuration
__BinDir="$__RootBinDir/Product/$__BuildOS.$__BuildArch.$__BuildType"
@@ -675,6 +736,18 @@ __TestWorkingDir="$__RootBinDir/tests/$__BuildOS.$__BuildArch.$__BuildType"
export __IntermediatesDir="$__RootBinDir/obj/$__BuildOS.$__BuildArch.$__BuildType"
__TestIntermediatesDir="$__RootBinDir/tests/obj/$__BuildOS.$__BuildArch.$__BuildType"
__isMSBuildOnNETCoreSupported=0
+__CrossComponentBinDir="$__BinDir"
+__CrossCompIntermediatesDir="$__IntermediatesDir/crossgen"
+
+__CrossArch="$__HostArch"
+if [[ "$__HostArch" == "x64" && "$__BuildArch" == "arm" ]]; then
+ __CrossArch="x86"
+fi
+if [ $__CrossBuild == 1 ]; then
+ __CrossComponentBinDir="$__CrossComponentBinDir/$__CrossArch"
+fi
+__CrossgenCoreLibLog="$__LogsDir/CrossgenCoreLib_$__BuildOS.$BuildArch.$__BuildType.log"
+__CrossgenExe="$__CrossComponentBinDir/crossgen"
# Init if MSBuild for .NET Core is supported for this platform
isMSBuildOnNETCoreSupported
@@ -701,17 +774,37 @@ if [ $__CrossBuild == 1 ]; then
fi
fi
-# Make the directories necessary for build if they don't exist
+# init the target distro name
+initTargetDistroRid
+# Make the directories necessary for build if they don't exist
setup_dirs
# Check prereqs.
-
check_prereqs
+# Generate event logging infrastructure sources
+generate_event_logging_sources
+
# Build the coreclr (native) components.
+__ExtraCmakeArgs="-DCLR_CMAKE_TARGET_OS=$__BuildOS -DCLR_CMAKE_PACKAGES_DIR=$__PackagesDir -DCLR_CMAKE_PGO_INSTRUMENT=$__PgoInstrument"
+build_native $__SkipCoreCLR "$__BuildArch" "$__IntermediatesDir" "$__ExtraCmakeArgs" "CoreCLR component"
-build_coreclr
+# Build cross-architecture components
+if [ $__CrossBuild == 1 ]; then
+ __SkipCrossArchBuild=1
+ if [ $__DoCrossArchBuild == 1 ]; then
+ # build cross-architecture components for x86-host/arm-target
+ if [[ "$__BuildArch" == "arm" && "$__CrossArch" == "x86" ]]; then
+ __SkipCrossArchBuild=0
+ fi
+ fi
+
+ export __CMakeBinDir="$__CrossComponentBinDir"
+ export CROSSCOMPONENT=1
+ __ExtraCmakeArgs="-DCLR_CMAKE_TARGET_ARCH=$__BuildArch -DCLR_CMAKE_TARGET_OS=$__BuildOS -DCLR_CMAKE_PACKAGES_DIR=$__PackagesDir -DCLR_CMAKE_PGO_INSTRUMENT=$__PgoInstrument"
+ build_native $__SkipCrossArchBuild "$__CrossArch" "$__CrossCompIntermediatesDir" "$__ExtraCmakeArgs" "cross-architecture component"
+fi
# Build System.Private.CoreLib.