source: trunk/mkspecs/features/moc.prf @ 94

Last change on this file since 94 was 94, checked in by Dmitry A. Kuminov, 11 years ago

qmake/OS/2: Added DEFINES_RSP file generation to overcome command line length limitation when calling moc (#23).

File size: 4.2 KB
Line 
1
2#global defaults
3isEmpty(QMAKE_MOC) {
4    win32|os2:QMAKE_MOC = $$[QT_INSTALL_BINS]\moc.exe
5    else:QMAKE_MOC = $$[QT_INSTALL_BINS]/moc
6}
7isEmpty(MOC_DIR):MOC_DIR = .
8isEmpty(QMAKE_H_MOD_MOC):QMAKE_H_MOD_MOC = moc_
9isEmpty(QMAKE_EXT_CPP_MOC):QMAKE_EXT_CPP_MOC = .moc
10
11# This function on Windows puts the includes into a .inc file which moc will read, if the project
12# has more than 30 includes. We do this to overcome a command-line limit on Win < XP
13# Otherwise the function simply returns the normal command-line for moc. On OS/2
14# (where similar command line length restrictions apply) the function does a similar
15# substitiution using response files defined in mkspecs/os2-*/qmake.conf (which are
16# also used by the compiler andn other tools)
17defineReplace(mocCmd) {
18    win32:count($$list($$INCPATH), 40, >) {
19        EOC = $$escape_expand(\n\t)
20
21        if(contains(TEMPLATE, "vc.*")|contains(TEMPLATE_PREFIX, "vc")) {
22            # the VCPROJ generator will replace the \r\h with the coded \r\n: &#x0d;&#x0a;
23            # No other generator understands the \h
24            if(win32-msvc.net|win32-msvc2*|wince*msvc*): EOC = $$escape_expand(\r\h)
25            else: EOC = $$escape_expand(\\)$$escape_expand(\n\t)
26        }
27
28        INCLUDETEMP = mocinclude.tmp
29        unset(INCFILELIST)
30        RET =
31        for(incfile, $$list($$INCPATH)) {
32            INCFILELIST = -I$$incfile
33            isEmpty(RET): RET += @echo $$INCFILELIST> $$INCLUDETEMP $$EOC
34            else:         RET += @echo $$INCFILELIST>> $$INCLUDETEMP $$EOC
35        }
36        !isEmpty(INCFILELIST):RET += @echo $$INCFILELIST>> $$INCLUDETEMP $$EOC
37        RET += $$QMAKE_MOC $(DEFINES) @$$INCLUDETEMP $$join(QMAKE_COMPILER_DEFINES, " -D", -D) $$1 -o $$2
38        return($$RET)
39    }
40    os2 {
41        isEmpty(QMAKE_INCPATH_RSP_VAR):I = $(INCPATH)
42        else:I = @$($$QMAKE_INCPATH_RSP_VAR)
43        isEmpty(QMAKE_DEFINES_RSP_VAR):D = $(INCPATH)
44        else:D = @$($$QMAKE_DEFINES_RSP_VAR)
45
46        return($$QMAKE_MOC $$D $$I $$join(QMAKE_COMPILER_DEFINES, " -D", -D) $$1 -o $$2)
47    }
48    return($$QMAKE_MOC $(DEFINES) $(INCPATH) $$join(QMAKE_COMPILER_DEFINES, " -D", -D) $$1 -o $$2)
49}
50
51#moc headers
52moc_header.CONFIG = moc_verify
53moc_header.dependency_type = TYPE_C
54moc_header.commands = ${QMAKE_FUNC_mocCmd}
55moc_header.output = $$MOC_DIR/$${QMAKE_H_MOD_MOC}${QMAKE_FILE_BASE}$${first(QMAKE_EXT_CPP)}
56moc_header.input = HEADERS
57moc_header.variable_out = SOURCES
58moc_header.name = MOC ${QMAKE_FILE_IN}
59silent:moc_header.commands = @echo moc ${QMAKE_FILE_IN} && $$moc_header.commands
60QMAKE_EXTRA_COMPILERS += moc_header
61INCREDIBUILD_XGE += moc_header
62
63#moc sources
64moc_source.CONFIG = no_link moc_verify
65moc_source.dependency_type = TYPE_C
66moc_source.commands = ${QMAKE_FUNC_mocCmd}
67moc_source.output = $$MOC_DIR/$${QMAKE_CPP_MOD_MOC}${QMAKE_FILE_BASE}$${QMAKE_EXT_CPP_MOC}
68moc_source.input = SOURCES OBJECTIVE_SOURCES
69moc_source.name = MOC ${QMAKE_FILE_IN}
70silent:moc_source.commands = @echo moc ${QMAKE_FILE_IN} && $$moc_source.commands
71QMAKE_EXTRA_COMPILERS += moc_source
72INCREDIBUILD_XGE += moc_source
73
74#make sure we can include these files
75moc_dir_short = $$MOC_DIR
76win32:moc_dir_short ~= s,^.:,/,
77contains(moc_dir_short, ^[/\\\\].*):INCLUDEPATH += $$MOC_DIR
78else:INCLUDEPATH += $$OUT_PWD/$$MOC_DIR
79
80# Backwards compatibility: Make shadow builds with default MOC_DIR work
81# if the user did not add the source dir explicitly.
82equals(MOC_DIR, .) {
83    CONFIG -= include_source_dir
84    CONFIG = include_source_dir $$CONFIG
85}
86
87#auto depend on moc
88unix:!no_mocdepend {
89     moc_source.depends += $$first(QMAKE_MOC)
90     moc_header.depends += $$first(QMAKE_MOC)
91     !contains(TARGET, moc) { #auto build moc
92         isEmpty(QMAKE_MOC_SRC):QMAKE_MOC_SRC = "$(QTDIR)/src/tools/moc"
93         make_moc.target = $$first(QMAKE_MOC)
94             make_moc.commands = (cd $$QMAKE_MOC_SRC && $(MAKE))
95             QMAKE_EXTRA_TARGETS += make_moc
96     }
97}
98
99#generate a mocclean
100build_pass|isEmpty(BUILDS):mocclean.depends = compiler_moc_header_clean compiler_moc_source_clean
101else:mocclean.CONFIG += recursive
102QMAKE_EXTRA_TARGETS += mocclean
103
104#generate a mocables
105build_pass|isEmpty(BUILDS):mocables.depends = compiler_moc_header_make_all compiler_moc_source_make_all
106else:mocables.CONFIG += recursive
107QMAKE_EXTRA_TARGETS += mocables
Note: See TracBrowser for help on using the repository browser.