| OLD | NEW |
| (Empty) |
| 1 # Copyright 2015 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 # Generates a header with preprocessor defines specified by the build file. | |
| 6 # | |
| 7 # The canonical documentation is in build/buildflag_header.gni. You should | |
| 8 # write the GN build, get it working, and then transform it into GYP. | |
| 9 # | |
| 10 # In every target that uses your generated header you must include a dependency | |
| 11 # on the GYP target that generates the header (this is implicit in GN). | |
| 12 # Otherwise, clean builds may not necessarily create the header before the | |
| 13 # source code is compiled. | |
| 14 # | |
| 15 # Assuming your GN code looks like this: | |
| 16 # | |
| 17 # buildflag_header("foo_features") { | |
| 18 # header = "foo_features.h" | |
| 19 # flags = [ | |
| 20 # "ENABLE_DOOM_MELON=$enable_doom_melon", | |
| 21 # "ENABLE_SPACE_LASER=true", | |
| 22 # "SPAM_SERVER_URL=\"http://www.example.com/\"", | |
| 23 # ] | |
| 24 # } | |
| 25 # | |
| 26 # Write a GYP target like this: | |
| 27 # | |
| 28 # { | |
| 29 # # GN version: //foo:foo_features | |
| 30 # 'target_name': 'foo_foo_features', | |
| 31 # 'includes': [ '../build/buildflag_header.gypi' ], | |
| 32 # 'variables': { | |
| 33 # 'buildflag_header_path': 'foo/foo_features.h', | |
| 34 # 'buildflag_flags': [ | |
| 35 # 'ENABLE_DOOM_MELON=<(enable_doom_melon)', | |
| 36 # 'ENABLE_SPACE_LASER=true', | |
| 37 # 'SPAM_SERVER_URL="http://www.example.com/"', | |
| 38 # ], | |
| 39 # }, | |
| 40 # } | |
| 41 # | |
| 42 # Variables | |
| 43 # | |
| 44 # target_name | |
| 45 # Base this on the GN label, replacing / and : with _ to make it globally | |
| 46 # unique. | |
| 47 # | |
| 48 # buildflag_header_path | |
| 49 # This must be the full path to the header from the source root. In GN | |
| 50 # you only say "features.h" and it uses the BUILD file's path implicitly. | |
| 51 # Use the path to BUILD.gn followed by your header name to produce the | |
| 52 # same output file. | |
| 53 # | |
| 54 # buildflag_flags (optional) | |
| 55 # List of the same format as GN's "flags". To expand variables, use | |
| 56 # "<(foo)" where GN would have used "$foo". | |
| 57 # | |
| 58 # includes | |
| 59 # List the relative path to build/buildflag_header.gypi from the .gyp | |
| 60 # file including this code, Note: If your code is in a .gypi file in a | |
| 61 # different directory, this must be relative to the .gyp including your | |
| 62 # file. | |
| 63 # | |
| 64 # | |
| 65 # Grit defines | |
| 66 # | |
| 67 # Follow the same advice as in the buildflag_header.gni, except on the grit | |
| 68 # action use the variable name 'grit_additional_defines' and explicitly add a | |
| 69 # '-D' in front: | |
| 70 # | |
| 71 # 'grit_grd_file': 'foo.grd', | |
| 72 # 'grit_additional_defines': [ | |
| 73 # '-D', 'enable_doom_melon=<(enable_doom_melon)', | |
| 74 # ], | |
| 75 # | |
| 76 # Put shared lists of defines in a .gypi. | |
| 77 | |
| 78 { | |
| 79 'type': 'none', | |
| 80 'hard_dependency': 1, | |
| 81 | |
| 82 'actions': [ | |
| 83 { | |
| 84 'action_name': 'buildflag_header', | |
| 85 'variables': { | |
| 86 # Default these values to empty if they're not defined. | |
| 87 'variables': { | |
| 88 'buildflag_flags%': [], | |
| 89 }, | |
| 90 | |
| 91 # Writes the flags to a response file with a name based on the name of | |
| 92 # this target. | |
| 93 'response_file_name': '<|(<(_target_name)_buildflag_header.rsp --flags <
@(buildflag_flags))', | |
| 94 | |
| 95 'build_header_script': '<(DEPTH)/build/write_buildflag_header.py', | |
| 96 }, | |
| 97 | |
| 98 'message': 'Generating build header.', | |
| 99 | |
| 100 'inputs': [ | |
| 101 '<(build_header_script)', | |
| 102 '<(response_file_name)', | |
| 103 ], | |
| 104 | |
| 105 'outputs': [ | |
| 106 '<(SHARED_INTERMEDIATE_DIR)/<(buildflag_header_path)', | |
| 107 ], | |
| 108 | |
| 109 'action': [ | |
| 110 'python', '<(build_header_script)', | |
| 111 '--output', '<(buildflag_header_path)', | |
| 112 '--rulename', '<(_target_name)', | |
| 113 '--gen-dir', '<(SHARED_INTERMEDIATE_DIR)', | |
| 114 '--definitions', '<(response_file_name)', | |
| 115 ], | |
| 116 } | |
| 117 ], | |
| 118 | |
| 119 # Allow the file to be included based on the given buildflag_header_path. | |
| 120 'direct_dependent_settings': { | |
| 121 'include_dirs': [ '<(SHARED_INTERMEDIATE_DIR)' ], | |
| 122 }, | |
| 123 } | |
| OLD | NEW |