Title: [207617] trunk
Revision
207617
Author
commit-qu...@webkit.org
Date
2016-10-20 07:34:24 -0700 (Thu, 20 Oct 2016)

Log Message

[CMake] CMake does not support the dep files for implicit dependency
https://bugs.webkit.org/show_bug.cgi?id=161433

Patch by Fujii Hironori <hironori.fu...@sony.com> on 2016-10-20
Reviewed by Brent Fulgham.

Created a Perl script to generate all IDL bindings for CMake.
This script can regenerate outdated bindings by based on the
supplemental dependency and dep files created by
'--write-dependencies' switch of generate-bindings.pl.

add_custom_target is used to invoke the script instead of
add_custom_command because Ninja deletes all output files before
executing the command in case of add_custom_command.

USES_TERMINAL option of add_custom_target has two effects:
1) Not buffering output of the command
2) Invoking the command in the special Ninja pool which inhibits parallel build
One needs to use CMake 3.2 or later to enable this feature.

.:

* Source/cmake/WebKitMacros.cmake (GENERATE_BINDINGS): Included
ProcessorCount.  Added a new argument 'target'.  Use
add_custom_target instead of add_custom_command.  Invoke the new
script.

Source/WebCore:

* CMakeLists.txt: Specified target names for
GENERATE_BINDINGS. Added dependency for the targets.
* bindings/scripts/generate-bindings-all.pl: Added.

Tools:

* DumpRenderTree/CMakeLists.txt: Specified a target name for
GENERATE_BINDINGS. Added dependency for the target.
* WebKitTestRunner/CMakeLists.txt: Ditto.

Modified Paths

Added Paths

Diff

Modified: trunk/ChangeLog (207616 => 207617)


--- trunk/ChangeLog	2016-10-20 13:18:09 UTC (rev 207616)
+++ trunk/ChangeLog	2016-10-20 14:34:24 UTC (rev 207617)
@@ -1,3 +1,29 @@
+2016-10-20  Fujii Hironori  <hironori.fu...@sony.com>
+
+        [CMake] CMake does not support the dep files for implicit dependency
+        https://bugs.webkit.org/show_bug.cgi?id=161433
+
+        Reviewed by Brent Fulgham.
+
+        Created a Perl script to generate all IDL bindings for CMake.
+        This script can regenerate outdated bindings by based on the
+        supplemental dependency and dep files created by
+        '--write-dependencies' switch of generate-bindings.pl.
+
+        add_custom_target is used to invoke the script instead of
+        add_custom_command because Ninja deletes all output files before
+        executing the command in case of add_custom_command.
+
+        USES_TERMINAL option of add_custom_target has two effects:
+        1) Not buffering output of the command
+        2) Invoking the command in the special Ninja pool which inhibits parallel build
+        One needs to use CMake 3.2 or later to enable this feature.
+
+        * Source/cmake/WebKitMacros.cmake (GENERATE_BINDINGS): Included
+        ProcessorCount.  Added a new argument 'target'.  Use
+        add_custom_target instead of add_custom_command.  Invoke the new
+        script.
+
 2016-10-19  Alex Christensen  <achristen...@webkit.org>
 
         Revert r207151

Modified: trunk/Source/WebCore/CMakeLists.txt (207616 => 207617)


--- trunk/Source/WebCore/CMakeLists.txt	2016-10-20 13:18:09 UTC (rev 207616)
+++ trunk/Source/WebCore/CMakeLists.txt	2016-10-20 14:34:24 UTC (rev 207617)
@@ -3641,7 +3641,7 @@
 set(FEATURE_DEFINES_JAVASCRIPT "LANGUAGE_JAVASCRIPT ${FEATURE_DEFINES_WITH_SPACE_SEPARATOR}")
 list(APPEND WebCoreTestSupport_IDL_FILES ${DERIVED_SOURCES_WEBCORE_DIR}/InternalSettingsGenerated.idl)
 
-GENERATE_BINDINGS(
+GENERATE_BINDINGS(WebCoreBindings
     OUTPUT_SOURCE WebCore_DERIVED_SOURCES
     INPUT_FILES ${WebCore_IDL_FILES}
     BASE_DIR ${WEBCORE_DIR}
@@ -3657,7 +3657,7 @@
         --workerGlobalScopeConstructorsFile ${WORKERGLOBALSCOPE_CONSTRUCTORS_FILE}
         --dedicatedWorkerGlobalScopeConstructorsFile ${DEDICATEDWORKERGLOBALSCOPE_CONSTRUCTORS_FILE})
 
-GENERATE_BINDINGS(
+GENERATE_BINDINGS(WebCoreTestSupportBindings
     OUTPUT_SOURCE WebCoreTestSupport_SOURCES
     INPUT_FILES ${WebCoreTestSupport_IDL_FILES}
     BASE_DIR ${WEBCORE_DIR}
@@ -3666,6 +3666,9 @@
     DESTINATION ${DERIVED_SOURCES_WEBCORE_DIR}
     GENERATOR JS)
 
+# WebCoreTestSupportBindings needs InternalSettingsGenerated.idl
+add_dependencies(WebCoreTestSupportBindings WebCoreDerivedSources)
+
 # WebCore JS Builtins
 
 set(WebCore_BUILTINS_SOURCES
@@ -3811,7 +3814,7 @@
 # files on OS X.
 add_library(WebCoreDerivedSources STATIC ${WebCore_DERIVED_SOURCES})
 set_target_properties(WebCoreDerivedSources PROPERTIES OUTPUT_NAME WebCoreDerivedSources${DEBUG_SUFFIX})
-add_dependencies(WebCoreDerivedSources _javascript_Core)
+add_dependencies(WebCoreDerivedSources _javascript_Core WebCoreBindings)
 if (NOT WIN32)
     list(APPEND WebCore_LIBRARIES WebCoreDerivedSources)
 endif ()
@@ -3842,7 +3845,7 @@
 
 include_directories(${WebCoreTestSupport_INCLUDE_DIRECTORIES})
 add_library(WebCoreTestSupport ${WebCoreTestSupport_LIBRARY_TYPE} ${WebCoreTestSupport_SOURCES})
-add_dependencies(WebCoreTestSupport WebCore)
+add_dependencies(WebCoreTestSupport WebCore WebCoreTestSupportBindings)
 target_link_libraries(WebCoreTestSupport ${WebCoreTestSupport_LIBRARIES})
 
 if (WebCoreTestSupport_OUTPUT_NAME)

Modified: trunk/Source/WebCore/ChangeLog (207616 => 207617)


--- trunk/Source/WebCore/ChangeLog	2016-10-20 13:18:09 UTC (rev 207616)
+++ trunk/Source/WebCore/ChangeLog	2016-10-20 14:34:24 UTC (rev 207617)
@@ -1,3 +1,28 @@
+2016-10-20  Fujii Hironori  <hironori.fu...@sony.com>
+
+        [CMake] CMake does not support the dep files for implicit dependency
+        https://bugs.webkit.org/show_bug.cgi?id=161433
+
+        Reviewed by Brent Fulgham.
+
+        Created a Perl script to generate all IDL bindings for CMake.
+        This script can regenerate outdated bindings by based on the
+        supplemental dependency and dep files created by
+        '--write-dependencies' switch of generate-bindings.pl.
+
+        add_custom_target is used to invoke the script instead of
+        add_custom_command because Ninja deletes all output files before
+        executing the command in case of add_custom_command.
+
+        USES_TERMINAL option of add_custom_target has two effects:
+        1) Not buffering output of the command
+        2) Invoking the command in the special Ninja pool which inhibits parallel build
+        One needs to use CMake 3.2 or later to enable this feature.
+
+        * CMakeLists.txt: Specified target names for
+        GENERATE_BINDINGS. Added dependency for the targets.
+        * bindings/scripts/generate-bindings-all.pl: Added.
+
 2016-10-20  Adam Jackson  <a...@redhat.com>
 
         Prefer eglGetPlatformDisplay to eglGetDisplay

Added: trunk/Source/WebCore/bindings/scripts/generate-bindings-all.pl (0 => 207617)


--- trunk/Source/WebCore/bindings/scripts/generate-bindings-all.pl	                        (rev 0)
+++ trunk/Source/WebCore/bindings/scripts/generate-bindings-all.pl	2016-10-20 14:34:24 UTC (rev 207617)
@@ -0,0 +1,236 @@
+#!/usr/bin/perl
+#
+# Copyright (C) 2016 Sony Interactive Entertainment Inc.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+# 2.  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+use strict;
+use warnings;
+use FindBin;
+use lib $FindBin::Bin;
+
+use File::Basename;
+use File::Spec;
+use File::Find;
+use Getopt::Long;
+use threads;
+use threads::shared;
+use Thread::Queue;
+
+my $perl = $^X;
+my $scriptDir = $FindBin::Bin;
+my @idlDirectories;
+my $outputDirectory;
+my $idlFilesList;
+my $generator;
+my @generatorDependency;
+my $defines;
+my $preprocessor;
+my $supplementalDependencyFile;
+my @ppExtraOutput;
+my @ppExtraArgs;
+my $numOfJobs = 1;
+my $idlAttributesFile;
+
+GetOptions('include=s@' => \@idlDirectories,
+           'outputDir=s' => \$outputDirectory,
+           'idlFilesList=s' => \$idlFilesList,
+           'generator=s' => \$generator,
+           'generatorDependency=s@' => \@generatorDependency,
+           'defines=s' => \$defines,
+           'preprocessor=s' => \$preprocessor,
+           'supplementalDependencyFile=s' => \$supplementalDependencyFile,
+           'ppExtraOutput=s@' => \@ppExtraOutput,
+           'ppExtraArgs=s@' => \@ppExtraArgs,
+           'idlAttributesFile=s' => \$idlAttributesFile,
+           'numOfJobs=i' => \$numOfJobs);
+
+$| = 1;
+my @idlFiles;
+open(my $fh, '<', $idlFilesList) or die "Cannot open $idlFilesList";
+@idlFiles = map { CygwinPathIfNeeded(s/\r?\n?$//r) } <$fh>;
+close($fh) or die;
+
+my %supplementedIdlFiles;
+if ($supplementalDependencyFile) {
+    my @output = ($supplementalDependencyFile, @ppExtraOutput);
+    my @deps = (@idlFiles, @generatorDependency);
+    if (needsUpdate(\@output, \@deps)) {
+        my @args = (File::Spec->catfile($scriptDir, 'preprocess-idls.pl'),
+                    '--defines', $defines,
+                    '--idlFilesList', $idlFilesList,
+                    '--supplementalDependencyFile', $supplementalDependencyFile,
+                    @ppExtraArgs);
+        print("Preprocess IDL\n");
+        executeCommand($perl, @args) == 0 or die;
+    }
+    open(my $fh, '<', $supplementalDependencyFile) or die "Cannot open $supplementalDependencyFile";
+    while (<$fh>) {
+        my ($idlFile, @followingIdlFiles) = split(/\s+/);
+        $supplementedIdlFiles{$idlFile} = \@followingIdlFiles;
+    }
+    close($fh) or die;
+}
+
+my @args = (File::Spec->catfile($scriptDir, 'generate-bindings.pl'),
+            '--defines', $defines,
+            '--generator', $generator,
+            '--outputDir', $outputDirectory,
+            '--preprocessor', $preprocessor,
+            '--idlAttributesFile', $idlAttributesFile,
+            '--write-dependencies');
+push @args, map { ('--include', $_) } @idlDirectories;
+push @args, '--supplementalDependencyFile', $supplementalDependencyFile if $supplementalDependencyFile;
+
+my %directoryCache;
+buildDirectoryCache();
+
+my @idlFilesToUpdate = grep {
+    my ($filename, $dirs, $suffix) = fileparse($_, '.idl');
+    my $sourceFile = File::Spec->catfile($outputDirectory, "JS$filename.cpp");
+    my $headerFile = File::Spec->catfile($outputDirectory, "JS$filename.h");
+    my $depFile = File::Spec->catfile($outputDirectory, "JS$filename.dep");
+    my @output = ($sourceFile, $headerFile);
+    my @deps = ($_,
+                $idlAttributesFile,
+                @generatorDependency,
+                @{$supplementedIdlFiles{$_} or []},
+                implicitDependencies($depFile));
+    needsUpdate(\@output, \@deps);
+} @idlFiles;
+my $queue = Thread::Queue->new(@idlFilesToUpdate);
+my $abort :shared = 0;
+my $terminalWidth = getTerminalWidth();
+my $totalCount = @idlFilesToUpdate;
+my $currentCount :shared = 0;
+
+my @threadPool = map { threads->create(\&worker) } (1 .. $numOfJobs);
+$_->join for @threadPool;
+exit $abort;
+
+sub needsUpdate
+{
+    my ($objects, $depends) = @_;
+    my $oldestObjectTime;
+    for (@$objects) {
+        return 1 if !-f;
+        my $m = mtime($_);
+        if (!defined $oldestObjectTime || $m < $oldestObjectTime) {
+            $oldestObjectTime = $m;
+        }
+    }
+    for (@$depends) {
+        die "Missing required dependency: $_" if !-f;
+        my $m = mtime($_);
+        if ($oldestObjectTime < $m) {
+            return 1;
+        }
+    }
+    return 0;
+}
+
+sub mtime
+{
+    my ($file) = @_;
+    return (stat $file)[9];
+}
+
+sub worker {
+    while (my $file = $queue->dequeue_nb()) {
+        last if $abort;
+        eval {
+            $currentCount++;
+            my $basename = basename($file);
+            if ($terminalWidth) {
+                my $w = $terminalWidth - 1;
+                print sprintf("%-*.*s\r", $w, $w, "[$currentCount/$totalCount] $basename");
+            } else {
+                print "[$currentCount/$totalCount] $basename\n";
+            }
+            executeCommand($perl, @args, $file) == 0 or die;
+        };
+        if ($@) {
+            $abort = 1;
+            die;
+        }
+    }
+}
+
+sub buildDirectoryCache
+{
+    my $wanted = sub {
+        $directoryCache{$_} = $File::Find::name;
+        $File::Find::prune = 1 unless ~/\./;
+    };
+    find($wanted, @idlDirectories);
+}
+
+sub implicitDependencies
+{
+    my ($depFile) = @_;
+    return () unless -f $depFile;
+    open(my $fh, '<', $depFile) or die "Cannot open $depFile";
+    my $firstLine = <$fh>;
+    close($fh) or die;
+    my (undef, $deps) = split(/ : /, $firstLine);
+    my @deps = split(/\s+/, $deps);
+    return map { $directoryCache{$_} or () } @deps;
+}
+
+sub executeCommand
+{
+    if ($^O eq 'cygwin') {
+        # 'system' of Cygwin Perl doesn't seem thread-safe
+        my $pid = fork();
+        defined($pid) or die;
+        if ($pid == 0) {
+            exec(@_) or die;
+        }
+        waitpid($pid, 0);
+        return $?;
+    }
+    if ($^O eq 'MSWin32') {
+        return system(quoteCommand(@_));
+    }
+    return system(@_);
+}
+
+sub quoteCommand
+{
+    return map {
+        '"' . s/([\\\"])/\\$1/gr . '"';
+    } @_;
+}
+
+sub CygwinPathIfNeeded
+{
+    my $path = shift;
+    return Cygwin::win_to_posix_path($path) if ($^O eq 'cygwin');
+    return $path;
+}
+
+sub getTerminalWidth
+{
+    return 0 unless -t STDOUT;
+    return 80 if $^O eq 'MSWin32';
+    return `stty size` =~ /\d+\s+(\d+)/ ? $1 : 80;
+}
Property changes on: trunk/Source/WebCore/bindings/scripts/generate-bindings-all.pl
___________________________________________________________________

Added: svn:executable

+* \ No newline at end of property

Modified: trunk/Source/cmake/WebKitMacros.cmake (207616 => 207617)


--- trunk/Source/cmake/WebKitMacros.cmake	2016-10-20 13:18:09 UTC (rev 207616)
+++ trunk/Source/cmake/WebKitMacros.cmake	2016-10-20 14:34:24 UTC (rev 207617)
@@ -1,4 +1,6 @@
 include(CMakeParseArguments)
+include(ProcessorCount)
+ProcessorCount(PROCESSOR_COUNT)
 
 macro(WEBKIT_INCLUDE_CONFIG_FILES_IF_EXISTS)
     set(_file ${CMAKE_CURRENT_SOURCE_DIR}/Platform${PORT}.cmake)
@@ -43,7 +45,8 @@
     #FIXME: Add support for Xcode.
 endmacro()
 
-# Helper macro which wraps preprocess-idls.pl and generate-bindings.pl scripts.
+# Helper macro which wraps generate-bindings-all.pl script.
+#   target is a new target name to be added
 #   OUTPUT_SOURCE is a list name which will contain generated sources.(eg. WebCore_SOURCES)
 #   INPUT_FILES are IDL files to generate.
 #   BASE_DIR is base directory where script is called.
@@ -54,15 +57,14 @@
 #   SUPPLEMENTAL_DEPFILE is a value of --supplementalDependencyFile. (optional)
 #   PP_EXTRA_OUTPUT is extra outputs of preprocess-idls.pl. (optional)
 #   PP_EXTRA_ARGS is extra arguments for preprocess-idls.pl. (optional)
-function(GENERATE_BINDINGS)
+function(GENERATE_BINDINGS target)
     set(options)
     set(oneValueArgs OUTPUT_SOURCE BASE_DIR FEATURES DESTINATION GENERATOR SUPPLEMENTAL_DEPFILE)
     set(multiValueArgs INPUT_FILES IDL_INCLUDES PP_EXTRA_OUTPUT PP_EXTRA_ARGS)
     cmake_parse_arguments(arg "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
-    set(binding_generator ${WEBCORE_DIR}/bindings/scripts/generate-bindings.pl)
+    set(binding_generator ${WEBCORE_DIR}/bindings/scripts/generate-bindings-all.pl)
     set(idl_attributes_file ${WEBCORE_DIR}/bindings/scripts/IDLAttributes.txt)
-    set(id ${arg_OUTPUT_SOURCE})
-    set(idl_files_list ${CMAKE_CURRENT_BINARY_DIR}/idl_files_${id}.tmp)
+    set(idl_files_list ${CMAKE_CURRENT_BINARY_DIR}/idl_files_${target}.tmp)
     set(_supplemental_dependency)
 
     set(content)
@@ -74,34 +76,37 @@
     endforeach ()
     file(WRITE ${idl_files_list} ${content})
 
+    set(args
+        --defines ${arg_FEATURES}
+        --generator ${arg_GENERATOR}
+        --outputDir ${arg_DESTINATION}
+        --idlFilesList ${idl_files_list}
+        --preprocessor "${CODE_GENERATOR_PREPROCESSOR}"
+        --idlAttributesFile ${idl_attributes_file})
     if (arg_SUPPLEMENTAL_DEPFILE)
-        set(_supplemental_dependency --supplementalDependencyFile ${arg_SUPPLEMENTAL_DEPFILE})
-
-        add_custom_command(
-            OUTPUT ${arg_SUPPLEMENTAL_DEPFILE} ${arg_PP_EXTRA_OUTPUT}
-            DEPENDS ${WEBCORE_DIR}/bindings/scripts/preprocess-idls.pl ${arg_INPUT_FILES}
-            COMMAND ${PERL_EXECUTABLE} ${WEBCORE_DIR}/bindings/scripts/preprocess-idls.pl --defines ${arg_FEATURES} --idlFilesList ${idl_files_list} --supplementalDependencyFile ${arg_SUPPLEMENTAL_DEPFILE} ${arg_PP_EXTRA_ARGS}
-            VERBATIM)
+        list(APPEND args --supplementalDependencyFile ${arg_SUPPLEMENTAL_DEPFILE})
     endif ()
-
-    set(idl_includes)
-    foreach (dir ${arg_IDL_INCLUDES})
-        if (IS_ABSOLUTE ${dir})
-            list(APPEND idl_includes --include=${dir})
+    if (PROCESSOR_COUNT)
+        list(APPEND args --numOfJobs ${PROCESSOR_COUNT})
+    endif ()
+    foreach (i IN LISTS arg_IDL_INCLUDES)
+        if (IS_ABSOLUTE ${i})
+            list(APPEND args --include ${i})
         else ()
-            list(APPEND idl_includes --include=${CMAKE_CURRENT_SOURCE_DIR}/${dir})
+            list(APPEND args --include ${CMAKE_CURRENT_SOURCE_DIR}/${i})
         endif ()
     endforeach ()
+    foreach (i IN LISTS arg_PP_EXTRA_OUTPUT)
+        list(APPEND args --ppExtraOutput ${i})
+    endforeach ()
+    foreach (i IN LISTS arg_PP_EXTRA_ARGS)
+        list(APPEND args --ppExtraArgs ${i})
+    endforeach ()
 
     set(common_generator_dependencies
-        ${binding_generator}
-        ${WEBCORE_DIR}/bindings/scripts/CodeGenerator.pm
+        ${WEBCORE_DIR}/bindings/scripts/generate-bindings.pl
         ${SCRIPTS_BINDINGS}
-        ${arg_SUPPLEMENTAL_DEPFILE}
-        ${idl_attributes_file}
     )
-    list(APPEND common_generator_dependencies ${arg_PP_EXTRA_OUTPUT})
-
     if (EXISTS ${WEBCORE_DIR}/bindings/scripts/CodeGenerator${arg_GENERATOR}.pm)
         list(APPEND common_generator_dependencies ${WEBCORE_DIR}/bindings/scripts/CodeGenerator${arg_GENERATOR}.pm)
     endif ()
@@ -108,21 +113,32 @@
     if (EXISTS ${arg_BASE_DIR}/CodeGenerator${arg_GENERATOR}.pm)
         list(APPEND common_generator_dependencies ${arg_BASE_DIR}/CodeGenerator${arg_GENERATOR}.pm)
     endif ()
+    foreach (i IN LISTS common_generator_dependencies)
+        list(APPEND args --generatorDependency ${i})
+    endforeach ()
 
     set(gen_sources)
+    set(gen_headers)
     foreach (_file ${arg_INPUT_FILES})
         get_filename_component(_name ${_file} NAME_WE)
-
-        add_custom_command(
-            OUTPUT ${arg_DESTINATION}/JS${_name}.cpp ${arg_DESTINATION}/JS${_name}.h
-            MAIN_DEPENDENCY ${_file}
-            DEPENDS ${common_generator_dependencies}
-            COMMAND ${PERL_EXECUTABLE} ${binding_generator} --defines ${arg_FEATURES} --generator ${arg_GENERATOR} ${idl_includes} --outputDir ${arg_DESTINATION} --preprocessor "${CODE_GENERATOR_PREPROCESSOR}" --idlAttributesFile ${idl_attributes_file} ${_supplemental_dependency} ${_file}
-            WORKING_DIRECTORY ${arg_BASE_DIR}
-            VERBATIM)
         list(APPEND gen_sources ${arg_DESTINATION}/JS${_name}.cpp)
+        list(APPEND gen_headers ${arg_DESTINATION}/JS${_name}.h)
     endforeach ()
     set(${arg_OUTPUT_SOURCE} ${${arg_OUTPUT_SOURCE}} ${gen_sources} PARENT_SCOPE)
+    set(act_args)
+    if (${CMAKE_VERSION} VERSION_LESS 3.2)
+        set_source_files_properties(${gen_sources} ${gen_headers} PROPERTIES GENERATED 1)
+    else ()
+        list(APPEND act_args
+            BYPRODUCTS ${gen_sources} ${gen_headers}
+            USES_TERMINAL
+        )
+    endif ()
+    add_custom_target(${target}
+        COMMAND ${PERL_EXECUTABLE} ${binding_generator} ${args}
+        WORKING_DIRECTORY ${arg_BASE_DIR}
+        COMMENT "Generate bindings (${target})"
+        VERBATIM ${act_args})
 endfunction()
 
 macro(GENERATE_FONT_NAMES _infile)

Modified: trunk/Tools/ChangeLog (207616 => 207617)


--- trunk/Tools/ChangeLog	2016-10-20 13:18:09 UTC (rev 207616)
+++ trunk/Tools/ChangeLog	2016-10-20 14:34:24 UTC (rev 207617)
@@ -1,3 +1,28 @@
+2016-10-20  Fujii Hironori  <hironori.fu...@sony.com>
+
+        [CMake] CMake does not support the dep files for implicit dependency
+        https://bugs.webkit.org/show_bug.cgi?id=161433
+
+        Reviewed by Brent Fulgham.
+
+        Created a Perl script to generate all IDL bindings for CMake.
+        This script can regenerate outdated bindings by based on the
+        supplemental dependency and dep files created by
+        '--write-dependencies' switch of generate-bindings.pl.
+
+        add_custom_target is used to invoke the script instead of
+        add_custom_command because Ninja deletes all output files before
+        executing the command in case of add_custom_command.
+
+        USES_TERMINAL option of add_custom_target has two effects:
+        1) Not buffering output of the command
+        2) Invoking the command in the special Ninja pool which inhibits parallel build
+        One needs to use CMake 3.2 or later to enable this feature.
+
+        * DumpRenderTree/CMakeLists.txt: Specified a target name for
+        GENERATE_BINDINGS. Added dependency for the target.
+        * WebKitTestRunner/CMakeLists.txt: Ditto.
+
 2016-10-20  Manuel Rego Casasnovas  <r...@igalia.com>
 
         [GTK] Cannot build GTK+ with CUPS 2.* versions

Modified: trunk/Tools/DumpRenderTree/CMakeLists.txt (207616 => 207617)


--- trunk/Tools/DumpRenderTree/CMakeLists.txt	2016-10-20 13:18:09 UTC (rev 207616)
+++ trunk/Tools/DumpRenderTree/CMakeLists.txt	2016-10-20 14:34:24 UTC (rev 207617)
@@ -120,7 +120,7 @@
     "${WEBKIT_TESTRUNNER_UISCRIPTCONTEXT_DIR}/Bindings/UIScriptController.idl"
 )
 
-GENERATE_BINDINGS(
+GENERATE_BINDINGS(DumpRenderTreeBindings
     OUTPUT_SOURCE DumpRenderTree_SOURCES
     INPUT_FILES ${DumpRenderTree_IDL_FILES}
     BASE_DIR ${DUMP_RENDER_TREE_BINDINGS_DIR}
@@ -135,6 +135,7 @@
 
 add_executable(DumpRenderTree ${DumpRenderTree_SOURCES})
 target_link_libraries(DumpRenderTree ${DumpRenderTree_LIBRARIES})
+add_dependencies(DumpRenderTree DumpRenderTreeBindings)
 
 if (ENABLE_NETSCAPE_PLUGIN_API)
     add_library(TestNetscapePlugin SHARED ${TestNetscapePlugin_SOURCES})

Modified: trunk/Tools/WebKitTestRunner/CMakeLists.txt (207616 => 207617)


--- trunk/Tools/WebKitTestRunner/CMakeLists.txt	2016-10-20 13:18:09 UTC (rev 207616)
+++ trunk/Tools/WebKitTestRunner/CMakeLists.txt	2016-10-20 14:34:24 UTC (rev 207617)
@@ -97,7 +97,7 @@
     "${WEBKIT_TESTRUNNER_UISCRIPTCONTEXT_DIR}/Bindings/UIScriptController.idl"
 )
 
-GENERATE_BINDINGS(
+GENERATE_BINDINGS(WebKitTestRunnerInjectedBundleBindings
     OUTPUT_SOURCE WebKitTestRunnerInjectedBundle_SOURCES
     INPUT_FILES ${WebKitTestRunnerInjectedBundle_IDL_FILES}
     BASE_DIR ${WEBKIT_TESTRUNNER_INJECTEDBUNDLE_DIR}/Bindings
@@ -106,7 +106,7 @@
     DESTINATION ${DERIVED_SOURCES_DIR}/InjectedBundle
     GENERATOR TestRunner)
 
-GENERATE_BINDINGS(
+GENERATE_BINDINGS(WebKitTestRunnerBindings
     OUTPUT_SOURCE WebKitTestRunner_SOURCES
     INPUT_FILES ${WebKitTestRunner_IDL_FILES}
     BASE_DIR ${WEBKIT_TESTRUNNER_INJECTEDBUNDLE_DIR}/Bindings
@@ -122,9 +122,11 @@
 
 add_library(TestRunnerInjectedBundle SHARED ${WebKitTestRunnerInjectedBundle_SOURCES})
 target_link_libraries(TestRunnerInjectedBundle ${WebKitTestRunner_LIBRARIES})
+add_dependencies(TestRunnerInjectedBundle WebKitTestRunnerInjectedBundleBindings)
 
 add_executable(WebKitTestRunner ${WebKitTestRunner_SOURCES})
 target_link_libraries(WebKitTestRunner ${WebKitTestRunner_LIBRARIES})
+add_dependencies(WebKitTestRunner WebKitTestRunnerBindings)
 
 if (NOT APPLE)
     add_dependencies(WebKit2 ${ForwardingHeadersForWebKitTestRunner_NAME})
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to