Skip to content

Instantly share code, notes, and snippets.

@itchyny
Last active November 21, 2020 03:46
Show Gist options
  • Save itchyny/0cc5d044b1a7775bdb963bdd54ab23ff to your computer and use it in GitHub Desktop.
Save itchyny/0cc5d044b1a7775bdb963bdd54ab23ff to your computer and use it in GitHub Desktop.
Build Vim from 7.3 to the latest with 100 patches step on macOS (x86_64) with clang 12 (clang-1200.0.32.27)
#!/bin/bash
set -euxo pipefail
git clone https://github.com/vim/vim.git /tmp/vim
cd /tmp/vim
BACKUP_DIR=/tmp/vim-backup
mkdir -p "$BACKUP_DIR"
while true; do
git restore .
while ! git describe --tags | grep -E '^v\d[.]\d(?:[.]\d(?:\d*00)?)?$'; do
git reset --hard HEAD^
done
gsed -i '/sizeof(uint32_t) != 4/,+1s/exit/return/' src/auto/configure # v8.2.1119
gsed -i '/if (\(p\|res\|e1.*\) [!=]= NUL)/s/NUL/NULL/g' src/*.c # v8.0.0046
gsed -i '/#define VV_NAME/s/, {0}$//' src/eval.c # v7.4.1648
gsed -i '/static struct vimvar/,+4s/dictitem_T/dictitem16_T/;/char\s*vv_filler.*/d' src/eval.c # v7.4.1648
if ! git grep 'struct dictitem16_S' src/structs.h >/dev/null; then
gsed -i '/typedef struct dictitem_S dictitem_T;/a struct dictitem16_S {\n typval_T di_tv;\n char_u di_flags;\n char_u di_key[17];\n};\ntypedef struct dictitem16_S dictitem16_T;' src/structs.h # v7.4.1648
fi
gsed -i 's/__ARGS(\(.*\))/\1/' src/proto/os_mac_conv.pro # v7.4.1202
gsed -i 's/!builtin_first == i/(!builtin_first) == i/' src/term.c # v7.4.914
gsed -i '/extern int sigaltstack/s/^/\/\//' src/os_unix.c # v8.0.1236
gsed -i '/+multi_byte/,+6s/FEAT_BIG/FEAT_NORMAL/' src/feature.h # v7.3.968
if ! ./configure; then
make distclean || :
rm -f auto/config.cache
./configure
fi
make -j8
src/vim --version
MAJOR=$(./src/vim --version | head -n 1 | awk '{ print $5 }' | tr -d '\n')
MINOR=$(./src/vim --version | grep patch | awk '{ print $3 }' | sed -e 's/^[0-9]*-//g' | tr -d '\n' || :)
cp src/vim "$BACKUP_DIR/vim-$MAJOR.$(printf "%04d" "$MINOR")"
git reset --hard HEAD^
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment