| # 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. |
| |
| _mkbootfs = "//out/build-zircon/tools/mkbootfs" |
| |
| # 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 = [] |
| } |
| |
| action(target_name) { |
| forward_variables_from(invoker, |
| [ |
| "deps", |
| "visibility", |
| "testonly", |
| ]) |
| |
| script = _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), |
| ] |
| |
| sources = invoker.inputs |
| input_args = rebase_path(sources, root_build_dir) |
| |
| args = output_args + target_args + input_args |
| } |
| } |
| |
| # 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") |
| # 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" |
| |
| action(target_name) { |
| forward_variables_from(invoker, |
| [ |
| "deps", |
| "visibility", |
| "testonly", |
| ]) |
| |
| script = _mkbootfs |
| |
| outputs = [ |
| output_file, |
| ] |
| |
| inputs = invoker.inputs |
| 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]), |
| ] |
| } |
| } |