@@ -6,7 +6,7 @@ initHostDistroRid()
6
6
if [ " $__HostOS " == " Linux" ]; then
7
7
if [ -e /etc/os-release ]; then
8
8
source /etc/os-release
9
- if [[ $ID == " alpine" ]]; then
9
+ if [[ $ID == " alpine" || $ID == " rhel " ]]; then
10
10
# remove the last version digit
11
11
VERSION_ID=${VERSION_ID% .* }
12
12
fi
@@ -18,13 +18,25 @@ initHostDistroRid()
18
18
fi
19
19
fi
20
20
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
+
21
33
if [ " $__HostOS " == " FreeBSD" ]; then
22
34
__freebsd_version=` sysctl -n kern.osrelease | cut -f1 -d' .' `
23
35
__HostDistroRid=" freebsd.$__freebsd_version -$__HostArch "
24
36
fi
25
37
26
38
if [ " $__HostDistroRid " == " " ]; then
27
- echo " WARNING: Cannot determine runtime id for current distro."
39
+ echo " WARNING: Can not determine runtime id for current distro."
28
40
fi
29
41
}
30
42
@@ -33,8 +45,13 @@ initTargetDistroRid()
33
45
if [ $__CrossBuild == 1 ]; then
34
46
if [ " $__BuildOS " == " Linux" ]; then
35
47
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
38
55
else
39
56
source $ROOTFS_DIR /etc/os-release
40
57
export __DistroRid=" $ID .$VERSION_ID -$__BuildArch "
@@ -52,16 +69,21 @@ initTargetDistroRid()
52
69
if [ " $__PortableBuild " == 1 ]; then
53
70
if [ " $__BuildOS " == " Linux" ]; then
54
71
export __DistroRid=" linux-$__BuildArch "
72
+ export __RuntimeId=" linux-$__BuildArch "
55
73
elif [ " $__BuildOS " == " OSX" ]; then
56
74
export __DistroRid=" osx-$__BuildArch "
75
+ export __RuntimeId=" osx-$__BuildArch "
76
+ elif [ " $__BuildOS " == " FreeBSD" ]; then
77
+ export __DistroRid=" freebsd-$__BuildArch "
78
+ export __RuntimeId=" freebsd-$__BuildArch "
57
79
fi
58
80
fi
59
81
60
- if [ " $ID .$VERSION_ID " == " ubuntu.16.04" ]; then
82
+ if [ " $ID .$VERSION_ID " == " ubuntu.16.04" ]; then
61
83
export __DistroRid=" ubuntu.14.04-$__BuildArch "
62
- fi
84
+ fi
63
85
64
- echo " __DistroRid: " $__DistroRid
86
+ echo " __DistroRid: " $__DistroRid
65
87
}
66
88
67
89
isMSBuildOnNETCoreSupported ()
@@ -89,7 +111,7 @@ isMSBuildOnNETCoreSupported()
89
111
fi
90
112
}
91
113
92
- build_Tests ()
114
+ generate_layout ()
93
115
{
94
116
__TestDir=$__ProjectDir /tests
95
117
__ProjectFilesDir=$__TestDir
@@ -108,10 +130,10 @@ build_Tests()
108
130
__TestIntermediateDir=" tests/obj/${__BuildOS} .${__BuildArch} .${__BuildType} "
109
131
fi
110
132
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} "
115
137
116
138
if [ ! -f " $__TestBinDir " ]; then
117
139
echo " Creating TestBinDir: ${__TestBinDir} "
@@ -132,27 +154,96 @@ build_Tests()
132
154
133
155
build_Tests_internal " Restore_Product" " ${__ProjectDir} /tests/build.proj" " -BatchRestorePackages" " Restore product binaries (build tests)"
134
156
135
- build_Tests_internal " Tests_GenerateRuntimeLayout" " ${__ProjectDir} /tests/runtest.proj" " -BinPlaceRef -BinPlaceProduct -CopyCrossgenToProduct" " Restore product binaries (run tests)"
136
-
137
157
if [ -n " $__UpdateInvalidPackagesArg " ]; then
138
158
__up=-updateinvalidpackageversion
139
159
fi
140
160
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
+
141
185
# Work hardcoded path around
142
186
if [ ! -f " ${__BuildToolsDir} /Microsoft.CSharp.Core.Targets" ]; then
143
187
ln -s " ${__BuildToolsDir} /Microsoft.CSharp.Core.targets" " ${__BuildToolsDir} /Microsoft.CSharp.Core.Targets"
144
188
fi
145
189
if [ ! -f " ${__BuildToolsDir} /Microsoft.CSharp.targets" ]; then
146
190
ln -s " ${__BuildToolsDir} /Microsoft.CSharp.Targets" " ${__BuildToolsDir} /Microsoft.CSharp.targets"
147
191
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
148
239
149
240
echo " Starting the Managed Tests Build..."
150
241
151
242
__ManagedTestBuiltMarker=${__TestBinDir} /managed_test_build
152
243
153
244
if [ ! -f $__ManagedTestBuiltMarker ]; then
154
245
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)"
156
247
157
248
if [ $? -ne 0 ]; then
158
249
echo " ${__MsgPrefix} Error: build failed. Refer to the build log files for details (above)"
@@ -188,6 +279,10 @@ build_Tests()
188
279
fi
189
280
fi
190
281
282
+ if [ -n " $__UpdateInvalidPackagesArg " ]; then
283
+ __up=-updateinvalidpackageversion
284
+ fi
285
+
191
286
echo " ${__MsgPrefix} Creating test overlay..."
192
287
193
288
if [ -z " $XuintTestBinBase " ]; then
@@ -202,25 +297,34 @@ build_Tests()
202
297
rm -rf $CORE_ROOT /*
203
298
fi
204
299
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"
208
301
209
302
if [ $__ZipTests -ne 0 ]; then
210
303
echo " ${__MsgPrefix} ZIP tests packages..."
211
304
build_Tests_internal " Helix_Prep" " $__ProjectDir /tests/helixprep.proj" " " " Prep test binaries for Helix publishing"
212
305
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
213
317
}
214
318
215
319
build_Tests_internal ()
216
320
{
217
- subDirectoryName=$1
218
- projectName=$2
219
- extraBuildParameters=$3
220
- stepName=" $4 "
321
+ subDirectoryName=$1
322
+ projectName=$2
323
+ extraBuildParameters=$3
324
+ stepName=" $4 "
221
325
222
- # Set up directories and file names
223
- __BuildLogRootName=$subDirectoryName
326
+ # Set up directories and file names
327
+ __BuildLogRootName=$subDirectoryName
224
328
__BuildLog=" $__LogsDir /${__BuildLogRootName} .${__BuildOS} .${__BuildArch} .${__BuildType} .log"
225
329
__BuildWrn=" $__LogsDir /${__BuildLogRootName} .${__BuildOS} .${__BuildArch} .${__BuildType} .wrn"
226
330
__BuildErr=" $__LogsDir /${__BuildLogRootName} .${__BuildOS} .${__BuildArch} .${__BuildType} .err"
@@ -262,8 +366,11 @@ usage()
262
366
echo " crosscomponent - optional argument to build cross-architecture component,"
263
367
echo " - will use CAC_ROOTFS_DIR environment variable if set."
264
368
echo " portableLinux - build for Portable Linux Distribution"
369
+ echo " portablebuild - Use portable build."
265
370
echo " verbose - optional argument to enable verbose build output."
266
371
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."
267
374
echo " runtests - run tests after building them"
268
375
echo " ziptests - zips CoreCLR tests & Core_Root for a Helix run"
269
376
echo " bindir - output directory (defaults to $__ProjectRoot /bin)"
@@ -376,6 +483,7 @@ __ClangMajorVersion=0
376
483
__ClangMinorVersion=0
377
484
__NuGetPath=" $__PackagesDir /NuGet.exe"
378
485
__HostDistroRid=" "
486
+ __BuildAgainstPackagesArg=
379
487
__DistroRid=" "
380
488
__cmakeargs=" "
381
489
__PortableLinux=0
@@ -385,9 +493,9 @@ __NativeTestIntermediatesDir=
385
493
__RunTests=0
386
494
__RebuildTests=0
387
495
__BuildTestWrappers=0
496
+ __GenarateLayoutOnly=
388
497
CORE_ROOT=
389
498
390
-
391
499
while : ; do
392
500
if [ $# -le 0 ]; then
393
501
break
@@ -440,6 +548,10 @@ while :; do
440
548
__CrossBuild=1
441
549
;;
442
550
551
+ portableBuild)
552
+ __PortableBuild=1
553
+ ;;
554
+
443
555
portablelinux)
444
556
if [ " $__BuildOS " == " Linux" ]; then
445
557
__PortableLinux=1
@@ -494,6 +606,14 @@ while :; do
494
606
__ZipTests=1
495
607
;;
496
608
609
+ generatelayoutonly)
610
+ __GenarateLayoutOnly=1
611
+ ;;
612
+
613
+ buildagainstpackages)
614
+ __BuildAgainstPackagesArg=1
615
+ ;;
616
+
497
617
bindir)
498
618
if [ -n " $2 " ]; then
499
619
__RootBinDir=" $2 "
@@ -527,7 +647,7 @@ __RunArgs="-BuildArch=$__BuildArch -BuildType=$__BuildType -BuildOS=$__BuildOS"
527
647
# Configure environment if we are doing a verbose build
528
648
if [ $__VerboseBuild == 1 ]; then
529
649
export VERBOSE=1
530
- __RunArgs=" $__RunArgs -verbose"
650
+ __RunArgs=" $__RunArgs -verbose"
531
651
fi
532
652
533
653
# Set default clang version
@@ -588,8 +708,9 @@ export __CMakeBinDir="$__BinDir"
588
708
589
709
if [ ! -d " $__BinDir " ] || [ ! -d " $__BinDir /bin" ]; then
590
710
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 '"
593
714
exit 1
594
715
fi
595
716
@@ -611,7 +732,11 @@ __sharedFxDir=$__BuildToolsDir/dotnetcli/shared/Microsoft.NETCore.App/$__CoreClr
611
732
612
733
echo " Building Tests..."
613
734
614
- build_Tests
735
+ if [ -z " __GenerateLayoutOnly" ]; then
736
+ build_Tests
737
+ else
738
+ generate_layout
739
+ fi
615
740
616
741
if [ $? -ne 0 ]; then
617
742
echo " Failed to build tests"
0 commit comments