Skip to content

Commit

Permalink
support customizing install directory with $DPATH
Browse files Browse the repository at this point in the history
This introduces the $DPATH environment variable to override the user's home directory just for D tools.

This is also intended to be used by DUB (dlang/dub#2281) when there is not the more explicit `$DUB_HOME` variable set on the system.

This allows users who install their D compiler through the install.sh script to both have the compiler installations as well as the dub packages be stored elsewhere in the system than in their home folder.

In case we have other tools that download their dependencies into the user's home directory, we should also make them support the same $DPATH environment variable.
  • Loading branch information
WebFreak001 committed Jun 28, 2022
1 parent 194c9c8 commit 6ce1cc9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
5 changes: 5 additions & 0 deletions changelog/dpath.dd
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
The `install.sh` script now respects the `$DPATH` environment variable

The `$DPATH` environment variable can be set on any system to make the install location of the install.sh script as well as other D related tools like DUB to store their cache files, dependencies, installed compilers, etc.

This way you can change where all the D tools are installed and keep a clean home folder.
18 changes: 13 additions & 5 deletions script/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,21 @@ GET_PATH_AUTO_INSTALL=0
GET_PATH_COMPILER=dc
# Set a default install path depending on the POSIX/Windows environment.
if posix_terminal; then
ROOT=~/dlang
if [ -z "$DPATH" ]; then
ROOT=~/dlang
else
ROOT="$DPATH/dlang"
fi
else
# Default to a ROOT that is outside the POSIX-like environment.
if [ -z "$USERPROFILE" ]; then
fatal '%USERPROFILE% should not be empty on Windows.';
if [ -z "$DPATH" ]; then
# Default to a ROOT that is outside the POSIX-like environment.
if [ -z "$USERPROFILE" ]; then
fatal '%USERPROFILE% should not be empty on Windows.';
fi
ROOT=$(posix_path "$USERPROFILE")/dlang
else
ROOT=$(posix_path "$DPATH")/dlang
fi
ROOT=$(posix_path "$USERPROFILE")/dlang
fi
TMP_ROOT=
DUB_VERSION=
Expand Down

0 comments on commit 6ce1cc9

Please sign in to comment.