Skip to content

Commit b6e75c8

Browse files
shoumikhinoscarandersson8218
authored andcommitted
Fix build_apple_frameworks.sh buck resolution (pytorch#9372)
1 parent 4126ba5 commit b6e75c8

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

build/build_apple_frameworks.sh

+18-9
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,31 @@ if [[ -z "$TOOLCHAIN" ]]; then
145145
fi
146146
[[ -f "$TOOLCHAIN" ]] || { echo >&2 "Toolchain file $TOOLCHAIN does not exist."; exit 1; }
147147

148+
BUCK2=$("$PYTHON" "$SOURCE_ROOT_DIR/tools/cmake/resolve_buck.py" --cache_dir="$SOURCE_ROOT_DIR/buck2-bin")
149+
150+
if [[ "$BUCK2" == "buck2" ]]; then
151+
BUCK2=$(command -v buck2)
152+
fi
153+
148154
check_command() {
149-
command -v "$1" >/dev/null 2>&1 || { echo >&2 "$1 is not installed"; exit 1; }
155+
if [[ "$1" == */* ]]; then
156+
if [[ ! -x "$1" ]]; then
157+
echo "Error: Command not found or not executable at '$1'" >&2
158+
exit 1
159+
fi
160+
else
161+
if ! command -v "$1" >/dev/null 2>&1; then
162+
echo "Error: Command '$1' not found in PATH" >&2
163+
exit 1
164+
fi
165+
fi
150166
}
151167

152168
check_command cmake
153169
check_command rsync
154170
check_command "$PYTHON"
155171
check_command "$FLATC"
172+
check_command "$BUCK2"
156173

157174
echo "Building libraries"
158175

@@ -205,14 +222,6 @@ echo "Exporting headers"
205222

206223
mkdir -p "$HEADERS_PATH"
207224

208-
BUCK2=$("$PYTHON" "$SOURCE_ROOT_DIR/tools/cmake/resolve_buck.py" --cache_dir="$SOURCE_ROOT_DIR/buck2-bin")
209-
if [[ -z "$BUCK2" ]]; then
210-
echo "Could not find buck2 executable in any buck2-bin directory under $SOURCE_ROOT_DIR"
211-
BUCK2=$(which buck2)
212-
fi
213-
214-
check_command "$BUCK2"
215-
216225
"$SOURCE_ROOT_DIR"/build/print_exported_headers.py --buck2=$(realpath "$BUCK2") --targets \
217226
//extension/module: \
218227
//extension/tensor: \

0 commit comments

Comments
 (0)