1# Copyright 2024 Google LLC 2# 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6import errno 7import glob 8import os 9import shutil 10import sys 11 12src = sys.argv[1] 13dst = sys.argv[2] 14build_products = sys.argv[3].split(',') 15 16try: 17 os.makedirs(dst) 18except OSError as e: 19 if e.errno != errno.EEXIST: 20 raise 21 22for pattern in build_products: 23 path = os.path.join(src, pattern) 24 for f in glob.glob(path): 25 dst_path = os.path.join(dst, os.path.relpath(f, src)) 26 if not os.path.isdir(os.path.dirname(dst_path)): 27 os.makedirs(os.path.dirname(dst_path)) 28 print('Copying build product %s to %s' % (f, dst_path)) 29 shutil.move(f, dst_path) 30