forked from apache/gluten
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgluten-build-info.sh
More file actions
executable file
·125 lines (112 loc) · 3.85 KB
/
Copy pathgluten-build-info.sh
File metadata and controls
executable file
·125 lines (112 loc) · 3.85 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/env bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
GLUTEN_ROOT=$(cd $(dirname -- $0)/..; pwd -P)
EXTRA_RESOURCE_DIR=$GLUTEN_ROOT/gluten-core/target/generated-resources
BUILD_INFO="$EXTRA_RESOURCE_DIR"/gluten-build-info.properties
BACKEND_HOME=""
# Delete old build-info file before regenerating
rm -f "$BUILD_INFO"
mkdir -p "$EXTRA_RESOURCE_DIR"
function echo_revision_info() {
echo branch=$(git rev-parse --abbrev-ref HEAD)
echo revision=$(git rev-parse HEAD)
echo revision_time=$(git show -s --format=%ci HEAD)
echo date=$(date -u +%Y-%m-%dT%H:%M:%SZ)
# Strip embedded credentials (user:pass@) from the URL to avoid exposing them in the build info.
echo url=$(git config --get remote.origin.url | sed 's|://[^:@]*:[^@]*@|://|')
}
function echo_velox_revision_info() {
BACKEND_HOME=$1
echo gcc_version=$(strings $GLUTEN_ROOT/cpp/build/releases/libgluten.so | grep "GCC:" | head -n 1)
echo velox_branch=$(git -C "$BACKEND_HOME" rev-parse --abbrev-ref HEAD)
echo velox_revision=$(git -C "$BACKEND_HOME" rev-parse HEAD)
echo velox_revision_time=$(git -C "$BACKEND_HOME" show -s --format=%ci HEAD)
}
function echo_clickhouse_revision_info() {
echo ch_org=$(cat $GLUTEN_ROOT/cpp-ch/clickhouse.version | grep -oP '(?<=^CH_ORG=).*')
echo ch_branch=$(cat $GLUTEN_ROOT/cpp-ch/clickhouse.version | grep -oP '(?<=^CH_BRANCH=).*')
echo ch_commit=$(cat $GLUTEN_ROOT/cpp-ch/clickhouse.version | grep -oP '(?<=^CH_COMMIT=).*')
}
function read_cmake_cache_path() {
CACHE_FILE="$GLUTEN_ROOT/cpp/build/CMakeCache.txt"
CACHE_KEY="$1"
if [ -f "$CACHE_FILE" ]; then
grep "^${CACHE_KEY}:PATH=" "$CACHE_FILE" | cut -d= -f2- | head -n 1
fi
}
function resolve_velox_home() {
if [ -n "$BACKEND_HOME" ]; then
echo "$BACKEND_HOME"
return
fi
if [ -n "${VELOX_HOME:-}" ]; then
echo "$VELOX_HOME"
return
fi
CACHED_VELOX_HOME=$(read_cmake_cache_path VELOX_HOME)
if [ -n "$CACHED_VELOX_HOME" ]; then
echo "$CACHED_VELOX_HOME"
return
fi
echo "$GLUTEN_ROOT/ep/build-velox/build/velox_ep"
}
while (( "$#" )); do
echo "$1"
case $1 in
--version)
echo gluten_version="$2" >> "$BUILD_INFO"
;;
--backend)
BACKEND_TYPE="$2"
echo backend_type="$BACKEND_TYPE" >> "$BUILD_INFO"
# Compute backend home path based on type
if [ "velox" = "$BACKEND_TYPE" ]; then
BACKEND_HOME=$(resolve_velox_home)
echo_velox_revision_info "$BACKEND_HOME" >> "$BUILD_INFO"
elif [ "ch" = "$BACKEND_TYPE" ] || [ "clickhouse" = "$BACKEND_TYPE" ]; then
echo_clickhouse_revision_info >> "$BUILD_INFO"
fi
;;
--backend_home|--velox_home)
if [ -n "$2" ]; then
BACKEND_HOME="$2"
fi
;;
--java)
echo java_version="$2" >> "$BUILD_INFO"
;;
--scala)
echo scala_version="$2" >> "$BUILD_INFO"
;;
--spark)
echo spark_version="$2" >> "$BUILD_INFO"
;;
--hadoop)
echo hadoop_version="$2" >> "$BUILD_INFO"
;;
--revision)
if [ "true" = "$2" ]; then
echo_revision_info >> "$BUILD_INFO"
fi
;;
*)
echo "Error: $1 is not supported"
;;
esac
shift 2
done