Home | History | Annotate | Download | only in mojo
      1 # Copyright 2013 The Chromium Authors. All rights reserved.
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 {
      6   'includes': [
      7     'mojom_bindings_generator_variables.gypi',
      8   ],
      9   'variables': {
     10     'variables': {
     11       'variables': {
     12         'for_blink%': 'false',
     13         'use_new_wrapper_types%': 'false',
     14       },
     15       'for_blink%': 'false',
     16       'use_new_wrapper_types%': 'false',
     17       'conditions': [
     18         ['for_blink=="true"', {
     19           'mojom_output_languages%': 'c++',
     20           'mojom_variant%': 'blink',
     21           'mojom_generator_wtf_arg%': [
     22             '--for_blink',
     23           ],
     24           'wtf_dependencies%': [
     25             '<(DEPTH)/mojo/mojo_public.gyp:mojo_cpp_bindings_wtf_support',
     26             '<(DEPTH)/third_party/WebKit/Source/wtf/wtf.gyp:wtf',
     27           ],
     28         }, {
     29           'mojom_output_languages%': 'c++,javascript,java',
     30           'mojom_variant%': 'none',
     31           'mojom_generator_wtf_arg%': [],
     32           'wtf_dependencies%': [],
     33         }],
     34         ['use_new_wrapper_types=="true"', {
     35           'mojom_generator_new_wrappers_arg%': [
     36             '--use_new_wrapper_types',
     37           ],
     38         }, {
     39           'mojom_generator_new_wrappers_arg%': [],
     40         }],
     41       ],
     42     },
     43     'for_blink%': '<(for_blink)',
     44     'use_new_wrapper_types%': '<(use_new_wrapper_types)',
     45     'mojom_variant%': '<(mojom_variant)',
     46     'mojom_generator_wtf_arg%': '<(mojom_generator_wtf_arg)',
     47     'mojom_generator_new_wrappers_arg%': '<(mojom_generator_new_wrappers_arg)',
     48     'wtf_dependencies%': '<(wtf_dependencies)',
     49     'mojom_output_languages%': '<(mojom_output_languages)',
     50     'mojom_typemaps%': [],
     51     'mojom_base_output_dir':
     52         '<!(python <(DEPTH)/build/inverse_depth.py <(DEPTH))',
     53     'mojom_generated_outputs': [
     54       '<!@(python <(DEPTH)/mojo/public/tools/bindings/mojom_list_outputs.py --basedir <(mojom_base_output_dir) --variant <(mojom_variant) <@(mojom_files))',
     55     ],
     56     'generated_typemap_file': '<(SHARED_INTERMEDIATE_DIR)/<(mojom_base_output_dir)/<(_target_name)_type_mappings',
     57     'mojom_include_path%': '<(DEPTH)',
     58     'require_interface_bindings%': 1,
     59   },
     60   # Given mojom files as inputs, generate sources.  These sources will be
     61   # exported to another target (via dependent_settings) to be compiled.  This
     62   # keeps code generation separate from compilation, allowing the same sources
     63   # to be compiled with multiple toolchains - target, NaCl, etc.
     64   'actions': [
     65     {
     66       'variables': {
     67         'java_out_dir': '<(PRODUCT_DIR)/java_mojo/<(_target_name)/src',
     68         'stamp_filename': '<(PRODUCT_DIR)/java_mojo/<(_target_name)/<(_target_name).stamp',
     69       },
     70       'action_name': '<(_target_name)_mojom_bindings_stamp',
     71       # The java output directory is deleted to ensure that the java library
     72       # doesn't try to compile stale files.
     73       'action': [
     74         'python', '<(DEPTH)/build/rmdir_and_stamp.py',
     75         '<(java_out_dir)',
     76         '<(stamp_filename)',
     77       ],
     78       'inputs': [
     79         '<@(mojom_files)',
     80       ],
     81       'outputs': [ '<(stamp_filename)' ],
     82     },
     83     {
     84       'variables': {
     85         'output': '<(generated_typemap_file)',
     86       },
     87       'action_name': '<(_target_name)_type_mappings',
     88       'action': [
     89         'python', '<(DEPTH)/mojo/public/tools/bindings/generate_type_mappings.py',
     90         '--output',
     91         '<(output)',
     92         '<!@(python <(DEPTH)/mojo/public/tools/bindings/format_typemap_generator_args.py <@(mojom_typemaps))',
     93       ],
     94       'inputs':[
     95         '<(DEPTH)/mojo/public/tools/bindings/generate_type_mappings.py',
     96       ],
     97       'outputs': [ '<(output)' ],
     98     },
     99     {
    100       'action_name': '<(_target_name)_mojom_bindings_generator',
    101       'variables': {
    102         'java_out_dir': '<(PRODUCT_DIR)/java_mojo/<(_target_name)/src',
    103         'stamp_filename': '<(PRODUCT_DIR)/java_mojo/<(_target_name)/<(_target_name).stamp',
    104         'mojom_import_args%': [
    105          '-I<(DEPTH)',
    106          '-I<(DEPTH)/mojo/services',
    107          '-I<(mojom_include_path)',
    108         ],
    109       },
    110       'inputs': [
    111         '<@(mojom_bindings_generator_sources)',
    112         '<@(mojom_files)',
    113         '<(stamp_filename)',
    114         '<(generated_typemap_file)',
    115         '<(SHARED_INTERMEDIATE_DIR)/mojo/public/tools/bindings/cpp_templates.zip',
    116         '<(SHARED_INTERMEDIATE_DIR)/mojo/public/tools/bindings/java_templates.zip',
    117         '<(SHARED_INTERMEDIATE_DIR)/mojo/public/tools/bindings/js_templates.zip',
    118       ],
    119       'outputs': [
    120         '<@(mojom_generated_outputs)',
    121       ],
    122       'action': [
    123         'python', '<@(mojom_bindings_generator)',
    124         '--use_bundled_pylibs', 'generate',
    125         '<@(mojom_files)',
    126         '-d', '<(DEPTH)',
    127         '<@(mojom_import_args)',
    128         '-o', '<(SHARED_INTERMEDIATE_DIR)',
    129         '--java_output_directory=<(java_out_dir)',
    130         '--variant', '<(mojom_variant)',
    131         '-g', '<(mojom_output_languages)',
    132         '--typemap',
    133         '<(generated_typemap_file)',
    134         '<@(mojom_generator_wtf_arg)',
    135         '<@(mojom_generator_new_wrappers_arg)',
    136         '--bytecode_path',
    137         '<(SHARED_INTERMEDIATE_DIR)/mojo/public/tools/bindings',
    138       ],
    139       'message': 'Generating Mojo bindings from <@(mojom_files)',
    140     }
    141   ],
    142   'conditions': [
    143     ['require_interface_bindings==1', {
    144       'dependencies': [
    145         '<(DEPTH)/base/base.gyp:base',
    146         '<(DEPTH)/mojo/mojo_public.gyp:mojo_interface_bindings_generation',
    147       ],
    148     }],
    149   ],
    150   'dependencies': [
    151     '<(DEPTH)/mojo/public/tools/bindings/bindings.gyp:precompile_mojom_bindings_generator_templates',
    152     '<@(wtf_dependencies)',
    153   ],
    154   'export_dependent_settings': [
    155     '<@(wtf_dependencies)',
    156   ],
    157   # Prevent the generated sources from being injected into the "all" target by
    158   # preventing the code generator from being directly depended on by the "all"
    159   # target.
    160   'suppress_wildcard': '1',
    161   'hard_dependency': '1',
    162   'direct_dependent_settings': {
    163     # A target directly depending on this action will compile the generated
    164     # sources.
    165     'sources': [
    166       '<@(mojom_generated_outputs)',
    167     ],
    168     # Include paths needed to compile the generated sources into a library.
    169     'include_dirs': [
    170       '<(DEPTH)',
    171       '<(SHARED_INTERMEDIATE_DIR)',
    172     ],
    173     # Make sure the generated header files are available for any static library
    174     # that depends on a static library that depends on this generator.
    175     'hard_dependency': 1,
    176     'direct_dependent_settings': {
    177       # Include paths needed to find the generated header files and their
    178       # transitive dependancies when using the library.
    179       'include_dirs': [
    180         '<(DEPTH)',
    181         '<(SHARED_INTERMEDIATE_DIR)',
    182       ],
    183       'variables': {
    184         'generated_src_dirs': [
    185           '<(PRODUCT_DIR)/java_mojo/<(_target_name)/src',
    186         ],
    187         'additional_input_paths': [
    188           '<@(mojom_bindings_generator_sources)',
    189           '<@(mojom_files)',
    190         ],
    191         'mojom_generated_sources': [ '<@(mojom_generated_outputs)' ],
    192       },
    193     }
    194   },
    195 }
    196