Skip to content

Commit

Permalink
generate qfeatures.h at build time
Browse files Browse the repository at this point in the history
much more elegant than the checked in file. and less chance to get it
wrong, as people often enough do.

Change-Id: I975a62dfd83ce4f15947ce54f3c40931b1badae0
Reviewed-by: Tasuku Suzuki <[email protected]>
Reviewed-by: Joerg Bornemann <[email protected]>
  • Loading branch information
ossilator authored and The Qt Project committed Oct 29, 2013
1 parent 569ec1a commit 08a737d
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 887 deletions.
47 changes: 47 additions & 0 deletions qtbase.pro
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,53 @@ prefix_build|!equals(PWD, $$OUT_PWD) {

}

# Generate qfeatures.h
features =
lines = $$cat("src/corelib/global/qfeatures.txt", lines)
for (line, lines) {
t = $$replace(line, "^Feature: (\\S+)\\s*$", "\\1")
!isEqual(t, $$line) {
feature = $$t
features += $$t
} else {
t = $$replace(line, "^Requires: (.*)$", "\\1")
!isEqual(t, $$line) {
features.$${feature}.depends = $$replace(t, \\s+$, )
} else {
t = $$replace(line, "^Name: (.*)$", "\\1")
!isEqual(t, $$line) {
features.$${feature}.name = $$replace(t, \\s+$, )
}
}
}
}
features = $$sort_depends(features, features.)
features = $$reverse(features)
FEATURES_H = \
"/*" \
" * All features and their dependencies." \
" *" \
" * This list is generated by qmake from <qtbase>/src/corelib/global/qfeatures.txt" \
" */"
for (ft, features) {
FEATURES_H += \
"$$escape_expand(\\n)// $$eval(features.$${ft}.name)"
isEmpty(features.$${ft}.depends) {
FEATURES_H += \
"//$${LITERAL_HASH}define QT_NO_$$ft"
} else {
FEATURES_H += \
"$${LITERAL_HASH}if !defined(QT_NO_$$ft) && ($$join($$list($$split(features.$${ft}.depends)), ") || defined(QT_NO_", "defined(QT_NO_", ")"))" \
"$${LITERAL_HASH} define QT_NO_$$ft" \
"$${LITERAL_HASH}endif"
}
}
write_file($$OUT_PWD/src/corelib/global/qfeatures.h, FEATURES_H)|error("Aborting.")
# Create forwarding header
FWD_FEATURES_H = \
'$${LITERAL_HASH}include "../../src/corelib/global/qfeatures.h"'
write_file($$OUT_PWD/include/QtCore/qfeatures.h, FWD_FEATURES_H)|error("Aborting.")

#mkspecs
mkspecs.path = $$[QT_HOST_DATA]/mkspecs
mkspecs.files = \
Expand Down
1 change: 1 addition & 0 deletions src/corelib/global/global.pri
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ INCLUDEPATH += $$QT_BUILD_TREE/src/corelib/global

# configure creates these, not syncqt, so we need to manually inject them
qconfig_h_files = \
$$OUT_PWD/global/qfeatures.h \
$$OUT_PWD/global/qconfig.h \
$$QT_BUILD_TREE/include/QtCore/QtConfig
targ_headers.files += $$qconfig_h_files
Expand Down
Loading

0 comments on commit 08a737d

Please sign in to comment.