1# Copyright 2019 The Chromium Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5import("//build/config/python.gni") 6 7# Copy a list of file into a destination directory. Potentially renaming 8# files are they are copied. This also ensures that symlinks are followed 9# during the copy (i.e. the symlinks are never copied, only their content). 10# 11# Variables: 12# dest: Destination directory path. 13# sources: List of source files or directories to copy to dest. 14# renaming_sources: Optional list of source file paths that will be renamed 15# during the copy operation. If provided, renaming_destinations is required. 16# renaming_destinations: Optional list of destination file paths, required 17# when renaming_sources is provided. Both lists should have the same size 18# and matching entries. 19# args: Optional. Additional arguments to the copy_ex.py script. 20# 21# The following variables have the usual GN meaning: data, deps, inputs, 22# outputs, testonly, visibility. 23# 24template("copy_ex") { 25 set_sources_assignment_filter([]) 26 action_with_pydeps(target_name) { 27 forward_variables_from(invoker, 28 [ 29 "data", 30 "deps", 31 "outputs", 32 "testonly", 33 "visibility", 34 ]) 35 sources = [] 36 if (defined(invoker.sources)) { 37 sources += invoker.sources 38 } 39 if (defined(invoker.inputs)) { 40 inputs = invoker.inputs 41 } 42 43 script = "//build/scripts/copy_ex.py" 44 45 args = [ 46 "--dest", 47 rebase_path(invoker.dest, root_build_dir), 48 ] 49 rebased_sources = rebase_path(sources, root_build_dir) 50 args += [ "--files=$rebased_sources" ] 51 52 if (defined(invoker.args)) { 53 args += invoker.args 54 } 55 56 if (defined(invoker.renaming_sources) && 57 defined(invoker.renaming_destinations)) { 58 sources += invoker.renaming_sources 59 rebased_renaming_sources = 60 rebase_path(invoker.renaming_sources, root_build_dir) 61 args += [ "--renaming-sources=$rebased_renaming_sources" ] 62 63 renaming_destinations = invoker.renaming_destinations 64 args += [ "--renaming-destinations=$renaming_destinations" ] 65 } 66 } 67} 68