Home | History | Annotate | Download | only in bindings
      1 #
      2 # Copyright (C) 2013 Google Inc. All rights reserved.
      3 #
      4 # Redistribution and use in source and binary forms, with or without
      5 # modification, are permitted provided that the following conditions are
      6 # met:
      7 #
      8 #     * Redistributions of source code must retain the above copyright
      9 # notice, this list of conditions and the following disclaimer.
     10 #     * Redistributions in binary form must reproduce the above
     11 # copyright notice, this list of conditions and the following disclaimer
     12 # in the documentation and/or other materials provided with the
     13 # distribution.
     14 #     * Neither the name of Google Inc. nor the names of its
     15 # contributors may be used to endorse or promote products derived from
     16 # this software without specific prior written permission.
     17 #
     18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     29 #
     30 
     31 {
     32   'includes': [
     33     '../build/scripts/scripts.gypi',
     34     '../build/win/precompile.gypi',
     35     '../build/scripts/scripts.gypi',
     36     '../core/core.gypi',
     37     '../modules/modules.gypi',
     38     'bindings.gypi',
     39   ],
     40 
     41   'variables': {
     42     'main_idl_files': [
     43       '<@(core_idl_files)',
     44       '<@(modules_idl_files)',
     45       '<@(svg_idl_files)',
     46     ],
     47     'support_idl_files': [
     48       '<@(webcore_testing_support_idl_files)',
     49       '<@(modules_testing_support_idl_files)',
     50     ],
     51     'generated_support_idl_files': [
     52       '<@(generated_webcore_testing_support_idl_files)',
     53     ],
     54     'compiler_module_files': [
     55         'scripts/idl_compiler.py',
     56         '<(DEPTH)/third_party/ply/lex.py',
     57         '<(DEPTH)/third_party/ply/yacc.py',
     58         # jinja2/__init__.py contains version string, so sufficient for package
     59         '<(DEPTH)/third_party/jinja2/__init__.py',
     60         '<(DEPTH)/third_party/markupsafe/__init__.py',  # jinja2 dep
     61         '<(DEPTH)/tools/idl_parser/idl_lexer.py',
     62         '<(DEPTH)/tools/idl_parser/idl_node.py',
     63         '<(DEPTH)/tools/idl_parser/idl_parser.py',
     64         'scripts/blink_idl_lexer.py',
     65         'scripts/blink_idl_parser.py',
     66         'scripts/code_generator_v8.py',
     67         'scripts/idl_definitions.py',
     68         'scripts/idl_definitions_builder.py',
     69         'scripts/idl_reader.py',
     70         'scripts/idl_validator.py',
     71         'scripts/interface_dependency_resolver.py',
     72         'scripts/v8_attributes.py',
     73         'scripts/v8_callback_interface.py',
     74         'scripts/v8_interface.py',
     75         'scripts/v8_types.py',
     76         'scripts/v8_utilities.py',
     77     ],
     78     'code_generator_template_files': [
     79         'templates/attributes.cpp',
     80         'templates/callback_interface.cpp',
     81         'templates/callback_interface.h',
     82         'templates/interface_base.cpp',
     83         'templates/interface.cpp',
     84         'templates/interface.h',
     85     ],
     86 
     87     'bindings_output_dir': '<(SHARED_INTERMEDIATE_DIR)/blink/bindings',
     88     'generated_global_constructors_idl_files': [
     89          '<(SHARED_INTERMEDIATE_DIR)/blink/WindowConstructors.idl',
     90          '<(SHARED_INTERMEDIATE_DIR)/blink/WorkerGlobalScopeConstructors.idl',
     91          '<(SHARED_INTERMEDIATE_DIR)/blink/SharedWorkerGlobalScopeConstructors.idl',
     92          '<(SHARED_INTERMEDIATE_DIR)/blink/DedicatedWorkerGlobalScopeConstructors.idl',
     93          '<(SHARED_INTERMEDIATE_DIR)/ServiceWorkerGlobalScopeConstructors.idl',
     94     ],
     95 
     96     'conditions': [
     97       ['OS=="win" and buildtype=="Official"', {
     98         # On windows official release builds, we try to preserve symbol space.
     99         'derived_sources_aggregate_files': [
    100           '<(bindings_output_dir)/V8DerivedSourcesAll.cpp',
    101         ],
    102       },{
    103         'derived_sources_aggregate_files': [
    104           '<(bindings_output_dir)/V8DerivedSources01.cpp',
    105           '<(bindings_output_dir)/V8DerivedSources02.cpp',
    106           '<(bindings_output_dir)/V8DerivedSources03.cpp',
    107           '<(bindings_output_dir)/V8DerivedSources04.cpp',
    108           '<(bindings_output_dir)/V8DerivedSources05.cpp',
    109           '<(bindings_output_dir)/V8DerivedSources06.cpp',
    110           '<(bindings_output_dir)/V8DerivedSources07.cpp',
    111           '<(bindings_output_dir)/V8DerivedSources08.cpp',
    112           '<(bindings_output_dir)/V8DerivedSources09.cpp',
    113           '<(bindings_output_dir)/V8DerivedSources10.cpp',
    114           '<(bindings_output_dir)/V8DerivedSources11.cpp',
    115           '<(bindings_output_dir)/V8DerivedSources12.cpp',
    116           '<(bindings_output_dir)/V8DerivedSources13.cpp',
    117           '<(bindings_output_dir)/V8DerivedSources14.cpp',
    118           '<(bindings_output_dir)/V8DerivedSources15.cpp',
    119           '<(bindings_output_dir)/V8DerivedSources16.cpp',
    120           '<(bindings_output_dir)/V8DerivedSources17.cpp',
    121           '<(bindings_output_dir)/V8DerivedSources18.cpp',
    122           '<(bindings_output_dir)/V8DerivedSources19.cpp',
    123         ],
    124       }],
    125       # The bindings generator can not write generated files if they are identical
    126       # to the already existing file  that way they don't need to be recompiled.
    127       # However, a reverse dependency having a newer timestamp than a
    128       # generated binding can confuse some build systems, so only use this on
    129       # ninja which explicitly supports this use case (gyp turns all actions into
    130       # ninja restat rules).
    131       ['"<(GENERATOR)"=="ninja"', {
    132         'write_file_only_if_changed': '--write-file-only-if-changed 1',
    133       },{
    134         'write_file_only_if_changed': '--write-file-only-if-changed 0',
    135       }],
    136     ],
    137   },
    138 
    139   'target_defaults': {
    140     'variables': {
    141       'optimize': 'max',
    142     },
    143   },
    144 
    145   'targets': [{
    146     'target_name': 'interface_dependencies',
    147     'type': 'none',
    148     'actions': [{
    149       'action_name': 'compute_interface_dependencies',
    150       'variables': {
    151         # Write sources into a file, so that the action command line won't
    152         # exceed OS limits.
    153         'main_idl_files_list': '<|(main_idl_files_list.tmp <@(main_idl_files))',
    154         'support_idl_files_list': '<|(support_idl_files_list.tmp <@(support_idl_files))',
    155       },
    156       'inputs': [
    157         'scripts/compute_dependencies.py',
    158         '<(main_idl_files_list)',
    159         '<@(main_idl_files)',
    160         '<(support_idl_files_list)',
    161         '<@(support_idl_files)',
    162        ],
    163        'outputs': [
    164          '<(SHARED_INTERMEDIATE_DIR)/blink/InterfaceDependencies.txt',
    165          '<(SHARED_INTERMEDIATE_DIR)/blink/BindingsDerivedSources.txt',
    166          '<@(generated_global_constructors_idl_files)',
    167          '<(SHARED_INTERMEDIATE_DIR)/blink/EventInterfaces.in',
    168        ],
    169        'msvs_cygwin_shell': 0,
    170        'action': [
    171          'python',
    172          'scripts/compute_dependencies.py',
    173          '--main-idl-files-list',
    174          '<(main_idl_files_list)',
    175          '--support-idl-files-list',
    176          '<(support_idl_files_list)',
    177          '--interface-dependencies-file',
    178          '<(SHARED_INTERMEDIATE_DIR)/blink/InterfaceDependencies.txt',
    179          '--bindings-derived-sources-file',
    180          '<(SHARED_INTERMEDIATE_DIR)/blink/BindingsDerivedSources.txt',
    181          '--window-constructors-file',
    182          '<(SHARED_INTERMEDIATE_DIR)/blink/WindowConstructors.idl',
    183          '--workerglobalscope-constructors-file',
    184          '<(SHARED_INTERMEDIATE_DIR)/blink/WorkerGlobalScopeConstructors.idl',
    185          '--sharedworkerglobalscope-constructors-file',
    186          '<(SHARED_INTERMEDIATE_DIR)/blink/SharedWorkerGlobalScopeConstructors.idl',
    187          '--dedicatedworkerglobalscope-constructors-file',
    188          '<(SHARED_INTERMEDIATE_DIR)/blink/DedicatedWorkerGlobalScopeConstructors.idl',
    189          '--serviceworkerglobalscope-constructors-file',
    190          '<(SHARED_INTERMEDIATE_DIR)/ServiceWorkerGlobalScopeConstructors.idl',
    191          '--event-names-file',
    192          '<(SHARED_INTERMEDIATE_DIR)/blink/EventInterfaces.in',
    193          '<@(write_file_only_if_changed)',
    194        ],
    195        'message': 'Resolving partial interfaces dependencies in all IDL files',
    196       }]
    197     },
    198     {
    199       'target_name': 'bindings_sources',
    200       'type': 'none',
    201       # The 'binding' rule generates .h files, so mark as hard_dependency, per:
    202       # https://code.google.com/p/gyp/wiki/InputFormatReference#Linking_Dependencies
    203       'hard_dependency': 1,
    204       'dependencies': [
    205         'interface_dependencies',
    206         '../config.gyp:config',
    207         '../core/core_derived_sources.gyp:generate_test_support_idls',
    208       ],
    209       'sources': [
    210         '<@(main_idl_files)',
    211         '<@(support_idl_files)',
    212         '<@(generated_support_idl_files)',
    213       ],
    214       'rules': [{
    215         'rule_name': 'binding',
    216         'extension': 'idl',
    217         'msvs_external_rule': 1,
    218         'inputs': [
    219           'scripts/generate_bindings.pl',
    220           'scripts/code_generator_v8.pm',
    221           'scripts/idl_parser.pm',
    222           'scripts/idl_serializer.pm',
    223           '../build/scripts/preprocessor.pm',
    224           'IDLExtendedAttributes.txt',
    225           # FIXME: If the dependency structure changes, we rebuild all files,
    226           # since we're not computing dependencies file-by-file in the build.
    227           '<(SHARED_INTERMEDIATE_DIR)/blink/InterfaceDependencies.txt',
    228           # FIXME: Similarly, if any partial interface changes, rebuild
    229           # everything, since every IDL potentially depends on them, because
    230           # we're not computing dependencies file-by-file.
    231           #
    232           # If a new partial interface is added, need to regyp to update these
    233           # dependencies, as these are computed statically at gyp runtime.
    234           '<!@pymod_do_main(list_idl_files_with_partial_interface <@(main_idl_files) <@(support_idl_files))',
    235           # Generated IDLs are all partial interfaces, hence everything
    236           # potentially depends on them.
    237           '<@(generated_global_constructors_idl_files)',
    238         ],
    239         'outputs': [
    240           '<(bindings_output_dir)/V8<(RULE_INPUT_ROOT).cpp',
    241           '<(bindings_output_dir)/V8<(RULE_INPUT_ROOT).h',
    242         ],
    243         'variables': {
    244           # IDL include paths. The generator will search recursively for IDL
    245           # files under these locations.
    246           'generator_include_dirs': [
    247             '--include', '../core',
    248             '--include', '../modules',
    249             '--include', '<(SHARED_INTERMEDIATE_DIR)/blink',
    250           ],
    251           # Hook for embedders to specify extra directories to find IDL files.
    252           'extra_blink_generator_include_dirs%': [],
    253         },
    254         'msvs_cygwin_shell': 0,
    255         # sanitize-win-build-log.sed uses a regex which matches this command
    256         # line (Perl script + .idl file being processed).
    257         # Update that regex if command line changes (other than changing flags)
    258         'action': [
    259           '<(perl_exe)',
    260           '-w',
    261           '-Iscripts',
    262           '-I../build/scripts',
    263           '-I<(DEPTH)/third_party/JSON/out/lib/perl5',
    264           'scripts/generate_bindings.pl',
    265           '--outputDir',
    266           '<(bindings_output_dir)',
    267           '--idlAttributesFile',
    268           'IDLExtendedAttributes.txt',
    269           '<@(generator_include_dirs)',
    270           '<@(extra_blink_generator_include_dirs)',
    271           '--interfaceDependenciesFile',
    272           '<(SHARED_INTERMEDIATE_DIR)/blink/InterfaceDependencies.txt',
    273           '--additionalIdlFiles',
    274           # Generated IDL files aren't listed in InterfaceDependencies.txt,
    275           # b/c they aren't available at GYP run time, so we need to sort them
    276           # manually, depending on whether they are (main) interface files,
    277           # for which we generate bindings, or dependencies, for which we don't.
    278           # generated_support_idl_files are main interfaces, so generate
    279           # bindings, but generated_global_constructors_idl_files are all
    280           # partial interfaces, so don't (b/c generated by dependents).
    281           '<(generated_support_idl_files)',
    282           '<@(preprocessor)',
    283           '<@(write_file_only_if_changed)',
    284           '<(RULE_INPUT_PATH)',
    285         ],
    286         'message': 'Generating binding from <(RULE_INPUT_PATH)',
    287       }],
    288     },
    289     {
    290       'target_name': 'bindings_derived_sources',
    291       'type': 'none',
    292       'dependencies': [
    293         'interface_dependencies',
    294         'bindings_sources',
    295       ],
    296       'actions': [{
    297         'action_name': 'derived_sources_all_in_one',
    298         'inputs': [
    299           '../build/scripts/action_derivedsourcesallinone.py',
    300           '<(SHARED_INTERMEDIATE_DIR)/blink/BindingsDerivedSources.txt',
    301         ],
    302         'outputs': [
    303           '<@(derived_sources_aggregate_files)',
    304         ],
    305         'action': [
    306           'python',
    307           '../build/scripts/action_derivedsourcesallinone.py',
    308           '<(SHARED_INTERMEDIATE_DIR)/blink/BindingsDerivedSources.txt',
    309           '--',
    310           '<@(derived_sources_aggregate_files)',
    311         ],
    312         'message': 'Generating bindings derived sources',
    313       }],
    314     },
    315   ],
    316 }
    317