-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqt_configure.prf
2471 lines (2167 loc) · 80.7 KB
/
qt_configure.prf
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
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#
# W A R N I N G
# -------------
#
# This file is not part of the Qt API. It exists purely as an
# implementation detail. It may change from version to version
# without notice, or even be removed.
#
# We mean it.
#
QT_CONFIGURE_REPORT =
QT_CONFIGURE_NOTES =
QT_CONFIGURE_WARNINGS =
QT_CONFIGURE_ERRORS =
defineTest(qtConfAddReport) {
QT_CONFIGURE_REPORT += "$$join(1, $$escape_expand(\\n))"
export(QT_CONFIGURE_REPORT)
}
defineTest(qtConfAddNote) {
QT_CONFIGURE_NOTES += "Note: $$join(1, $$escape_expand(\\n))"
export(QT_CONFIGURE_NOTES)
}
defineTest(qtConfAddWarning) {
QT_CONFIGURE_WARNINGS += "WARNING: $$join(1, $$escape_expand(\\n))"
export(QT_CONFIGURE_WARNINGS)
}
defineTest(qtConfAddError) {
QT_CONFIGURE_ERRORS += "ERROR: $$join(1, $$escape_expand(\\n))"
export(QT_CONFIGURE_ERRORS)
equals(2, log):qt_conf_tests_allowed {
CONFIG += mention_config_log
export(CONFIG)
}
}
defineTest(qtConfFatalError) {
qtConfAddError($$1, $$2)
qtConfPrintReport()
error()
}
# Return a string list for the specified JSON path, which may be either a
# single string or an array of strings.
# Note that this returns a variable name, so it can be directly iterated over.
defineReplace(qtConfScalarOrList) {
defined($$1, var): return($$1)
vals = $$list()
for (i, $${1}._KEYS_): \
$$vals += $$eval($${1}.$$i)
export($$vals)
return($$vals)
}
defineTest(qtConfCommandlineSetInput) {
arg = $${1}
val = $${2}
!isEmpty($${currentConfig}.commandline.options.$${arg}.name): \
arg = $$eval($${currentConfig}.commandline.options.$${arg}.name)
!isEmpty(config.input.$$arg) {
oldval = $$eval(config.input.$$arg)
equals(oldval, $$val): \
qtConfAddNote("Option '$$arg' with value '$$val' was specified twice")
else: \
qtConfAddNote("Overriding option '$$arg' with '$$val' (was: '$$oldval')")
}
config.input.$$arg = $$val
export(config.input.$$arg)
}
defineReplace(qtConfGetNextCommandlineArg) {
c = $$take_first(QMAKE_EXTRA_ARGS)
export(QMAKE_EXTRA_ARGS)
return($$c)
}
defineReplace(qtConfPeekNextCommandlineArg) {
return($$first(QMAKE_EXTRA_ARGS))
}
defineTest(qtConfCommandline_boolean) {
opt = $${1}
val = $${2}
isEmpty(val): val = yes
!equals(val, yes):!equals(val, no) {
qtConfAddError("Invalid value given for boolean command line option '$$opt'.")
return()
}
qtConfCommandlineSetInput($$opt, $$val)
}
defineTest(qtConfCommandline_void) {
opt = $${1}
val = $${2}
!isEmpty(val) {
qtConfAddError("Command line option '$$opt' expects no argument ('$$val' given).")
return()
}
val = $$eval($${currentConfig}.commandline.options.$${opt}.value)
isEmpty(val): val = yes
qtConfCommandlineSetInput($$opt, $$val)
}
defineTest(qtConfCommandline_enum) {
opt = $${1}
val = $${2}
isEmpty(val): val = yes
# validate and map value
mapped = $$eval($${currentConfig}.commandline.options.$${opt}.values.$${val})
isEmpty(mapped) {
# just a list of allowed values
for (i, $${currentConfig}.commandline.options.$${opt}.values._KEYS_) {
equals($${currentConfig}.commandline.options.$${opt}.values.$${i}, $$val) {
mapped = $$val
break()
}
}
}
isEmpty(mapped) {
qtConfAddError("Invalid value '$$val' supplied to command line option '$$opt'.")
return()
}
qtConfCommandlineSetInput($$opt, $$mapped)
}
defineTest(qtConfValidateValue) {
opt = $${1}
val = $${2}
validValues = $$eval($${currentConfig}.commandline.options.$${opt}.values._KEYS_)
isEmpty(validValues): \
return(true)
for (i, validValues) {
equals($${currentConfig}.commandline.options.$${opt}.values.$${i}, $$val): \
return(true)
}
qtConfAddError("Invalid value '$$val' supplied to command line option '$$opt'.")
return(false)
}
defineTest(qtConfCommandline_string) {
opt = $${1}
val = $${2}
nextok = $${3}
isEmpty(val):$$nextok: val = $$qtConfGetNextCommandlineArg()
# Note: Arguments which are variable assignments are legit here.
contains(val, "^-.*")|isEmpty(val) {
qtConfAddError("No value supplied to command line option '$$opt'.")
return()
}
!qtConfValidateValue($$opt, $$val): \
return()
qtConfCommandlineSetInput($$opt, $$val)
}
defineTest(qtConfCommandline_optionalString) {
opt = $${1}
val = $${2}
nextok = $${3}
isEmpty(val) {
$$nextok: val = $$qtConfPeekNextCommandlineArg()
contains(val, "^-.*|[A-Z0-9_]+=.*")|isEmpty(val): \
val = "yes"
else: \
val = $$qtConfGetNextCommandlineArg()
}
!qtConfValidateValue($$opt, $$val): \
return()
qtConfCommandlineSetInput($$opt, $$val)
}
defineTest(qtConfCommandline_addString) {
opt = $${1}
val = $${2}
nextok = $${3}
isEmpty(val):$$nextok: val = $$qtConfGetNextCommandlineArg()
# Note: Arguments which are variable assignments are legit here.
contains(val, "^-.*")|isEmpty(val) {
qtConfAddError("No value supplied to command line option '$$opt'.")
return()
}
!qtConfValidateValue($$opt, $$val): \
return()
!isEmpty($${currentConfig}.commandline.options.$${opt}.name): \
opt = $$eval($${currentConfig}.commandline.options.$${opt}.name)
config.input.$$opt += $$val
export(config.input.$$opt)
}
defineTest(qtConfCommandline_redo) {
!exists($$OUT_PWD/config.opt) {
qtConfAddError("No config.opt present - cannot redo configuration.")
return()
}
QMAKE_EXTRA_REDO_ARGS = $$cat($$OUT_PWD/config.opt, lines)
export(QMAKE_EXTRA_REDO_ARGS) # just for config.log
QMAKE_EXTRA_ARGS = $$QMAKE_EXTRA_REDO_ARGS $$QMAKE_EXTRA_ARGS
export(QMAKE_EXTRA_ARGS)
QMAKE_REDO_CONFIG = true
export(QMAKE_REDO_CONFIG)
}
defineTest(qtConfParseCommandLine) {
customCalls =
for (cc, allConfigs) {
custom = $$eval($${cc}.commandline.custom)
!isEmpty(custom) {
customCall = qtConfCommandline_$$custom
!defined($$customCall, test): \
error("Custom command line callback '$$custom' is undefined.")
customCalls += $$customCall
}
}
for (ever) {
c = $$qtConfGetNextCommandlineArg()
isEmpty(c): break()
didCustomCall = false
for (customCall, customCalls) {
$${customCall}($$c) {
didCustomCall = true
break()
}
}
$$didCustomCall: \
next()
contains(c, "([A-Z0-9_]+)=(.*)") {
opt = $$replace(c, "^([A-Z0-9_]+)=(.*)", "\\1")
val = $$replace(c, "^([A-Z0-9_]+)=(.*)", "\\2")
for (cc, allConfigs) {
var = $$eval($${cc}.commandline.assignments.$${opt})
!isEmpty(var): \
break()
}
isEmpty(var) {
qtConfAddError("Assigning unknown variable '$$opt' on command line.")
return()
}
config.input.$$var = $$val
export(config.input.$$var)
next()
}
# parse out opt and val
nextok = false
contains(c, "^--?enable-(.*)") {
opt = $$replace(c, "^--?enable-(.*)", "\\1")
val = yes
} else: contains(c, "^--?(disable|no)-(.*)") {
opt = $$replace(c, "^--?(disable|no)-(.*)", "\\2")
val = no
} else: contains(c, "^--([^=]+)=(.*)") {
opt = $$replace(c, "^--([^=]+)=(.*)", "\\1")
val = $$replace(c, "^--([^=]+)=(.*)", "\\2")
} else: contains(c, "^--(.*)") {
opt = $$replace(c, "^--(.*)", "\\1")
val =
} else: contains(c, "^-(.*)") {
opt = $$replace(c, "^-(.*)", "\\1")
val =
nextok = true
for (cc, allConfigs) {
type = $$eval($${cc}.commandline.options.$${opt})
!isEmpty(type): break()
type = $$eval($${cc}.commandline.options.$${opt}.type)
!isEmpty(type): break()
}
isEmpty(type):contains(opt, "(qt|system)-.*") {
val = $$replace(opt, "(qt|system)-(.*)", "\\1")
opt = $$replace(opt, "(qt|system)-(.*)", "\\2")
}
} else {
qtConfAddError("Invalid command line parameter '$$c'.")
return()
}
for (cc, allConfigs) {
type = $$eval($${cc}.commandline.options.$${opt})
isEmpty(type): \
type = $$eval($${cc}.commandline.options.$${opt}.type)
isEmpty(type) {
# no match in the regular options, try matching the prefixes
for (p, $${cc}.commandline.prefix._KEYS_) {
e = "^-$${p}(.*)"
contains(c, $$e) {
opt = $$eval($${cc}.commandline.prefix.$${p})
val = $$replace(c, $$e, "\\1")
nextok = true
type = "addString"
break()
}
}
}
!isEmpty(type) {
currentConfig = $$cc
break()
}
}
# handle builtin [-no]-feature-xxx
isEmpty(type):contains(opt, "feature-(.*)") {
opt ~= s,^feature-,,
found = false
for (cc, allConfigs) {
contains($${cc}.features._KEYS_, $$opt) {
found = true
break()
}
}
!$$found {
qtConfAddError("Enabling/Disabling unknown feature '$$opt'.")
return()
}
# this is a boolean enabling/disabling the corresponding feature
type = boolean
}
# Skip the -qmake option.
isEmpty(type):contains(opt, "qmake") {
next()
}
isEmpty(type):contains(opt, "skip") {
isEmpty(skipOptionWarningAdded) {
qtConfAddWarning("Command line option -skip is only effective in top-level builds.")
skipOptionWarningAdded = 1
}
val = $$qtConfGetNextCommandlineArg()
next()
}
isEmpty(type) {
qtConfAddError("Unknown command line option '$$c'.")
equals(config.input.continue, yes): \
next()
else: \
return()
}
call = "qtConfCommandline_$${type}"
!defined($$call, test): \
error("Command line option '$$c' has unknown type '$$type'.")
# now that we have opt and value, process it
$${call}($$opt, $$val, $$nextok)
}
}
defineReplace(qtConfToolchainSupportsFlag) {
test_out_dir = $$OUT_PWD/$$basename(QMAKE_CONFIG_TESTS_DIR)
test_cmd_base = "$$QMAKE_CD $$system_quote($$system_path($$test_out_dir)) &&"
conftest = "int main() { return 0; }"
write_file("$$test_out_dir/conftest.cpp", conftest)|error()
qtRunLoggedCommand("$$test_cmd_base $$QMAKE_CXX $$QMAKE_CXXFLAGS $${1} -o conftest-out conftest.cpp"): \
return(true)
return(false)
}
defineTest(qtConfTest_compilerSupportsFlag) {
flag = $$eval($${1}.flag)
return($$qtConfToolchainSupportsFlag($$flag))
}
defineTest(qtConfTest_linkerSupportsFlag) {
flag = $$eval($${1}.flag)
use_bfd_linker: \
LFLAGS = -fuse-ld=bfd
use_gold_linker: \
LFLAGS = -fuse-ld=gold
use_lld_linker: \
LFLAGS = -fuse-ld=lld
return($$qtConfToolchainSupportsFlag($$LFLAGS "-Wl,$$flag"))
}
defineReplace(qtConfFindInPathList) {
# This nesting is consistent with Apple ld -search_paths_first,
# and presumably with GNU ld (no actual documentation found).
for (dir, 2) {
for (file, 1) {
exists("$$dir/$$file"): \
return("$$dir/$$file")
}
}
return()
}
defineReplace(qtConfFindInPath) {
ensurePathEnv()
equals(QMAKE_HOST.os, Windows):!contains(1, .*\\.exe): 1 = $${1}.exe
return($$qtConfFindInPathList($$1, $$2 $$QMAKE_PATH_ENV))
}
defineReplace(qtConfPkgConfigEnv) {
env =
!isEmpty(PKG_CONFIG_SYSROOT_DIR): env = "$${SETENV_PFX}PKG_CONFIG_SYSROOT_DIR=$${PKG_CONFIG_SYSROOT_DIR}$${SETENV_SFX} "
!isEmpty(PKG_CONFIG_LIBDIR): env = "$$env$${SETENV_PFX}PKG_CONFIG_LIBDIR=$${PKG_CONFIG_LIBDIR}$${SETENV_SFX} "
return($$env)
}
defineReplace(qtConfPkgConfig) {
host = $$1
isEmpty(host): host = false
$$host {
pkg_config = $$qtConfFindInPath("pkg-config")
} else {
pkg_config = "$$qtConfPkgConfigEnv()$$PKG_CONFIG_EXECUTABLE"
}
return($$pkg_config)
}
defineTest(qtConfPkgConfigPackageExists) {
isEmpty(1)|isEmpty(2): \
return(false)
!qtRunLoggedCommand("$${1} --exists --silence-errors $${2}"): \
return(false)
return(true)
}
defineReplace(qtSystemQuote) {
args =
for (a, 1): \
args += $$system_quote($$a)
return($$args)
}
defineReplace(qtConfPrepareArgs) {
return($$qtSystemQuote($$split(1)))
}
defineTest(qtConfSetupLibraries) {
asspfx = $${currentConfig}.commandline.assignments
for (l, $${currentConfig}.libraries._KEYS_) {
lpfx = $${currentConfig}.libraries.$${l}
# 'export' may be omitted, in which case it falls back to the library's name
!defined($${lpfx}.export, var) {
$${lpfx}.export = $$replace(l, -, _)
export($${lpfx}.export)
}
# 'export' may also be empty, but we need a derived identifier
alias = $$eval($${lpfx}.export)
isEmpty(alias): alias = $$replace(l, -, _)
$${lpfx}.alias = $$alias
export($${lpfx}.alias)
# make it easy to refer to the library by its export name.
$${currentConfig}.exports._KEYS_ += $$alias
$${currentConfig}.exports.$$alias += $$l
export($${currentConfig}.exports.$$alias)
isEmpty($${lpfx}.sources._KEYS_): \
error("Library $$l defines no sources")
for (s, $${lpfx}.sources._KEYS_) {
spfx = $${lpfx}.sources.$${s}
# link back to parent object
$${spfx}.library = $$l
export($${spfx}.library)
# a plain string is transformed into a structure
isEmpty($${spfx}._KEYS_) {
$${spfx}.libs = $$eval($${spfx})
export($${spfx}.libs)
}
# if the type is missing (implicitly in the case of plain strings), assume 'inline'
isEmpty($${spfx}.type) {
$${spfx}.type = inline
export($${spfx}.type)
}
}
}
$${currentConfig}.exports._KEYS_ = $$unique($${currentConfig}.exports._KEYS_)
export($${currentConfig}.exports._KEYS_)
for (alias, $${currentConfig}.exports._KEYS_) {
ua = $$upper($$alias)
$${asspfx}._KEYS_ += \
$${ua}_PREFIX $${ua}_INCDIR $${ua}_LIBDIR \
$${ua}_LIBS $${ua}_LIBS_DEBUG $${ua}_LIBS_RELEASE
uapfx = $${asspfx}.$${ua}
$${uapfx}_PREFIX = $${alias}.prefix
$${uapfx}_INCDIR = $${alias}.incdir
$${uapfx}_LIBDIR = $${alias}.libdir
$${uapfx}_LIBS = $${alias}.libs
$${uapfx}_LIBS_DEBUG = $${alias}.libs.debug
$${uapfx}_LIBS_RELEASE = $${alias}.libs.release
export($${uapfx}_PREFIX)
export($${uapfx}_INCDIR)
export($${uapfx}_LIBDIR)
export($${uapfx}_LIBS)
export($${uapfx}_LIBS_DEBUG)
export($${uapfx}_LIBS_RELEASE)
}
export($${asspfx}._KEYS_)
# reverse mapping for assignments on command line.
for (a, $${asspfx}._KEYS_) {
apfx = $${asspfx}.$${a}
ra = config.commandline.rev_assignments.$$eval($$apfx)
$$ra = $$a
export($$ra)
}
}
defineReplace(qtGccSysrootifiedPath) {
return($$replace(1, ^=, $$[QT_SYSROOT]))
}
defineReplace(qtGccSysrootifiedPaths) {
sysrootified =
for (path, 1): \
sysrootified += $$qtGccSysrootifiedPath($$path)
return($$sysrootified)
}
# libs-var, libs, in-paths
defineTest(qtConfResolveLibs) {
for (path, 3): \
pre_lflags += -L$$path
$$1 = $$pre_lflags $$2
export($$1)
return(true)
}
# libs-var, in-paths, libs
defineTest(qtConfResolvePathLibs) {
ret = true
gcc: \
local_paths = $$qtGccSysrootifiedPaths($$2)
else: \
local_paths = $$2
for (libdir, local_paths) {
!exists($$libdir/.) {
qtLog("Library path $$val_escape(libdir) is invalid.")
ret = false
}
}
!qtConfResolveLibs($$1, $$3, $$2): \
ret = false
return($$ret)
}
defineReplace(qtConfGetTestSourceList) {
result =
!isEmpty($${1}.test.inherit) {
base = $$section(1, ., 0, -2)
for (i, $${1}.test.inherit): \
result += $$qtConfGetTestSourceList($${base}.$$i)
}
return($$result $$1)
}
defineReplace(qtConfGetTestIncludes) {
defined($${1}._KEYS_, var) {
1st = $$first($${1}._KEYS_)
equals(1st, 0) {
# array; recurse for every element
ret =
for (k, $${1}._KEYS_): \
ret += $$qtConfGetTestIncludes($${1}.$$k)
return($$ret)
}
# object; try condition and recurse
!defined($${1}.headers, var):!defined($${1}.headers._KEYS_, var): \ # just plain broken without it
error("headers object '$$1' has no nested headers entry")
cond = $$eval($${1}.condition)
isEmpty(cond): \ # would be pointless otherwise
error("headers object '$$1' has no condition")
!$$qtConfEvaluate($$cond) {
qtLog("header entry '$$1' failed condition '$$cond'.")
return()
}
qtLog("header entry '$$1' passed condition.")
return($$qtConfGetTestIncludes($${1}.headers))
}
return($$eval($$1)) # plain string - or nothing (can happen for top-level call only)
}
# includes-var, in-paths, test-object-var
defineTest(qtConfResolvePathIncs) {
ret = true
gcc: \
local_paths = $$qtGccSysrootifiedPaths($$2)
else: \
local_paths = $$2
for (incdir, local_paths) {
!exists($$incdir/.) {
qtLog("Include path $$val_escape(incdir) is invalid.")
ret = false
}
}
2 -= $$QMAKE_DEFAULT_INCDIRS
$$1 = $$2
export($$1)
wasm {
# FIXME: emcc downloads pre-built libraries and adds their include
# path to the clang call dynamically. it would be possible to parse
# the emcc -s USE_xyz=1 --cflags output to populate xzy_INCDIR and
# thus make the code below work.
return($$ret)
}
tests = $$qtConfGetTestSourceList($$3)
hdrs =
for (test, tests): \
hdrs += $$qtConfGetTestIncludes($${test}.headers)
for (hdr, hdrs) {
h = $$qtConfFindInPathList($$hdr, $$2 $$EXTRA_INCLUDEPATH $$QMAKE_DEFAULT_INCDIRS)
isEmpty(h) {
qtLog("$$hdr not found in [$$val_escape(2)] and global paths.")
ret = false
}
}
return($$ret)
}
# the library is specified inline in a 'libs' field.
# overrides from the command line are accepted.
defineTest(qtConfLibrary_inline) {
lib = $$eval($${1}.library)
!defined($${1}.libs, var):isEmpty($${1}.builds._KEYS_): \
error("'inline' source in library '$$lib' specifies neither 'libs' nor 'builds'.")
# library lists are specified as strings in the json sources for
# readability, but it's a pain to work with that, so expand it now.
eval($${1}.libs = $$eval($${1}.libs))
export($${1}.libs)
for (b, $${1}.builds._KEYS_) {
eval($${1}.builds.$${b} = $$eval($${1}.builds.$${b}))
export($${1}.builds.$${b})
}
# if multiple libraries provide the same export, it makes sense
# to make them recognize the same input variables.
input = $$eval($${2}.alias)
# build-specific direct libs. overwrites inline libs.
vars =
any = false
all = true
for (b, $$list(debug release)) {
iv = $${input}.libs.$${b}
vars += $$eval(config.commandline.rev_assignments.$${iv})
defined(config.input.$${iv}, var) {
eval($${1}.builds.$${b} = $$eval(config.input.$${iv}))
export($${1}.builds.$${b})
$${1}.builds._KEYS_ *= $${b}
any = true
} else {
all = false
}
}
$$any {
!$$all {
qtConfAddError("Either none or all of $$join(vars, ", ", [, ]) must be specified.")
return(false)
}
export($${1}.builds._KEYS_)
# we also reset the generic libs, to avoid surprises.
$${1}.libs =
export($${1}.libs)
}
# direct libs. overwrites inline libs.
defined(config.input.$${input}.libs, var) {
eval($${1}.libs = $$eval(config.input.$${input}.libs))
export($${1}.libs)
}
includes = $$eval(config.input.$${input}.incdir)
# prefix. prepends to (possibly overwritten) inline libs.
prefix = $$eval(config.input.$${input}.prefix)
!isEmpty(prefix) {
includes += $$prefix/include
$${1}.libs = -L$$prefix/lib $$eval($${1}.libs)
export($${1}.libs)
}
libdir = $$eval(config.input.$${input}.libdir)
!isEmpty(libdir) {
libs =
for (ld, libdir): \
libs += -L$$ld
$${1}.libs = $$libs $$eval($${1}.libs)
export($${1}.libs)
}
!qtConfResolvePathIncs($${1}.includedir, $$includes, $$2): \
return(false)
return(true)
}
# the library is provided by the qmake spec.
# this source type cannot fail.
defineTest(qtConfLibrary_makeSpec) {
spec = $$eval($${1}.spec)
isEmpty(spec): \
error("makeSpec source in library '$$eval($${1}.library)' does not specify 'spec'.")
!qtConfResolvePathLibs($${1}.libs, $$eval(QMAKE_LIBDIR_$$spec), $$eval(QMAKE_LIBS_$$spec)): \
return(false)
!qtConfResolvePathIncs($${1}.includedir, $$eval(QMAKE_INCDIR_$$spec), $$2): \
return(false)
!isEmpty(QMAKE_EXPORT_INCDIR_$$spec) {
$${1}.exportincludedir = $$eval(QMAKE_EXPORT_INCDIR_$$spec)
export($${1}.exportincludedir)
}
# note that the object is re-exported, because we resolve the libraries.
return(true)
}
# the library is found via pkg-config.
defineTest(qtConfLibrary_pkgConfig) {
pkg_config = $$qtConfPkgConfig($$eval($${1}.host))
isEmpty(pkg_config) {
qtLog("pkg-config use disabled globally.")
return(false)
}
args = $$qtConfPrepareArgs($$eval($${1}.args))
!qtConfPkgConfigPackageExists($$pkg_config, $$args) {
qtLog("pkg-config did not find package.")
return(false)
}
qtRunLoggedCommand("$$pkg_config --modversion $$args", version)|return(false)
version ~= s/[^0-9.].*$//
$${1}.version = $$first(version)
export($${1}.version)
qtRunLoggedCommand("$$pkg_config --libs-only-L $$args", libpaths)|return(false)
qtRunLoggedCommand("$$pkg_config --libs-only-l $$args", libs)|return(false)
eval(libs = $$libpaths $$libs)
!qtConfResolveLibs($${1}.libs, $$libs): \
return(false)
contains($${1}.libs, ".*\\.$${QMAKE_EXTENSION_STATICLIB}$") {
qtRunLoggedCommand("$$pkg_config --static --libs $$args", libs)|return(false)
# Split by space
eval(libs = $$libs)
!qtConfResolveLibs($${1}.libs, $$libs): \
return(false)
}
qtRunLoggedCommand("$$pkg_config --cflags $$args", $${1}.cflags)|return(false)
# Split CFLAGS into stuff that goes into DEFINES, INCLUDEPATH, and other stuff.
# The compound variable is still set in case something wants to use it outside
# regular library exports.
defines =
includes =
ignored =
eval(cflags = $$eval($${1}.cflags))
for (i, cflags) {
contains(i, "-I.*") {
i ~= s/^-I//
includes += $$i
} else: contains(i, "-D.*") {
i ~= s/^-D//
defines += $$i
} else {
# Sometimes, pkg-config files include other flags
# we really don't need and shouldn't add.
ignored += $$i
}
}
!isEmpty(ignored): \
qtLog("Note: Dropped compiler flags '$$ignored'.")
!qtConfResolvePathIncs($${1}.includedir, $$includes, $$2): \
return(false)
$${1}.defines = $$defines
# now remove the content of the transitive deps we know about.
largs = $$qtConfAllLibraryArgs($$eval($${2}.dependencies))
for (la, largs): \
eval("$$la")
USES = $$eval($$list($$upper($$replace(QMAKE_USE, -, _))))
# _CC == _LD for configure's library sources, so pick first arbitrarily.
DEPS = $$resolve_depends(USES, QMAKE_DEPENDS_, _CC)
for (DEP, DEPS) {
$${1}.libs -= $$eval(QMAKE_LIBS_$${DEP})
$${1}.includedir -= $$eval(QMAKE_INCDIR_$${DEP})
$${1}.defines -= $$eval(QMAKE_DEFINES_$${DEP})
}
export($${1}.libs)
export($${1}.includedir)
export($${1}.defines)
return(true)
}
defineTest(qtConfTest_getPkgConfigVariable) {
pkg_config = $$qtConfPkgConfig($$eval($${1}.host))
isEmpty(pkg_config): \
return(false)
args = $$qtConfPrepareArgs($$eval($${1}.pkg-config-args))
!qtConfPkgConfigPackageExists($$pkg_config, $$args): \
return(false)
variable = $$eval($${1}.pkg-config-variable)
qtRunLoggedCommand("$$pkg_config --variable=$$variable $$args", $${1}.value)|return(false)
export($${1}.value)
$${1}.cache += value
export($${1}.cache)
return(true)
}
defineReplace(qtConfLibraryArgs) {
NAME = $$upper($$replace($${1}.library, -, _))
qmake_args = "QMAKE_LIBS_$${NAME} = $$val_escape($${1}.libs)"
for (b, $${1}.builds._KEYS_): \
qmake_args += "QMAKE_LIBS_$${NAME}_$$upper($$b) = $$val_escape($${1}.builds.$${b})"
includedir = $$eval($${1}.includedir)
!isEmpty(includedir): \
qmake_args += "QMAKE_INCDIR_$${NAME} = $$val_escape(includedir)"
defines = $$eval($${1}.defines)
!isEmpty(defines): \
qmake_args += "QMAKE_DEFINES_$${NAME} = $$val_escape(defines)"
depends = $$eval($${2}.dependencies)
!isEmpty(depends) {
dep_uses =
for (use, depends): \
dep_uses += $$section(use, :, 1, 1)
qmake_args += \
"QMAKE_DEPENDS_$${NAME}_CC = $$upper($$replace(dep_uses, -, _))" \
"QMAKE_DEPENDS_$${NAME}_LD = $$upper($$replace(dep_uses, -, _))"
}
return($$qmake_args)
}
defineReplace(qtConfAllLibraryArgs) {
isEmpty(1): return()
dep_uses =
for (use, 1): \
dep_uses += $$section(use, :, 1, 1)
dep_args =
seen =
for(ever) {
isEmpty(1): break()
use = $$take_last(1)
contains(seen, $$use): next()
seen += $$use
use_cfg = $$section(use, :, 0, 0)
!isEmpty(use_cfg) {
use_lib = $$section(use, :, 1, 1)
lpfx = $${use_cfg}.libraries.$$use_lib
dep_args += $$qtConfLibraryArgs($${lpfx}.sources.$$eval($${lpfx}.source), $$lpfx)
1 += $$eval($${lpfx}.dependencies)
}
}
return("QMAKE_USE += $$dep_uses" $$dep_args)
}
defineTest(qtConfExportLibrary) {
lpfx = $${currentConfig}.libraries.$$1
alias = $$eval($${lpfx}.alias)
$${currentConfig}.found.$$alias = $$1
export($${currentConfig}.found.$$alias)
name = $$eval($${lpfx}.export)
isEmpty(name): return()
spfx = $${lpfx}.sources.$$eval($${lpfx}.source)
!$$qtConfEvaluate($$eval($${spfx}.export)): return()
output = privatePro
NAME = $$upper($$name)
# LIBS is emitted even if empty, as this allows the library to be "seen".
libs = $$eval($${spfx}.libs)
qtConfOutputVar(assign, $$output, QMAKE_LIBS_$$NAME, $$libs)
for (b, $${spfx}.builds._KEYS_) {
blibs = $$eval($${spfx}.builds.$${b})
qtConfOutputVar(assign, $$output, QMAKE_LIBS_$${NAME}_$$upper($$b), $$blibs)
}
defines = $$eval($${spfx}.defines)
!isEmpty(defines): qtConfOutputVar(assign, $$output, QMAKE_DEFINES_$$NAME, $$defines)
includes = $$eval($${spfx}.exportincludedir)
!equals(includes, -) {
isEmpty(includes): includes = $$eval($${spfx}.includedir)
!isEmpty(includes): qtConfOutputVar(assign, $$output, QMAKE_INCDIR_$$NAME, $$includes)
}
uses = $$eval($${lpfx}.dependencies)
!isEmpty(uses) {
# FIXME: ideally, we would export transitive deps only for static
# libs, to not extend the link interface unduly. however, the system
# does currently not differentiate between public and private deps.
depends =
for (use, uses) {
use_cfg = $$section(use, :, 0, 0)
use_lib = $$section(use, :, 1, 1)
!isEmpty(use_cfg): \
depends += $$upper($$eval($${use_cfg}.libraries.$${use_lib}.export))
else: \
depends += $$upper($$replace(use_lib, -, _))
}
# we use suffixes instead of infixes, because $$resolve_depends() demands it.
qtConfOutputVar(assign, $$output, QMAKE_DEPENDS_$${NAME}_CC, $$depends)
qtConfOutputVar(assign, $$output, QMAKE_DEPENDS_$${NAME}_LD, $$depends)
}
!isEmpty($${currentConfig}.module): \
qtConfExtendVar($$output, "QT.$${currentModule}_private.libraries", $$name)
}
defineTest(qtConfHandleLibrary) {
lpfx = $${currentConfig}.libraries.$$1
defined($${lpfx}.result, var): return()
alias = $$eval($${lpfx}.alias)
!isEmpty($${currentConfig}.found.$$alias) {
# this happening indicates a logic error in the conditions
# of the feature(s) referring to this library.
# note that this does not look across module boundaries, as
# multiple modules may know the same libraries; de-duplication
# happens via the cache (obviously, this assumes identical
# definitions and logic).
error("A library exporting '$$alias' was already found.")
}
qtConfEnsureTestTypeDeps("library")
!qtConfTestPrepare_compile($$lpfx) {
$${lpfx}.result = false
export($${lpfx}.result)
return()
}
$${lpfx}.dependencies = $$eval($${lpfx}.resolved_uses)
export($${lpfx}.dependencies)
qtConfLoadResult($${lpfx}, $$1, "library") {
$$eval($${lpfx}.result): \
qtConfExportLibrary($$1)
return()
}
qtLogTestIntro($${lpfx}, "looking for library $${1}")
qtPersistLog()
result = false
for (s, $${lpfx}.sources._KEYS_) {
spfx = $${lpfx}.sources.$${s}
t = $$eval($${spfx}.type)
call = qtConfLibrary_$$t
!defined($$call, test): \
error("Library $${1} source $${s} has unknown type '$$t'")
qtLog("Trying source $$s (type $$t) of library $${1} ...")
cond = $$eval($${spfx}.condition)
!$$qtConfEvaluate($$cond) {
qtLog(" => source failed condition '$$cond'.")
next()
}
!$${call}($$spfx, $$lpfx) {
qtLog(" => source produced no result.")
next()
}
$${lpfx}.source = $$s
export($${lpfx}.source)
# if the library defines a test, use it to verify the source.
defined($${lpfx}.test, var)|defined($${lpfx}.test._KEYS_, var) {
$${lpfx}.resolved_uses = $$currentConfig:$$1
$${lpfx}.host = $$eval($${spfx}.host)
!qtConfTest_compile($$lpfx) {
qtLog(" => source failed verification.")
next()
}