Skip to content

Commit

Permalink
fix(bootstrap): support Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
jhen0409 committed Aug 10, 2023
1 parent 0b01bbb commit 9edfa07
Showing 1 changed file with 29 additions and 23 deletions.
52 changes: 29 additions & 23 deletions scripts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 9edfa07

Please sign in to comment.