diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 2c71a30..c91a518 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -18,29 +18,35 @@ cp ./llama.cpp/k_quants.c ./cpp/k_quants.c cp ./llama.cpp/examples/common.h ./cpp/common.h cp ./llama.cpp/examples/common.cpp ./cpp/common.cpp -# Add prefix to avoid redefinition with other libraries using ggml like whisper.rn -sed -i '' 's/GGML_/LM_GGML_/g' ./cpp/ggml.h -sed -i '' 's/ggml_/lm_ggml_/g' ./cpp/ggml.h -sed -i '' 's/GGML_/LM_GGML_/g' ./cpp/ggml.c -sed -i '' 's/ggml_/lm_ggml_/g' ./cpp/ggml.c -sed -i '' 's/GGML_/LM_GGML_/g' ./cpp/ggml-metal.h -sed -i '' 's/ggml_/lm_ggml_/g' ./cpp/ggml-metal.h -sed -i '' 's/GGML_/LM_GGML_/g' ./cpp/ggml-metal.m -sed -i '' 's/ggml_/lm_ggml_/g' ./cpp/ggml-metal.m -sed -i '' 's/GGML_/LM_GGML_/g' ./cpp/llama.h -sed -i '' 's/ggml_/lm_ggml_/g' ./cpp/llama.h -sed -i '' 's/GGML_/LM_GGML_/g' ./cpp/llama.cpp -sed -i '' 's/ggml_/lm_ggml_/g' ./cpp/llama.cpp -sed -i '' 's/GGML_/LM_GGML_/g' ./cpp/llama-util.h -sed -i '' 's/ggml_/lm_ggml_/g' ./cpp/llama-util.h -sed -i '' 's/GGML_/LM_GGML_/g' ./cpp/k_quants.h -sed -i '' 's/ggml_/lm_ggml_/g' ./cpp/k_quants.h -sed -i '' 's/GGML_/LM_GGML_/g' ./cpp/k_quants.c -sed -i '' 's/ggml_/lm_ggml_/g' ./cpp/k_quants.c -sed -i '' 's/GGML_/LM_GGML_/g' ./cpp/ggml-alloc.h -sed -i '' 's/ggml_/lm_ggml_/g' ./cpp/ggml-alloc.h -sed -i '' 's/GGML_/LM_GGML_/g' ./cpp/ggml-alloc.c -sed -i '' 's/ggml_/lm_ggml_/g' ./cpp/ggml-alloc.c +# List of files to process +files=( + "./cpp/ggml.h" + "./cpp/ggml.c" + "./cpp/ggml-metal.h" + "./cpp/ggml-metal.m" + "./cpp/llama.h" + "./cpp/llama.cpp" + "./cpp/llama-util.h" + "./cpp/k_quants.h" + "./cpp/k_quants.c" + "./cpp/ggml-alloc.h" + "./cpp/ggml-alloc.c" +) + +# Loop through each file and run the sed commands +OS=$(uname) +for file in "${files[@]}"; do + # Add prefix to avoid redefinition with other libraries using ggml like whisper.rn + if [ "$OS" = "Darwin" ]; then + sed -i '' 's/GGML_/LM_GGML_/g' $file + sed -i '' 's/ggml_/lm_ggml_/g' $file + else + sed -i 's/GGML_/LM_GGML_/g' $file + sed -i 's/ggml_/lm_ggml_/g' $file + fi +done + +echo "Replacement completed successfully!" yarn example