@@ -48,33 +48,34 @@ Pass extra flags to all cargo invocations.
48
48
EOF
49
49
)
50
50
51
- # # Run the subcommands that the user requested to always run first
51
+ # # We need to know where we are.
52
+ # macOS does not have a useful readlink/realpath so we have to use Python instead...
53
+ MIRIDIR=$( python3 -c ' import os, sys; print(os.path.dirname(os.path.realpath(sys.argv[1])))' " $0 " )
54
+
55
+ # # Run the auto-things.
52
56
if [ -z " $AUTO_OPS " ]; then
53
57
export AUTO_OPS=42
54
58
55
59
# Run this first, so that the toolchain doesn't change after
56
60
# other code has run.
57
- if [ -f " .auto-everything" ] || [ -f " .auto-toolchain" ] ; then
61
+ if [ -f " $MIRIDIR / .auto-everything" ] || [ -f " $MIRIDIR / .auto-toolchain" ] ; then
58
62
" $MIRIDIR " /rustup-toolchain
59
63
fi
60
64
61
- if [ -f " .auto-everything" ] || [ -f " .auto-fmt" ] ; then
65
+ if [ -f " $MIRIDIR / .auto-everything" ] || [ -f " $MIRIDIR / .auto-fmt" ] ; then
62
66
$0 fmt
63
67
fi
64
68
65
- if [ -f " .auto-everything" ] || [ -f " .auto-clippy" ] ; then
69
+ if [ -f " $MIRIDIR / .auto-everything" ] || [ -f " $MIRIDIR / .auto-clippy" ] ; then
66
70
$0 clippy -- -D warnings
67
71
fi
68
72
fi
69
73
70
- # # Preparation
71
- # macOS does not have a useful readlink/realpath so we have to use Python instead...
72
- MIRIDIR=$( python3 -c ' import os, sys; print(os.path.dirname(os.path.realpath(sys.argv[1])))' " $0 " )
73
- TOOLCHAIN=$( cd " $MIRIDIR " ; rustup show active-toolchain | head -n 1 | cut -d ' ' -f 1)
74
-
75
- # Determine command.
74
+ # # Determine command and toolchain.
76
75
COMMAND=" $1 "
77
76
[ $# -gt 0 ] && shift
77
+ # Doing this *after* auto-toolchain logic above, since that might change the toolchain.
78
+ TOOLCHAIN=$( cd " $MIRIDIR " ; rustup show active-toolchain | head -n 1 | cut -d ' ' -f 1)
78
79
79
80
# # Handle some commands early, since they should *not* alter the environment.
80
81
case " $COMMAND " in
0 commit comments