2
0
Fork 0
mirror of https://github.com/bazel-contrib/rules_foreign_cc synced 2024-11-30 16:42:07 +00:00
rules_foreign_cc/test/expected/inner_fun_text_osx.txt
irengrig 3515b20a24
Fix shell_script_helper.bzl to replace function calls inside function… (#375)
Fix shell_script_helper.bzl to replace function calls inside function texts.

Add test for shell_script_helper.bzl.
In particular, this fixes the case when some of the shell toolchain functions calls other shell toolchain functions (symlink_contents_to_dir and symlink_to_dir).
2020-04-30 11:24:25 +02:00

33 lines
597 B
Plaintext
Executable file

function symlink_contents_to_dir() {
local target="$2"
mkdir -p $target
if [[ -f $1 ]]; then
symlink_to_dir $1 $target
return 0
fi
if [[ -d $1 || -L $1 ]]; then
local children=$(find -H $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 [[ -d $1 ]]; then
local dir_name="$(basename "$1")"
ln -s $1 ${target}/${dir_name}
elif [[ -f $1 ]]; then
ln -s $1 ${target}
elif [[ -L $1 ]]; then
cp $1 ${target}
else
echo "Can not copy $1"
fi
}
symlink_contents_to_dir $SOURCE_DIR $TARGET_DIR