[commit: ghc] wip/andrey/drop-symlink-traversal: Hadrian: Drop remaining symlink traversal code from build scripts (3ed7777)

git at git.haskell.org git at git.haskell.org
Wed Mar 6 21:49:33 UTC 2019


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/andrey/drop-symlink-traversal
Link       : http://ghc.haskell.org/trac/ghc/changeset/3ed77774bd07a85ffedb085d7cfe11809e1d2f0f/ghc

>---------------------------------------------------------------

commit 3ed77774bd07a85ffedb085d7cfe11809e1d2f0f
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date:   Wed Mar 6 13:42:27 2019 +0000

    Hadrian: Drop remaining symlink traversal code from build scripts
    
    This partly resolves #16325 (https://ghc.haskell.org/trac/ghc/ticket/16325).
    
    As previously discussed in https://github.com/snowleopard/hadrian/issues/667,
    we do not need the symlink traversal code in build scripts. However, it
    appears we forgot to delete this code from our Stack-based build scripts,
    which led to placing all build artefacts in an unexpected location when
    using Hadrian in combination with symlink trees. This commit fixes this.


>---------------------------------------------------------------

3ed77774bd07a85ffedb085d7cfe11809e1d2f0f
 hadrian/build.stack.nix.sh | 32 +-------------------------------
 hadrian/build.stack.sh     | 38 +++++---------------------------------
 2 files changed, 6 insertions(+), 64 deletions(-)

diff --git a/hadrian/build.stack.nix.sh b/hadrian/build.stack.nix.sh
index 59ac061..b30c114 100755
--- a/hadrian/build.stack.nix.sh
+++ b/hadrian/build.stack.nix.sh
@@ -1,33 +1,3 @@
 #!/usr/bin/env bash
 
-set -euo pipefail
-
-# readlink on os x, doesn't support -f, to prevent the
-# need of installing coreutils (e.g. through brew, just
-# for readlink, we use the follownig substitute.
-#
-# source: http://stackoverflow.com/a/1116890
-function rl {
-    TARGET_FILE="$1"
-
-    cd "$(dirname "$TARGET_FILE")"
-    TARGET_FILE="$(basename "$TARGET_FILE")"
-
-    # Iterate down a (possible) chain of symlinks
-    while [ -L "$TARGET_FILE" ]
-    do
-        TARGET_FILE="$(readlink "$TARGET_FILE")"
-        cd "$(dirname "$TARGET_FILE")"
-        TARGET_FILE="$(basename "$TARGET_FILE")"
-    done
-
-    # Compute the canonicalized name by finding the physical path
-    # for the directory we're in and appending the target file.
-    PHYS_DIR="$(pwd -P)"
-    RESULT="$PHYS_DIR/$TARGET_FILE"
-    echo "$RESULT"
-}
-
-absoluteRoot="$(dirname "$(rl "$0")")"
-
-HADRIAN_NIX=YES ${absoluteRoot}/build.stack.sh
+HADRIAN_NIX=YES hadrian/build.stack.sh
diff --git a/hadrian/build.stack.sh b/hadrian/build.stack.sh
index 2e6c444..1f59843 100755
--- a/hadrian/build.stack.sh
+++ b/hadrian/build.stack.sh
@@ -1,38 +1,10 @@
 #!/usr/bin/env bash
 
-set -euo pipefail
-
-# readlink on os x, doesn't support -f, to prevent the
-# need of installing coreutils (e.g. through brew, just
-# for readlink, we use the follownig substitute.
-#
-# source: http://stackoverflow.com/a/1116890
-function rl {
-    TARGET_FILE="$1"
-
-    cd "$(dirname "$TARGET_FILE")"
-    TARGET_FILE="$(basename "$TARGET_FILE")"
-
-    # Iterate down a (possible) chain of symlinks
-    while [ -L "$TARGET_FILE" ]
-    do
-        TARGET_FILE="$(readlink "$TARGET_FILE")"
-        cd "$(dirname "$TARGET_FILE")"
-        TARGET_FILE="$(basename "$TARGET_FILE")"
-    done
-
-    # Compute the canonicalized name by finding the physical path
-    # for the directory we're in and appending the target file.
-    PHYS_DIR="$(pwd -P)"
-    RESULT="$PHYS_DIR/$TARGET_FILE"
-    echo "$RESULT"
-}
-
-absoluteRoot="$(dirname "$(rl "$0")")"
-cd "$absoluteRoot"
-
+# Make sure Hadrian is up-to-date
+cd hadrian
 stack build --no-library-profiling ${HADRIAN_NIX:+--nix}
 
-stack exec hadrian --              \
-    --directory "$absoluteRoot/.." \
+# Run Hadrian in the top-level GHC directory
+stack exec hadrian -- \
+    --directory ".."  \
     "$@"



More information about the ghc-commits mailing list