Bump API version for the Scintilla 5.1.5 change
[geany-mirror.git] / scripts / update-scintilla.sh
blob75d3834c24a8f0a5db541a74360871c0c2115ced
1 #!/bin/sh
3 # Copyright: 2012, The Geany contributors
4 # License: GNU GPL v2 or later
6 # Update Geany's bundled Scintilla from a given Scintilla source directory
7 # (e.g. an upstream Mercurial clone or tarball)
10 SCI_SRC=
12 # parse arguments
13 if [ $# -eq 2 ]; then
14 SCI_SRC="$1"
15 LEX_SRC="$2"
16 else
17 echo "USAGE: $0 SCINTILLA_SOURCE_DIRECTORY LEXILLA_SOURCE_DIRECTORY" >&2
18 exit 1
21 # check source directory
22 if ! [ -f "$SCI_SRC/src/ScintillaBase.cxx" ]; then
23 echo "'$SCI_SRC' is not a valid Scintilla source directory!" >&2
24 exit 1
26 if ! [ -f "$LEX_SRC/src/Lexilla.cxx" ]; then
27 echo "'$LEX_SRC' is not a valid Lexilla source directory!" >&2
28 exit 1
30 # check destination directory
31 if ! [ -d .git ] || ! [ -f scintilla/version.txt ]; then
32 echo "Please run this script from Geany's root source directory." >&2
33 exit 1
36 # make sure destination directory is clean
37 if git status -unormal -s scintilla | grep '^??'; then
38 echo "Please clean scintilla directory from untracked files before." >&2
39 exit 1
42 copy_to()
44 dest="$1"
45 shift
47 if ! [ -d "$dest" ]; then
48 echo "$dest does not exist." >&2;
49 exit 1
51 for f in $@; do
52 dos2unix -k -q -n $f $dest/$(basename $f) || (echo "dos2unix $f failed" >&2 ; exit 1)
53 done || exit 1
56 # purge executbale bits
57 umask 111
58 # copy everything from scintilla but lexers
59 copy_to scintilla/src "$SCI_SRC"/src/*.cxx
60 copy_to scintilla/src "$SCI_SRC"/src/*.h
61 copy_to scintilla/include "$SCI_SRC"/include/*.h
62 copy_to scintilla/include "$SCI_SRC"/include/*.iface
63 copy_to scintilla/gtk "$SCI_SRC"/gtk/*.c
64 copy_to scintilla/gtk "$SCI_SRC"/gtk/*.cxx
65 copy_to scintilla/gtk "$SCI_SRC"/gtk/*.h
66 copy_to scintilla/gtk "$SCI_SRC"/gtk/*.list
67 copy_to scintilla "$SCI_SRC"/License.txt
68 copy_to scintilla "$SCI_SRC"/version.txt
69 copy_to scintilla/lexilla/src "$LEX_SRC"/src/*.cxx
70 copy_to scintilla/lexilla/include "$LEX_SRC"/include/*.h
71 copy_to scintilla/lexilla/lexlib "$LEX_SRC"/lexlib/*.cxx
72 copy_to scintilla/lexilla/lexlib "$LEX_SRC"/lexlib/*.h
73 copy_to scintilla/lexilla/ "$LEX_SRC"/License.txt
74 copy_to scintilla/lexilla/ "$LEX_SRC"/version.txt
75 # now copy the lexers we use
76 git -C scintilla/lexilla/lexers/ ls-files *.cxx | while read f; do
77 copy_to "scintilla/lexilla/lexers" "$LEX_SRC/lexers/$f"
78 done
80 # apply our patch
81 git apply -p0 scintilla/scintilla_changes.patch || {
82 echo "scintilla_changes.patch doesn't apply, please update it and retry."
83 exit 1
86 echo "Upstream lexer catalogue changes:"
87 git diff -p --src-prefix= --dst-prefix= scintilla/lexilla/src/Lexilla.cxx
89 # show a nice success banner
90 echo "Scintilla update successful!" | sed 'h;s/./=/g;p;x;p;x'
92 #check whether there are new files
93 if git status -unormal -s scintilla | grep '^??'; then
94 cat <<EOF
96 Untracked files above have been introduced by the new Scintilla version and
97 should be added to version control if appropriate, or removed.
99 You can add them to Git with the command:
100 $ git add $(git status -unormal -s scintilla | grep '^??' | cut -b4- | sed '$!{s/$/ \\/};1!{s/^/ /}')
102 Don't forget to add new files to the build system (scintilla/Makefile.am).
106 # check for possible changes to styles
107 if ! git diff --quiet scintilla/lexilla/include/SciLexer.h; then
108 cat << EOF
110 Check the diff of scintilla/lexilla/include/SciLexer.h to see whether and which
111 mapping to add or update in src/highlightingmappings.h
112 (use git diff scintilla/lexilla/include/SciLexer.h).
113 Don't forget to also update the comment and string styles in
114 src/highlighting.c.
118 # summary
119 cat << EOF
121 Don't forget to add or update the appropriate line in NEWS.