Chromium Code Reviews| 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/build_header.gni. You should write | |
| 8 # 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 | |
|
Mark Mentovai
2015/11/19 21:52:55
WHY ARE YOU YELLING AT ME?
brettw
2015/11/20 00:02:37
Done.
| |
| 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: | |
|
Mark Mentovai
2015/11/19 21:52:55
It’d be helpful if this matched the GN example exa
brettw
2015/11/20 00:02:37
But GYP doesn't support the space laser!
| |
| 16 # | |
| 17 # build_header("foo_features") { | |
| 18 # header = "foo_features.h" | |
| 19 # flags = [ "ENABLE_DOOM_MELON=$enable_doom_melon" ] | |
| 20 # variables = [ "MY_URL=\"http://www.example.com/" ] | |
|
Mark Mentovai
2015/11/19 21:52:55
\" as before. You got this right in the GYP exampl
brettw
2015/11/20 00:02:37
Done.
| |
| 21 # } | |
| 22 # | |
| 23 # Write a GYP target like this: | |
|
Mark Mentovai
2015/11/19 21:52:55
It’d be useful to know that you’re expecting to se
brettw
2015/11/20 00:02:37
I renamed the target too foo_features. I left out
| |
| 24 # | |
| 25 # { | |
| 26 # # GN version: //foo/bar:foo_features | |
| 27 # 'target_name': 'foo_bar_foo_features', | |
| 28 # 'includes': [ '../build/build_header.gypi' ], | |
| 29 # 'variables': { | |
| 30 # 'build_header_path': 'foo/bar/foo_features.h', | |
|
Mark Mentovai
2015/11/19 21:52:55
You’d be more likely to find bar_featues.h or foob
brettw
2015/11/20 00:02:37
Renamed to just foo/foo_features.h
| |
| 31 # 'build_header_flags': [ 'ENABLE_DOOM_MELON=<(enable_doom_melon)' ], | |
| 32 # 'build_header_variables': [ 'MY_URL="http://www.example.com/"' ], | |
| 33 # }, | |
| 34 # } | |
| 35 # | |
| 36 # Variables | |
| 37 # | |
| 38 # target_name | |
| 39 # Base this on the GN label, replacing / and : with _ to make it globally | |
| 40 # unique. | |
| 41 # | |
| 42 # build_header_path | |
| 43 # This must be the full path to the header from the source root. In GN | |
| 44 # you only say "features.h" and it uses the BUILD file's path implicitly. | |
| 45 # Use the path to BUILD.gn followed by your header name to produce the | |
| 46 # same output file. | |
| 47 # | |
| 48 # build_header_flags (optional) | |
| 49 # List of the same format as GN's "flags". To expand variables, use | |
| 50 # "<(foo)" where GN would have used "$foo". | |
| 51 # | |
| 52 # build_header_variables (optional) | |
| 53 # List of the same format as GN's "variables". | |
| 54 # | |
| 55 # includes | |
| 56 # List the relative path to build/build_header.gypi from the .gyp file | |
| 57 # including this code, Note: If your code is in a .gypi file in a | |
| 58 # different directory, this must be relative to the .gyp including your | |
| 59 # file. | |
| 60 # | |
| 61 # | |
| 62 # Grit defines | |
| 63 # | |
| 64 # Follow the same advice as in the build_header.gni, except on the grit action | |
| 65 # use the variable name 'grit_additional_defines' and explicitly add a '-D' in | |
| 66 # front: | |
| 67 # | |
| 68 # 'grit_grd_file': 'foo.grd', | |
| 69 # 'grit_additional_defines': [ | |
| 70 # '-D', 'enable_doom_melon=<(enable_doom_melon)', | |
| 71 # ], | |
| 72 # | |
| 73 # Put shared lists of defines in a .gypi. | |
| 74 | |
| 75 { | |
| 76 'type': 'none', | |
|
Mark Mentovai
2015/11/19 21:52:55
Why do this in a separate target? If you write thi
brettw
2015/11/20 00:02:37
I considered the action thing but I did this on pu
| |
| 77 'hard_dependency': 1, | |
| 78 | |
| 79 'actions': [ | |
| 80 { | |
| 81 'action_name': 'build_header', | |
| 82 'variables': { | |
| 83 # Default these values to empty if they're not defined. | |
| 84 'variables': { | |
| 85 'build_header_flags%': [], | |
| 86 'build_header_variables%': [], | |
| 87 }, | |
| 88 | |
| 89 # Writes the flags and variables to a response file with a name based | |
| 90 # on the name of this target. | |
|
Mark Mentovai
2015/11/19 21:52:55
Where does this file live? Hopefully not in the so
brettw
2015/11/20 00:02:37
I spent a long time on this. This <| thing seems t
| |
| 91 'response_file_name': '<|(<(_target_name)_build_header.rsp --flags <@(bu ild_header_flags) --variables <@(build_header_variables))', | |
| 92 | |
| 93 'build_header_script': '<(DEPTH)/build/write_build_header.py', | |
| 94 'relative_header_path': '<(SHARED_INTERMEDIATE_DIR)/<(build_header_path) ', | |
| 95 }, | |
| 96 | |
| 97 'message': 'Generating build header.', | |
| 98 | |
| 99 'inputs': [ | |
| 100 '<(build_header_script)', | |
| 101 '<(response_file_name)', | |
| 102 ], | |
| 103 | |
| 104 'outputs': [ | |
| 105 '<(relative_header_path)', | |
| 106 ], | |
| 107 | |
| 108 'action': [ | |
| 109 'python', '<(build_header_script)', | |
| 110 '--output', '<(relative_header_path)', | |
| 111 '--path-for-guard', '<(build_header_path)', | |
| 112 '--definitions', '<(response_file_name)', | |
| 113 ], | |
| 114 } | |
| 115 ], | |
| 116 } | |
| OLD | NEW |