-
Notifications
You must be signed in to change notification settings - Fork 116
/
mlx-run
executable file
·45 lines (37 loc) · 1.04 KB
/
mlx-run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/sh
# Wrapper to help run command line tools -- this will find the build directory
# and set the DYLD_FRAMEWORK_PATH so that command line tools that link frameworks
# can be run.
#
# Example:
# ./mlx-run --debug llm-tool --help
if [ "$#" -lt 1 ]; then
echo "usage: mlx-run [--debug/--release] <tool-name> arguments"
exit 1
fi
CONFIGURATION=Release
if [ "$1" == "--release" ]; then
CONFIGURATION=Release
shift
fi
if [ "$1" == "--debug" ]; then
CONFIGURATION=Debug
shift
fi
if [ "$1" == "--list" ]; then
xcodebuild -list
exit 0
fi
COMMAND="$1"
shift
BUILD_DIR=`xcodebuild -configuration $CONFIGURATION -showBuildSettings -scheme $COMMAND | grep 'BUILT_PRODUCTS_DIR = /' | sed -e 's/^[^=]*= //g'`
if [ -d "$BUILD_DIR/$COMMAND.app" ]; then
exec $BUILD_DIR/$COMMAND.app/Contents/MacOS/$COMMAND "$@" &
fi
if [ -f "$BUILD_DIR/$COMMAND" ]; then
export DYLD_FRAMEWORK_PATH=$BUILD_DIR/PackageFrameworks:$BUILD_DIR
exec "$BUILD_DIR/$COMMAND" "$@"
else
echo "$BUILD_DIR/$COMMAND does not exist -- check build configuration ($CONFIGURATION)"
exit 1
fi