16
16
import argparse
17
17
import hashlib
18
18
import os
19
+ import platform
19
20
import re
20
21
import subprocess
21
22
@@ -79,6 +80,9 @@ def get_build_distro_info():
79
80
distro_info [key ] = value
80
81
return distro_info
81
82
83
+ def get_build_arch ():
84
+ return platform .uname ().machine
85
+
82
86
def get_java_version ():
83
87
java_home = os .getenv ("JAVA_HOME" )
84
88
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):
105
109
with open (file_name , 'w' ) as fh :
106
110
fh .write (file_content )
107
111
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 ):
109
113
file_format = '''
110
114
// Copyright 2021-present StarRocks, Inc. All rights reserved.
111
115
//
@@ -135,13 +139,14 @@ def generate_java_file(java_path, version, commit_hash, build_type, build_time,
135
139
public static final String STARROCKS_BUILD_USER = "{BUILD_USER}";
136
140
public static final String STARROCKS_BUILD_HOST = "{BUILD_HOST}";
137
141
public static final String STARROCKS_BUILD_DISTRO_ID = "{BUILD_DISTRO_ID}";
142
+ public static final String STARROCKS_BUILD_ARCH = "{BUILD_ARCH}";
138
143
public static final String STARROCKS_JAVA_COMPILE_VERSION = "{JAVA_VERSION}";
139
144
}}
140
145
'''
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 ])
142
147
file_content = file_format .format (VERSION = version , COMMIT_HASH = commit_hash ,
143
148
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 ,
145
150
JAVA_VERSION = java_version , FINGERPRINT = fingerprint )
146
151
147
152
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,
150
155
os .makedirs (d )
151
156
skip_write_if_fingerprint_unchanged (file_name , file_content , fingerprint )
152
157
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 ):
154
159
file_format = '''
155
160
// Copyright 2021-present StarRocks, Inc. All rights reserved.
156
161
//
@@ -177,13 +182,14 @@ def generate_cpp_file(cpp_path, version, commit_hash, build_type, build_time, us
177
182
const char* STARROCKS_BUILD_USER = "{BUILD_USER}";
178
183
const char* STARROCKS_BUILD_HOST = "{BUILD_HOST}";
179
184
const char* STARROCKS_BUILD_DISTRO_ID = "{BUILD_DISTRO_ID}";
185
+ const char* STARROCKS_BUILD_ARCH = "{BUILD_ARCH}";
180
186
}}
181
187
182
188
'''
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 ])
184
190
file_content = file_format .format (VERSION = version , COMMIT_HASH = commit_hash ,
185
191
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 )
187
193
188
194
file_name = cpp_path + "/version.cpp"
189
195
d = os .path .dirname (file_name )
@@ -204,14 +210,15 @@ def main():
204
210
distro_info = get_build_distro_info ()
205
211
build_distro_id = distro_info .get ("ID" , "unknown" )
206
212
build_pretty_name = distro_info .get ("PRETTY_NAME" , build_distro_id )
213
+ build_arch = get_build_arch ()
207
214
user = get_user ()
208
215
# append build distro pretty name into hostname
209
216
hostname = '%s (%s)' % (get_hostname (), build_pretty_name )
210
217
211
218
java_version = get_java_version ()
212
219
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 )
215
222
216
223
if __name__ == '__main__' :
217
224
main ()
0 commit comments