|  | # 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. | 
|  | # | 
|  | #   non_sdk_deps (optional) | 
|  | #     List of GN labels which this target needs built. | 
|  |  | 
|  | 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", | 
|  | "non_sdk_deps", | 
|  | ]) | 
|  |  | 
|  | 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 ] | 
|  | } | 
|  | } | 
|  | } | 
|  | } |