| # Copyright 2017 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/config/fuchsia/zircon.gni") |
| |
| # Template for assembling a Zircon `bootdata.bin` file from inputs. |
| # The inputs can be either other `BOOTDATA` format files, or manifest files |
| # in the trivial `target=source\n` format. |
| # |
| # Parameters |
| # |
| # output_name (optional, default: target_name) |
| # output_extension (optional, default: "bin") |
| # [string] These together determine the name of the output file. |
| # If `output_name` is omitted, then the name of the target is |
| # used. If `output_extension` is "" then `output_name` is the |
| # file name; otherwise, `${output_name}.${output_extension}`; |
| # the output file is always under `root_out_dir`. |
| # |
| # inputs (required) |
| # [list of files] Input files. Each can be either a `BOOTDATA` format |
| # file (e.g. from another `bootdata` action), or a manifest file to |
| # generate a `BOOTFS` filesystem embedded in the `BOOTDATA` output. |
| # |
| # boot (optional) |
| # [Boolean] If true, any `BOOTFS` manifest files in `inputs` name |
| # files to go under `/boot` rather than `/system` (the default). |
| # |
| # deps (usually required) |
| # visibility (optional) |
| # testonly (optional) |
| # Same as for any GN `action` target. `deps` must list labels that |
| # produce all the `inputs` that are generated by the build (none |
| # are required for inputs that are part of the source tree). |
| # |
| template("bootdata") { |
| assert(defined(invoker.inputs), "inputs required for $target_name") |
| |
| if (defined(invoker.output_name)) { |
| output_file = invoker.output_name |
| } else { |
| output_file = target_name |
| } |
| |
| if (defined(invoker.output_extension)) { |
| if (invoker.output_extension != "") { |
| output_file += ".${invoker.output_extension}" |
| } |
| } else { |
| output_file += ".bin" |
| } |
| |
| output_file = "$root_out_dir/$output_file" |
| |
| if (defined(invoker.boot) && invoker.boot) { |
| target_args = [ "--target=boot" ] |
| } else { |
| target_args = [] |
| } |
| |
| zircon_tool_action(target_name) { |
| forward_variables_from(invoker, |
| [ |
| "deps", |
| "inputs", |
| "visibility", |
| "testonly", |
| ]) |
| |
| tool = "mkbootfs" |
| |
| outputs = [ |
| output_file, |
| ] |
| depfile = "${output_file}.d" |
| |
| output_args = [ |
| "-o", |
| rebase_path(output_file, root_build_dir), |
| "--depfile", |
| rebase_path(depfile, root_build_dir), |
| ] |
| |
| args = output_args + target_args + rebase_path(inputs, root_build_dir) |
| } |
| } |
| |
| # Template for writing a Zircon `bootdata.bin` file containing a kernel |
| # command line. |
| # |
| # Parameters |
| # |
| # output_name (optional, default: target_name) |
| # output_extension (optional, default: "bin") |
| # deps (usually required) |
| # visibility (optional) |
| # testonly (optional) |
| # Same as for `bootdata`, which see. |
| # |
| # inputs (required) |
| # [list of single file] This is a list to match GN conventions, but |
| # it should name a single text file as input. Any kind of whitespace |
| # (including line breaks) separates the argument strings. |
| # |
| template("bootdata_cmdline") { |
| assert(defined(invoker.inputs), "inputs required for $target_name") |
| |
| if (defined(invoker.output_name)) { |
| output_file = invoker.output_name |
| } else { |
| output_file = target_name |
| } |
| |
| if (defined(invoker.output_extension)) { |
| if (invoker.output_extension != "") { |
| output_file += ".${invoker.output_extension}" |
| } |
| } else { |
| output_file += ".bin" |
| } |
| |
| output_file = "$root_out_dir/$output_file" |
| |
| zircon_tool_action(target_name) { |
| forward_variables_from(invoker, |
| [ |
| "deps", |
| "inputs", |
| "visibility", |
| "testonly", |
| ]) |
| tool = "mkbootfs" |
| outputs = [ |
| output_file, |
| ] |
| assert(inputs == [ inputs[0] ], |
| "$target_name inputs must contain exactly one file name") |
| args = [ |
| "-o", |
| rebase_path(output_file, root_build_dir), |
| "-C", |
| rebase_path(inputs[0]), |
| ] |
| } |
| } |
| |
| # Template for writing a Zircon `bootdata.bin` file containing RAM disk images. |
| # |
| # Parameters |
| # |
| # output_name (optional, default: target_name) |
| # output_extension (optional, default: "bin") |
| # deps (usually required) |
| # visibility (optional) |
| # testonly (optional) |
| # Same as for `bootdata`, which see. |
| # |
| # inputs (required) |
| # [list of files] Input files. Each is a raw disk image, which will |
| # become a `ramdisk` block device at runtime. |
| # |
| template("bootdata_ramdisk") { |
| assert(defined(invoker.inputs), "inputs required for $target_name") |
| |
| if (defined(invoker.output_name)) { |
| output_file = invoker.output_name |
| } else { |
| output_file = target_name |
| } |
| |
| if (defined(invoker.output_extension)) { |
| if (invoker.output_extension != "") { |
| output_file += ".${invoker.output_extension}" |
| } |
| } else { |
| output_file += ".bin" |
| } |
| |
| output_file = "$root_out_dir/$output_file" |
| |
| zircon_tool_action(target_name) { |
| forward_variables_from(invoker, |
| [ |
| "deps", |
| "inputs", |
| "visibility", |
| "testonly", |
| ]) |
| tool = "mkbootfs" |
| outputs = [ |
| output_file, |
| ] |
| args = [ |
| "-o", |
| rebase_path(output_file, root_build_dir), |
| "--ramdisk", |
| ] + rebase_path(inputs) |
| } |
| } |
| |
| # Template for writing a Zircon `bootdata.bin` file containing Platform ID. |
| # |
| # Parameters |
| # |
| # vid (required) |
| # VID for Platform ID record. |
| # pid (required) |
| # PID for Platform ID record. |
| # board (required) |
| # Board name for Platform ID record. |
| # |
| # output_name (optional, default: target_name) |
| # output_extension (optional, default: "bin") |
| # visibility (optional) |
| # testonly (optional) |
| # Same as for `bootdata`. |
| # |
| template("bootdata_platform") { |
| assert(defined(invoker.vid), "vid required for $target_name") |
| assert(defined(invoker.pid), "pid required for $target_name") |
| assert(defined(invoker.board), "board required for $target_name") |
| |
| if (defined(invoker.output_name)) { |
| output_file = invoker.output_name |
| } else { |
| output_file = target_name |
| } |
| |
| if (defined(invoker.output_extension)) { |
| if (invoker.output_extension != "") { |
| output_file += ".${invoker.output_extension}" |
| } |
| } else { |
| output_file += ".bin" |
| } |
| |
| output_file = "$root_out_dir/$output_file" |
| |
| zircon_tool_action(target_name) { |
| forward_variables_from(invoker, |
| [ |
| "visibility", |
| "testonly", |
| ]) |
| tool = "mkbootfs" |
| outputs = [ |
| output_file, |
| ] |
| args = [ |
| "-o", |
| rebase_path(output_file, root_build_dir), |
| "--vid", |
| "${invoker.vid}", # Turns integer into string. |
| "--pid", |
| "${invoker.pid}", # Turns integer into string. |
| "--board", |
| invoker.board, |
| ] |
| } |
| } |
| |
| # Template for compiling Zircon MDI files into BOOTDATA format, via `mdigen`. |
| # |
| # Parameters |
| # |
| # output_name (optional, default: target_name) |
| # output_extension (optional, default: "bin") |
| # deps (usually required) |
| # visibility (optional) |
| # testonly (optional) |
| # Same as for `bootdata`, which see. |
| # |
| # sources (required) |
| # [list of files] Source files, usually ending in `.mdi`. |
| # |
| template("bootdata_mdi") { |
| assert(defined(invoker.sources), "sources required for $target_name") |
| |
| if (defined(invoker.output_name)) { |
| output_file = invoker.output_name |
| } else { |
| output_file = target_name |
| } |
| |
| if (defined(invoker.output_extension)) { |
| if (invoker.output_extension != "") { |
| output_file += ".${invoker.output_extension}" |
| } |
| } else { |
| output_file += ".bin" |
| } |
| |
| output_file = "$root_out_dir/$output_file" |
| |
| zircon_tool_action(target_name) { |
| forward_variables_from(invoker, |
| [ |
| "deps", |
| "sources", |
| "visibility", |
| "testonly", |
| ]) |
| tool = "mdigen" |
| outputs = [ |
| output_file, |
| ] |
| args = [ |
| "-o", |
| rebase_path(output_file, root_build_dir), |
| ] + rebase_path(sources, root_build_dir) |
| } |
| } |