Chromium Code Reviews| Index: build/build_header.gypi |
| diff --git a/build/build_header.gypi b/build/build_header.gypi |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8b3dc2d1b336bc4284dd46ef0ca2bc70fe3839ee |
| --- /dev/null |
| +++ b/build/build_header.gypi |
| @@ -0,0 +1,118 @@ |
| +# Copyright 2015 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +# Generates a header with preprocessor defines specified by the build file. |
| +# |
| +# The canonical documentation is in build/build_header.gni. You should write |
| +# the GN build, get it working, and then transform it into GYP. |
| +# |
| +# In every target that uses your generated header you must include a dependency |
| +# on the GYP target that generates the header (this is implicit in GN). |
| +# Otherwise, clean builds may not necessarily create the header before the |
| +# source code is compiled. |
| +# |
| +# Assuming your GN code looks like this: |
| +# |
| +# build_header("foo_features") { |
| +# header = "foo_features.h" |
| +# flags = [ |
| +# "ENABLE_DOOM_MELON=$enable_doom_melon", |
| +# "ENABLE_SPACE_LASER=true", |
| +# "SPAM_SERVER_URL=\"http://www.example.com/"", |
|
Mark Mentovai
2015/11/24 14:33:33
Missing backslash after example.com, here and on l
brettw
2015/11/24 23:36:01
Done in this case. I shouldn't need it for the GYP
|
| +# ] |
| +# } |
| +# |
| +# Write a GYP target like this: |
| +# |
| +# { |
| +# # GN version: //foo:foo_features |
| +# 'target_name': 'foo_foo_features', |
| +# 'includes': [ '../build/build_header.gypi' ], |
| +# 'variables': { |
| +# 'build_header_path': 'foo/foo_features.h', |
| +# 'build_header_flags': [ |
| +# 'ENABLE_DOOM_MELON=<(enable_doom_melon)', |
| +# 'ENABLE_SPACE_LASER=true', |
| +# 'SPAM_SERVER_URL="http://www.example.com/"', |
| +# ], |
| +# }, |
| +# } |
| +# |
| +# Variables |
| +# |
| +# target_name |
| +# Base this on the GN label, replacing / and : with _ to make it globally |
| +# unique. |
| +# |
| +# build_header_path |
| +# This must be the full path to the header from the source root. In GN |
| +# you only say "features.h" and it uses the BUILD file's path implicitly. |
| +# Use the path to BUILD.gn followed by your header name to produce the |
| +# same output file. |
| +# |
| +# build_header_flags (optional) |
| +# List of the same format as GN's "flags". To expand variables, use |
| +# "<(foo)" where GN would have used "$foo". |
| +# |
| +# includes |
| +# List the relative path to build/build_header.gypi from the .gyp file |
| +# including this code, Note: If your code is in a .gypi file in a |
| +# different directory, this must be relative to the .gyp including your |
| +# file. |
| +# |
| +# |
| +# Grit defines |
| +# |
| +# Follow the same advice as in the build_header.gni, except on the grit action |
| +# use the variable name 'grit_additional_defines' and explicitly add a '-D' in |
| +# front: |
| +# |
| +# 'grit_grd_file': 'foo.grd', |
| +# 'grit_additional_defines': [ |
| +# '-D', 'enable_doom_melon=<(enable_doom_melon)', |
| +# ], |
| +# |
| +# Put shared lists of defines in a .gypi. |
| + |
| +{ |
| + 'type': 'none', |
| + 'hard_dependency': 1, |
| + |
| + 'actions': [ |
| + { |
| + 'action_name': 'build_header', |
| + 'variables': { |
| + # Default these values to empty if they're not defined. |
| + 'variables': { |
| + 'build_header_flags%': [], |
| + }, |
| + |
| + # Writes the flags to a response file with a name based on the name of |
| + # this target. |
| + 'response_file_name': '<|(<(_target_name)_build_header.rsp --flags <@(build_header_flags))', |
| + |
| + 'build_header_script': '<(DEPTH)/build/write_build_header.py', |
| + }, |
| + |
| + 'message': 'Generating build header.', |
| + |
| + 'inputs': [ |
| + '<(build_header_script)', |
| + '<(response_file_name)', |
| + ], |
| + |
| + 'outputs': [ |
| + '<(SHARED_INTERMEDIATE_DIR)/<(build_header_path)', |
| + ], |
| + |
| + 'action': [ |
| + 'python', '<(build_header_script)', |
| + '--output', '<(build_header_path)', |
| + '--rulename', '<(_target_name)', |
| + '--gen-dir', '<(SHARED_INTERMEDIATE_DIR)', |
| + '--definitions', '<(response_file_name)', |
| + ], |
| + } |
| + ], |
| +} |