Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / content / browser / tracing / tracing_resources.gyp
blobfcd132fadd4d85971a204d0b67e513c9803680d7
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.
6   'variables': {
7     'trace_viewer_src_dir': '../../../third_party/trace-viewer',
8     'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/content/browser/tracing',
9   },
10   'targets': [
11     {
12       # GN version: //content/browser/tracing:generate_tracing_grd
13       'target_name': 'generate_tracing_grd',
14       'type': 'none',
15       'dependencies': [
16         '<(trace_viewer_src_dir)/trace_viewer.gyp:generate_about_tracing',
17       ],
18       'actions': [
19         {
20           'action_name': 'generate_tracing_grd',
21           'script_name': 'generate_trace_viewer_grd.py',
22           'input_pages': [
23             '<(SHARED_INTERMEDIATE_DIR)/content/browser/tracing/about_tracing.html',
24             '<(SHARED_INTERMEDIATE_DIR)/content/browser/tracing/about_tracing.js'
25           ],
26           'inputs': [
27             '<@(_script_name)',
28             '<@(_input_pages)'
29           ],
30           'outputs': [
31             '<(SHARED_INTERMEDIATE_DIR)/content/browser/tracing/tracing_resources.grd'
32           ],
33           'action': [
34             'python', '<@(_script_name)', '<@(_input_pages)', '--output', '<@(_outputs)'
35           ]
36         }
37       ]
38     },
40     {
41       # GN version: //content/browser/tracing:resources
42       'target_name': 'tracing_resources',
43       'type': 'none',
44       'dependencies': [
45         '<(trace_viewer_src_dir)/trace_viewer.gyp:generate_about_tracing',
46         'generate_tracing_grd',
47       ],
48       'variables': {
49         'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/content/browser/tracing',
50       },
51       'actions': [
52         {
53           'action_name': 'tracing_resources',
54           # This can't use build/grit_action.gypi because the grd file
55           # is generated at build time, so the trick of using grit_info to get
56           # the real inputs/outputs at GYP time isn't possible.
57           'variables': {
58             'grit_cmd': ['python', '../../../tools/grit/grit.py'],
59             'grit_grd_file': '<(SHARED_INTERMEDIATE_DIR)/content/browser/tracing/tracing_resources.grd',
60             'grit_rc_header_format%': '',
62             'conditions': [
63               # These scripts can skip writing generated files if they are
64               # identical to the already existing files, which avoids further
65               # build steps, like recompilation. However, a dependency (earlier
66               # build step) having a newer timestamp than an output (later
67               # build step) confuses some build systems, so only use this on
68               # ninja, which explicitly supports this use case (gyp turns all
69               # actions into ninja restat rules).
70               ['"<(GENERATOR)"=="ninja"', {
71                 'write_only_new': '1',
72               }, {
73                 'write_only_new': '0',
74               }],
75             ],
76           },
77           'inputs': [
78             '<(grit_grd_file)',
79             '<!@pymod_do_main(grit_info --inputs)',
80           ],
81           'outputs': [
82             '<(grit_out_dir)/grit/tracing_resources.h',
83             '<(grit_out_dir)/tracing_resources.pak',
84           ],
85           'action': ['<@(grit_cmd)',
86                      '-i', '<(grit_grd_file)', 'build',
87                      '-f', '<(DEPTH)/tools/gritsettings/resource_ids',
88                      '-o', '<(grit_out_dir)',
89                      '--write-only-new=<(write_only_new)',
90                      '-D', 'SHARED_INTERMEDIATE_DIR=<(SHARED_INTERMEDIATE_DIR)',
91                      '<@(grit_defines)',
92                      '<@(grit_rc_header_format)'],
93           'message': 'Generating resources from <(grit_grd_file)',
94         }
95       ],
96       'includes': [ '../../../build/grit_target.gypi' ]
97     }
98   ]