File: ecbuild_windows_replace_symlinks.sh

package info (click to toggle)
ecflow 5.15.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 51,868 kB
  • sloc: cpp: 269,341; python: 22,756; sh: 3,609; perl: 770; xml: 333; f90: 204; ansic: 141; makefile: 70
file content (37 lines) | stat: -rwxr-xr-x 1,083 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#
# Bash script to replace all symlinks with copies on Windows.
#
# Cmake on non-cygwin windows will completely ignore symlinks, causing install to fail for any repos
# with symlinks in the source (e.g. ecCodes). See SystemTools::CreateSymlink [0], which at time of
# writing is:
#
# ```
# #if defined(_WIN32) && !defined(__CYGWIN__)
# bool SystemTools::CreateSymlink(const std::string&, const std::string&)
# {
#   return false;
# }
# ```
#
# [0] https://github.com/Kitware/CMake/blob/master/Source/kwsys/SystemTools.cxx#L2969
#
echo ""
echo "======================="
echo " REMOVING ALL SYMLINKS "
echo "======================="
echo ""

for link in `find . -type l -not -path './build/*'`
do
    if [ -e $link ]
    then
        echo "removing link $link"
        target=$(readlink -f $link)
        # Remove the symlink before copying (rather than passing --remove-destination to cp)
        # to prevent cp complaining about overwriting a symlink with a directory.
        rm -r $link
        cp -rTL $target $link
    else
        echo "ignoring broken link $link"
    fi
done