mirror of
https://github.com/bazel-contrib/rules_foreign_cc
synced 2024-12-04 08:02:31 +00:00
74b146dc87
Fix shell function symlink_contents_to_dir, add test - test for the case when we symlink the contents of two directories with the same inner directories (include) - the test data of the test for shell script helper also changes, as it uses the real shell toolchain implementation text - Fixes the issue from #330
34 lines
795 B
Plaintext
Executable file
34 lines
795 B
Plaintext
Executable file
function symlink_contents_to_dir() {
|
|
local target="$2"
|
|
mkdir -p "$target"
|
|
if [[ -f "$1" ]]; then
|
|
symlink_to_dir $1 $target
|
|
elif [[ -L "$1" ]]; then
|
|
local actual=$(readlink "$1")
|
|
symlink_contents_to_dir $actual $target
|
|
elif [[ -d "$1" ]]; then
|
|
local children=$(find "$1" -maxdepth 1 -mindepth 1)
|
|
for child in $children; do
|
|
symlink_to_dir $child $target
|
|
done
|
|
fi
|
|
}
|
|
function symlink_to_dir() {
|
|
local target="$2"
|
|
mkdir -p "$target"
|
|
if [[ -f "$1" ]]; then
|
|
ln -s -f "$1" "$target"
|
|
elif [[ -L "$1" ]]; then
|
|
cp $1 $2
|
|
elif [[ -d "$1" ]]; then
|
|
local children=$(find "$1" -maxdepth 1 -mindepth 1)
|
|
local dirname=$(basename "$1")
|
|
mkdir -p "$target/$dirname"
|
|
for child in $children; do
|
|
symlink_to_dir $child $target/$dirname
|
|
done
|
|
else
|
|
echo "Can not copy $1"
|
|
fi
|
|
}
|
|
symlink_contents_to_dir $SOURCE_DIR $TARGET_DIR |