Modified: trunk/Source/WebCore/CMakeLists.txt (206971 => 206972)
--- trunk/Source/WebCore/CMakeLists.txt 2016-10-09 23:11:56 UTC (rev 206971)
+++ trunk/Source/WebCore/CMakeLists.txt 2016-10-10 00:38:06 UTC (rev 206972)
@@ -3630,7 +3630,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}
@@ -3646,7 +3646,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}
@@ -3655,6 +3655,9 @@
DESTINATION ${DERIVED_SOURCES_WEBCORE_DIR}
GENERATOR JS)
+# WebCoreTestSupportBindings needs InternalSettingsGenerated.idl
+add_dependencies(WebCoreTestSupportBindings WebCoreDerivedSources)
+
# WebCore JS Builtins
set(WebCore_BUILTINS_SOURCES
@@ -3800,7 +3803,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 ()
@@ -3831,7 +3834,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)
Added: trunk/Source/WebCore/bindings/scripts/generate-bindings-all.pl (0 => 206972)
--- trunk/Source/WebCore/bindings/scripts/generate-bindings-all.pl (rev 0)
+++ trunk/Source/WebCore/bindings/scripts/generate-bindings-all.pl 2016-10-10 00:38:06 UTC (rev 206972)
@@ -0,0 +1,199 @@
+#!/usr/bin/perl -w
+#
+# 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 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);
+
+my @idlFiles;
+open(my $fh, '<', $idlFilesList) or die "Cannot open $idlFilesList";
+@idlFiles = <$fh>;
+close($fh) or die;
+s/\r?\n?$// for @idlFiles;
+
+my %supplementedIdlFiles;
+if ($supplementalDependencyFile) {
+ my @output = ($supplementalDependencyFile, @ppExtraOutput);
+ my @deps = (@idlFiles, @generatorDependency);
+ if (needsUpdate(\@output, \@deps)) {
+ my @args = ('--defines', $defines,
+ '--idlFilesList', $idlFilesList,
+ '--supplementalDependencyFile', $supplementalDependencyFile,
+ @ppExtraArgs);
+ print("Preprocess IDL\n");
+ system($perl, "$scriptDir/preprocess-idls.pl", @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 = ('--defines', $defines,
+ '--generator', $generator,
+ '--outputDir', $outputDirectory,
+ '--preprocessor', quoteCommand($preprocessor),
+ '--idlAttributesFile', $idlAttributesFile,
+ '--write-dependencies');
+push @args, map { ('--include', $_) } @idlDirectories;
+push @args, '--supplementalDependencyFile', $supplementalDependencyFile if $supplementalDependencyFile;
+
+my %directoryCache;
+buildDirectoryCache();
+
+my $queue = Thread::Queue->new(@idlFiles);
+my $abort :shared = 0;
+
+my @threadPool = map { threads->create(\&worker) } (1 .. $numOfJobs);
+$_->join for @threadPool;
+exit $abort;
+
+sub needsUpdate
+{
+ my ($objects, $depends) = @_;
+ my $oldestObject;
+ my $oldestObjectTime;
+ for (@$objects) {
+ return 1 if !-f;
+ my $m = mtime($_);
+ if (!defined $oldestObjectTime || $m < $oldestObjectTime) {
+ $oldestObject = $_;
+ $oldestObjectTime = $m;
+ }
+ }
+ for (@$depends) {
+ die "Missing required dependency: $_" if !-f;
+ my $m = mtime($_);
+ if ($oldestObjectTime < $m) {
+ # print "$_ is newer than $oldestObject\n";
+ return 1;
+ }
+ }
+ return 0;
+}
+
+sub mtime
+{
+ my ($file) = @_;
+ return (stat $file)[9];
+}
+
+sub worker {
+ while (my $file = $queue->dequeue_nb()) {
+ last if $abort;
+ eval {
+ my ($filename, $dirs, $suffix) = fileparse($file, '.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 = ($file,
+ $idlAttributesFile,
+ @generatorDependency,
+ @{$supplementedIdlFiles{$file} or []},
+ implicitDependencies($depFile));
+ if (needsUpdate(\@output, \@deps)) {
+ print "$filename$suffix\n";
+ system($perl, "$scriptDir/generate-bindings.pl", @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 quoteCommand
+{
+ use Config;
+ if ($Config::Config{osname} eq 'MSWin32') {
+ return map {
+ s/\\/\\\\/g;
+ s/\"/\\\"/g;
+ "\"$_\"";
+ } @_;
+ }
+ return @_;
+}
Property changes on: trunk/Source/WebCore/bindings/scripts/generate-bindings-all.pl
___________________________________________________________________
Modified: trunk/Source/cmake/WebKitMacros.cmake (206971 => 206972)
--- trunk/Source/cmake/WebKitMacros.cmake 2016-10-09 23:11:56 UTC (rev 206971)
+++ trunk/Source/cmake/WebKitMacros.cmake 2016-10-10 00:38:06 UTC (rev 206972)
@@ -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)