2010-08-13 Patrick Gansterer <paroga@paroga.com>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Aug 2010 13:16:56 +0000 (13:16 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Aug 2010 13:16:56 +0000 (13:16 +0000)
        Reviewed by Nikolas Zimmermann.

        [CMake] Cleanup generator code.
        https://bugs.webkit.org/show_bug.cgi?id=39164

        * cmake/WebKitGenerators.cmake:
        * cmake/WebKitMacros.cmake:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@65319 268f45cc-cd09-0410-ab3c-d52691b4dbfc

ChangeLog
cmake/WebKitGenerators.cmake
cmake/WebKitMacros.cmake

index 001b244..fe7eb11 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,16 @@
 
         Reviewed by Nikolas Zimmermann.
 
+        [CMake] Cleanup generator code.
+        https://bugs.webkit.org/show_bug.cgi?id=39164
+
+        * cmake/WebKitGenerators.cmake:
+        * cmake/WebKitMacros.cmake:
+
+2010-08-13  Patrick Gansterer  <paroga@paroga.com>
+
+        Reviewed by Nikolas Zimmermann.
+
         [CMake] Add missing FIND_PACKAGE(Gperf)
         https://bugs.webkit.org/show_bug.cgi?id=43937
 
index 50c9077..92b83f1 100644 (file)
@@ -7,89 +7,6 @@
 
 INCLUDE (WebKitFS)
 
-FIND_PACKAGE(Perl REQUIRED)
-
-# - Create hash table *.lut.h
-# GENERATE_HASH_LUT(input_file output_file)
-MACRO(GENERATE_HASH_LUT _input _output)
-    SET(HASH_LUT_GENERATOR "${JAVASCRIPTCORE_DIR}/create_hash_table")
-
-    FOREACH (_tmp ${ARGN})
-        IF (${_tmp} STREQUAL "MAIN_DEPENDENCY")
-            SET(_main_dependency ${_input})
-        ENDIF ()
-    ENDFOREACH ()
-
-    ADD_CUSTOM_COMMAND(
-        OUTPUT ${_output}
-        MAIN_DEPENDENCY ${_main_dependency}
-        DEPENDS ${_input} ${HASH_LUT_GENERATOR}
-        COMMAND ${PERL_EXECUTABLE} ${HASH_LUT_GENERATOR} ${_input} > ${_output}
-        VERBATIM)
-ENDMACRO()
-
-# - Create hash table *.lut.h using at JavaScriptCore/runtime
-# GENERATE_HASH_LUT_RUNTIME(source)
-#
-# The generated files lives in ${CMAKE_BINARY_DIR}/JavaScriptCore/runtime/
-# and will have suffix ".lut.h"
-#
-# Input file is assumed to be in JavaScriptCore/runtime/${source}.cpp
-MACRO(GENERATE_HASH_LUT_RUNTIME _file)
-  ADD_CUSTOM_COMMAND(
-    OUTPUT  ${CMAKE_BINARY_DIR}/JavaScriptCore/runtime/${_file}.lut.h
-    DEPENDS ${JAVASCRIPTCORE_DIR}/runtime/${_file}.cpp  ${HASH_LUT_GENERATOR}
-    COMMAND ${PERL_EXECUTABLE} ${HASH_LUT_GENERATOR} ${JAVASCRIPTCORE_DIR}/runtime/${_file}.cpp -i > ${CMAKE_BINARY_DIR}/JavaScriptCore/runtime/${_file}.lut.h
-    VERBATIM)
-  LIST(APPEND GENERATED_HASH_LUT_RUNTIME_FILES "${CMAKE_BINARY_DIR}/JavaScriptCore/runtime/${_file}.lut.h")
-ENDMACRO()
-
-
-FIND_PROGRAM (BISON_EXECUTABLE bison)
-IF (NOT BISON_EXECUTABLE)
-  MESSAGE(FATAL_ERROR "Missing bison")
-ENDIF (NOT BISON_EXECUTABLE)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(Bison DEFAULT_MSG BISON_EXECUTABLE)
-
-# - Create a grammar using bison.
-# GENERATE_GRAMMAR(prefix source_file)
-#
-# Reads a source_file (*.y) Generates the .cpp and .h files in
-# ${DERIVED_SOURCES_DIR}
-MACRO(GENERATE_GRAMMAR _prefix _source)
-  GET_FILENAME_COMPONENT(_name ${_source} NAME_WE)
-  SET(_out_base ${DERIVED_SOURCES_DIR}/${_name})
-  ADD_CUSTOM_COMMAND(
-    OUTPUT  ${_out_base}.cpp ${_out_base}.h
-    DEPENDS ${_source}
-    COMMAND ${BISON_EXECUTABLE} -p ${_prefix} ${_source} -o ${_out_base}.cpp --defines=${_out_base}.h
-    VERBATIM)
-  UNSET(_out_base)
-  UNSET(_name)
-ENDMACRO ()
-
-
-FIND_PROGRAM(GPERF_EXECUTABLE gperf)
-IF (NOT GPERF_EXECUTABLE)
-  MESSAGE(FATAL_ERROR "Missing gperf")
-ENDIF ()
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(GPerf DEFAULT_MSG GPERF_EXECUTABLE)
-SET(PERF_HASH_GENERATOR ${WEBCORE_DIR}/make-hash-tools.pl)
-
-# - Create perfect hash tables using gperf
-# GENERATE_GPERF(extension source_file)
-#
-# The generated files lives in ${DERIVED_SOURCES_DIR} and ends in .cpp
-MACRO(GENERATE_GPERF _source)
-  GET_FILENAME_COMPONENT(_name ${_source} NAME_WE)
-  ADD_CUSTOM_COMMAND(
-    OUTPUT ${DERIVED_SOURCES_DIR}/${_name}.cpp
-    DEPENDS ${_source}
-    COMMAND ${PERL_EXECUTABLE} ${PERF_HASH_GENERATOR} ${DERIVED_SOURCES_DIR} ${_source}
-    VERBATIM)
-ENDMACRO ()
-
-
 # Modules that the bindings generator scripts may use
 SET(SCRIPTS_BINDINGS
   ${WEBCORE_DIR}/bindings/scripts/CodeGenerator.pm
index 99acb25..f79f196 100644 (file)
-MACRO(INCLUDE_IF_EXISTS _file)
+MACRO (INCLUDE_IF_EXISTS _file)
     IF (EXISTS ${_file})
         MESSAGE(STATUS "Using platform-specific CMakeLists: ${_file}")
-       INCLUDE(${_file})
+        INCLUDE(${_file})
     ELSE ()
         MESSAGE(STATUS "Platform-specific CMakeLists not found: ${_file}")
     ENDIF ()
-ENDMACRO()
+ENDMACRO ()
+
 
 # Append the given dependencies to the source file
-MACRO(ADD_SOURCE_DEPENDENCIES _source _deps)
-    GET_SOURCE_FILE_PROPERTY (_tmp ${_source} OBJECT_DEPENDS)
+MACRO (ADD_SOURCE_DEPENDENCIES _source _deps)
+    SET(_tmp)
+    GET_SOURCE_FILE_PROPERTY(_tmp ${_source} OBJECT_DEPENDS)
     IF (NOT _tmp)
-        SET (_tmp "")
+        SET(_tmp "")
     ENDIF ()
 
     FOREACH (f ${_deps})
         LIST(APPEND _tmp "${f}")
     ENDFOREACH ()
 
-    SET_SOURCE_FILES_PROPERTIES (${_source} PROPERTIES OBJECT_DEPENDS "${_tmp}")
-    UNSET(_tmp)
-ENDMACRO()
+    SET_SOURCE_FILES_PROPERTIES(${_source} PROPERTIES OBJECT_DEPENDS "${_tmp}")
+ENDMACRO ()
+
+
+MACRO (GENERATE_DOM_NAMES _namespace _attrs)
+    SET(NAMES_GENERATOR ${WEBCORE_DIR}/dom/make_names.pl)
+    SET(_arguments  --attrs ${_attrs})
+    SET(_outputfiles ${DERIVED_SOURCES_DIR}/${_namespace}Names.cpp ${DERIVED_SOURCES_DIR}/${_namespace}Names.h)
+    SET(_extradef)
+    SET(_tags)
+
+    FOREACH (f ${ARGN})
+        IF (_tags)
+            SET(_extradef "${_extradef} ${f}")
+        ELSE ()
+            SET(_tags ${f})
+        ENDIF ()
+    ENDFOREACH ()
+
+    IF (_tags)
+        SET(_arguments "${_arguments}" --tags ${_tags} --factory --wrapperFactory)
+        SET(_outputfiles "${_outputfiles}" ${DERIVED_SOURCES_DIR}/${_namespace}ElementFactory.cpp ${DERIVED_SOURCES_DIR}/${_namespace}ElementFactory.h ${DERIVED_SOURCES_DIR}/JS${_namespace}ElementWrapperFactory.cpp ${DERIVED_SOURCES_DIR}/JS${_namespace}ElementWrapperFactory.h)
+    ENDIF ()
+
+    IF (_extradef)
+        SET(_additionArguments "${_additionArguments}" --extraDefines=${_extradef})
+    ENDIF ()
+
+    ADD_CUSTOM_COMMAND(
+        OUTPUT  ${_outputfiles}
+        DEPENDS ${NAMES_GENERATOR} ${SCRIPTS_BINDINGS} ${_attrs} ${_tags}
+        COMMAND ${PERL_EXECUTABLE} -I${WEBCORE_DIR}/bindings/scripts ${NAMES_GENERATOR} --outputDir ${DERIVED_SOURCES_DIR} ${_arguments}
+        VERBATIM)
+ENDMACRO ()
+
+
+# - Create hash table *.lut.h
+# GENERATE_HASH_LUT(input_file output_file)
+MACRO (GENERATE_HASH_LUT _input _output)
+    SET(HASH_LUT_GENERATOR "${JAVASCRIPTCORE_DIR}/create_hash_table")
+
+    FOREACH (_tmp ${ARGN})
+        IF (${_tmp} STREQUAL "MAIN_DEPENDENCY")
+            SET(_main_dependency ${_input})
+        ENDIF ()
+    ENDFOREACH ()
+
+    ADD_CUSTOM_COMMAND(
+        OUTPUT ${_output}
+        MAIN_DEPENDENCY ${_main_dependency}
+        DEPENDS ${_input} ${HASH_LUT_GENERATOR}
+        COMMAND ${PERL_EXECUTABLE} ${HASH_LUT_GENERATOR} ${_input} > ${_output}
+        VERBATIM)
+ENDMACRO ()
+
+
+MACRO (GENERATE_GRAMMAR _prefix _input _output_header _output_source)
+    ADD_CUSTOM_COMMAND(
+        OUTPUT ${_output_header} ${_output_source}
+        MAIN_DEPENDENCY ${_input}
+        COMMAND ${BISON_EXECUTABLE} -p ${_prefix} ${_input} -o ${_output_source} --defines=${_output_header}
+        VERBATIM)
+ENDMACRO ()
+
+
+MACRO (GENERATE_GPERF _input _output _func _opts)
+    ADD_CUSTOM_COMMAND(
+        OUTPUT ${_output}
+        MAIN_DEPENDENCY ${_input}
+        COMMAND ${GPERF_EXECUTABLE} -CDEGIot -L ANSI-C --key-positions=* -s 2 -N ${_func} ${_opts} < ${_input} > ${_output}
+        VERBATIM)
+ENDMACRO ()
+
 
-MACRO(WEBKIT_WRAP_SOURCELIST _input)
+MACRO (WEBKIT_WRAP_SOURCELIST _input)
     IF (WTF_PLATFORM_QT)
         FOREACH (_file ${ARGN})
             GET_FILENAME_COMPONENT(_basename ${_file} NAME_WE)
@@ -34,7 +106,7 @@ MACRO(WEBKIT_WRAP_SOURCELIST _input)
             IF (_match)
                 QT4_GENERATE_MOC(${_file} ${_moc_filename})
                 ADD_SOURCE_DEPENDENCIES(${_file} ${_moc_filename})
-            ENDIF()
+            ENDIF ()
         ENDFOREACH ()
     ENDIF ()
-ENDMACRO()
+ENDMACRO ()