Document.cpp shouldn't need to know about every event for every feature
[WebKit-https.git] / Source / cmake / WebKitMacros.cmake
1 MACRO (INCLUDE_IF_EXISTS _file)
2     IF (EXISTS ${_file})
3         MESSAGE(STATUS "Using platform-specific CMakeLists: ${_file}")
4         INCLUDE(${_file})
5     ELSE ()
6         MESSAGE(STATUS "Platform-specific CMakeLists not found: ${_file}")
7     ENDIF ()
8 ENDMACRO ()
9
10
11 # Append the given dependencies to the source file
12 MACRO (ADD_SOURCE_DEPENDENCIES _source _deps)
13     SET(_tmp)
14     GET_SOURCE_FILE_PROPERTY(_tmp ${_source} OBJECT_DEPENDS)
15     IF (NOT _tmp)
16         SET(_tmp "")
17     ENDIF ()
18
19     FOREACH (f ${_deps})
20         LIST(APPEND _tmp "${f}")
21     ENDFOREACH ()
22
23     SET_SOURCE_FILES_PROPERTIES(${_source} PROPERTIES OBJECT_DEPENDS "${_tmp}")
24 ENDMACRO ()
25
26
27 MACRO (GENERATE_FONT_NAMES _infile)
28     SET(NAMES_GENERATOR ${WEBCORE_DIR}/dom/make_names.pl)
29     SET(_arguments  --fonts ${_infile})
30     SET(_outputfiles ${DERIVED_SOURCES_WEBCORE_DIR}/WebKitFontFamilyNames.cpp ${DERIVED_SOURCES_WEBCORE_DIR}/WebKitFontFamilyNames.h)
31
32     ADD_CUSTOM_COMMAND(
33         OUTPUT  ${_outputfiles}
34         DEPENDS ${NAMES_GENERATOR} ${SCRIPTS_BINDINGS} ${_infile}
35         COMMAND ${PERL_EXECUTABLE} -I${WEBCORE_DIR}/bindings/scripts ${NAMES_GENERATOR} --outputDir ${DERIVED_SOURCES_WEBCORE_DIR} ${_arguments}
36         VERBATIM)
37 ENDMACRO ()
38
39
40 MACRO (GENERATE_EVENT_FACTORY _infile)
41     SET(NAMES_GENERATOR ${WEBCORE_DIR}/dom/make_event_factory.pl)
42     SET(_arguments  --events ${_infile})
43     SET(_outputfiles ${DERIVED_SOURCES_WEBCORE_DIR}/EventFactory.cpp)
44
45     ADD_CUSTOM_COMMAND(
46         OUTPUT  ${_outputfiles}
47         DEPENDS ${NAMES_GENERATOR} ${SCRIPTS_BINDINGS} ${_infile}
48         COMMAND ${PERL_EXECUTABLE} -I${WEBCORE_DIR}/bindings/scripts ${NAMES_GENERATOR} --outputDir ${DERIVED_SOURCES_WEBCORE_DIR} ${_arguments}
49         VERBATIM)
50 ENDMACRO ()
51
52
53 MACRO (GENERATE_DOM_NAMES _namespace _attrs)
54     SET(NAMES_GENERATOR ${WEBCORE_DIR}/dom/make_names.pl)
55     SET(_arguments  --attrs ${_attrs})
56     SET(_outputfiles ${DERIVED_SOURCES_WEBCORE_DIR}/${_namespace}Names.cpp ${DERIVED_SOURCES_WEBCORE_DIR}/${_namespace}Names.h)
57     SET(_extradef)
58     SET(_tags)
59
60     FOREACH (f ${ARGN})
61         IF (_tags)
62             SET(_extradef "${_extradef} ${f}")
63         ELSE ()
64             SET(_tags ${f})
65         ENDIF ()
66     ENDFOREACH ()
67
68     IF (_tags)
69         SET(_arguments "${_arguments}" --tags ${_tags} --factory --wrapperFactory)
70         SET(_outputfiles "${_outputfiles}" ${DERIVED_SOURCES_WEBCORE_DIR}/${_namespace}ElementFactory.cpp ${DERIVED_SOURCES_WEBCORE_DIR}/${_namespace}ElementFactory.h ${DERIVED_SOURCES_WEBCORE_DIR}/JS${_namespace}ElementWrapperFactory.cpp ${DERIVED_SOURCES_WEBCORE_DIR}/JS${_namespace}ElementWrapperFactory.h)
71     ENDIF ()
72
73     IF (_extradef)
74         SET(_additionArguments "${_additionArguments}" --extraDefines=${_extradef})
75     ENDIF ()
76
77     ADD_CUSTOM_COMMAND(
78         OUTPUT  ${_outputfiles}
79         DEPENDS ${NAMES_GENERATOR} ${SCRIPTS_BINDINGS} ${_attrs} ${_tags}
80         COMMAND ${PERL_EXECUTABLE} -I${WEBCORE_DIR}/bindings/scripts ${NAMES_GENERATOR} --preprocessor "${CODE_GENERATOR_PREPROCESSOR}" --outputDir ${DERIVED_SOURCES_WEBCORE_DIR} ${_arguments} ${_additionArguments}
81         VERBATIM)
82 ENDMACRO ()
83
84
85 # - Create hash table *.lut.h
86 # GENERATE_HASH_LUT(input_file output_file)
87 MACRO (GENERATE_HASH_LUT _input _output)
88     SET(HASH_LUT_GENERATOR "${JAVASCRIPTCORE_DIR}/create_hash_table")
89
90     FOREACH (_tmp ${ARGN})
91         IF (${_tmp} STREQUAL "MAIN_DEPENDENCY")
92             SET(_main_dependency ${_input})
93         ENDIF ()
94     ENDFOREACH ()
95
96     ADD_CUSTOM_COMMAND(
97         OUTPUT ${_output}
98         MAIN_DEPENDENCY ${_main_dependency}
99         DEPENDS ${_input} ${HASH_LUT_GENERATOR}
100         COMMAND ${PERL_EXECUTABLE} ${HASH_LUT_GENERATOR} ${_input} -i > ${_output}
101         VERBATIM)
102 ENDMACRO ()
103
104
105 MACRO (GENERATE_GRAMMAR _prefix _input _output_header _output_source)
106     ADD_CUSTOM_COMMAND(
107         OUTPUT ${_output_header} ${_output_source}
108         MAIN_DEPENDENCY ${_input}
109         COMMAND ${BISON_EXECUTABLE} -p ${_prefix} ${_input} -o ${_output_source} --defines=${_output_header}
110         VERBATIM)
111 ENDMACRO ()
112
113 MACRO(MAKE_HASH_TOOLS _source)
114     GET_FILENAME_COMPONENT(_name ${_source} NAME_WE)
115
116     IF (${_source} STREQUAL "DocTypeStrings")
117         SET(_hash_tools_h "${DERIVED_SOURCES_WEBCORE_DIR}/HashTools.h")
118     ELSE ()
119         SET(_hash_tools_h "")
120     ENDIF ()
121
122     ADD_CUSTOM_COMMAND(
123         OUTPUT ${DERIVED_SOURCES_WEBCORE_DIR}/${_name}.cpp ${_hash_tools_h}
124         MAIN_DEPENDENCY ${_source}.gperf 
125         COMMAND ${PERL_EXECUTABLE} ${WEBCORE_DIR}/make-hash-tools.pl ${DERIVED_SOURCES_WEBCORE_DIR} ${_source}.gperf
126         VERBATIM)
127
128     UNSET(_name)
129     UNSET(_hash_tools_h)
130 ENDMACRO()
131
132 MACRO (WEBKIT_WRAP_SOURCELIST)
133     FOREACH (_file ${ARGN})
134         GET_FILENAME_COMPONENT(_basename ${_file} NAME_WE)
135         GET_FILENAME_COMPONENT(_path ${_file} PATH)
136
137                 IF (NOT _file MATCHES "${DERIVED_SOURCES_WEBCORE_DIR}")
138             STRING(REGEX REPLACE "/" "\\\\\\\\" _sourcegroup "${_path}")
139             SOURCE_GROUP("${_sourcegroup}" FILES ${_file})
140                 ENDIF ()
141
142         IF (WTF_PLATFORM_QT)
143             SET(_moc_filename ${DERIVED_SOURCES_WEBCORE_DIR}/${_basename}.moc)
144
145             FILE(READ ${_file} _contents)
146
147             STRING(REGEX MATCHALL "#include[ ]+\"${_basename}\\.moc\"" _match "${_contents}")
148             IF (_match)
149                 QT4_GENERATE_MOC(${_file} ${_moc_filename})
150                 ADD_SOURCE_DEPENDENCIES(${_file} ${_moc_filename})
151             ENDIF ()
152         ENDIF ()
153     ENDFOREACH ()
154
155     SOURCE_GROUP("DerivedSources" REGULAR_EXPRESSION "${DERIVED_SOURCES_WEBCORE_DIR}")
156 ENDMACRO ()