naiveproxy/remoting/tools/build/remoting_localize.gni
2018-01-28 13:32:06 -05:00

114 lines
2.5 KiB
Plaintext

# 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.
# Calls the remoting_localize script with a jinja2 template.
#
# Arguments
#
# sources (required)
# List of jinja2 files to load. This is the template.
#
# locales (required)
# List of locales.
#
# locale_dir (optional)
#
# defines (optional)
# List of defines to pass to script.
# Example: defines = [ "FOO_HOST_PATH=bar" ]
#
# variables (optional)
# List of variables to pass to script.
#
# output (optiona)
# Substitution pattern for the output. Defaults to a file in the target
# gen dir with the extension stripped (normally the extension is ".jinja2"
# which then leaves the non-tempaltized file name).
# TODO(brettw) Need locale_output. This is a per-locale output file.
#
# encoding (optional)
# String.
#
# deps (optional)
# visibility (optional)
template("remoting_localize") {
action_foreach(target_name) {
if (defined(invoker.visibility)) {
visibility = invoker.visibility
}
script = "//remoting/tools/build/remoting_localize.py"
sources = invoker.sources
if (defined(invoker.output)) {
outputs = [
invoker.output,
]
} else {
outputs = [
"$target_gen_dir/{{source_name_part}}",
]
}
args = []
if (defined(invoker.locale_dir)) {
args += [
"--locale_dir",
rebase_path(invoker.locale_dir, root_build_dir),
]
}
# Add defines to command line.
if (defined(invoker.defines)) {
foreach(i, invoker.defines) {
args += [
"--define",
i,
]
}
}
# Add variables to command line.
if (defined(invoker.variables)) {
foreach(i, invoker.variables) {
args += [
"--variables",
rebase_path(i, root_build_dir),
]
}
}
# The template file is required.
args += [
"--template",
"{{source}}",
]
args += [
"--output",
rebase_path(outputs[0], root_build_dir),
]
if (defined(invoker.encoding)) {
args += [
"--encoding",
invoker.encoding,
]
}
args += invoker.locales
if (defined(invoker.deps)) {
deps = invoker.deps
} else {
deps = []
}
# This script reads the messages strings from the generated resource files.
deps += [ "//remoting/resources:strings" ]
}
}