forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-test.sh
executable file
·678 lines (544 loc) · 23.1 KB
/
build-test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
#!/usr/bin/env bash
build_test_wrappers()
{
if [[ "$__BuildTestWrappers" -ne -0 ]]; then
echo "${__MsgPrefix}Creating test wrappers..."
__Exclude="${__ProjectDir}/tests/issues.targets"
__BuildLogRootName="Tests_XunitWrapper"
export __Exclude __BuildLogRootName
buildVerbosity="Summary"
if [[ "$__VerboseBuild" == 1 ]]; then
buildVerbosity="Diag"
fi
# Set up directories and file names
__BuildLogRootName="$subDirectoryName"
__BuildLog="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.log"
__BuildWrn="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.wrn"
__BuildErr="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.err"
__MsbuildLog="/fileloggerparameters:\"Verbosity=normal;LogFile=${__BuildLog}\""
__MsbuildWrn="/fileloggerparameters1:\"WarningsOnly;LogFile=${__BuildWrn}\""
__MsbuildErr="/fileloggerparameters2:\"ErrorsOnly;LogFile=${__BuildErr}\""
__Logging="$__MsbuildLog $__MsbuildWrn $__MsbuildErr /consoleloggerparameters:$buildVerbosity"
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
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 "$exitCode"
else
echo "XUnit Wrappers have been built."
echo { "\"build_os\"": "\"${__BuildOS}\"", "\"build_arch\"": "\"${__BuildArch}\"", "\"build_type\"": "\"${__BuildType}\"" } > "${__TestWorkingDir}/build_info.json"
fi
fi
}
generate_layout()
{
echo "${__MsgPrefix}Creating test overlay..."
__TestDir="$__ProjectDir"/tests
__ProjectFilesDir="$__TestDir"
__TestBinDir="$__TestWorkingDir"
if [[ "$__RebuildTests" -ne 0 ]]; then
if [[ -d "${__TestBinDir}" ]]; then
echo "Removing tests build dir: ${__TestBinDir}"
rm -rf "$__TestBinDir"
fi
fi
__CMakeBinDir="${__TestBinDir}"
if [[ -z "$__TestIntermediateDir" ]]; then
__TestIntermediateDir="tests/obj/${__BuildOS}.${__BuildArch}.${__BuildType}"
fi
echo "__BuildOS: ${__BuildOS}"
echo "__BuildArch: ${__BuildArch}"
echo "__BuildType: ${__BuildType}"
echo "__TestIntermediateDir: ${__TestIntermediateDir}"
if [[ ! -f "$__TestBinDir" ]]; then
echo "Creating TestBinDir: ${__TestBinDir}"
mkdir -p "$__TestBinDir"
fi
if [[ ! -f "$__LogsDir" ]]; then
echo "Creating LogsDir: ${__LogsDir}"
mkdir -p "$__LogsDir"
fi
if [[ ! -f "$__MsbuildDebugLogsDir" ]]; then
echo "Creating MsbuildDebugLogsDir: ${__MsbuildDebugLogsDir}"
mkdir -p "$__MsbuildDebugLogsDir"
fi
# Set up the directory for MSBuild debug logs.
MSBUILDDEBUGPATH="${__MsbuildDebugLogsDir}"
export MSBUILDDEBUGPATH
__BuildProperties="-p:OSGroup=${__BuildOS} -p:BuildOS=${__BuildOS} -p:BuildArch=${__BuildArch} -p:BuildType=${__BuildType}"
# =========================================================================================
# ===
# === Restore product binaries from packages
# ===
# =========================================================================================
build_MSBuild_projects "Restore_Packages" "${__ProjectDir}/tests/build.proj" "Restore product binaries (build tests)" "/t:BatchRestorePackages"
if [[ -n "$__UpdateInvalidPackagesArg" ]]; then
__up="/t:UpdateInvalidPackageVersions"
fi
echo "${__MsgPrefix}Creating test overlay..."
if [[ -z "$xUnitTestBinBase" ]]; then
xUnitTestBinBase="$__TestWorkingDir"
fi
CORE_ROOT="$xUnitTestBinBase"/Tests/Core_Root
export CORE_ROOT
if [[ -d "${CORE_ROOT}" ]]; then
rm -rf "$CORE_ROOT"
fi
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"
# Make sure to copy over the pulled down packages
cp -r "$__BinDir"/* "$CORE_ROOT/" > /dev/null
if [[ "$__BuildOS" != "OSX" ]]; then
nextCommand="\"$__TestDir/setup-stress-dependencies.sh\" --arch=$__BuildArch --outputDir=$CORE_ROOT"
echo "Resolve runtime dependences via $nextCommand"
eval $nextCommand
local exitCode="$?"
if [[ "$exitCode" != 0 ]]; then
echo "${__ErrMsgPrefix}${__MsgPrefix}Error: setup-stress-dependencies failed."
exit "$exitCode"
fi
fi
# Precompile framework assemblies with crossgen if required
if [[ "$__DoCrossgen" != 0 || "$__DoCrossgen2" != 0 ]]; then
precompile_coreroot_fx
fi
}
precompile_coreroot_fx()
{
local overlayDir="$CORE_ROOT"
local compilerName=Crossgen
# Read the exclusion file for this platform
skipCrossGenFiles=($(grep -v '^#' "$(dirname "$0")/tests/skipCrossGenFiles.${__BuildArch}.txt" 2> /dev/null))
skipCrossGenFiles+=('System.Runtime.WindowsRuntime.dll')
# Temporary output folder for Crossgen2-compiled assemblies
local outputDir="$overlayDir"/out
# Delete previously crossgened assemblies
rm "$overlayDir"/*.ni.dll
# Collect reference assemblies for Crossgen2
local crossgen2References=""
if [[ "$__DoCrossgen2" != 0 ]]; then
compilerName=Crossgen2
mkdir "$outputDir"
skipCrossGenFiles+=('Microsoft.CodeAnalysis.CSharp.dll')
skipCrossGenFiles+=('Microsoft.CodeAnalysis.dll')
skipCrossGenFiles+=('Microsoft.CodeAnalysis.VisualBasic.dll')
for reference in "$overlayDir"/*.dll; do
crossgen2References+=" -r:${reference}"
done
fi
echo "${__MsgPrefix}Running ${compilerName} on framework assemblies in CORE_ROOT: '${CORE_ROOT}'"
local totalPrecompiled=0
local failedToPrecompile=0
declare -a failedAssemblies
filesToPrecompile=$(find -L "$overlayDir" -maxdepth 1 -iname Microsoft.\*.dll -o -iname System.\*.dll -type f)
for fileToPrecompile in ${filesToPrecompile}; do
local filename="$fileToPrecompile"
if is_skip_crossgen_test "$(basename $filename)"; then
continue
fi
local commandLine=""
if [[ "$__DoCrossgen" != 0 ]]; then
commandLine="$__CrossgenExe /Platform_Assemblies_Paths $overlayDir $filename"
fi
if [[ "$__DoCrossgen2" != 0 ]]; then
commandLine="$overlayDir/crossgen2/crossgen2 $crossgen2References -O --inputbubble --out $outputDir/$(basename $filename) $filename"
fi
echo Precompiling "$filename"
$commandLine 1> "$filename".stdout 2> "$filename".stderr
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".
echo Command-line: "$commandLine"
cat "$filename".stdout
cat "$filename".stderr
failedAssemblies+=($(basename -- "$filename"))
failedToPrecompile=$((failedToPrecompile+1))
fi
else
rm "$filename".{stdout,stderr}
fi
totalPrecompiled=$((totalPrecompiled+1))
echo "Processed: $totalPrecompiled, failed $failedToPrecompile"
done
if [[ "$__DoCrossgen2" != 0 ]]; then
# Copy the Crossgen-compiled assemblies back to CORE_ROOT
mv -f "$outputDir"/* "$overlayDir"/
rm -r "$outputDir"
fi
if [[ "$failedToPrecompile" != 0 ]]; then
echo Failed assemblies:
for assembly in "${failedAssemblies[@]}"; do
echo " $assembly"
done
exit 1
fi
}
declare -a skipCrossGenFiles
function is_skip_crossgen_test {
for skip in "${skipCrossGenFiles[@]}"; do
if [[ "$1" == "$skip" ]]; then
return 0
fi
done
return 1
}
build_Tests()
{
echo "${__MsgPrefix}Building Tests..."
__TestDir="$__ProjectDir"/tests
__ProjectFilesDir="$__TestDir"
__TestBinDir="$__TestWorkingDir"
if [[ -f "${__TestWorkingDir}/build_info.json" ]]; then
rm "${__TestWorkingDir}/build_info.json"
fi
if [[ "$__RebuildTests" -ne 0 ]]; then
if [[ -d "$__TestBinDir" ]]; then
echo "Removing tests build dir: ${__TestBinDir}"
rm -rf "$__TestBinDir"
fi
fi
__CMakeBinDir="$__TestBinDir"
export __CMakeBinDir
if [[ ! -d "$__TestIntermediatesDir" ]]; then
mkdir -p "$__TestIntermediatesDir"
fi
__NativeTestIntermediatesDir="${__TestIntermediatesDir}/Native"
if [[ ! -d "${__NativeTestIntermediatesDir}" ]]; then
mkdir -p "${__NativeTestIntermediatesDir}"
fi
__ManagedTestIntermediatesDir="${__TestIntermediatesDir}/Managed"
if [[ ! -d "${__ManagedTestIntermediatesDir}" ]]; then
mkdir -p "${__ManagedTestIntermediatesDir}"
fi
echo "__BuildOS: ${__BuildOS}"
echo "__BuildArch: ${__BuildArch}"
echo "__BuildType: ${__BuildType}"
echo "__TestIntermediatesDir: ${__TestIntermediatesDir}"
echo "__NativeTestIntermediatesDir: ${__NativeTestIntermediatesDir}"
echo "__ManagedTestIntermediatesDir: ${__ManagedTestIntermediatesDir}"
if [[ ! -f "$__TestBinDir" ]]; then
echo "Creating TestBinDir: ${__TestBinDir}"
mkdir -p "$__TestBinDir"
fi
if [[ ! -f "$__LogsDir" ]]; then
echo "Creating LogsDir: ${__LogsDir}"
mkdir -p "$__LogsDir"
fi
if [[ ! -f "$__MsbuildDebugLogsDir" ]]; then
echo "Creating MsbuildDebugLogsDir: ${__MsbuildDebugLogsDir}"
mkdir -p "$__MsbuildDebugLogsDir"
fi
# Set up the directory for MSBuild debug logs.
MSBUILDDEBUGPATH="${__MsbuildDebugLogsDir}"
export MSBUILDDEBUGPATH
__BuildProperties="-p:OSGroup=${__BuildOS} -p:BuildOS=${__BuildOS} -p:BuildArch=${__BuildArch} -p:BuildType=${__BuildType}"
# =========================================================================================
# ===
# === Restore product binaries from packages
# ===
# =========================================================================================
if [[ "${__SkipRestorePackages}" != 1 ]]; then
build_MSBuild_projects "Restore_Product" "${__ProjectDir}/tests/build.proj" "Restore product binaries (build tests)" "/t:BatchRestorePackages"
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 "$__BuildArch" "$__TestDir" "$__ProjectRoot" "$__NativeTestIntermediatesDir" "CoreCLR test component"
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
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
echo "${__ErrMsgPrefix}${__MsgPrefix}Error: managed test build failed. Refer to the build log files for details (above)"
exit 1
else
echo "Checking the Managed Tests Build..."
build_MSBuild_projects "Check_Test_Build" "${__ProjectDir}/tests/src/runtest.proj" "Check Test Build" "/t:CheckTestBuild"
if [[ "$?" -ne 0 ]]; then
echo "${__ErrMsgPrefix}${__MsgPrefix}Error: Check Test Build failed."
exit 1
fi
fi
echo "Managed tests build success!"
build_test_wrappers
fi
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
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
__up="/t:UpdateInvalidPackageVersions"
fi
if [[ "$__SkipGenerateLayout" != 1 ]]; then
generate_layout
fi
}
build_MSBuild_projects()
{
subDirectoryName="$1"
shift
projectName="$1"
shift
stepName="$1"
shift
extraBuildParameters=("$@")
# Set up directories and file names
__BuildLogRootName="$subDirectoryName"
__BuildLog="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.log"
__BuildWrn="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.wrn"
__BuildErr="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.err"
if [[ "$subDirectoryName" == "Tests_Managed" ]]; then
# Execute msbuild managed test build in stages - workaround for excessive data retention in MSBuild ConfigCache
# See https://github.com/Microsoft/msbuild/issues/2993
# __SkipPackageRestore and __SkipTargetingPackBuild used to control build by tests/src/dirs.proj
__SkipPackageRestore=false
__SkipTargetingPackBuild=false
__NumberOfTestGroups=3
__AppendToLog=false
if [[ -n "$__priority1" ]]; then
__NumberOfTestGroups=10
fi
export __SkipPackageRestore __SkipTargetingPackBuild __NumberOfTestGroups
for (( testGroupToBuild=1 ; testGroupToBuild <= __NumberOfTestGroups; testGroupToBuild = testGroupToBuild + 1 ))
do
__msbuildLog="\"/flp:Verbosity=normal;LogFile=${__BuildLog};Append=${__AppendToLog}\""
__msbuildWrn="\"/flp1:WarningsOnly;LogFile=${__BuildWrn};Append=${__AppendToLog}\""
__msbuildErr="\"/flp2:ErrorsOnly;LogFile=${__BuildErr};Append=${__AppendToLog}\""
__TestGroupToBuild="$testGroupToBuild"
export __TestGroupToBuild
# Generate build command
buildArgs=("$projectName")
buildArgs+=("/p:RestoreDefaultOptimizationDataPackage=false" "/p:PortableBuild=true")
buildArgs+=("/p:UsePartialNGENOptimization=false" "/maxcpucount")
buildArgs+=("${__msbuildLog}" "${__msbuildWrn}" "${__msbuildErr}")
buildArgs+=("${extraBuildParameters[@]}")
buildArgs+=("${__CommonMSBuildArgs}")
buildArgs+=("${__UnprocessedBuildArgs[@]}")
buildArgs+=("\"/p:CopyNativeProjectBinaries=${__CopyNativeProjectsAfterCombinedTestBuild}\"");
buildArgs+=("/p:__SkipPackageRestore=true");
# Disable warnAsError - coreclr issue 19922
nextCommand="\"$__RepoRootDir/eng/common/msbuild.sh\" $__ArcadeScriptArgs --warnAsError false ${buildArgs[@]}"
echo "Building step '$stepName' testGroupToBuild=$testGroupToBuild via $nextCommand"
eval $nextCommand
# Make sure everything is OK
if [[ "$?" -ne 0 ]]; then
echo "${__ErrMsgPrefix}${__MsgPrefix}Failed to build $stepName. See the build logs:"
echo " $__BuildLog"
echo " $__BuildWrn"
echo " $__BuildErr"
exit 1
fi
__SkipPackageRestore=true
__SkipTargetingPackBuild=true
export __SkipPackageRestore __SkipTargetingPackBuild
__AppendToLog=true
done
else
__msbuildLog="\"/flp:Verbosity=normal;LogFile=${__BuildLog}\""
__msbuildWrn="\"/flp1:WarningsOnly;LogFile=${__BuildWrn}\""
__msbuildErr="\"/flp2:ErrorsOnly;LogFile=${__BuildErr}\""
# Generate build command
buildArgs=("$projectName")
buildArgs+=("/p:RestoreDefaultOptimizationDataPackage=false" "/p:PortableBuild=true")
buildArgs+=("/p:UsePartialNGENOptimization=false" "/maxcpucount")
buildArgs+=("${__msbuildLog}" "${__msbuildWrn}" "${__msbuildErr}")
buildArgs+=("${extraBuildParameters[@]}")
buildArgs+=("${__CommonMSBuildArgs}")
buildArgs+=("${__UnprocessedBuildArgs[@]}")
# Disable warnAsError - coreclr issue 19922
nextCommand="\"$__RepoRootDir/eng/common/msbuild.sh\" $__ArcadeScriptArgs --warnAsError false ${buildArgs[@]}"
echo "Building step '$stepName' via $nextCommand"
eval $nextCommand
# Make sure everything is OK
if [[ "$?" -ne 0 ]]; then
echo "${__ErrMsgPrefix}${__MsgPrefix}Failed to build $stepName. See the build logs:"
echo " $__BuildLog"
echo " $__BuildWrn"
echo " $__BuildErr"
exit 1
fi
fi
}
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+=("-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.")
# 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)"
handle_arguments_local() {
case "$1" in
buildtestwrappersonly|-buildtestwrappersonly)
__BuildTestWrappersOnly=1
;;
copynativeonly|-copynativeonly)
__SkipNative=1
__SkipManaged=1
__CopyNativeTestBinaries=1
__CopyNativeProjectsAfterCombinedTestBuild=true
;;
crossgen|-crossgen)
__DoCrossgen=1
;;
crossgen2|-crossgen2)
__DoCrossgen2=1
;;
generatetesthostonly|-generatetesthostonly)
__GenerateTestHostOnly=1
;;
generatelayoutonly|-generatelayoutonly)
__GenerateLayoutOnly=1
;;
priority1|-priority1)
__priority1=1
__UnprocessedBuildArgs+=("/p:CLRTestPriorityToBuild=1")
;;
rebuild|-rebuild)
__RebuildTests=1
;;
runtests|-runtests)
__RunTests=1
;;
skiprestorepackages|-skiprestorepackages)
__SkipRestorePackages=1
;;
skipgeneratelayout|-skipgeneratelayout)
__SkipGenerateLayout=1
;;
*)
__UnprocessedBuildArgs+=("$1")
;;
esac
}
__BuildArch=
__BuildType=Debug
__CodeCoverage=
__IncludeTests=INCLUDE_TESTS
# Set the various build properties here so that CMake and MSBuild can pick them up
__ProjectDir="$__ProjectRoot"
export __ProjectDir
__BuildTestWrappers=1
__BuildTestWrappersOnly=
__Compiler=clang
__CompilerMajorVersion=
__CompilerMinorVersion=
__CommonMSBuildArgs=
__ConfigureOnly=0
__CopyNativeProjectsAfterCombinedTestBuild=true
__CopyNativeTestBinaries=0
__CrossBuild=0
__DistroRid=""
__DoCrossgen=0
__DoCrossgen2=0
__DotNetCli="$__RepoRootDir/dotnet.sh"
__GenerateLayoutOnly=
__GenerateTestHostOnly=
__IsMSBuildOnNETCoreSupported=0
__MSBCleanBuildArgs=
__NativeTestIntermediatesDir=
__PortableBuild=1
__RebuildTests=0
__RootBinDir="$__RepoRootDir/artifacts"
__RunTests=0
__SkipConfigure=0
__SkipGenerateLayout=0
__SkipGenerateVersion=0
__SkipManaged=0
__SkipNative=0
__SkipRestore=""
__SkipRestorePackages=0
__SourceDir="$__ProjectDir/src"
__UnprocessedBuildArgs=
__LocalCoreFXConfig=${__BuildType}
__UseNinja=0
__VerboseBuild=0
__CMakeArgs=""
__priority1=
CORE_ROOT=
source "$__ProjectRoot"/_build-commons.sh
if [[ "${__BuildArch}" != "${__HostArch}" ]]; then
__CrossBuild=1
fi
# Set dependent variables
__LogsDir="$__RootBinDir/log"
__MsbuildDebugLogsDir="$__LogsDir/MsbuildDebugLogs"
# Set the remaining variables based upon the determined build configuration
__BinDir="$__RootBinDir/bin/coreclr/$__BuildOS.$__BuildArch.$__BuildType"
__PackagesBinDir="$__BinDir/.nuget"
__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"
__CrossComponentBinDir="$__BinDir"
__CrossCompIntermediatesDir="$__IntermediatesDir/crossgen"
__CrossArch="$__HostArch"
if [[ "$__CrossBuild" == 1 ]]; then
__CrossComponentBinDir="$__CrossComponentBinDir/$__CrossArch"
fi
__CrossgenCoreLibLog="$__LogsDir/CrossgenCoreLib_$__BuildOS.$BuildArch.$__BuildType.log"
__CrossgenExe="$__CrossComponentBinDir/crossgen"
# 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
mkdir temp_home
fi
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
build_test_wrappers
else
generate_layout
fi
if [[ "$?" -ne 0 ]]; then
echo "Failed to build tests"
exit 1
fi
echo "${__MsgPrefix}Test build successful."
echo "${__MsgPrefix}Test binaries are available at ${__TestBinDir}"
__testNativeBinDir="$__IntermediatesDir"/tests
if [[ "$__RunTests" -ne 0 ]]; then
echo "Run Tests..."
nextCommand="$__TestDir/runtest.sh --testRootDir=$__TestBinDir --coreClrBinDir=$__BinDir --coreFxBinDir=$CORE_ROOT --testNativeBinDir=$__testNativeBinDir"
echo "$nextCommand"
eval $nextCommand
echo "Tests run successful."
else
echo "To run all tests use 'tests/runtests.sh' where:"
echo " testRootDir = $__TestBinDir"
echo " coreClrBinDir = $__BinDir"
echo " coreFxBinDir = $CORE_ROOT"
echo " testNativeBinDir = $__testNativeBinDir"
echo " -------------------------------------------------- "
echo " Example runtest.sh command"
echo ""
echo " ./tests/runtest.sh --coreOverlayDir=$CORE_ROOT --testNativeBinDir=$__testNativeBinDir --testRootDir=$__TestBinDir --copyNativeTestBin"
echo " -------------------------------------------------- "
echo "To run single test use the following command:"
echo " bash ${__TestBinDir}/__TEST_PATH__/__TEST_NAME__.sh -coreroot=${CORE_ROOT}"
fi