Skip to content

Commit 8fc6720

Browse files
authoredJul 18, 2024
[Feature] Add build arch info when showing FE/BE version (StarRocks#48572)
Signed-off-by: Dejun Xia <[email protected]>
1 parent ca5a6db commit 8fc6720

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed
 

‎be/src/util/debug_util.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ std::string get_build_version(bool compact) {
6666
if (!compact) {
6767
ss << std::endl
6868
<< "Build distributor id: " << STARROCKS_BUILD_DISTRO_ID << std::endl
69+
<< "Build arch: " << STARROCKS_BUILD_ARCH << std::endl
6970
<< "Built on " << STARROCKS_BUILD_TIME << " by " << STARROCKS_BUILD_USER << "@" << STARROCKS_BUILD_HOST;
7071
}
7172

‎build-support/gen_build_version.py

+15-8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import argparse
1717
import hashlib
1818
import os
19+
import platform
1920
import re
2021
import subprocess
2122

@@ -79,6 +80,9 @@ def get_build_distro_info():
7980
distro_info[key] = value
8081
return distro_info
8182

83+
def get_build_arch():
84+
return platform.uname().machine
85+
8286
def get_java_version():
8387
java_home = os.getenv("JAVA_HOME")
8488
java_res = subprocess.Popen([java_home + "/bin/java", "-fullversion"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
@@ -105,7 +109,7 @@ def skip_write_if_fingerprint_unchanged(file_name, file_content, fingerprint):
105109
with open(file_name, 'w') as fh:
106110
fh.write(file_content)
107111

108-
def generate_java_file(java_path, version, commit_hash, build_type, build_time, user, host, java_version, build_distro_id):
112+
def generate_java_file(java_path, version, commit_hash, build_type, build_time, user, host, java_version, build_distro_id, build_arch):
109113
file_format = '''
110114
// Copyright 2021-present StarRocks, Inc. All rights reserved.
111115
//
@@ -135,13 +139,14 @@ def generate_java_file(java_path, version, commit_hash, build_type, build_time,
135139
public static final String STARROCKS_BUILD_USER = "{BUILD_USER}";
136140
public static final String STARROCKS_BUILD_HOST = "{BUILD_HOST}";
137141
public static final String STARROCKS_BUILD_DISTRO_ID = "{BUILD_DISTRO_ID}";
142+
public static final String STARROCKS_BUILD_ARCH = "{BUILD_ARCH}";
138143
public static final String STARROCKS_JAVA_COMPILE_VERSION = "{JAVA_VERSION}";
139144
}}
140145
'''
141-
fingerprint = get_fingerprint([version, commit_hash, build_type, user, host, java_version, build_distro_id])
146+
fingerprint = get_fingerprint([version, commit_hash, build_type, user, host, java_version, build_distro_id, build_arch])
142147
file_content = file_format.format(VERSION=version, COMMIT_HASH=commit_hash,
143148
BUILD_TYPE=build_type, BUILD_TIME=build_time,
144-
BUILD_USER=user, BUILD_HOST=host, BUILD_DISTRO_ID=build_distro_id,
149+
BUILD_USER=user, BUILD_HOST=host, BUILD_DISTRO_ID=build_distro_id, BUILD_ARCH=build_arch,
145150
JAVA_VERSION=java_version, FINGERPRINT=fingerprint)
146151

147152
file_name = java_path + "/com/starrocks/common/Version.java"
@@ -150,7 +155,7 @@ def generate_java_file(java_path, version, commit_hash, build_type, build_time,
150155
os.makedirs(d)
151156
skip_write_if_fingerprint_unchanged(file_name, file_content, fingerprint)
152157

153-
def generate_cpp_file(cpp_path, version, commit_hash, build_type, build_time, user, host, build_distro_id):
158+
def generate_cpp_file(cpp_path, version, commit_hash, build_type, build_time, user, host, build_distro_id, build_arch):
154159
file_format = '''
155160
// Copyright 2021-present StarRocks, Inc. All rights reserved.
156161
//
@@ -177,13 +182,14 @@ def generate_cpp_file(cpp_path, version, commit_hash, build_type, build_time, us
177182
const char* STARROCKS_BUILD_USER = "{BUILD_USER}";
178183
const char* STARROCKS_BUILD_HOST = "{BUILD_HOST}";
179184
const char* STARROCKS_BUILD_DISTRO_ID = "{BUILD_DISTRO_ID}";
185+
const char* STARROCKS_BUILD_ARCH = "{BUILD_ARCH}";
180186
}}
181187
182188
'''
183-
fingerprint = get_fingerprint([version, commit_hash, build_type, user, host, build_distro_id])
189+
fingerprint = get_fingerprint([version, commit_hash, build_type, user, host, build_distro_id, build_arch])
184190
file_content = file_format.format(VERSION=version, COMMIT_HASH=commit_hash,
185191
BUILD_TYPE=build_type, BUILD_TIME=build_time,
186-
BUILD_USER=user, BUILD_HOST=host, BUILD_DISTRO_ID=build_distro_id, FINGERPRINT=fingerprint)
192+
BUILD_USER=user, BUILD_HOST=host, BUILD_DISTRO_ID=build_distro_id, BUILD_ARCH=build_arch, FINGERPRINT=fingerprint)
187193

188194
file_name = cpp_path + "/version.cpp"
189195
d = os.path.dirname(file_name)
@@ -204,14 +210,15 @@ def main():
204210
distro_info = get_build_distro_info()
205211
build_distro_id = distro_info.get("ID", "unknown")
206212
build_pretty_name = distro_info.get("PRETTY_NAME", build_distro_id)
213+
build_arch = get_build_arch()
207214
user = get_user()
208215
# append build distro pretty name into hostname
209216
hostname = '%s (%s)' % (get_hostname(), build_pretty_name)
210217

211218
java_version = get_java_version()
212219

213-
generate_cpp_file(args.cpp_path, version, commit_hash, build_type, build_time, user, hostname, build_distro_id)
214-
generate_java_file(args.java_path, version, commit_hash, build_type, build_time, user, hostname, java_version, build_distro_id)
220+
generate_cpp_file(args.cpp_path, version, commit_hash, build_type, build_time, user, hostname, build_distro_id, build_arch)
221+
generate_java_file(args.java_path, version, commit_hash, build_type, build_time, user, hostname, java_version, build_distro_id, build_arch)
215222

216223
if __name__ == '__main__':
217224
main()

‎fe/fe-core/src/main/java/com/starrocks/StarRocksFE.java

+1
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ private static void checkCommandLineOptions(CommandLineOptions cmdLineOpts) {
320320
System.out.println("Build type: " + Version.STARROCKS_BUILD_TYPE);
321321
System.out.println("Build time: " + Version.STARROCKS_BUILD_TIME);
322322
System.out.println("Build distributor id: " + Version.STARROCKS_BUILD_DISTRO_ID);
323+
System.out.println("Build arch: " + Version.STARROCKS_BUILD_ARCH);
323324
System.out.println("Build user: " + Version.STARROCKS_BUILD_USER + "@" + Version.STARROCKS_BUILD_HOST);
324325
System.out.println("Java compile version: " + Version.STARROCKS_JAVA_COMPILE_VERSION);
325326
System.exit(0);

0 commit comments

Comments
 (0)
Please sign in to comment.