From f4fdf479d115813f97c31dc0eba085574bfb4596 Mon Sep 17 00:00:00 2001 From: Illia Vysochyn Date: Wed, 7 Aug 2024 15:58:06 +0200 Subject: [PATCH] deploy.tpl: Avoid copying existing file to the output Signed-off-by: Illia Vysochyn --- deploy.tpl | 17 ++++++++++++++--- openroad.bzl | 7 ++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/deploy.tpl b/deploy.tpl index aad7c6f..726f5ca 100644 --- a/deploy.tpl +++ b/deploy.tpl @@ -10,6 +10,7 @@ usage() { main() { local progname local dst + local dep local config local genfiles local make @@ -35,6 +36,10 @@ main() { shift shift ;; + -d|--dependency) + dep="true" + shift + ;; *) dst="$1" shift @@ -58,13 +63,19 @@ main() { fi mkdir --parents "$dst" - cp --recursive --parents --target-directory "$dst" -- * + if [ -z "$dep" ]; then + cp --update --recursive --parents --target-directory "$dst" -- * + else + cp --recursive --parents --target-directory "$dst" -- * + fi for file in $genfiles; do if [ -L "$dst/$file" ]; then unlink "$dst/$file" fi - cp --force --dereference --no-preserve=all --parents --target-directory "$dst" "$file" + if [ -z "$dep" ] || [ ! -e "$dst/$file" ]; then + cp --force --dereference --no-preserve=all --parents --target-directory "$dst" "$file" + fi done cp --force "$make" "$dst/make" @@ -73,4 +84,4 @@ main() { exit $? } -main --genfiles "${GENFILES}" --make "${MAKE}" --config "${CONFIG}" "$@" \ No newline at end of file +main --genfiles "${GENFILES}" --make "${MAKE}" --config "${CONFIG}" "$@" diff --git a/openroad.bzl b/openroad.bzl index d565c89..f6f4806 100644 --- a/openroad.bzl +++ b/openroad.bzl @@ -217,9 +217,10 @@ def _deps_impl(ctx): template = ctx.file._deploy_template, output = exe, substitutions = { - "${GENFILES}": " ".join([f.short_path for f in ctx.attr.src[OrfsDepInfo].files]), - "${CONFIG}": ctx.attr.src[OrfsDepInfo].config.short_path, - "${MAKE}": ctx.attr.src[OrfsDepInfo].make.short_path, + '${GENFILES}': ' '.join([f.short_path for f in ctx.attr.src[OrfsDepInfo].files]), + '${CONFIG}': ctx.attr.src[OrfsDepInfo].config.short_path, + '${MAKE}': ctx.attr.src[OrfsDepInfo].make.short_path, + '"$@"': '--dependency "$@"', }, ) return [