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