Skip to content

Commit

Permalink
deploy.tpl: Avoid copying existing file to the output
Browse files Browse the repository at this point in the history
Signed-off-by: Illia Vysochyn <ivysochyn@antmicro.com>
  • Loading branch information
ivysochyn committed Aug 8, 2024
1 parent d417829 commit f4fdf47
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
17 changes: 14 additions & 3 deletions deploy.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ usage() {
main() {
local progname
local dst
local dep
local config
local genfiles
local make
Expand All @@ -35,6 +36,10 @@ main() {
shift
shift
;;
-d|--dependency)
dep="true"
shift
;;
*)
dst="$1"
shift
Expand All @@ -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"
Expand All @@ -73,4 +84,4 @@ main() {
exit $?
}

main --genfiles "${GENFILES}" --make "${MAKE}" --config "${CONFIG}" "$@"
main --genfiles "${GENFILES}" --make "${MAKE}" --config "${CONFIG}" "$@"
7 changes: 4 additions & 3 deletions openroad.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
Expand Down

0 comments on commit f4fdf47

Please sign in to comment.