summaryrefslogtreecommitdiff
path: root/Tools/qmake/mkspecs/features/configure.prf
blob: b5fb2aed81a66c9f6e08f090713fcabe5222ecd0 (plain)
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
# -------------------------------------------------------------------
# This file does basic 'configure' style checks to determine the
# set of enable/use/have defines and their values.
#
# See 'Tools/qmake/README' for an overview of the build system
# -------------------------------------------------------------------

# This file is read after .qmake.cache, but before command line options,
# which means we might have a config from a previous build.

load(features)
load(configure)

WEBKIT_TOOLS_CONFIG = \
    build_drt \
    build_wtr \
    build_imagediff \
    build_test_npapi \
    build_testbrowser \
    build_minibrowser \
    build_qttestsupport

defineTest(runConfigure) {
    !webkit_configured:!print_defaults {
        log($${EOL}Running configure tests...$${EOL}$${EOL})
        QMAKE_CONFIG_TESTS_DIR = $$ROOT_WEBKIT_DIR/Tools/qmake/config.tests
        CONFIG_TESTS = $$files($$QMAKE_CONFIG_TESTS_DIR/*.pro, true)
        for(test, CONFIG_TESTS) {
            test = $$basename(test)
            test ~= s/\\.pro$//
            qtCompileTest($$test)
        }
    } else {
        CONFIG += skipped_config_tests

        # Save and reset configuration from .qmake.cache, so that we can
        # detect changes to the configuration and abort the build.
        PREVIOUS_WEBKIT_CONFIG = $$WEBKIT_CONFIG
        unset(WEBKIT_CONFIG)
        export(PREVIOUS_WEBKIT_CONFIG)
    }

    # Running feature detection inside a function ensures that we only
    # export WEBKIT_CONFIG, and don not mess up any other variables.
    detectFeatures()

    # Set up a base list of optional things to build, which we later on
    # sanitize based on constraints of the platform.

    WEBKIT_CONFIG += \
        build_webkit1 \
        build_webkit2 \
        build_tests \
        $$WEBKIT_TOOLS_CONFIG

    # Sanatize WebKit1/WebKit2, as WebKit.pro uses these two options
    # to determine which pro-files to include. The remaining sanitazion
    # is done when finalizing configure.

    !qtHaveModule(widgets) {
        CONFIGURE_WARNINGS += "Missing QtWidgets module, disabling WebKit1"
        WEBKIT_CONFIG -= build_webkit1
    }

    # WebKit2 requires OpenGL TextureMapper, which requires 3D Graphics
    !use?(3d_graphics): WEBKIT_CONFIG -= build_webkit2

    export(CONFIG)
    export(WEBKIT_CONFIG)
    export(CONFIGURE_WARNINGS)
}

defineReplace(configEnabled) {
    trueValue = $$2
    isEmpty(trueValue): trueValue = yes

    falseValue = $$3
    isEmpty(falseValue): falseValue = no

    $$1: return($$trueValue)
    return($$falseValue)
}

# This is called from default_post, at which point we've also parsed
# command line options
defineTest(finalizeConfigure) {

    # Sanitize build options
    !qtHaveModule(testlib) {
        CONFIGURE_WARNINGS += "Missing QtTest module, disabling DumpRenderTree, WebKitTestRunner and tests"
        WEBKIT_CONFIG -= build_drt build_wtr build_tests
    }

    win32|!enable?(NETSCAPE_PLUGIN_API): WEBKIT_CONFIG -= build_test_npapi

    win* {
        WEBKIT_CONFIG -= build_drt
    }

    production_build {
        WEBKIT_CONFIG -= $$WEBKIT_TOOLS_CONFIG build_tests
    }

    static {
        CONFIGURE_WARNINGS += "QtWebKitQml will not be build. It is not supported with static linking"
        WEBKIT_CONFIG -= build_webkit2 build_minibrowser build_wtr
    }

    production_build:qnx {
        CONFIGURE_WARNINGS += "QtWebKitQml will not be build. It is not supported on QNX."
        WEBKIT_CONFIG -= build_webkit2 build_minibrowser build_wtr
    }

    # Sanitize clashing options
    sanitizeFeatures()

    print_defaults {
        log(DEFINES: $$configDefines()$${EOL})
        error(Done computing defaults)
    }

    # Sanity checks that would prevent us from building the whole project altogether.
    !config_icu:!osx:!use?(wchar_unicode) {
       addReasonForSkippingBuild("ICU is required.")
    }
    production_build:blackberry {
        addReasonForSkippingBuild("Build not supported on BB10.")
    }
    production_build:android {
        addReasonForSkippingBuild("Build not supported on Android.")
    }
    production_build:contains(QT_CONFIG, mirclient) {
        addReasonForSkippingBuild("Build not supported on Ubuntu Touch.")
    }
    !gnu_thin_archives:!win32-msvc2013:!mingw:contains(QT_CONFIG, static) {
        addReasonForSkippingBuild("QtWebKit cannot be built as a static library on this platform. Check your configuration in qtbase/config.summary.")
    }
    winrt: addReasonForSkippingBuild("QtWebKit is not supported on Windows Phone/Windows RT")
    requiredPrograms = gperf python perl bison ruby flex
    for(program, requiredPrograms): \
        !programExistsInPath($$program): \
            addReasonForSkippingBuild("Missing $$program from PATH")

    requiredModules = gui
    for(module, requiredModules): \
        !qtHaveModule($$module): \
            addReasonForSkippingBuild("QtWebKit depends on $$module for building.")

    # Detect changes to the configuration. Changes need a clean build.
    webkit_configured {
        added_features = $$WEBKIT_CONFIG
        added_features -= $$PREVIOUS_WEBKIT_CONFIG

        removed_features = $$PREVIOUS_WEBKIT_CONFIG
        removed_features -= $$WEBKIT_CONFIG

        !isEmpty(added_features)|!isEmpty(removed_features) {
            CONFIG += configuration_changed
        }
    }

    reconfigureMsg = \
        "Reconfiguration likely requires a clean build. You$${QUOTE}ve been warned!" \
        "You may execute $${QUOTE}make wipeclean$${QUOTE} to wipe the build directory."

    # Add target for reconfiguring the build
    reconfigure.target = reconfigure
    double_quote = $$escape_expand(\")
    reconfigure.commands = echo > .qmake.cache && $(MAKE) -f $(MAKEFILE) qmake $$EOC
    reconfigure.commands += @echo $${double_quote}WARNING: $$join(reconfigureMsg,\\n,,)\\n$${double_quote}
    QMAKE_EXTRA_TARGETS += reconfigure
    export(reconfigure.target)
    export(reconfigure.commands)
    export(QMAKE_EXTRA_TARGETS)

    # Add target for wiping clean the build
    wipeclean.target = wipeclean
    win_cmd_shell: wipeclean.commands = FOR /D %%p IN (*) DO rmdir "%%p" /s /q
    else: wipeclean.commands = $(COPY_FILE) $(MAKEFILE) .$(MAKEFILE) && rm -Rf * && $(MOVE) .$(MAKEFILE) $(MAKEFILE)
    QMAKE_EXTRA_TARGETS += wipeclean
    export(wipeclean.target)
    export(wipeclean.commands)
    export(QMAKE_EXTRA_TARGETS)

    # Print a prettified dump of the configuration, for easier debugging
    !webkit_configured|configuration_changed|buildbot {

        skipped_config_tests {
            log($${EOL}Skipping configure tests. Execute $${QUOTE}make reconfigure$${QUOTE} to re-run.$${EOL})
        }

        leftoverConfig = $$WEBKIT_CONFIG

        for(config, WEBKIT_CONFIG) {
            match = $$find(config, "^build_")
            !isEmpty(match) {
                build += $$replace(match, ^build_,)
                leftoverConfig -= $$config
                next()
            }
            match = $$find(config, "^have_")
            !isEmpty(match) {
                have += $$replace(match, ^have_,)
                leftoverConfig -= $$config
                next()
            }
            match = $$find(config, "^use_")
            !isEmpty(match) {
                use += $$replace(match, ^use_,)
                leftoverConfig -= $$config
            }
        }

        scripts_dir = $$toSystemPath($$ROOT_WEBKIT_DIR/Tools/Scripts)
        features = $$system(perl -I $${scripts_dir} -I $${scripts_dir}$${QMAKE_DIR_SEP}webkitperl $$toSystemPath($$ROOT_WEBKIT_DIR/Tools/qmake/dump-features.pl))
        for(feature, features) {
            parts = $$split(feature, =)
            desc = $$member(parts, 0, 0)
            desc ~= s/_/ /
            value = $$member(parts, 1, 1)

            contains(WEBKIT_CONFIG, $$value) {
                leftoverConfig -= $$value
                value = yes
            } else {
                value = no
            }

            featureConfiguration += "$$desc $$value$${EOL}"
        }

        log($${EOL}Final configuration:$${EOL}$${EOL})

        debug:release:debug_and_release: buildConfig = debug+release
        else: CONFIG(debug, debug|release): buildConfig = debug
        else: buildConfig = release

        log(Build ......................... $$build$${EOL})
        log(Configuration ................. $$buildConfig$${EOL})
        log(All-in-one files .............. $$configEnabled(use_all_in_one_files)$$EOL)
        log(GNUmake ....................... $$configEnabled(GNUmake)$$EOL)
        log(Static libs as shared ......... $$configEnabled(force_static_libs_as_shared)$$EOL)
        log(Static libs as thin archives .. $$configEnabled(gnu_thin_archives)$$EOL)
        log(Production build .............. $$configEnabled(production_build)$$EOL)
        log($$EOL)

        log(Have .......................... $$have$${EOL})
        log(Use ........................... $$use$${EOL})
        log(Features ...................... $${leftoverConfig}$${EOL})
        log($$EOL)

        for(feature, featureConfiguration) {
            log($$feature)
        }

        !isEmpty(CONFIGURE_WARNINGS) {
            log("$${EOL}Encountered $$size(CONFIGURE_WARNINGS) configuration warning(s):$${EOL}$${EOL}")
            for(warn, CONFIGURE_WARNINGS) {
                log(" ! $$warn$${EOL}")
            }
        }

        !isEmpty(skipBuildReason) {
            log("$${EOL}The WebKit build was disabled for the following reasons: $$skipBuildReason $${EOL}$${EOL}")
            SUBDIRS=
            export(SUBDIRS)
        } else {
            log("$${EOL}WebKit is now configured for building. Just run 'make'.$${EOL}$${EOL}")
        }

        configuration_changed {
            log(WARNING: The configuration was changed since the last build:$${EOL}$${EOL})

            !isEmpty(added_features): log($${TAB}Added feature(s): $${added_features}$${EOL})
            !isEmpty(removed_features): log($${TAB}Removed feature(s): $${removed_features}$${EOL})

            log($$join(reconfigureMsg,$${EOL},$${EOL},$${EOL}$${EOL}))
        }
    }

    # Cache the result for all the other project files, and for
    # the next build, so we can detect changes to the config.
    !webkit_configured|configuration_changed {
        !configuration_changed: cache(CONFIG, add, $$list(webkit_configured))

        msg = "$${EOL}$${LITERAL_HASH} Configuration changed $$_DATE_"
        write_file($$_QMAKE_CACHE_, msg, append)

        !configuration_changed {
            cache(WEBKIT_CONFIG, set, WEBKIT_CONFIG)
        } else {
            !isEmpty(added_features): cache(WEBKIT_CONFIG, add, added_features)
            !isEmpty(removed_features): cache(WEBKIT_CONFIG, sub, removed_features)
        }
    }
}