blob: 95037e6d418eef3c1babf4e3b0489f92b8248a5e (
plain)
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
|
#!/usr/bin/env bash
scriptRoot="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [ "$BUILDVARS_DONE" != 1 ]; then
. $scriptRoot/buildvars-setup.sh $*
fi
# Check the system to ensure the right pre-reqs are in place
check_native_prereqs()
{
echo "Checking pre-requisites..."
# Check presence of CMake on the path
hash cmake 2>/dev/null || { echo >&2 "Please install cmake before running this script"; exit 1; }
# Check for clang
hash clang-$__ClangMajorVersion.$__ClangMinorVersion 2>/dev/null || hash clang$__ClangMajorVersion$__ClangMinorVersion 2>/dev/null || hash clang 2>/dev/null || { echo >&2 "Please install clang before running this script"; exit 1; }
# Check for additional prereqs for wasm build
if [ $__BuildArch == "wasm" ]; then
hash emcmake 2>/dev/null || { echo >&2 "Please install Emscripten before running this script. See https://github.com/dotnet/corert/blob/master/Documentation/how-to-build-WebAssembly.md for more information."; exit 1; }
if [ -z ${EMSCRIPTEN+x} ]; then echo "EMSCRIPTEN is not set. Ensure your have set up the Emscripten environment using \"source <emsdk_dir>/emsdk_env.sh\""; exit 1; fi
fi
}
prepare_native_build()
{
# Specify path to be set for CMAKE_INSTALL_PREFIX.
# This is where all built CoreClr libraries will copied to.
export __CMakeBinDir="$__ProductBinDir"
# Configure environment if we are doing a verbose build
if [ $__VerboseBuild == 1 ]; then
export VERBOSE=1
fi
}
build_native_corert()
{
# All set to commence the build
echo "Commencing build of corert native components for $__BuildOS.$__BuildArch.$__BuildType"
pushd "$__IntermediatesDir"
# Regenerate the CMake solution
echo "Invoking cmake with arguments: \"$__ProjectRoot\" $__BuildType"
"$__ProjectRoot/src/Native/gen-buildsys-clang.sh" "$__ProjectRoot" $__ClangMajorVersion $__ClangMinorVersion $__BuildArch $__BuildType
# Check that the makefiles were created.
if [ ! -f "$__IntermediatesDir/Makefile" ]; then
echo "Failed to generate native component build project!"
popd
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.
if [ `uname` = "FreeBSD" ]; then
NumProc=`sysctl hw.ncpu | awk '{ print $2+1 }'`
elif [ `uname` = "NetBSD" ]; then
NumProc=$(($(getconf NPROCESSORS_ONLN)+1))
else
NumProc=$(($(getconf _NPROCESSORS_ONLN)+1))
fi
# Build
echo "Executing make install -j $NumProc $__UnprocessedBuildArgs"
if [ $__BuildArch == "wasm" ]; then
emmake make install -j $NumProc $__UnprocessedBuildArgs
else
make install -j $NumProc $__UnprocessedBuildArgs
fi
if [ $? != 0 ]; then
echo "Failed to build corert native components."
popd
exit $?
fi
echo "CoreRT native components successfully built."
popd
}
initHostDistroRid()
{
if [ "$__HostOS" == "Linux" ]; then
if [ ! -e /etc/os-release ]; then
echo "WARNING: Can not determine runtime id for current distro."
__HostDistroRid=""
else
source /etc/os-release
__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
}
build_host_native_corert()
{
__SavedBuildArch=$__BuildArch
__SavedIntermediatesDir=$__IntermediatesDir
export __IntermediatesDir=$__IntermediatesHostDir
export __BuildArch=$__HostArch
export __CMakeBinDir="$__ProductHostBinDir"
export CROSSCOMPILE=
build_native_corert
cp ${__ProductHostBinDir}/jitinterface.so ${__ProductBinDir}
export __BuildArch=$__SavedBuildArch
export __IntermediatesDir=$__SavedIntermediatesDir
export CROSSCOMPILE=1
}
if $__buildnative; then
# 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 corert native components.
build_native_corert
if [ $__CrossBuild = 1 ]; then
build_host_native_corert
fi
# Build complete
fi
|