Replace utils_make_human_readable_str() with g_format_size()
[geany-mirror.git] / scripts / update-scintilla.sh
blob6cd9515f8c7b90bf1c61f004bd080bdd237a8034
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/README "$SCI_SRC"/README
60 copy_to scintilla/src "$SCI_SRC"/src/*.cxx
61 copy_to scintilla/src "$SCI_SRC"/src/*.h
62 copy_to scintilla/include "$SCI_SRC"/include/*.h
63 copy_to scintilla/include "$SCI_SRC"/include/*.iface
64 copy_to scintilla/gtk "$SCI_SRC"/gtk/*.c
65 copy_to scintilla/gtk "$SCI_SRC"/gtk/*.cxx
66 copy_to scintilla/gtk "$SCI_SRC"/gtk/*.h
67 copy_to scintilla/gtk "$SCI_SRC"/gtk/*.list
68 copy_to scintilla "$SCI_SRC"/License.txt
69 copy_to scintilla "$SCI_SRC"/version.txt
70 copy_to scintilla/lexilla/src "$LEX_SRC"/src/*.cxx
71 copy_to scintilla/lexilla/include "$LEX_SRC"/include/*.h
72 copy_to scintilla/lexilla/lexlib "$LEX_SRC"/lexlib/*.cxx
73 copy_to scintilla/lexilla/lexlib "$LEX_SRC"/lexlib/*.h
74 copy_to scintilla/lexilla/ "$LEX_SRC"/License.txt
75 copy_to scintilla/lexilla/ "$LEX_SRC"/version.txt
76 # now copy the lexers we use
77 git -C scintilla/lexilla/lexers/ ls-files *.cxx | while read f; do
78 copy_to "scintilla/lexilla/lexers" "$LEX_SRC/lexers/$f"
79 done
81 # apply our patch
82 git apply -p0 scintilla/scintilla_changes.patch || {
83 echo "scintilla_changes.patch doesn't apply, please update it and retry."
84 exit 1
87 echo "Upstream lexer catalogue changes:"
88 git diff -p --src-prefix= --dst-prefix= scintilla/lexilla/src/Lexilla.cxx
90 # show a nice success banner
91 echo "Scintilla update successful!" | sed 'h;s/./=/g;p;x;p;x'
93 #check whether there are new files
94 if git status -unormal -s scintilla | grep '^??'; then
95 cat <<EOF
97 Untracked files above have been introduced by the new Scintilla version and
98 should be added to version control if appropriate, or removed.
100 You can add them to Git with the command:
101 $ git add $(git status -unormal -s scintilla | grep '^??' | cut -b4- | sed '$!{s/$/ \\/};1!{s/^/ /}')
103 Don't forget to add new files to the build system (scintilla/Makefile.am).
107 # check for possible changes to styles
108 if ! git diff --quiet scintilla/lexilla/include/SciLexer.h; then
109 cat << EOF
111 Check the diff of scintilla/lexilla/include/SciLexer.h to see whether and which
112 mapping to add or update in src/highlightingmappings.h
113 (use git diff scintilla/lexilla/include/SciLexer.h).
114 Don't forget to also update the comment and string styles in
115 src/highlighting.c.
119 # summary
120 cat << EOF
122 Don't forget to add or update the appropriate line in NEWS.