-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate
executable file
·738 lines (632 loc) · 23.1 KB
/
generate
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
#!/usr/bin/env bash
# file : generate
# license : MIT
# Create the infrastructure required by our Qt packages:
#
# - Create a source layout more suitable to our purposes which is still
# compatible with the Qt upstream (the way they include stuff, etc).
#
# - Separate private headers to a deeper directory subtree to prevent them
# from being found without the addition of the header search directories
# exported by the lib{Qt5CorePrivate} and similar targets.
#
# For QtGui, for example, the public headers are under libQt5Gui/QtGui/
# while the private headers are under
# libQt5Gui/QtGui/private/QtGui/{private,qpa}/. Thus include paths such as
# <QtGui/private/foo_p.h> or <private/foo_p.h> will not work without
# lib{Qt5GuiPrivate}'s exported poptions of "-IlibQt5Gui/QtGui/private
# -IlibQt5Gui/QtGui/private/QtGui".
#
# - Most upstream files are symlinked into our source layout but in some cases
# this is not possible. The upstream build runs a script, syncqt.pl, for
# each module which rearranges its public headers to be fit for consumption
# by their clients (other Qt modules and Qt users). For example, it
# generates camelcase-named versions of the public headers and groups
# headers from different source subdirectories into the same directory, the
# name of which clients then use in their include paths. Because these
# conversions are not trivial enough to reproduce here we cannot symlink to
# the original sources so we copy them from the script's output directories
# instead.
#
owd="$(pwd)"
trap "{ cd '$owd'; exit 1; }" ERR
set -o errtrace # Trap in functions and subshells.
set -o pipefail # Fail if any pipeline command fails.
shopt -s lastpipe # Execute last pipeline command in the current shell.
shopt -s nullglob # Expand no-match globs to nothing rather than themselves.
function info () { echo "$*" 1>&2; }
function error () { info "$*"; exit 1; }
# Recursively remove all files in <dir> that are symlinks.
#
function rm_symlinks () # <dir>
{
find "$1" -type l -exec rm {} \;
}
# Recursively remove all empty directories in <dir>.
#
function rm_empty_dirs () # <dir>
{
local d="${1%/}"
local sd # Subdirectory.
for sd in "$d"/*/; do
# Remove subdirectory contents, then remove subdirectory itself if empty.
#
rm_empty_dirs "$sd"
if [[ -z "$(ls -a "$sd")" ]]; then
rmdir "$sd"
fi
done
}
# Remove previously-generated files and directories.
#
rm_symlinks Qt5Moc/moc/
rm_empty_dirs Qt5Moc/moc/
rm_symlinks Qt5Rcc/rcc/
rm_empty_dirs Qt5Rcc/rcc/
rm_symlinks Qt5Uic/uic/
rm_empty_dirs Qt5Uic/uic/
rm_symlinks libQt5Core/QtCore/
rm_empty_dirs libQt5Core/QtCore/
rm -f libQt5Core/QtCore/Q*
rm -rf libQt5Core/3rdparty
rm_symlinks libQt5Gui/QtGui/
rm_empty_dirs libQt5Gui/QtGui/
rm -rf libQt5Gui/3rdparty
rm -f libQt5Gui/mkspecs
rm -rf libQt5Gui/QtGui/qpa/
rm -rf libQt5Gui/QtGui/private/QtGui/qpa/
rm -f libQt5Gui/QtGui/Q*
rm_symlinks libQt5Gui/QtGuiPlugins/
rm_empty_dirs libQt5Gui/QtGuiPlugins/
rm -rf libQt5Gui/QtGuiPlugins/{Qt*Support,QtPlatformHeaders}
rm -f libQt5GuiTests/mkspecs
rm -f libQt5Widgets/mkspecs
rm -rf libQt5Widgets/QtWidgets/QtPlatformHeaders
rm_symlinks libQt5Widgets/QtWidgets/
rm_empty_dirs libQt5Widgets/QtWidgets/
rm -f libQt5Widgets/QtWidgets/Q*
rm_symlinks libQt5Widgets/QtWidgetsPlugins/
rm_empty_dirs libQt5Widgets/QtWidgetsPlugins/
rm_symlinks libQt5WidgetsTests/widgets-app
rm -f libQt5WidgetsTests/mkspecs
# Create output directories.
#
# 3rdparty/ has to be a sibling to QtCore/ because the QtCore source files use
# include paths such as "../../3rdparty/freebsd/strtoll.c".
#
mkdir -p Qt5Moc/moc/QtCore/private/QtCore/private
mkdir -p Qt5Rcc/rcc/QtCore/private/QtCore/private
mkdir -p Qt5Uic/uic/QtCore/private/QtCore/private
mkdir libQt5Core/3rdparty
# Directory for the MIME type database source XML file.
#
mkdir -p libQt5Core/QtCore/mimetypes/mime/packages
mkdir libQt5Gui/3rdparty
mkdir libQt5Gui/QtGui/qpa
mkdir libQt5Gui/QtGui/private/QtGui/qpa
# Create a symlink to one or more upstream directories and set the
# `symlink=dir` attribute on each in the containing directory's
# .gitattributes.
#
# Create symlinks to all <target-dir-path> arguments inside
# <symlink-dir-path>.
#
# Recreates .gitattributes from scratch so invoke this function only once for
# each containing directory.
#
function symlink_dirs ()
# <target-dir-path> [<target-dir-path>..] <symlink-dir-path>
{
local args=("$@")
# Process the symlink path (the last function argument).
#
local si="${#args[@]}"-1 # Symlink path's index in `args()`
local sp="${args[$si]}" # Symlink path.
sp="${sp%/}" # Strip trailing '/'.
unset "args[$si]" # Remove from `args` (leaving only targets).
# Target path prefix consisting of the right number of "../"s to get from
# the symlink directory to the project root (working) directory.
#
local tpfx="$(sed -E 's%[^/]+%..%g' <<<"$sp")"
rm -f "$sp/.gitattributes"
# Apply the prefix to each target and create its entry in .gitattributes.
#
local i # Index into `args` array.
for i in "${!args[@]}"; do
local t="${args[$i]}" # Target path currently being processed.
t="${t%/}" # Strip trailing '/'.
args["$i"]="$tpfx/$t" # Apply prefix to target path.
echo "$(basename "$t") symlink=dir" >> "$sp/.gitattributes"
done
# Create the symlinks.
#
ln -s "${args[@]}" "$sp/"
}
# Symlink upstream directories.
#
symlink_dirs upstream/qtbase/mkspecs Qt5Moc/moc/
symlink_dirs upstream/qtbase/src/3rdparty/{freebsd,sha1} \
Qt5Moc/moc/3rdparty/
symlink_dirs upstream/qtbase/mkspecs Qt5Rcc/rcc/
symlink_dirs upstream/qtbase/src/3rdparty/{freebsd,sha1} \
Qt5Rcc/rcc/3rdparty/
symlink_dirs upstream/qtbase/mkspecs Qt5Uic/uic/
symlink_dirs upstream/qtbase/src/3rdparty/{freebsd,sha1} \
Qt5Uic/uic/3rdparty/
symlink_dirs upstream/qtbase/mkspecs libQt5Core/QtCore/
symlink_dirs upstream/qtbase/src/3rdparty/{easing,freebsd,forkfd,md4,md5,rfc6234,sha1,sha3,harfbuzz} \
libQt5Core/3rdparty/
symlink_dirs upstream/qtbase/mkspecs libQt5Gui/
symlink_dirs upstream/qtbase/src/3rdparty/{icc,wintab} \
libQt5Gui/3rdparty/
symlink_dirs upstream/qtbase/mkspecs libQt5GuiTests/
symlink_dirs upstream/qtbase/mkspecs libQt5Widgets/
symlink_dirs upstream/qtbase/mkspecs libQt5WidgetsTests/
# Symlink the upstream third-party directories.
#
# Symlink an upstream source file into our project directory structure.
#
# If there is a downstream version of the source file, its symlink gets the
# upstream filename while the upstream original's symlink gets the upstream
# filename with a ".orig" extension.
#
# <symlink-target-path>: path to the symlink's upstream target, relative to
# the destination directory (so will contain some
# `../`s).
#
# <destination-dir-path>: path to the directory that will contain the symlink,
# relative to the project root.
#
# For example, assuming downstream/foo/bar/baz.cpp exists:
#
# call: symlink_source_file ../../upstream/foo/bar/baz.cpp foo/bar/
# result: foo/bar/baz.cpp -> downstream/foo/bar/baz.cpp
# foo/bar/baz.cpp.orig -> upstream/foo/bar/baz.cpp
#
function symlink_source_file () # <symlink-target-path> <destination-dir-path>
{
local ut="${1%/}" # Upstream symlink target path.
local d="${2%/}" # Destination directory path.
local fn="$(basename "$ut")" # Upstream target file name.
# Path to the downstream version of the symlink target, relative to the
# destination directory. (Don't use sed because doing so for every file is
# too slow).
#
local dt="${ut/upstream/downstream}" # Downstream symlink target path.
if [[ -f "$d/$dt" ]]; then
ln -sf "$ut" "$d/$fn.orig"
ln -sf "$dt" "$d/$fn"
else
ln -sf "$ut" "$d/$fn"
fi
}
# Symlink the sources of an upstream non-module.
#
# Non-modules include tools, plugins, and internal modules such as those in
# upstream/qtbase/src/platformsupport/.
#
# Note that we don't rearrange non-modules' sources as we do those of "proper"
# Qt modules such as QtCore and QtGui because it does not seem worth the
# trouble for the following reasons: 1) These subprojects have a different
# layout in that there are source files in the root directory (for example, in
# upstream/qtbase/src/plugins/platforms/xcb/) which is where subdirectory
# headers would be copied to, and 2) in some instances source files are more
# than one directory level down from the root (for example, in
# upstream/qtbase/src/plugins/platforms/xcb/gl_integrations/xcb_egl/). And 3)
# tools are not libraries while the plugin libraries are loaded at runtime by
# one of the "proper" Qt modules (for example, libQt5Gui loads libqxcb) and
# are thus not user-facing to the same degree.
#
function symlink_non_module () # <source-directory> <destination-directory>
{
local s="${1%/}" # Source directory.
local d="${2%/}/$(basename "$s")" # Destination directory.
# Prefix to make target path relative to the destination directory (one
# `../` for each directory component in the destination path).
#
local tp="$(sed -Ee 's%[^/]+%..%g' <<<"$d")" # Target prefix.
local t # Target file.
for t in "$s"/*; do
case "$t" in
*.h|*.cpp|*.c|*.mm|*.json)
symlink_source_file "$tp/$t" "$d"
;;
*)
if [[ -d "$t" ]]; then
local sp="$d/$(basename "$t")" # Directory symlink path.
mkdir -p "$sp"
symlink_non_module "$t" "$d"
# Remove the directory if it's empty (contained no interesting
# files).
#
if [[ -z "$(ls "$sp")" ]]; then
rmdir "$sp"
fi
fi
esac
done
}
# Symlink all of the sources and other files of interest in the upstream Qt
# module subdirectory <subdir> into <output-path-prefix>/<module-name>/,
# preserving subdirectories.
#
# <subdir> is a path of the following form:
# upstream/qtbase/src/module/foo[/bar[/baz]].
#
# Note that we have to rearrange the upstream sources because they cannot be
# built the way they're laid out in upstream/qtbase/src/module (the upstream
# build also rearranges them).
#
# From the upstream directory layout (after the repeated application of this
# function to all of a module's subdirectories):
#
# upstream/qtbase/src/module
# ├── foo
# │ ├── foo.cpp
# │ ├── foo.h
# │ ├── foo_p.h
# │ ...
# ├── bar
# │ ├── bar.cpp
# │ ├── bar.h
# │ ├── bar_p.h
# │ ...
# ...
#
# create the following layout:
#
# <output-path-prefix>
# └── QtModuleName
# ├── foo
# │ ├── foo.cpp
# │ ...
# ├── bar
# │ ├── bar.cpp
# │ ...
# ├── private
# │ ├── foo_p.h
# │ ├── bar_p.h
# │ ...
# ├── foo.h
# ├── bar.h
# ...
#
function symlink_module_subdir () # <output-path-prefix> <module-name> <subdir>
{
local opp="$1" # Output path prefix.
local mod="$2" # Qt module name.
local sd="${3%/}" # Subdir path (with upstream/qtbase/src/module prefix).
# Unprefixed subdir path. For example, a <subdir> argument of
# "upstream/qtbase/src/corelib/kernel" becomes "kernel" and
# "upstream/qtbase/src/gui/platform/unix" becomes "platform/unix".
#
local usd="$(sed -E 's%upstream/qtbase/src/[^/]+/%%' <<<"$sd")"
# Symlink target path prefix base: the relative path to get to the project
# directory from <output-path-prefix>.
#
# For example, "../../" for a <output-path-prefix> of Qt6Moc/moc/:
#
# ln -s ../../upstream/qtbase/src/tools/moc/main.cpp Qt6Moc/moc/
#
local tpp_base="$(sed -E 's%[^/]+%..%g' <<<"$opp")"
# Portion of the symlink target path prefix corresponding to the unprefixed
# subdir path (that is, needs to be appended to `tpp_base`).
#
local tpp_sd="$(sed -E 's%[^/]+%..%g' <<<"$mod/$usd")"
# Create the output directory for non-header files.
#
mkdir -p "$opp/$mod/$usd"
# All of the source files of interest are directly under one of
# src/<module>/'s subdirectories (that is, nested no deeper).
#
local f
for f in "$sd"/*; do
tpp= # Target path prefix.
spp= # Symlink path prefix.
case "$f" in
# Private header.
#
*_p.h)
tpp="$tpp_base/../../../.."
spp="$opp/$mod/private/$mod/private"
;;
# Public header.
#
*.h)
tpp="$tpp_base/.."
spp="$opp/$mod"
;;
# Source files and other file types we are interested in.
#
*.cpp | *.mm | *.c | *.xml | *.qsb)
tpp="$tpp_base/$tpp_sd"
spp="$opp/$mod/$usd"
;;
# Not an interesting file type. Recurse into subdirectories and skip
# regular files.
#
*)
if [[ -d "$f" ]]; then
symlink_module_subdir "$opp" "$mod" "$sd/$(basename "$f")"
fi
continue
;;
esac
symlink_source_file "$tpp/$f" "$spp"
done
# Remove the output directory for non-header files if it is empty (which
# would be the case if the upstream directory contained no files of
# interest).
#
if [[ -z "$(ls "$opp/$mod/$usd")" ]]; then
rmdir "$opp/$mod/$usd"
fi
}
# Symlink the moc, rcc, and uic applications' headers and source files into
# Qt5Moc/moc/, Qt5Rcc/rcc/, and Qt5Uic/uic/.
#
symlink_non_module upstream/qtbase/src/tools/moc \
Qt5Moc/
symlink_non_module upstream/qtbase/src/tools/rcc \
Qt5Rcc/
symlink_non_module upstream/qtbase/src/tools/uic \
Qt5Uic/
# Symlink the upstream QtCore sources into Qt5Moc/, Qt5Rcc/, and
# libQt5Core/. Although the Qt5Moc and Qt5Rcc builds include only a subset of
# the QtCore sources we symlink all of them for the sake of simplicity (their
# buildfiles do not use wildcards).
#
for d in upstream/qtbase/src/corelib/*/; do
if [[ "$(basename "$d")" == doc ]]; then
continue
fi
symlink_module_subdir Qt5Moc/moc QtCore "$d"
symlink_module_subdir Qt5Rcc/rcc QtCore "$d"
symlink_module_subdir Qt5Uic/uic QtCore "$d"
symlink_module_subdir libQt5Core QtCore "$d"
done
# This is made necessary by the inclusion of
# "../testlib/3rdparty/valgrind_p.h" by corelib/tools/qsimd.cpp.
#
ln -sf ../../upstream/qtbase/src/testlib libQt5Core/QtCore/
# Symlink the upstream QtGui sources into libQt5Gui/.
#
for d in upstream/qtbase/src/gui/*/; do
if [[ "$(basename "$d")" == doc ]]; then
continue
fi
symlink_module_subdir libQt5Gui QtGui "$d"
done
# Remove the QPA headers because they belong under qpa/ (and will be moved
# there below, as per the upstream build).
#
rm libQt5Gui/QtGui/qplatform*.h
rm libQt5Gui/QtGui/private/QtGui/private/qplatform*_p.h
mv libQt5Gui/QtGui/kernel/qguiapplication.cpp \
libQt5Gui/QtGui/kernel/qguiapplication-install.cpp
# Symlink upstream Qt resource collection files and their associated resources
# into libQt5Gui/.
#
ln -s ../../../upstream/qtbase/src/gui/painting/qpdf.qrc \
libQt5Gui/QtGui/painting/
ln -s ../../../upstream/qtbase/src/gui/painting/webgradients.binaryjson \
libQt5Gui/QtGui/painting/
symlink_non_module upstream/qtbase/src/platformsupport \
libQt5Gui/QtGuiPlugins/platforms/
symlink_non_module upstream/qtbase/src/plugins/platforms/xcb/ \
libQt5Gui/QtGuiPlugins/platforms/
symlink_non_module upstream/qtbase/src/plugins/platforms/cocoa/ \
libQt5Gui/QtGuiPlugins/platforms/
symlink_non_module upstream/qtbase/src/plugins/platforms/windows/ \
libQt5Gui/QtGuiPlugins/platforms/
# Symlink the Cocoa plugin's resource collection file and its associated
# resources.
#
ln -s ../../../../upstream/qtbase/src/plugins/platforms/cocoa/qcocoaresources.qrc \
libQt5Gui/QtGuiPlugins/platforms/cocoa/
symlink_dirs upstream/qtbase/src/plugins/platforms/cocoa/images/ \
libQt5Gui/QtGuiPlugins/platforms/cocoa/
# Symlink the Windows plugin's resource collection files and their associated
# resources.
#
ln -s ../../../../upstream/qtbase/src/plugins/platforms/windows/cursors.qrc \
libQt5Gui/QtGuiPlugins/platforms/windows/
symlink_dirs upstream/qtbase/src/plugins/platforms/windows/images/ \
libQt5Gui/QtGuiPlugins/platforms/windows/
ln -s ../../../../upstream/qtbase/src/plugins/platforms/windows/openglblacklists.qrc \
libQt5Gui/QtGuiPlugins/platforms/windows/
symlink_non_module \
upstream/qtbase/src/plugins/platforminputcontexts/compose/ \
libQt5Gui/QtGuiPlugins/platforminputcontexts/
# Symlink directly to the imageformats plugins' directories (not their
# contents).
#
symlink_dirs upstream/qtbase/src/plugins/imageformats/{gif,ico,jpeg} \
libQt5Gui/QtGuiPlugins/imageformats/
# Symlink the upstream QtWidgets sources into libQt5Widgets/.
#
for d in upstream/qtbase/src/widgets/*/; do
if [[ "$(basename "$d")" == doc ]]; then
continue
fi
symlink_module_subdir libQt5Widgets QtWidgets "$d"
done
mv libQt5Widgets/QtWidgets/kernel/qapplication.cpp \
libQt5Widgets/QtWidgets/kernel/qapplication-install.cpp
# Symlink upstream Qt resources collection files and their associated
# resources into libQt5Widgets/.
#
ln -s ../../../upstream/qtbase/src/widgets/dialogs/qmessagebox.qrc \
libQt5Widgets/QtWidgets/dialogs/
ln -s ../../../upstream/qtbase/src/widgets/styles/qstyle.qrc \
libQt5Widgets/QtWidgets/styles/
symlink_dirs upstream/qtbase/src/widgets/styles/images \
libQt5Widgets/QtWidgets/styles/
ln -s ../../../upstream/qtbase/src/widgets/dialogs/qfiledialog.ui \
libQt5Widgets/QtWidgets/dialogs/
symlink_dirs upstream/qtbase/src/widgets/dialogs/images \
libQt5Widgets/QtWidgets/dialogs/
ln -s ../../upstream/qtbase/examples/widgets/widgets/spinboxes/window.h \
libQt5WidgetsTests/widgets-app/
ln -s ../../upstream/qtbase/examples/widgets/widgets/spinboxes/window.cpp \
libQt5WidgetsTests/widgets-app/
symlink_non_module upstream/qtbase/src/plugins/styles/mac/ \
libQt5Widgets/QtWidgetsPlugins/styles/
symlink_non_module upstream/qtbase/src/plugins/styles/windowsvista/ \
libQt5Widgets/QtWidgetsPlugins/styles/
# Extract the Qt version from upstream/qtbase/.qmake.conf.
#
qt_version="$(sed -nE 's%MODULE_VERSION = (.+)%\1%p' \
upstream/qtbase/.qmake.conf)"
# Copy headers generated by the upstream build.
#
# The majority of the generated headers are camelcase versions of the public
# headers (foobar.h -> QFooBar) but in some cases headers from different
# subdirectories are copied to a single directory to allow their inclusion
# using a common path prefix.
#
# Run the upstream syncqt.pl script to produce the include tree and copy only
# those headers that don't already exist in the upstream directory (in which
# case they are not generated and will already have been symlinked above).
#
# Run the upstream syncqt.pl script to generate headers for the given Qt
# module in a temporary directory.
#
# Return the path to the temporary directory.
#
function gen_hdrs () # <module-name>
{
local mod="$1" # Module name.
local tmpdir
if ! tmpdir="$(mktemp -d)"; then
error "mktemp failed"
fi
if ! upstream/qtbase/bin/syncqt.pl \
-copy -module "$mod" -version "$qt_version" \
-outdir "$tmpdir" upstream/qtbase \
> /dev/null; then
rm -r "$tmpdir"
error "syncqt.pl failed"
fi
echo "$tmpdir"
}
# Copy headers generated for QtCore into libQt5Core/QtCore/.
#
tmpdir="$(gen_hdrs QtCore)"
for p in "$tmpdir/include/QtCore/"*; do
f="$(basename "$p")"
if [[ ("$f" == *.h && ! -e "libQt5Core/QtCore/$f") || "$f" == Q* ]]; then
cp "$p" libQt5Core/QtCore/
fi
done
rm -r "$tmpdir"
# This (empty) header is generated by qmake in the upstream build.
#
touch libQt5Core/QtCore/QtCoreDepends
# Copy headers generated for QtGui into libQt5Gui/QtGui/.
#
tmpdir="$(gen_hdrs QtGui)"
# In addition to the generated public *.h and Q* headers as for QtCore, also
# copy the generated QPA (Qt Platform Abstraction) headers.
#
# Note that they are usually included with a `qpa/` prefix so must go into
# their own subdirectory (unlike normal headers).
#
for p in "$tmpdir/include/QtGui/"*; do
f="$(basename "$p")"
if [[ ("$f" == *.h && ! -e "libQt5Gui/QtGui/$f") || "$f" == Q* ]]; then
cp "$p" libQt5Gui/QtGui/
elif [[ "$f" == "$qt_version" ]]; then
for p2 in "$p/QtGui/qpa/"*; do
case "$p2" in
*_p.h)
cp "$p2" libQt5Gui/QtGui/private/QtGui/qpa/
;;
*.h)
cp "$p2" libQt5Gui/QtGui/qpa/
;;
esac
done
fi
done
rm -r "$tmpdir"
# This header is generated by qmake in the upstream build.
#
cat > libQt5Gui/QtGui/QtGuiDepends << EOF
#ifdef __cplusplus /* create empty PCH in C mode */
#include <QtCore/QtCore>
#endif
EOF
# Copy headers generated for the platform support modules (required by the
# code in platformsupport/ and the platform plugins via includes such as
# <QtServiceSupport/foo_p.h>) into libQt5Gui/QtGuiPlugins/.
#
# Note: A few of these platform support modules are referenced from outside of
# libQt5Plugins/platforms/ so they have to reside at a higher level.
#
# Currently only one out of many camelcase platform support headers
# (QPlatformHeaderHelper) is actually referenced by the code.
#
for mod in QtAccessibilitySupport \
QtClipboardSupport \
QtEdidSupport \
QtEventDispatcherSupport \
QtFontDatabaseSupport \
QtGraphicsSupport \
QtPlatformHeaders \
QtPrintSupport \
QtServiceSupport \
QtThemeSupport \
QtWindowsUIAutomationSupport \
QtXkbCommonSupport; do
tmpdir="$(gen_hdrs "$mod")"
mkdir "libQt5Gui/QtGuiPlugins/$mod/"
for p in "$tmpdir/include/$mod/"*; do
f="$(basename "$p")"
case "$f" in
*.h|QPlatformHeaderHelper) # Public header.
cp "$p" "libQt5Gui/QtGuiPlugins/$mod/"
;;
"$qt_version") # Private header directory.
cp -r "$p/$mod/private/" "libQt5Gui/QtGuiPlugins/$mod/"
;;
esac
done
rm -r "$tmpdir"
done
# Copy headers generated for QtWidgets into libQt5Widgets/QtWidgets/.
#
tmpdir="$(gen_hdrs QtWidgets)"
for p in "$tmpdir/include/QtWidgets/"*; do
f="$(basename "$p")"
if [[ ("$f" == *.h && ! -e "libQt5Widgets/QtWidgets/$f") || "$f" == Q* ]]; then
cp "$p" libQt5Widgets/QtWidgets/
fi
done
rm -r "$tmpdir"
# This header is generated by qmake in the upstream build.
#
cat > libQt5Widgets/QtWidgets/QtWidgetsDepends << EOF
#ifdef __cplusplus /* create empty PCH in C mode */
#include <QtCore/QtCore>
#include <QtGui/QtGui>
#endif
EOF
# Copy generated platform headers to libQt5Widgets/QtWidgets.
#
for mod in QtPlatformHeaders; do
tmpdir="$(gen_hdrs "$mod")"
mkdir "libQt5Widgets/QtWidgets/$mod/"
for p in "$tmpdir/include/$mod/"*; do
f="$(basename "$p")"
case "$f" in
*.h|QPlatformHeaderHelper) # Public header.
cp "$p" "libQt5Widgets/QtWidgets/$mod/"
;;
"$qt_version") # Private header directory.
cp -r "$p/$mod/private/" "libQt5Widgets/QtWidgets/$mod/"
;;
esac
done
rm -r "$tmpdir"
done