blob: 9bcb919036d77ba96eeab3d0167a69b39b143794 [file] [log] [blame]
# Copyright 2018 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/compiled_action.gni")
# Validate a JSON file against a JSON schema.
#
# data (required)
# [file] JSON file to validate.
# If this file is not valid JSON, or does not meet the schema, then this
# target will fail to build.
#
# schema (required)
# [file] Schema to use for validation.
#
# sources (optional)
# [list of files] Additional schema files referenced by schema.
# Additional schema files used by the original schema file must be listed
# here for validation to be re-run when they change.
#
# deps (optional)
# public_deps (optional)
# testonly (optional)
# visibility (optional)
# Standard GN meaning.
#
# Example of usage:
#
# validate_json("validate_my_json") {
# data = "my_file.json"
# schema = "my_schema.json"
# }
template("validate_json") {
compiled_action(target_name) {
forward_variables_from(invoker,
[
"deps",
"sources",
"public_deps",
"testonly",
"visibility",
])
tool = "//build/tools/json_validator"
stamp_file = "$target_gen_dir/$target_name.verified"
inputs = [
invoker.data,
invoker.schema,
]
outputs = [
stamp_file,
]
args = [
rebase_path(invoker.schema),
rebase_path(invoker.data),
rebase_path(stamp_file),
]
}
}