Armando Montanez | 7cd6f08 | 2020-11-11 18:36:15 -0800 | [diff] [blame] | 1 | # Copyright 2020 The Pigweed Authors |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 4 | # use this file except in compliance with the License. You may obtain a copy of |
| 5 | # the License at |
| 6 | # |
| 7 | # https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | # License for the specific language governing permissions and limitations under |
| 13 | # the License. |
| 14 | |
Duda, Lukasz | 70c630d | 2021-01-15 22:53:23 +0100 | [diff] [blame] | 15 | import("//build_overrides/pigweed.gni") |
| 16 | |
Armando Montanez | 7cd6f08 | 2020-11-11 18:36:15 -0800 | [diff] [blame] | 17 | pw_universal_copy = { |
| 18 | if (host_os == "win") { |
Duda, Lukasz | 70c630d | 2021-01-15 22:53:23 +0100 | [diff] [blame] | 19 | cp_command = "cp -af {{source}} {{output}}" |
| 20 | |
| 21 | # Use python script in absence of cp command. |
Michael Spang | c8b9390 | 2021-05-30 15:53:56 -0400 | [diff] [blame^] | 22 | copy_tool_path = rebase_path(dir_pw_toolchain, root_build_dir) + |
| 23 | "/py/pw_toolchain/copy_with_metadata.py" |
Duda, Lukasz | 70c630d | 2021-01-15 22:53:23 +0100 | [diff] [blame] | 24 | fallback_command = "python $copy_tool_path {{source}} {{output}}" |
| 25 | |
| 26 | command = "cmd /c \"($cp_command > NUL 2>&1) || ($fallback_command)\"" |
Armando Montanez | 7cd6f08 | 2020-11-11 18:36:15 -0800 | [diff] [blame] | 27 | } else { |
| 28 | # Use a hard link if possible as this is faster. Also, Mac doesn't |
| 29 | # preserve timestamps properly with cp -af. |
| 30 | fallback_command = string_join(" ", |
| 31 | [ |
| 32 | "rm -rf", |
| 33 | "{{output}}", |
| 34 | "&&", |
| 35 | "cp -af", |
| 36 | "{{source}}", |
| 37 | "{{output}}", |
| 38 | ]) |
| 39 | command = string_join(" ", |
| 40 | [ |
| 41 | "ln -f", |
| 42 | "{{source}}", |
| 43 | "{{output}}", |
| 44 | "2>/dev/null", |
| 45 | "||", |
| 46 | "($fallback_command)", |
| 47 | ]) |
| 48 | } |
| 49 | description = "cp {{source}} {{output}}" |
| 50 | } |
| 51 | |
| 52 | pw_universal_stamp = { |
| 53 | if (host_os == "win") { |
| 54 | command = "cmd /c type nul > \"{{output}}\"" |
| 55 | } else { |
| 56 | command = "touch {{output}}" |
| 57 | } |
| 58 | description = "stamp {{output}}" |
| 59 | } |