-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·135 lines (117 loc) · 4.95 KB
/
build.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
#!/bin/bash
set -ex
# Should be release or debug (case sensitive)
DEPS_CONFIG="release"
# Note this should match the vcpkg triplet name,
# such as x64-linux or x64-osx
DEPS_ARCH="${DEPS_ARCH:-x64-linux}"
DEPS_ROOT="$(pwd)/$DEPS_ARCH"
DEPS_INCLUDE_FOLDER="$DEPS_ROOT/include"
DEPS_LIB_FOLDER="$DEPS_ROOT/lib"
if [ "$DEPS_ARCH" = "x64-osx" ] ; then
IS_MAC=true
else
IS_MAC=false
fi
# Dependency revisions to use
VCPKG_REV=d51b4cd532662e5a32d3d0799430edc502d7d296
DEPOT_TOOLS_REV=a680c23e78599f7f0b761ada3158387a9e9a05b3
DAWN_REV=3da19b843ffd63d884f3a67f2da3eea20818499a
# Wipe out existing artifacts and replace with the ones that are now being built
rm -rf "$DEPS_ROOT"
mkdir -p "$DEPS_INCLUDE_FOLDER"
mkdir -p "$DEPS_LIB_FOLDER"
# vcpkg
if [ ! -d vcpkg ] ; then git clone https://github.com/Microsoft/vcpkg.git ; fi
pushd vcpkg
git fetch
# git reset is being done to wipe out the triplet change below, if this is a rerun
git reset --hard HEAD
git checkout "$VCPKG_REV"
# TODO: May repeatedly add this to the triplet file, so using git reset above
# TODO: can't because arrow has dependencies that need the debug build
#echo "set(VCPKG_BUILD_TYPE $DEPS_CONFIG)" >> "triplets/$DEPS_ARCH.cmake"
./bootstrap-vcpkg.sh -disableMetrics
VCPKG_DEPENDENCIES="jsoncpp gtest range-v3 fmt shaderc"
# Installing arrow through vcpkg fails using this revision of vcpkg. We handle this in a special way
if ! $IS_MAC ; then VCPKG_DEPENDENCIES="$VCPKG_DEPENDENCIES arrow" ; fi
# Ignore the expansion here because we are intentionally splitting on spaces to get vcpkg to install a list of packages.
# shellcheck disable=SC2086
VCPKG_ROOT="." ./vcpkg install $VCPKG_DEPENDENCIES
# Copy over headers and libs. Not using vcpkg export as it creates a lot of intermediate folders
cp -R "installed/$DEPS_ARCH/include/"* "$DEPS_INCLUDE_FOLDER"
cp -R "installed/$DEPS_ARCH/lib/"*.a "$DEPS_LIB_FOLDER"
popd
# For dawn, follow the standard build instructions: https://dawn.googlesource.com/dawn/+/HEAD/docs/buiding.md
if [ ! -d depot_tools ] ; then git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git ; fi
pushd depot_tools
# You may add depot_tools to your path rather than using absolute or relative paths
DT_ROOT="$(pwd)"
git fetch
git checkout "$DEPOT_TOOLS_REV"
popd
if [ ! -d dawn ] ; then git clone https://dawn.googlesource.com/dawn ; fi
pushd dawn
git fetch
git checkout "$DAWN_REV"
cp scripts/standalone.gclient .gclient
"$DT_ROOT/gclient" sync
if [ "$DEPS_CONFIG" = "release" ] ; then
DAWN_IS_DEBUG="false"
else
DAWN_IS_DEBUG="true"
fi
# Override EDITOR to prevent bringing up the editor during the build.
# TODO: disable building tests
"$DT_ROOT/gn" gen "out/$DEPS_CONFIG" --args="is_debug=$DAWN_IS_DEBUG"
# You may with to specify `-j #` to change the number of parallel builds in Ninja.
"$DT_ROOT/ninja" -C "out/$DEPS_CONFIG"
cp -R "src/include/"* "$DEPS_INCLUDE_FOLDER"
# Needed for webgpu_cpp.h
cp -R "out/$DEPS_CONFIG/gen/src/include/"* "$DEPS_INCLUDE_FOLDER"
cp -R third_party/glfw/include/* "$DEPS_INCLUDE_FOLDER"
# These are .so on Linux, and .dylib on Mac
if [ -f "out/$DEPS_CONFIG/libdawn_native.dylib" ] ; then
cp "out/$DEPS_CONFIG/libdawn_native.dylib" "$DEPS_LIB_FOLDER"
fi
if [ -f "out/$DEPS_CONFIG/libdawn_native.so" ] ; then
cp "out/$DEPS_CONFIG/libdawn_native.so" "$DEPS_LIB_FOLDER"
fi
if [ -f "out/$DEPS_CONFIG/libdawn_proc.dylib" ] ; then
cp "out/$DEPS_CONFIG/libdawn_proc.dylib" "$DEPS_LIB_FOLDER"
fi
if [ -f "out/$DEPS_CONFIG/libdawn_proc.so" ] ; then
cp "out/$DEPS_CONFIG/libdawn_proc.so" "$DEPS_LIB_FOLDER"
fi
if [ -f "out/$DEPS_CONFIG/libdawn_proc.a" ] ; then
cp "out/$DEPS_CONFIG/libdawn_proc.a" "$DEPS_LIB_FOLDER"
fi
if [ -f "out/$DEPS_CONFIG/libdawn_wire.dylib" ] ; then
cp "out/$DEPS_CONFIG/libdawn_wire.dylib" "$DEPS_LIB_FOLDER"
fi
if [ -f "out/$DEPS_CONFIG/libdawn_wire.so" ] ; then
cp "out/$DEPS_CONFIG/libdawn_wire.so" "$DEPS_LIB_FOLDER"
fi
if ! $IS_MAC ; then
# Under Linux this is a thin archive and needs the objects
# to be at certain relative paths.
cp -R "out/$DEPS_CONFIG/obj/third_party/glfw/" "$DEPS_LIB_FOLDER"
fi
cp "out/$DEPS_CONFIG/obj/third_party/libglfw.a" "$DEPS_LIB_FOLDER"
cp "out/$DEPS_CONFIG/obj/src/dawn/dawncpp/webgpu_cpp.o" "$DEPS_LIB_FOLDER"
popd
# macOS specific setup
if $IS_MAC ; then
# Check if Homebrew is installed
if ! command -v brew >/dev/null; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
fi
# Lookup version 0.16.0 and install it
# We could create our own cask and maintain it, but as noted above this is (hopefully) a temporary solution
ARROW_VERSION=0.16.0
brew extract --force apache-arrow homebrew/cask "--version=$ARROW_VERSION"
brew install "homebrew/cask/apache-arrow@$ARROW_VERSION"
# TODO: Can this path be detected at runtime?
cp -R "/usr/local/Cellar/apache-arrow/$ARROW_VERSION/include/" "$DEPS_INCLUDE_FOLDER"
cp -R "/usr/local/Cellar/apache-arrow/$ARROW_VERSION/lib/libarrow.a" "$DEPS_LIB_FOLDER"
fi