1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
build / win / message_compiler.gni [blame]
# Copyright 2015 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
assert(is_win, "This only runs on Windows.")
# Runs mc.exe over a list of sources. The outputs (a header and rc file) are
# placed in the target gen dir, and compiled. Sources without a BOM will be
# processed as if they are UTF-16LE. Generated text files will be written in the
# ANSI codepage.
#
# sources
# List of message files to process.
#
# user_mode_logging (optional bool)
# Generates user-mode logging code. Defaults to false (no logging code).
#
# compile_generated_code (optional, deafults = true)
# If unset or true, the generated code will be compiled and linked into
# targets that depend on it. If set to false, the .h and .rc files will only
# be generated.
#
# deps, public_deps, visibility
# Normal meaning.
template("message_compiler") {
if (defined(invoker.compile_generated_code) &&
!invoker.compile_generated_code) {
compile_generated_code = false
action_name = target_name
} else {
compile_generated_code = true
action_name = "${target_name}_mc"
source_set_name = target_name
}
action_foreach(action_name) {
if (compile_generated_code) {
visibility = [ ":$source_set_name" ]
} else {
forward_variables_from(invoker, [ "visibility" ])
}
script = "//build/win/message_compiler.py"
outputs = [
"$target_gen_dir/{{source_name_part}}.h",
"$target_gen_dir/{{source_name_part}}.rc",
]
args = [
# The first argument is the environment file saved to the build
# directory. This is required because the Windows toolchain setup saves
# the VC paths and such so that running "mc.exe" will work with the
# configured toolchain. This file is in the root build dir.
"environment.$current_cpu",
# Where to put the header.
"-h",
rebase_path(target_gen_dir, root_build_dir),
# Where to put the .rc file.
"-r",
rebase_path(target_gen_dir, root_build_dir),
# Sources without a BOM are UTF-16LE.
"-u",
]
if (defined(invoker.user_mode_logging) && invoker.user_mode_logging) {
args += [ "-um" ]
}
args += [ "{{source}}" ]
forward_variables_from(invoker,
[
"deps",
"public_deps",
"sources",
])
}
if (compile_generated_code) {
# Compile the generated rc file.
source_set(source_set_name) {
forward_variables_from(invoker, [ "visibility" ])
sources = get_target_outputs(":$action_name")
deps = [ ":$action_name" ]
}
}
}