/ updatesymlinks.sh
updatesymlinks.sh
1 #!/bin/bash 2 3 folders=("engine/src" "lib/raylib/include" "lib/tiny/inc" "lib/luajit/inc") 4 names=("enginend" "raylib" "tiny" "luajit") 5 outdir="include" 6 types=("h" "hpp") 7 8 mkdir -p "$outdir" 9 10 11 create_symlinks() { 12 local src="$1" 13 local outnam="$2" 14 local currout="$outdir/$outnam" 15 16 mkdir -p "$currout" 17 18 find "$src" -mindepth 1 -print0 | while IFS= read -r -d '' item; do 19 rl="${item#$src/}" 20 outpath="$currout/$rl" 21 mkdir -p "$(dirname "$outpath")" 22 23 if [ -f "$item" ]; then 24 nam=$(basename "$item") 25 ftype="${nam##*.}" 26 27 skip=true 28 for type in "${types[@]}"; do 29 if [ "$ftype" = "$type" ]; then 30 skip=false 31 break 32 fi 33 done 34 35 if [ "$skip" = false ]; then 36 ln -sf "$(realpath --relative-to="$(dirname "$outpath")" "$item")" "$outpath" 37 fi 38 elif [ -d "$item" ]; then 39 mkdir -p "$outpath" 40 fi 41 done 42 } 43 44 for i in "${!folders[@]}"; do 45 if [ $i -lt ${#names[@]} ]; then 46 src="${folders[$i]}" 47 outnam="${names[$i]}" 48 49 if [ -d "$src" ]; then 50 create_symlinks "$src" "$outnam" 51 echo 52 else 53 echo "'$src' not exist" 54 fi 55 fi 56 done