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 action_with_pydeps(target_name) { 26 forward_variables_from(invoker, 27 [ 28 "data", 29 "deps", 30 "outputs", 31 "testonly", 32 "visibility", 33 ]) 34 sources = [] 35 if (defined(invoker.sources)) { 36 sources += invoker.sources 37 } 38 if (defined(invoker.inputs)) { 39 inputs = invoker.inputs 40 } 41 42 script = "//build/scripts/copy_ex.py" 43 44 args = [ 45 "--dest", 46 rebase_path(invoker.dest, root_build_dir), 47 ] 48 rebased_sources = rebase_path(sources, root_build_dir) 49 args += [ "--files=$rebased_sources" ] 50 51 if (defined(invoker.args)) { 52 args += invoker.args 53 } 54 55 if (defined(invoker.renaming_sources) && 56 defined(invoker.renaming_destinations)) { 57 sources += invoker.renaming_sources 58 rebased_renaming_sources = 59 rebase_path(invoker.renaming_sources, root_build_dir) 60 args += [ "--renaming-sources=$rebased_renaming_sources" ] 61 62 renaming_destinations = invoker.renaming_destinations 63 args += [ "--renaming-destinations=$renaming_destinations" ] 64 } 65 } 66} 67