blob: 820276d994781a031e7661f738997e85d032d24e [file] [log] [blame]
# Copyright 2020 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
import("//build_overrides/pigweed.gni")
pw_universal_copy = {
if (host_os == "win") {
cp_command = "cp -af {{source}} {{output}}"
# Use python script in absence of cp command.
copy_tool_path =
rebase_path(dir_pw_toolchain) + "/py/pw_toolchain/copy_with_metadata.py"
fallback_command = "python $copy_tool_path {{source}} {{output}}"
command = "cmd /c \"($cp_command > NUL 2>&1) || ($fallback_command)\""
} else {
# Use a hard link if possible as this is faster. Also, Mac doesn't
# preserve timestamps properly with cp -af.
fallback_command = string_join(" ",
[
"rm -rf",
"{{output}}",
"&&",
"cp -af",
"{{source}}",
"{{output}}",
])
command = string_join(" ",
[
"ln -f",
"{{source}}",
"{{output}}",
"2>/dev/null",
"||",
"($fallback_command)",
])
}
description = "cp {{source}} {{output}}"
}
pw_universal_stamp = {
if (host_os == "win") {
command = "cmd /c type nul > \"{{output}}\""
} else {
command = "touch {{output}}"
}
description = "stamp {{output}}"
}