-
Notifications
You must be signed in to change notification settings - Fork 37
Symlink traversing logic in build scripts #667
Comments
@hvr on IRC:
|
To elaborate a bit; the important bit is that we want
It's also worth noting that the script could effectively be reduced to a single invocation of
No need to |
@hvr Aha, I see. This makes sense, although Hadrian currently doesn't support $PWD-based build targets.
Let's do this! I'm happy to sacrifice the support of older versions of Cabal if need be. Could you send a PR? |
@snowleopard what about locating the project-root? do we need to change how that is accomplished? |
@hvr I am tempted to first support only the most basic version of the build script, which assumes that it is run from Hadrian folder, i.e. Later we can think how we can implement more a feature-rich script, which could simply be calling this most basic script with the right parameters. |
you mean "which assumes that it is run from the top of the GHC source tree" ? |
Ah, yes, that's right. |
that'd be quite a regression compared to ...and actually I've got an idea how to salvage this w/o resorting to readlink |
Yes, but let's do one step at a time please :)
Right now we have neither! |
@snowleopard fair enough; I've tweaked the script a bit, how does this look? #!/usr/bin/env bash
CABAL=cabal
CABFLAGS="--disable-documentation --disable-profiling -v0"
PROJ="$PWD/hadrian/cabal.project"
set -euo pipefail
if ! [ -f "$PROJ" ]; then
echo "Current working directory must be GHC's top-level folder"
exit 2
fi
if ! type "$CABAL" > /dev/null; then
echo "Please make sure 'cabal' is in your PATH"
exit 2
fi
CABVERSTR=$("$CABAL" --numeric-version)
CABVER=( ${CABVERSTR//./ } )
if [ "${CABVER[0]}" -gt 2 -o "${CABVER[0]}" -eq 2 -a "${CABVER[1]}" -ge 2 ]; then
# New enough Cabal version detected, so let's use the superior new-build + new-run
# modes. Note that pre-2.2 Cabal does not support passing additional parameters
# to the executable (hadrian) after the separator '--', see #438.
"$CABAL" --project-file="$PROJ" new-build $CABFLAGS -j exe:hadrian
"$CABAL" --project-file="$PROJ" new-run $CABFLAGS exe:hadrian -- \
--lint \
--directory "$PWD" \
"$@"
else
echo "cabal version too old; you need at least cabal-install 2.2"
exit 2
fi There's a few optimization one could consider; like e.g. compiling the local lib:Cabal w/ -O0 (but you'd have to benchmark whether it's tolerable), or possibly injecting |
@snowleopard oh and btw, do we need a powershell script for windows? or does windows use bash as well? |
@hvr Thanks! Why do we need
Indeed, I'll give it a try.
We do have |
By the way, we've got quite a lot of scripts, perhaps we should move all but |
Yes, sounds like a good idea to me. |
Are you sure you really meant to say Also, it's more robust currently to pass
Ok, so we need a |
Btw, what's the point of the |
@hvr Apologies, I later edited it to
OK, I'll try your current version then. My only concern is unnecessary complexity. If it is necessary, I'll add a comment about the potential Cabal bug.
Yes, we do. I fully agree about the uniform workflow -- I actually tried to make |
I have no idea why it is that long. My preference would be to simply call the default script: the Cabal or Stack based one.
I prefer to use plain files if symlinks are avoidable. To me, there is always some additional mental overhead associated with symlinks. (Maybe I'm just wrong.) |
OK, I put together a PR: #668. Please have a look. @hvr Regarding $ cabal --version
cabal-install version 2.2.0.0
compiled using version 2.2.0.1 of the Cabal library
$ cabal --project-file=$PWD/hadrian/cabal.project new-build --disable-documentation --disable-profiling -v0 -j exe:hadrian
cabal.exe: Could not resolve dependencies:
[__0] trying: Cabal-2.4.0.0 (user goal)
[__1] next goal: text (dependency of Cabal)
[__1] rejecting: text-1.2.2.2, text-1.2.2.1, text-1.2.2.0, text-1.2.1.3,
text-1.2.1.2, text-1.2.1.1, text-1.2.1.0, text-1.2.0.6, text-1.2.0.5,
text-1.2.0.4, text-1.2.0.3, text-1.2.0.2, text-1.2.0.0, text-1.1.1.4,
text-1.1.1.3, text-1.1.1.2, text-1.1.1.1, text-1.1.1.0, text-1.1.0.1,
text-1.1.0.0, text-1.0.0.1, text-1.0.0.0, text-0.11.3.1, text-0.11.3.0,
text-0.11.2.3, text-0.11.2.2, text-0.11.2.1, text-0.11.2.0, text-0.11.1.13,
text-0.11.1.12, text-0.11.1.11, text-0.11.1.10, text-0.11.1.9, text-0.11.1.8,
text-0.11.1.7, text-0.11.1.6, text-0.11.1.5, text-0.11.1.3, text-0.11.1.2,
text-0.11.1.1, text-0.11.1.0, text-0.11.0.8, text-0.11.0.7, text-0.11.0.6,
text-0.11.0.5, text-0.11.0.4, text-0.11.0.3, text-0.11.0.2, text-0.11.0.1,
text-0.11.0.0, text-0.10.0.2, text-0.10.0.1, text-0.10.0.0, text-0.9.1.0,
text-0.9.0.1, text-0.9.0.0, text-0.8.1.0, text-0.8.0.0, text-0.7.2.1,
text-0.7.1.0, text-0.7.0.1, text-0.7, text-0.6, text-0.5, text-0.4, text-0.3,
text-0.2, text-0.1 (conflict: Cabal => text>=1.2.3.0 && <1.3)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: Cabal, text Any idea why this works on Linux and OSX but not Windows? |
@snowleopard this looks like your package db doesn't contain do you happen to have an old So if PS: For windows, you may need (in case you run into weird permission denied errors) to use |
@hvr Somehow I managed to make it work, thank you for your pointers! I will add |
btw, in case it helps, this is a 1-1 convertion of the sh file
|
Closed by #668. |
Note: there is a separate issue about creating the subdirectory |
This partly resolves #16325 (https://ghc.haskell.org/trac/ghc/ticket/16325). As previously discussed in snowleopard/hadrian#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.
This partly resolves #16325 (https://ghc.haskell.org/trac/ghc/ticket/16325). As previously discussed in snowleopard/hadrian#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.
This partly resolves #16325 (https://ghc.haskell.org/trac/ghc/ticket/16325). As previously discussed in snowleopard/hadrian#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.
This partly resolves #16325 (https://ghc.haskell.org/trac/ghc/ticket/16325). As previously discussed in snowleopard/hadrian#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.
This partly resolves #16325 (https://ghc.haskell.org/trac/ghc/ticket/16325). As previously discussed in snowleopard/hadrian#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.
Hadrian build scripts
build.sh
,build.cabal.sh
etc contain mysterious (to me) symlink-traversing logic, which may be confusing in certain setups, as reported in https://ghc.haskell.org/trac/ghc/ticket/15576.@hvr I think this logic was introduced by you. I couldn't recall why. Could you please clarify? Do we still need it? If yes, how do we avoid the confusion as described in the above ticket?
I'm tempted to classify this as a bug, since it leads to producing build results in an unexpected place.
The text was updated successfully, but these errors were encountered: