Skip to content

Commit 4633fa0

Browse files
committed
updated bash formatting
1 parent 328a6be commit 4633fa0

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

scripts/build_apple_frameworks.sh

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ usage() {
8787
echo " --mps Only build the Metal Performance Shaders backend."
8888
echo " --optimized Only build the Optimized kernels."
8989
echo " --quantized Only build the Quantized kernels."
90+
echo " --torchao Only build the TorchAO kernels."
9091
echo " --xnnpack Only build the XNNPACK backend."
91-
echo " --torchao Build the TorchAO kernels."
9292
echo
9393
exit 0
9494
}
@@ -105,8 +105,8 @@ set_cmake_options_override() {
105105
"-DEXECUTORCH_BUILD_MPS=OFF"
106106
"-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=OFF"
107107
"-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=OFF"
108-
"-DEXECUTORCH_BUILD_XNNPACK=OFF"
109108
"-DEXECUTORCH_BUILD_KERNELS_TORCHAO=OFF"
109+
"-DEXECUTORCH_BUILD_XNNPACK=OFF"
110110
)
111111
fi
112112

@@ -120,28 +120,28 @@ set_cmake_options_override() {
120120

121121
for arg in "$@"; do
122122
case $arg in
123-
-h | --help) usage ;;
124-
--Release)
125-
if [[ ! " ${MODES[*]:-} " =~ \bRelease\b ]]; then
126-
MODES+=("Release")
127-
fi
128-
;;
129-
--Debug)
130-
if [[ ! " ${MODES[*]:-} " =~ \bDebug\b ]]; then
131-
MODES+=("Debug")
132-
fi
133-
;;
134-
--coreml) set_cmake_options_override "EXECUTORCH_BUILD_COREML" ;;
135-
--custom) set_cmake_options_override "EXECUTORCH_BUILD_KERNELS_CUSTOM" ;;
136-
--mps) set_cmake_options_override "EXECUTORCH_BUILD_MPS" ;;
137-
--optimized) set_cmake_options_override "EXECUTORCH_BUILD_KERNELS_OPTIMIZED" ;;
138-
--quantized) set_cmake_options_override "EXECUTORCH_BUILD_KERNELS_QUANTIZED" ;;
139-
--xnnpack) set_cmake_options_override "EXECUTORCH_BUILD_XNNPACK" ;;
140-
--torchao) set_cmake_options_override "EXECUTORCH_BUILD_KERNELS_TORCHAO" ;;
141-
*)
142-
echo -e "\033[31m[error] unknown option: ${arg}\033[0m"
143-
exit 1
144-
;;
123+
-h|--help) usage ;;
124+
--Release)
125+
if [[ ! " ${MODES[*]:-} " =~ \bRelease\b ]]; then
126+
MODES+=("Release")
127+
fi
128+
;;
129+
--Debug)
130+
if [[ ! " ${MODES[*]:-} " =~ \bDebug\b ]]; then
131+
MODES+=("Debug")
132+
fi
133+
;;
134+
--coreml) set_cmake_options_override "EXECUTORCH_BUILD_COREML";;
135+
--custom) set_cmake_options_override "EXECUTORCH_BUILD_KERNELS_CUSTOM" ;;
136+
--mps) set_cmake_options_override "EXECUTORCH_BUILD_MPS" ;;
137+
--optimized) set_cmake_options_override "EXECUTORCH_BUILD_KERNELS_OPTIMIZED" ;;
138+
--quantized) set_cmake_options_override "EXECUTORCH_BUILD_KERNELS_QUANTIZED" ;;
139+
--xnnpack) set_cmake_options_override "EXECUTORCH_BUILD_XNNPACK" ;;
140+
--torchao) set_cmake_options_override "EXECUTORCH_BUILD_KERNELS_TORCHAO" ;;
141+
*)
142+
echo -e "\033[31m[error] unknown option: ${arg}\033[0m"
143+
exit 1
144+
;;
145145
esac
146146
done
147147

@@ -157,15 +157,15 @@ for preset_index in "${!PRESETS[@]}"; do
157157

158158
# Do NOT add options here. Update the respective presets instead.
159159
cmake -S "${SOURCE_ROOT_DIR}" \
160-
-B "${preset_output_dir}" \
161-
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY="${preset_output_dir}" \
162-
-DCMAKE_BUILD_TYPE="${mode}" \
163-
${CMAKE_OPTIONS_OVERRIDE[@]:-} \
164-
--preset "${preset}"
160+
-B "${preset_output_dir}" \
161+
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY="${preset_output_dir}" \
162+
-DCMAKE_BUILD_TYPE="${mode}" \
163+
${CMAKE_OPTIONS_OVERRIDE[@]:-} \
164+
--preset "${preset}"
165165

166166
cmake --build "${preset_output_dir}" \
167-
--config "${mode}" \
168-
-j$(sysctl -n hw.ncpu)
167+
--config "${mode}" \
168+
-j$(sysctl -n hw.ncpu)
169169
done
170170
done
171171

@@ -175,7 +175,7 @@ mkdir -p "$HEADERS_ABSOLUTE_PATH"
175175

176176
"$SOURCE_ROOT_DIR"/scripts/print_exported_headers.py --buck2=$(realpath "$BUCK2") --targets \
177177
//extension/module: \
178-
//extension/tensor: |
178+
//extension/tensor: \
179179
rsync -av --files-from=- "$SOURCE_ROOT_DIR" "$HEADERS_ABSOLUTE_PATH/executorch"
180180

181181
# HACK: XCFrameworks don't appear to support exporting any build
@@ -186,16 +186,16 @@ mkdir -p "$HEADERS_ABSOLUTE_PATH"
186186
sed -i '' '1i\
187187
#define C10_USING_CUSTOM_GENERATED_MACROS
188188
' \
189-
"$HEADERS_ABSOLUTE_PATH/executorch/runtime/core/portable_type/c10/c10/macros/Macros.h" \
190-
"$HEADERS_ABSOLUTE_PATH/executorch/runtime/core/portable_type/c10/c10/macros/Export.h" \
191-
"$HEADERS_ABSOLUTE_PATH/executorch/runtime/core/portable_type/c10/torch/standalone/macros/Export.h"
189+
"$HEADERS_ABSOLUTE_PATH/executorch/runtime/core/portable_type/c10/c10/macros/Macros.h" \
190+
"$HEADERS_ABSOLUTE_PATH/executorch/runtime/core/portable_type/c10/c10/macros/Export.h" \
191+
"$HEADERS_ABSOLUTE_PATH/executorch/runtime/core/portable_type/c10/torch/standalone/macros/Export.h"
192192

193193
cp -r $HEADERS_ABSOLUTE_PATH/executorch/runtime/core/portable_type/c10/c10 "$HEADERS_ABSOLUTE_PATH/"
194194
cp -r $HEADERS_ABSOLUTE_PATH/executorch/runtime/core/portable_type/c10/torch "$HEADERS_ABSOLUTE_PATH/"
195195

196196
cp "$SOURCE_ROOT_DIR/extension/apple/ExecuTorch/Exported/"*.h "$HEADERS_ABSOLUTE_PATH/executorch"
197197

198-
cat >"$HEADERS_ABSOLUTE_PATH/module.modulemap" <<'EOF'
198+
cat > "$HEADERS_ABSOLUTE_PATH/module.modulemap" << 'EOF'
199199
module ExecuTorch {
200200
umbrella header "ExecuTorch/ExecuTorch.h"
201201
export *
@@ -219,10 +219,10 @@ append_framework_flag() {
219219
fi
220220

221221
if [[ -n "$mode" && "$mode" != "Release" ]]; then
222-
local name spec
223-
name=$(echo "$framework" | cut -d: -f1)
224-
spec=$(echo "$framework" | cut -d: -f2-)
225-
framework="${name}_$(echo "$mode" | tr '[:upper:]' '[:lower:]'):${spec}"
222+
local name spec
223+
name=$(echo "$framework" | cut -d: -f1)
224+
spec=$(echo "$framework" | cut -d: -f2-)
225+
framework="${name}_$(echo "$mode" | tr '[:upper:]' '[:lower:]'):${spec}"
226226
fi
227227
echo "Adding framework: ${framework}"
228228
FRAMEWORK_FLAGS+=("--framework=$framework")

0 commit comments

Comments
 (0)