Skip to content

Commit a8e2f16

Browse files
committed
Issue #41161: Update sage -b to use ninja and deprecate sage -br
1 parent aa27703 commit a8e2f16

File tree

1 file changed

+20
-28
lines changed

1 file changed

+20
-28
lines changed

src/bin/sage

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -191,43 +191,35 @@ fi
191191
# build/bin/sage-site. See #29111; but OTOH #34627.
192192

193193
build_sage() {
194-
( cd "$SAGE_ROOT" && make sagelib-no-deps ) || exit $?
194+
SAGE_VENV_BUILD_DIR="$SAGE_VENV/var/lib/sage/build"
195+
196+
# Meson Build Detection
197+
if [ -f "build/build.ninja" ] && [ -f "build/meson-info/meson-info.json" ]; then
198+
echo "Building Sage with ninja (build/)..."
199+
( cd "$SAGE_ROOT" && ninja -C build ) || exit $?
200+
elif [ -f "$SAGE_VENV_BUILD_DIR/build.ninja" ] && [ -f "$SAGE_VENV_BUILD_DIR/meson-info/meson-info.json" ]; then
201+
echo "Building Sage with ninja (venv build dir)..."
202+
( cd "$SAGE_ROOT" && ninja -C "$SAGE_VENV_BUILD_DIR" ) || exit $?
203+
elif [ -f "build.ninja" ] && [ -f "meson-info/meson-info.json" ]; then
204+
echo "Building Sage with ninja (root)..."
205+
( cd "$SAGE_ROOT" && ninja ) || exit $?
206+
else
207+
echo "Building Sage (make sagelib-no-deps)..."
208+
( cd "$SAGE_ROOT" && make sagelib-no-deps ) || exit $?
209+
fi
195210
}
196211

197-
# Check for '-i' etc. before sourcing sage-env: running "make"
198-
# should be run outside of the Sage shell.
199212
case "$1" in
200-
-i|-f|-p)
201-
# Delegate further option handling to the non-installed sage-site script.
202-
# (These options become unavailable if the directory $SAGE_ROOT is removed.)
203-
if [ -d "$SAGE_ROOT" ]; then
204-
exec "$SAGE_ROOT/build/bin/sage-site" "$@"
205-
# fallthrough if there is no sage-site script
206-
fi
207-
echo >&2 "Error: unknown option: $1"
208-
exit 1
209-
;;
213+
210214
-b)
211215
build_sage
212216
exit 0
213217
;;
214218
-br|--br)
219+
echo "Warning: 'sage -br' is deprecated." >&2
220+
echo "In an editable install, just run './sage' to use the latest built code." >&2
215221
build_sage
216-
shift; set -- -r "$@" # delegate to handling of "-r" below, after sourcing sage-env
217-
;;
218-
-bn|--build-and-notebook)
219-
build_sage
220-
shift; set -- -n "$@" # delegate to handling of "-n" below, after sourcing sage-env
221-
;;
222-
-ba)
223-
( cd "$SAGE_ROOT" && make sagelib-clean )
224-
build_sage
225-
exit 0
226-
;;
227-
-bt*)
228-
build_sage
229-
switch_without_b=-${1#-b}
230-
shift; set -- $switch_without_b "$@" # delegate to handling of "-t...." below, after sourcing sage-env
222+
shift; set -- -r "$@"
231223
;;
232224
esac
233225

0 commit comments

Comments
 (0)