Commit 47742ce6 authored by nbarth@chromium.org's avatar nbarth@chromium.org

IDL build: Split global object computation into core and modules

This completes the split!

Note that this deletes the top-level:
* bindings/generated.gypi
* bindings/idl.gypi
...and eliminates the variable bindings_output_dir, b/c we do not output
anything to there any longer!

One layering violation is:
constructors for interfaces in core need to know about
global objects defined in modules,
namely ServiceWorker, because some of these are exposed
to ServiceWorker.

This can be fixed by moving
ServiceWorkerGlobalScopeCoreConstructors.idl
to modules, which I'll do in a followup.

R=haraken
BUG=358074

Review URL: https://codereview.chromium.org/315003004

git-svn-id: svn://svn.chromium.org/blink/trunk@175554 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent e9da1f90
......@@ -8,7 +8,6 @@
],
'variables': {
'bindings_dir': '.',
'bindings_output_dir': '<(SHARED_INTERMEDIATE_DIR)/blink/bindings',
'bindings_unittest_files': [
'<@(bindings_v8_unittest_files)',
],
......
......@@ -11,6 +11,6 @@
],
'variables': {
'bindings_core_output_dir': '<(bindings_output_dir)/core',
'bindings_core_output_dir': '<(SHARED_INTERMEDIATE_DIR)/blink/bindings/core',
},
}
......@@ -10,6 +10,10 @@
'includes': [
# ../.. == Source
'../../bindings/bindings.gypi',
# FIXME: need info about modules for constructors on global objects
# http://crbug.com/358074
'../../bindings/modules/idl.gypi',
'../../bindings/modules/modules.gypi',
'../../bindings/scripts/scripts.gypi',
'../../core/core.gypi',
'core.gypi',
......@@ -18,13 +22,78 @@
],
'targets': [
################################################################################
{
'target_name': 'core_global_objects',
'type': 'none',
'actions': [{
'action_name': 'core_modules_global_objects',
'inputs': [
'<(bindings_scripts_dir)/compute_global_objects.py',
'<(bindings_scripts_dir)/utilities.py',
# Only look in main IDL files (exclude dependencies and testing,
# which should not define global objects).
'<(core_idl_files_list)',
'<@(core_idl_files)',
],
'outputs': [
'<(bindings_core_output_dir)/GlobalObjectsCore.pickle',
],
'action': [
'python',
'<(bindings_scripts_dir)/compute_global_objects.py',
'--idl-files-list',
'<(core_idl_files_list)',
'--write-file-only-if-changed',
'<(write_file_only_if_changed)',
'--',
'<(bindings_core_output_dir)/GlobalObjectsCore.pickle',
],
'message': 'Computing global objects in core',
}]
},
################################################################################
{
# FIXME: should be in modules/generated.gyp http://crbug.com/358074
'target_name': 'modules_global_objects',
'type': 'none',
'dependencies': [
'core_global_objects',
],
'actions': [{
'action_name': 'compute_modules_global_objects',
'inputs': [
'<(bindings_scripts_dir)/compute_global_objects.py',
'<(bindings_scripts_dir)/utilities.py',
# Only look in main IDL files (exclude dependencies and testing,
# which should not define global objects).
'<(modules_idl_files_list)',
'<@(modules_idl_files)',
],
'outputs': [
'<(bindings_modules_output_dir)/GlobalObjectsModules.pickle',
],
'action': [
'python',
'<(bindings_scripts_dir)/compute_global_objects.py',
'--idl-files-list',
'<(modules_idl_files_list)',
'--write-file-only-if-changed',
'<(write_file_only_if_changed)',
'--',
'<(bindings_core_output_dir)/GlobalObjectsCore.pickle',
'<(bindings_modules_output_dir)/GlobalObjectsModules.pickle',
],
'message': 'Computing global objects in modules',
}]
},
################################################################################
{
'target_name': 'core_global_constructors_idls',
'type': 'none',
'dependencies': [
# FIXME: should be core_global_objects http://crbug.com/358074
'../generated.gyp:global_objects',
'modules_global_objects',
],
'actions': [{
'action_name': 'generate_core_global_constructors_idls',
......@@ -35,7 +104,7 @@
# which should not appear on global objects).
'<(core_idl_files_list)',
'<@(core_idl_files)',
'<(bindings_output_dir)/GlobalObjects.pickle',
'<(bindings_modules_output_dir)/GlobalObjectsModules.pickle',
],
'outputs': [
'<@(core_global_constructors_generated_idl_files)',
......@@ -47,7 +116,7 @@
'--idl-files-list',
'<(core_idl_files_list)',
'--global-objects-file',
'<(bindings_output_dir)/GlobalObjects.pickle',
'<(bindings_modules_output_dir)/GlobalObjectsModules.pickle',
'--write-file-only-if-changed',
'<(write_file_only_if_changed)',
'--',
......
#
# Copyright (C) 2013 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * 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.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
# OWNER OR 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.
#
# Generate IDL bindings, together with auxiliary files
# (constructors on global objects, aggregate bindings files).
#
# Design doc: http://www.chromium.org/developers/design-documents/idl-build
{
'includes': [
'bindings.gypi',
'idl.gypi',
],
'targets': [
################################################################################
{
# FIXME: Generate separate core_global_objects
# http://crbug.com/358074
'target_name': 'global_objects',
'type': 'none',
'actions': [{
'action_name': 'compute_global_objects',
'inputs': [
'scripts/compute_global_objects.py',
'scripts/utilities.py',
# Only look in main IDL files (exclude dependencies and testing,
# which should not define global objects).
'<(main_interface_idl_files_list)',
'<@(main_interface_idl_files)',
],
'outputs': [
'<(bindings_output_dir)/GlobalObjects.pickle',
],
'action': [
'python',
'scripts/compute_global_objects.py',
'--idl-files-list',
'<(main_interface_idl_files_list)',
'--write-file-only-if-changed',
'<(write_file_only_if_changed)',
'--',
'<(bindings_output_dir)/GlobalObjects.pickle',
],
'message': 'Computing global objects',
}]
},
################################################################################
], # targets
}
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# IDL file lists; see: http://www.chromium.org/developers/web-idl-interfaces
{
'includes': [
'../core/core.gypi',
'../modules/modules.gypi',
],
'variables': {
# Main interface IDL files (excluding dependencies and testing)
# are included as properties on global objects, and in aggregate bindings
# FIXME: split into core vs. modules http://crbug.com/358074
'main_interface_idl_files': [
'<@(core_idl_files)',
'<@(modules_idl_files)',
],
# Write lists of main IDL files to a file, so that the command lines don't
# exceed OS length limits.
'main_interface_idl_files_list': '<|(main_interface_idl_files_list.tmp <@(main_interface_idl_files))',
},
}
......@@ -137,8 +137,7 @@
'target_name': 'modules_global_constructors_idls',
'type': 'none',
'dependencies': [
# FIXME: should be modules_global_objects http://crbug.com/358074
'../generated.gyp:global_objects',
'../core/generated.gyp:modules_global_objects',
],
'actions': [{
'action_name': 'generate_modules_global_constructors_idls',
......@@ -149,7 +148,7 @@
# which should not appear on global objects).
'<(modules_idl_files_list)',
'<@(modules_idl_files)',
'<(bindings_output_dir)/GlobalObjects.pickle',
'<(bindings_modules_output_dir)/GlobalObjectsModules.pickle',
],
'outputs': [
'<@(modules_global_constructors_generated_idl_files)',
......@@ -161,7 +160,7 @@
'--idl-files-list',
'<(modules_idl_files_list)',
'--global-objects-file',
'<(bindings_output_dir)/GlobalObjects.pickle',
'<(bindings_modules_output_dir)/GlobalObjectsModules.pickle',
'--write-file-only-if-changed',
'<(write_file_only_if_changed)',
'--',
......
......@@ -9,6 +9,6 @@
],
'variables': {
'bindings_modules_output_dir': '<(bindings_output_dir)/modules',
'bindings_modules_output_dir': '<(SHARED_INTERMEDIATE_DIR)/blink/bindings/modules',
},
}
......@@ -14,9 +14,10 @@ Design document: http://www.chromium.org/developers/design-documents/idl-build
import optparse
import os
import cPickle as pickle
import sys
from utilities import get_file_contents, idl_filename_to_interface_name, get_interface_extended_attributes_from_idl, read_file_to_list, write_pickle_file
from utilities import get_file_contents, idl_filename_to_interface_name, get_interface_extended_attributes_from_idl, read_file_to_list, read_pickle_files, write_pickle_file
GLOBAL_EXTENDED_ATTRIBUTES = frozenset([
'Global',
......@@ -25,7 +26,8 @@ GLOBAL_EXTENDED_ATTRIBUTES = frozenset([
def parse_options():
parser = optparse.OptionParser()
usage = 'Usage: %prog [options] [GlobalObjectsComponent.pickle]... [GlobalObjects.pickle]'
parser = optparse.OptionParser(usage=usage)
parser.add_option('--idl-files-list', help='file listing IDL files')
parser.add_option('--write-file-only-if-changed', type='int', help='if true, do not write an output file if it would be identical to the existing one, which avoids unnecessary rebuilds in ninja')
......@@ -36,10 +38,15 @@ def parse_options():
if options.write_file_only_if_changed is None:
parser.error('Must specify whether output files are only written if changed using --write-file-only-if-changed.')
options.write_file_only_if_changed = bool(options.write_file_only_if_changed)
if len(args) != 1:
parser.error('Must specify a single output pickle filename as argument.')
if not args:
parser.error('Must specify an output pickle filename as argument, '
'optionally preceeded by input pickle filenames.')
return options, args[0]
return options, args
def dict_union(dicts):
return dict((k, v) for d in dicts for k, v in d.iteritems())
def idl_file_to_global_names(idl_filename):
......@@ -72,7 +79,7 @@ def idl_file_to_global_names(idl_filename):
return [interface_name]
def interface_name_global_names(idl_files):
def idl_files_to_interface_name_global_names(idl_files):
"""Yields pairs (interface_name, global_names) found in IDL files."""
for idl_filename in idl_files:
interface_name = idl_filename_to_interface_name(idl_filename)
......@@ -84,14 +91,21 @@ def interface_name_global_names(idl_files):
################################################################################
def main():
options, global_objects_filename = parse_options()
options, args = parse_options()
# args = Input1, Input2, ..., Output
output_global_objects_filename = args.pop()
interface_name_global_names = dict_union(
existing_interface_name_global_names
for existing_interface_name_global_names in read_pickle_files(args))
# Input IDL files are passed in a file, due to OS command line length
# limits. This is generated at GYP time, which is ok b/c files are static.
idl_files = read_file_to_list(options.idl_files_list)
interface_name_global_names.update(
idl_files_to_interface_name_global_names(idl_files))
write_pickle_file(global_objects_filename,
dict(interface_name_global_names(idl_files)),
write_pickle_file(output_global_objects_filename,
interface_name_global_names,
options.write_file_only_if_changed)
......
......@@ -81,7 +81,7 @@ import cPickle as pickle
import optparse
import sys
from utilities import write_pickle_file
from utilities import read_pickle_files, write_pickle_file
INHERITED_EXTENDED_ATTRIBUTES = set([
'ActiveDOMObject',
......@@ -137,13 +137,6 @@ def dict_of_dicts_of_lists_update_or_append(existing, other):
# Computations
################################################################################
def read_interfaces_info(interfaces_info_individual_filenames):
# Read in individual info from files
for interfaces_info_individual_filename in interfaces_info_individual_filenames:
with open(interfaces_info_individual_filename) as interfaces_info_individual_file:
yield pickle.load(interfaces_info_individual_file)
def compute_inheritance_info(interface_name):
"""Compute inheritance information, namely ancestors and inherited extended attributes."""
def generate_ancestors(interface_name):
......@@ -259,7 +252,7 @@ def main():
options, args = parse_options()
# args = Input1, Input2, ..., Output
interfaces_info_filename = args.pop()
info_individuals = read_interfaces_info(args)
info_individuals = read_pickle_files(args)
compute_interfaces_info_overall(info_individuals)
write_pickle_file(interfaces_info_filename,
......
......@@ -38,6 +38,12 @@ def read_file_to_list(filename):
return [line.rstrip('\n') for line in f]
def read_pickle_files(pickle_filenames):
for pickle_filename in pickle_filenames:
with open(pickle_filename) as pickle_file:
yield pickle.load(pickle_file)
def write_file(new_text, destination_filename, only_if_changed):
if only_if_changed and os.path.isfile(destination_filename):
with open(destination_filename) as destination_file:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment