forked from microsoft/GraphEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·102 lines (91 loc) · 2.87 KB
/
build.sh
File metadata and controls
executable file
·102 lines (91 loc) · 2.87 KB
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
#!/usr/bin/env bash
if [ "$REPO_ROOT" == "" ] ; then REPO_ROOT="$(readlink -f $(dirname $(readlink -f $0))/../)" ; fi
# check for build environment, tools and libraries
if [ "$(command -v cmake)" == "" ] ;
then
echo "error: cmake not found." 1>&2
exit -1
fi
if [ ! -e /etc/os-release ] ;
then
echo "error: cannot determine distro." 1>&2
exit -1
else
source /etc/os-release
echo "current distro: $ID $VERSION_ID"
fi
# check if we have dotnet sdk
if [ ! -e "$REPO_ROOT/tools/dotnet" ];
then
tmp=$(tempfile)
echo "dotnet sdk not found, downloading."
case "$ID $VERSION_ID" in
"ubuntu 16.04")
dotnet_url="https://dotnetcli.blob.core.windows.net/dotnet/Sdk/master/dotnet-dev-ubuntu.16.04-x64.latest.tar.gz"
;;
*)
echo "error: unsupported distro." 1>&2
exit -1
;;
esac
wget $dotnet_url -O $tmp || exit -1
mkdir "$REPO_ROOT/tools/dotnet"
tar -xzf $tmp -C "$REPO_ROOT/tools/dotnet" || exit -1
rm $tmp
fi
export PATH="$REPO_ROOT/tools/dotnet":$PATH
# build Trinity.C
build_trinity_c()
{
echo "Building Trinity.C"
mkdir -p "$REPO_ROOT/bin/coreclr" || exit -1
mkdir -p "$REPO_ROOT/bin/build_trinityc" && pushd "$_" || exit -1
cmake "$REPO_ROOT/src/Trinity.C" || exit -1
make || exit -1
# copy native Trinity.C for Windows-CoreCLR
cp "$REPO_ROOT/lib/Trinity.dll" "$REPO_ROOT/bin/coreclr/Trinity.dll" || exit -1
# copy freshly built Trinity.C for Linux-CoreCLR
cp "$REPO_ROOT/bin/build_trinityc/libTrinity.so" "$REPO_ROOT/bin/coreclr/libTrinity.so" || exit -1
popd
}
# build Trinity.TSL
build_trinity_tsl()
{
echo "Building Trinity.TSL"
mkdir -p "$REPO_ROOT/bin/tsl" && pushd "$_" || exit -1
cmake "$REPO_ROOT/src/Trinity.TSL" || exit -1
make || exit -1
# copy native Trinity.TSL.CodeGen.exe for Windows
cp "$REPO_ROOT/tools/Trinity.TSL.CodeGen.exe" "$REPO_ROOT/bin/" || exit -1
# copy freshly built Trinity.TSL.CodeGen for Linux
cp "Trinity.TSL.CodeGen" "$REPO_ROOT/bin/" || exit -1
popd
}
# build Trinity.Core
build_trinity_core()
{
echo "Building Trinity.Core"
pushd "$REPO_ROOT/src/Trinity.Core"
dotnet restore Trinity.Core.NETStandard.sln || exit -1
dotnet build Trinity.Core.NETStandard.sln || exit -1
dotnet pack Trinity.Core.NETStandard.sln || exit -1
popd
}
# register local nuget repo, remove GraphEngine.CoreCLR packages in the cache.
setup_nuget_repo()
{
nuget_repo_name="Graph Engine OSS Local"
nuget_repo_location=$(printf "%q" "$REPO_ROOT/bin/coreclr")
echo "registering NuGet local repository '$nuget_repo_name'."
if [ "$(grep "$nuget_repo_name" ~/.nuget/NuGet/NuGet.Config)" != "" ];
then
sed -i "/$nuget_repo_name/d" ~/.nuget/NuGet/NuGet.Config
fi
sed -i "s#</packageSources># <add key=\"$nuget_repo_name\" value=\"$nuget_repo_location\" \/>\n <\/packageSources>#g" ~/.nuget/NuGet/NuGet.Config
echo "remove local package cache."
rm -rf ~/.nuget/packages/graphengine.coreclr
}
build_trinity_c
build_trinity_tsl
build_trinity_core
setup_nuget_repo