-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate.sh
More file actions
executable file
·186 lines (170 loc) · 6.74 KB
/
Copy pathgenerate.sh
File metadata and controls
executable file
·186 lines (170 loc) · 6.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/usr/bin/env bash
set -euo pipefail
set -x
XKBCOMMON_REV=c5ec563644aa937924b539066b94346427f6debc
XLIB_REV=80dbb7d029b2bbf58b96421e59c83e34f763ab70
XCURSOR_REV=15efad7ccd035f5d1ddc8d437e047569d1775fa7
XRANDR_REV=8a4ba1974bcf07057cf891128d86ae1ab5303574
XFIXES_REV=55bb2d1d57d43e0595ce45393f26eb433d75a7cc
XRENDER_REV=f32afe9f877ae032c6bc9c27b17b7978b1b4c856
XINERAMA_REV=d7162b962710bc724b41cabab4e7cea303c4b541
XI_REV=f00f7e9140b4707775331950dd67851e55058c40
XSCRNSAVER_REV=3f753e7a4050db083474444ae91cc17a849eaa4d
XEXT_REV=2a694ba264ccdb205909909abfe8b136f9156ebe
XORGPROTO_REV=fcb7e9a1a0b593a44740d83b0babddd331fea830
XCBPROTO_REV=cf7e2581b613802f2f8ec2a4b50a6a20aad4bf52
XCB_REV=4d6e1c8fffaf811cf4d0e68ff3bc6f50e62c32c7
# `git clone --depth 1` but at a specific revision
git_clone_rev() {
repo=$1
rev=$2
dir=$3
rm -rf "$dir"
mkdir "$dir"
pushd "$dir"
git init -q
git fetch "$repo" "$rev" --depth 1
git checkout -q FETCH_HEAD
popd
}
# macOS: use gsed for GNU compatibility
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
sed=$(which sed)
else
if ! command -v gsed &>/dev/null; then
echo "error: gsed not found. Install it with: brew install gnu-sed" >&2
exit 1
fi
sed=gsed
fi
# append_license <target_copying_file> <label> <source_license_file>
append_license() {
if [ -s "$1" ]; then
printf '\n%s\n\n' "===============================================================================" >> "$1"
fi
printf '%s\n\n' "--- $2 ---" >> "$1"
cat "$3" >> "$1"
}
# xkbcommon
rm -rf xkbcommon
git_clone_rev https://github.com/xkbcommon/libxkbcommon.git "$XKBCOMMON_REV" _xkbcommon
mv _xkbcommon/include/xkbcommon .
cp _xkbcommon/LICENSE xkbcommon/LICENSE
rm -rf _xkbcommon
# Xlib
rm -rf X11
mkdir -p X11/extensions
git_clone_rev https://gitlab.freedesktop.org/xorg/lib/libx11.git "$XLIB_REV" _xlib
mv _xlib/include/X11/*.h X11
mv _xlib/include/X11/extensions/*.h X11/extensions
# generate config header
$sed \
-e "s/#undef XTHREADS/#define XTHREADS 1/" \
-e "s/#undef XUSE_MTSAFE_API/#define XUSE_MTSAFE_API 1/" \
_xlib/include/X11/XlibConf.h.in > X11/XlibConf.h
append_license X11/LICENSE libx11 _xlib/COPYING
rm -rf _xlib
# xcursor
mkdir -p X11/Xcursor
# generate header file with version
xcursor_ver=($(
curl -L "https://gitlab.freedesktop.org/xorg/lib/libxcursor/-/raw/$XCURSOR_REV/configure.ac" |
$sed -n 's/.*\[\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)\].*/\1 \2 \3/p'
))
curl -L "https://gitlab.freedesktop.org/xorg/lib/libxcursor/-/raw/$XCURSOR_REV/include/X11/Xcursor/Xcursor.h.in" |
$sed \
-e "s/#undef XCURSOR_LIB_MAJOR/#define XCURSOR_LIB_MAJOR ${xcursor_ver[0]}/" \
-e "s/#undef XCURSOR_LIB_MINOR/#define XCURSOR_LIB_MINOR ${xcursor_ver[1]}/" \
-e "s/#undef XCURSOR_LIB_REVISION/#define XCURSOR_LIB_REVISION ${xcursor_ver[2]}/" \
> X11/Xcursor/Xcursor.h
curl -L "https://gitlab.freedesktop.org/xorg/lib/libxcursor/-/raw/$XCURSOR_REV/COPYING" \
-o _copying_libxcursor
append_license X11/LICENSE libxcursor _copying_libxcursor
rm _copying_libxcursor
# xrandr, xfixes, xrender, xinerama, xi, xscrnsaver
curl -LZ \
-O "https://gitlab.freedesktop.org/xorg/lib/libxrandr/-/raw/$XRANDR_REV/include/X11/extensions/Xrandr.h" \
-O "https://gitlab.freedesktop.org/xorg/lib/libxfixes/-/raw/$XFIXES_REV/include/X11/extensions/Xfixes.h" \
-O "https://gitlab.freedesktop.org/xorg/lib/libxrender/-/raw/$XRENDER_REV/include/X11/extensions/Xrender.h" \
-O "https://gitlab.freedesktop.org/xorg/lib/libxinerama/-/raw/$XINERAMA_REV/include/X11/extensions/Xinerama.h" \
-O "https://gitlab.freedesktop.org/xorg/lib/libxinerama/-/raw/$XINERAMA_REV/include/X11/extensions/panoramiXext.h" \
-O "https://gitlab.freedesktop.org/xorg/lib/libxi/-/raw/$XI_REV/include/X11/extensions/XInput.h" \
-O "https://gitlab.freedesktop.org/xorg/lib/libxi/-/raw/$XI_REV/include/X11/extensions/XInput2.h" \
-O "https://gitlab.freedesktop.org/xorg/lib/libxscrnsaver/-/raw/$XSCRNSAVER_REV/include/X11/extensions/scrnsaver.h" \
--output-dir X11/extensions
mkdir -p _copying_tmp
curl -LZ \
-o "_copying_tmp/libxrandr" "https://gitlab.freedesktop.org/xorg/lib/libxrandr/-/raw/$XRANDR_REV/COPYING" \
-o "_copying_tmp/libxfixes" "https://gitlab.freedesktop.org/xorg/lib/libxfixes/-/raw/$XFIXES_REV/COPYING" \
-o "_copying_tmp/libxrender" "https://gitlab.freedesktop.org/xorg/lib/libxrender/-/raw/$XRENDER_REV/COPYING" \
-o "_copying_tmp/libxinerama" "https://gitlab.freedesktop.org/xorg/lib/libxinerama/-/raw/$XINERAMA_REV/COPYING" \
-o "_copying_tmp/libxi" "https://gitlab.freedesktop.org/xorg/lib/libxi/-/raw/$XI_REV/COPYING" \
-o "_copying_tmp/libxscrnsaver" "https://gitlab.freedesktop.org/xorg/lib/libxscrnsaver/-/raw/$XSCRNSAVER_REV/COPYING"
for f in _copying_tmp/*; do
append_license X11/LICENSE "$(basename "$f")" "$f"
done
rm -rf _copying_tmp
# xext
git_clone_rev https://gitlab.freedesktop.org/xorg/lib/libxext.git "$XEXT_REV" _xext
mv _xext/include/X11/extensions/*.h X11/extensions
append_license X11/LICENSE libxext _xext/COPYING
rm -rf _xext
# xorgproto
git_clone_rev https://gitlab.freedesktop.org/xorg/proto/xorgproto.git "$XORGPROTO_REV" _xorgproto
{
cd _xorgproto/include/X11
find . -name '*.h'
} | while read -r file; do
source=_xorgproto/include/X11/$file
target=X11/$file
mkdir -p "$(dirname "$target")"
mv "$source" "$target"
done
# generate template Xpoll.h header
$sed \
's/@USE_FDS_BITS@/__fds_bits/' \
_xorgproto/include/X11/Xpoll.h.in > X11/Xpoll.h
# GLX headers
rm -rf GL
mkdir GL
{
cd _xorgproto/include/GL
find . -name '*.h'
} | while read -r file; do
source=_xorgproto/include/GL/$file
target=GL/$file
mkdir -p "$(dirname "$target")"
mv "$source" "$target"
done
# xorgproto license files (one per protocol)
for f in _xorgproto/COPYING-*; do
label="xorgproto/$(basename "$f")"
append_license X11/LICENSE "$label" "$f"
done
append_license GL/LICENSE xorgproto/COPYING-glproto _xorgproto/COPYING-glproto
rm -rf _xorgproto
# xcb (this one's bad!)
rm -rf xcb
mkdir xcb
git_clone_rev https://gitlab.freedesktop.org/xorg/lib/libxcb.git "$XCB_REV" _xcb
git_clone_rev https://gitlab.freedesktop.org/xorg/proto/xcbproto.git "$XCBPROTO_REV" _xcbproto
mv _xcb/src/c_client.py _xcbproto
pushd _xcbproto
./autogen.sh
make
make DESTDIR="$PWD/out" install
mkdir c_client_out
pushd c_client_out
export PYTHONPATH="../out/usr/local/lib/python3.10/site-packages"
for file in ../src/*.xml; do
# The -c, -l and -s parameter are only used for man page
# generation and aren't relevant for headers.
python3 ../c_client.py -c _ -l _ -s _ "$file"
done
popd
popd
mv _xcb/src/*.h xcb
mv _xcbproto/c_client_out/*.h xcb
append_license xcb/LICENSE libxcb _xcb/COPYING
append_license xcb/LICENSE xcbproto _xcbproto/COPYING
rm -rf _xcb _xcbproto