1*d9f75844SAndroid Build Coastguard Worker#!/usr/bin/env vpython3 2*d9f75844SAndroid Build Coastguard Worker 3*d9f75844SAndroid Build Coastguard Worker# Copyright (c) 2020 The WebRTC project authors. All Rights Reserved. 4*d9f75844SAndroid Build Coastguard Worker# 5*d9f75844SAndroid Build Coastguard Worker# Use of this source code is governed by a BSD-style license 6*d9f75844SAndroid Build Coastguard Worker# that can be found in the LICENSE file in the root of the source 7*d9f75844SAndroid Build Coastguard Worker# tree. An additional intellectual property rights grant can be found 8*d9f75844SAndroid Build Coastguard Worker# in the file PATENTS. All contributing project authors may 9*d9f75844SAndroid Build Coastguard Worker# be found in the AUTHORS file in the root of the source tree. 10*d9f75844SAndroid Build Coastguard Worker 11*d9f75844SAndroid Build Coastguard Workerimport re 12*d9f75844SAndroid Build Coastguard Workerimport subprocess 13*d9f75844SAndroid Build Coastguard Workerimport sys 14*d9f75844SAndroid Build Coastguard Worker 15*d9f75844SAndroid Build Coastguard WorkerWEBRTC_VERSION_RE = re.compile( 16*d9f75844SAndroid Build Coastguard Worker r'WebRTC source stamp [0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}' 17*d9f75844SAndroid Build Coastguard Worker) 18*d9f75844SAndroid Build Coastguard Worker 19*d9f75844SAndroid Build Coastguard Worker 20*d9f75844SAndroid Build Coastguard Workerif __name__ == '__main__': 21*d9f75844SAndroid Build Coastguard Worker args = sys.argv 22*d9f75844SAndroid Build Coastguard Worker if len(args) != 2: 23*d9f75844SAndroid Build Coastguard Worker print('Usage: binary_version_test.py <FILE_NAME>') 24*d9f75844SAndroid Build Coastguard Worker sys.exit(1) 25*d9f75844SAndroid Build Coastguard Worker filename = sys.argv[1] 26*d9f75844SAndroid Build Coastguard Worker output = subprocess.check_output(['strings', filename]) 27*d9f75844SAndroid Build Coastguard Worker strings_in_binary = output.decode('utf-8').splitlines() 28*d9f75844SAndroid Build Coastguard Worker for symbol in strings_in_binary: 29*d9f75844SAndroid Build Coastguard Worker if WEBRTC_VERSION_RE.match(symbol): 30*d9f75844SAndroid Build Coastguard Worker with open('webrtc_binary_version_check', 'w') as f: 31*d9f75844SAndroid Build Coastguard Worker f.write(symbol) 32*d9f75844SAndroid Build Coastguard Worker sys.exit(0) 33*d9f75844SAndroid Build Coastguard Worker print('WebRTC source timestamp not found in "%s"' % filename) 34*d9f75844SAndroid Build Coastguard Worker print('Check why "kSourceTimestamp" from call/version.cc is not linked ' 35*d9f75844SAndroid Build Coastguard Worker '(or why it has been optimized away by the compiler/linker)') 36*d9f75844SAndroid Build Coastguard Worker sys.exit(1) 37