blob: 40aa7c1253f526d359f18db53b4a2d34a5084fc7 [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/sdk/sdk_atom.gni")
# Declares a set of data files to be added to an SDK.
#
# Parameters
#
# category (required)
# Publication level of the data set in SDKs.
# See //build/sdk/sdk_atom.gni.
#
# name (required)
# Name of the data set in the SDK.
#
# file (required)
# Path to the data file to add to the SDK.
#
# type (required)
# Type of the data set in the SDK.
# Currently only "license" and "config" data types are supported.
template("sdk_data") {
assert(defined(invoker.category), "Must define an SDK category")
assert(defined(invoker.name), "Must define an SDK name")
assert(defined(invoker.file), "Must add data file path")
assert(defined(invoker.type), "Must define a data type")
assert(invoker.type == "config" || invoker.type == "license",
"Type must be one of [config, license]")
# The directory structure will look as follows:
# > data/
# > config/
# > ${invoker.name}/
# > config.json
# > meta.json
# > license/
# > ${invoker.name}/
# > LICENSE
# > meta.json
file_base = "data/${invoker.type}/${invoker.name}/"
file_dest = ""
if (invoker.type == "config") {
file_dest = file_base + "config.json"
} else if (invoker.type == "license") {
file_dest = file_base + "LICENSE"
}
meta_dest = file_base + "meta.json"
sdk_atom(target_name) {
forward_variables_from(invoker, [ "category" ])
id = "sdk://data/${invoker.name}"
files = [
{
source = invoker.file
dest = file_dest
},
]
meta = {
schema = "data"
dest = meta_dest
value = {
type = "${invoker.type}"
name = invoker.name
data = [ file_dest ]
}
}
}
}