Skip to content

Commit 4cf7d0d

Browse files
author
jashook
committed
# This is a combination of 18 commits.
# This is the 1st commit message: Remove CoreFX runtest dependency This change will start using build-test.sh generatelayoutonly to build the coreoverlay directory for use with runtest.sh. # This is the commit message #2: Missing ./ # This is the commit message #3: Fix untar location # This is the commit message #4: Use portable builds # This is the commit message #5: Get ci green # This is the commit message #6: Small changes # This is the commit message #7: Small changes # This is the commit message #8: Small changes # This is the commit message #9: Add generateonly builds.sh # This is the commit message #10: Ensure correct test location # This is the commit message #11: netci change # This is the commit message #12: netci change # This is the commit message #13: Working on setting up build-test # This is the commit message #14: Remove generatelayoutonly # This is the commit message #15: Undo some of the changes to use generatelayoutonly # This is the commit message #16: Correctly remove build-test.sh invocation # This is the commit message #17: Fix build-test generatelayoutonly # This is the commit message #18: Fix a few netci issues
1 parent 600902d commit 4cf7d0d

File tree

5 files changed

+463
-73
lines changed

5 files changed

+463
-73
lines changed

build-test.sh

Lines changed: 154 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ initHostDistroRid()
66
if [ "$__HostOS" == "Linux" ]; then
77
if [ -e /etc/os-release ]; then
88
source /etc/os-release
9-
if [[ $ID == "alpine" ]]; then
9+
if [[ $ID == "alpine" || $ID == "rhel" ]]; then
1010
# remove the last version digit
1111
VERSION_ID=${VERSION_ID%.*}
1212
fi
@@ -18,13 +18,25 @@ initHostDistroRid()
1818
fi
1919
fi
2020
fi
21+
22+
if [ "$__HostOS" == "OSX" ]; then
23+
__PortableBuild=1
24+
fi
25+
26+
# Portable builds target the base RID
27+
if [ "$__PortableBuild" == 1 ]; then
28+
if [ "$__BuildOS" == "OSX" ]; then
29+
export __HostDistroRid="osx-$__BuildArch"
30+
fi
31+
fi
32+
2133
if [ "$__HostOS" == "FreeBSD" ]; then
2234
__freebsd_version=`sysctl -n kern.osrelease | cut -f1 -d'.'`
2335
__HostDistroRid="freebsd.$__freebsd_version-$__HostArch"
2436
fi
2537

2638
if [ "$__HostDistroRid" == "" ]; then
27-
echo "WARNING: Cannot determine runtime id for current distro."
39+
echo "WARNING: Can not determine runtime id for current distro."
2840
fi
2941
}
3042

@@ -33,8 +45,13 @@ initTargetDistroRid()
3345
if [ $__CrossBuild == 1 ]; then
3446
if [ "$__BuildOS" == "Linux" ]; then
3547
if [ ! -e $ROOTFS_DIR/etc/os-release ]; then
36-
echo "WARNING: Can not determine runtime id for current distro."
37-
export __DistroRid=""
48+
if [ -e $ROOTFS_DIR/android_platform ]; then
49+
source $ROOTFS_DIR/android_platform
50+
export __DistroRid="$RID"
51+
else
52+
echo "WARNING: Can not determine runtime id for current distro."
53+
export __DistroRid=""
54+
fi
3855
else
3956
source $ROOTFS_DIR/etc/os-release
4057
export __DistroRid="$ID.$VERSION_ID-$__BuildArch"
@@ -52,16 +69,21 @@ initTargetDistroRid()
5269
if [ "$__PortableBuild" == 1 ]; then
5370
if [ "$__BuildOS" == "Linux" ]; then
5471
export __DistroRid="linux-$__BuildArch"
72+
export __RuntimeId="linux-$__BuildArch"
5573
elif [ "$__BuildOS" == "OSX" ]; then
5674
export __DistroRid="osx-$__BuildArch"
75+
export __RuntimeId="osx-$__BuildArch"
76+
elif [ "$__BuildOS" == "FreeBSD" ]; then
77+
export __DistroRid="freebsd-$__BuildArch"
78+
export __RuntimeId="freebsd-$__BuildArch"
5779
fi
5880
fi
5981

60-
if [ "$ID.$VERSION_ID" == "ubuntu.16.04" ]; then
82+
if [ "$ID.$VERSION_ID" == "ubuntu.16.04" ]; then
6183
export __DistroRid="ubuntu.14.04-$__BuildArch"
62-
fi
84+
fi
6385

64-
echo "__DistroRid: " $__DistroRid
86+
echo "__DistroRid: " $__DistroRid
6587
}
6688

6789
isMSBuildOnNETCoreSupported()
@@ -89,7 +111,7 @@ isMSBuildOnNETCoreSupported()
89111
fi
90112
}
91113

92-
build_Tests()
114+
generate_layout()
93115
{
94116
__TestDir=$__ProjectDir/tests
95117
__ProjectFilesDir=$__TestDir
@@ -108,10 +130,10 @@ build_Tests()
108130
__TestIntermediateDir="tests/obj/${__BuildOS}.${__BuildArch}.${__BuildType}"
109131
fi
110132

111-
echo "__BuildOS: ${__BuildOS}"
112-
echo "__BuildArch: ${__BuildArch}"
113-
echo "__BuildType: ${__BuildType}"
114-
echo "__TestIntermediateDir: ${__TestIntermediateDir}"
133+
echo "__BuildOS: ${__BuildOS}"
134+
echo "__BuildArch: ${__BuildArch}"
135+
echo "__BuildType: ${__BuildType}"
136+
echo "__TestIntermediateDir: ${__TestIntermediateDir}"
115137

116138
if [ ! -f "$__TestBinDir" ]; then
117139
echo "Creating TestBinDir: ${__TestBinDir}"
@@ -132,27 +154,96 @@ build_Tests()
132154

133155
build_Tests_internal "Restore_Product" "${__ProjectDir}/tests/build.proj" " -BatchRestorePackages" "Restore product binaries (build tests)"
134156

135-
build_Tests_internal "Tests_GenerateRuntimeLayout" "${__ProjectDir}/tests/runtest.proj" "-BinPlaceRef -BinPlaceProduct -CopyCrossgenToProduct" "Restore product binaries (run tests)"
136-
137157
if [ -n "$__UpdateInvalidPackagesArg" ]; then
138158
__up=-updateinvalidpackageversion
139159
fi
140160

161+
echo "${__MsgPrefix}Creating test overlay..."
162+
163+
if [ -z "$XuintTestBinBase" ]; then
164+
XuintTestBinBase=$__TestWorkingDir
165+
fi
166+
167+
export CORE_ROOT=$XuintTestBinBase/Tests/Core_Root
168+
169+
if [ ! -f "${CORE_ROOT}" ]; then
170+
mkdir -p $CORE_ROOT
171+
else
172+
rm -rf $CORE_ROOT/*
173+
fi
174+
175+
build_Tests_internal "Tests_Overlay_Managed" "${__ProjectDir}/tests/runtest.proj" "-testOverlay" "Creating test overlay"
176+
177+
if [ $__ZipTests -ne 0 ]; then
178+
echo "${__MsgPrefix}ZIP tests packages..."
179+
build_Tests_internal "Helix_Prep" "$__ProjectDir/tests/helixprep.proj" " " "Prep test binaries for Helix publishing"
180+
fi
181+
182+
# Make sure to copy over the pulled down packages
183+
cp -r $__BinDir/* $CORE_ROOT/ > /dev/null
184+
141185
# Work hardcoded path around
142186
if [ ! -f "${__BuildToolsDir}/Microsoft.CSharp.Core.Targets" ]; then
143187
ln -s "${__BuildToolsDir}/Microsoft.CSharp.Core.targets" "${__BuildToolsDir}/Microsoft.CSharp.Core.Targets"
144188
fi
145189
if [ ! -f "${__BuildToolsDir}/Microsoft.CSharp.targets" ]; then
146190
ln -s "${__BuildToolsDir}/Microsoft.CSharp.Targets" "${__BuildToolsDir}/Microsoft.CSharp.targets"
147191
fi
192+
}
193+
194+
build_Tests()
195+
{
196+
__TestDir=$__ProjectDir/tests
197+
__ProjectFilesDir=$__TestDir
198+
__TestBinDir=$__TestWorkingDir
199+
200+
if [ $__RebuildTests -ne 0 ]; then
201+
if [ -d "${__TestBinDir}" ]; then
202+
echo "Removing tests build dir: ${__TestBinDir}"
203+
rm -rf $__TestBinDir
204+
fi
205+
fi
206+
207+
__CMakeBinDir="${__TestBinDir}"
208+
209+
if [ -z "$__TestIntermediateDir" ]; then
210+
__TestIntermediateDir="tests/obj/${__BuildOS}.${__BuildArch}.${__BuildType}"
211+
fi
212+
213+
echo "__BuildOS: ${__BuildOS}"
214+
echo "__BuildArch: ${__BuildArch}"
215+
echo "__BuildType: ${__BuildType}"
216+
echo "__TestIntermediateDir: ${__TestIntermediateDir}"
217+
218+
if [ ! -f "$__TestBinDir" ]; then
219+
echo "Creating TestBinDir: ${__TestBinDir}"
220+
mkdir -p $__TestBinDir
221+
fi
222+
if [ ! -f "$__LogsDir" ]; then
223+
echo "Creating LogsDir: ${__LogsDir}"
224+
mkdir -p $__LogsDir
225+
fi
226+
227+
__BuildProperties="-p:OSGroup=${__BuildOS} -p:BuildOS=${__BuildOS} -p:BuildArch=${__BuildArch} -p:BuildType=${__BuildType}"
228+
229+
# =========================================================================================
230+
# ===
231+
# === Restore product binaries from packages
232+
# ===
233+
# =========================================================================================
234+
235+
if [ -n "$__BuildAgainstPackagesArg" ]; then
236+
build_Tests_internal "Restore_Product" "${__ProjectDir}/tests/build.proj" " -BatchRestorePackages" "Restore product binaries (build tests)"
237+
build_Tests_internal "Tests_GenerateRuntimeLayout" "${__ProjectDir}/tests/runtest.proj" "-BinPlaceRef -BinPlaceProduct -CopyCrossgenToProduct" "Restore product binaries (run tests)"
238+
fi
148239

149240
echo "Starting the Managed Tests Build..."
150241

151242
__ManagedTestBuiltMarker=${__TestBinDir}/managed_test_build
152243

153244
if [ ! -f $__ManagedTestBuiltMarker ]; then
154245

155-
build_Tests_internal "Tests_Managed" "$__ProjectDir/tests/build.proj" "$__up" "Managed tests build (build tests)"
246+
build_Tests_internal "Tests_Managed" "$__ProjectDir/tests/build.proj" "$__up" "Managed tests build (build tests)"
156247

157248
if [ $? -ne 0 ]; then
158249
echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)"
@@ -188,6 +279,10 @@ build_Tests()
188279
fi
189280
fi
190281

282+
if [ -n "$__UpdateInvalidPackagesArg" ]; then
283+
__up=-updateinvalidpackageversion
284+
fi
285+
191286
echo "${__MsgPrefix}Creating test overlay..."
192287

193288
if [ -z "$XuintTestBinBase" ]; then
@@ -202,25 +297,34 @@ build_Tests()
202297
rm -rf $CORE_ROOT/*
203298
fi
204299

205-
cp -r $__BinDir/* $CORE_ROOT/ > /dev/null
206-
207-
build_Tests_internal "Tests_Overlay_Managed" "$__ProjectDir/tests/runtest.proj" "-testOverlay" "Creating test overlay"
300+
build_Tests_internal "Tests_Overlay_Managed" "${__ProjectDir}/tests/runtest.proj" "-testOverlay" "Creating test overlay"
208301

209302
if [ $__ZipTests -ne 0 ]; then
210303
echo "${__MsgPrefix}ZIP tests packages..."
211304
build_Tests_internal "Helix_Prep" "$__ProjectDir/tests/helixprep.proj" " " "Prep test binaries for Helix publishing"
212305
fi
306+
307+
# Make sure to copy over the pulled down packages
308+
cp -r $__BinDir/* $CORE_ROOT/ > /dev/null
309+
310+
# Work hardcoded path around
311+
if [ ! -f "${__BuildToolsDir}/Microsoft.CSharp.Core.Targets" ]; then
312+
ln -s "${__BuildToolsDir}/Microsoft.CSharp.Core.targets" "${__BuildToolsDir}/Microsoft.CSharp.Core.Targets"
313+
fi
314+
if [ ! -f "${__BuildToolsDir}/Microsoft.CSharp.targets" ]; then
315+
ln -s "${__BuildToolsDir}/Microsoft.CSharp.Targets" "${__BuildToolsDir}/Microsoft.CSharp.targets"
316+
fi
213317
}
214318

215319
build_Tests_internal()
216320
{
217-
subDirectoryName=$1
218-
projectName=$2
219-
extraBuildParameters=$3
220-
stepName="$4"
321+
subDirectoryName=$1
322+
projectName=$2
323+
extraBuildParameters=$3
324+
stepName="$4"
221325

222-
# Set up directories and file names
223-
__BuildLogRootName=$subDirectoryName
326+
# Set up directories and file names
327+
__BuildLogRootName=$subDirectoryName
224328
__BuildLog="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.log"
225329
__BuildWrn="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.wrn"
226330
__BuildErr="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.err"
@@ -262,8 +366,11 @@ usage()
262366
echo "crosscomponent - optional argument to build cross-architecture component,"
263367
echo " - will use CAC_ROOTFS_DIR environment variable if set."
264368
echo "portableLinux - build for Portable Linux Distribution"
369+
echo "portablebuild - Use portable build."
265370
echo "verbose - optional argument to enable verbose build output."
266371
echo "rebuild - if tests have already been built - rebuild them"
372+
echo "generatelayoutonly - only pull down dependencies and build coreroot"
373+
echo "buildagainstpackages - pull down and build using packages."
267374
echo "runtests - run tests after building them"
268375
echo "ziptests - zips CoreCLR tests & Core_Root for a Helix run"
269376
echo "bindir - output directory (defaults to $__ProjectRoot/bin)"
@@ -376,6 +483,7 @@ __ClangMajorVersion=0
376483
__ClangMinorVersion=0
377484
__NuGetPath="$__PackagesDir/NuGet.exe"
378485
__HostDistroRid=""
486+
__BuildAgainstPackagesArg=
379487
__DistroRid=""
380488
__cmakeargs=""
381489
__PortableLinux=0
@@ -385,9 +493,9 @@ __NativeTestIntermediatesDir=
385493
__RunTests=0
386494
__RebuildTests=0
387495
__BuildTestWrappers=0
496+
__GenarateLayoutOnly=
388497
CORE_ROOT=
389498

390-
391499
while :; do
392500
if [ $# -le 0 ]; then
393501
break
@@ -440,6 +548,10 @@ while :; do
440548
__CrossBuild=1
441549
;;
442550

551+
portableBuild)
552+
__PortableBuild=1
553+
;;
554+
443555
portablelinux)
444556
if [ "$__BuildOS" == "Linux" ]; then
445557
__PortableLinux=1
@@ -494,6 +606,14 @@ while :; do
494606
__ZipTests=1
495607
;;
496608

609+
generatelayoutonly)
610+
__GenarateLayoutOnly=1
611+
;;
612+
613+
buildagainstpackages)
614+
__BuildAgainstPackagesArg=1
615+
;;
616+
497617
bindir)
498618
if [ -n "$2" ]; then
499619
__RootBinDir="$2"
@@ -527,7 +647,7 @@ __RunArgs="-BuildArch=$__BuildArch -BuildType=$__BuildType -BuildOS=$__BuildOS"
527647
# Configure environment if we are doing a verbose build
528648
if [ $__VerboseBuild == 1 ]; then
529649
export VERBOSE=1
530-
__RunArgs="$__RunArgs -verbose"
650+
__RunArgs="$__RunArgs -verbose"
531651
fi
532652

533653
# Set default clang version
@@ -588,8 +708,9 @@ export __CMakeBinDir="$__BinDir"
588708

589709
if [ ! -d "$__BinDir" ] || [ ! -d "$__BinDir/bin" ]; then
590710

591-
echo "Has not been found built CoreCLR instance"
592-
echo "Please build it before tests using './build.sh $__BuildArch $__BuildType'"
711+
echo "Cannot find build directory for the Coreclr Product."
712+
echo "Please make sure CoreCLR is built before building tests."
713+
echo "Example use: './build.sh $__BuildArch $__BuildType'"
593714
exit 1
594715
fi
595716

@@ -611,7 +732,11 @@ __sharedFxDir=$__BuildToolsDir/dotnetcli/shared/Microsoft.NETCore.App/$__CoreClr
611732

612733
echo "Building Tests..."
613734

614-
build_Tests
735+
if [ -z "__GenerateLayoutOnly" ]; then
736+
build_Tests
737+
else
738+
generate_layout
739+
fi
615740

616741
if [ $? -ne 0 ]; then
617742
echo "Failed to build tests"

0 commit comments

Comments
 (0)