Simplify GN logic by creating a target for prebuilt Linux
The `initrd` GN template currently supports two different ways of
specifying a primary VM image - name of a target or a path to a prebuilt
image. These use different target properties (as GN has no mechanism of
classifying a string as either a target or a path).
Simplify this in anticipation of using different Linux targets for
different HW boards in platform args by creating a target for each
prebuilt image. The `linux_kernel` template accepts a `prebuilt` path
and creates a "${target_name}__prebuilt" target which copies the image
into the out folder. As a side effect, this more closely ties the image
to the source code in the GN file.
Change-Id: I2afa295e666581393e9a80c311d7d8fe56d4fbba
diff --git a/build/linux/linux.gni b/build/linux/linux.gni
index b675813..6ac0b8a 100644
--- a/build/linux/linux.gni
+++ b/build/linux/linux.gni
@@ -31,6 +31,7 @@
template("linux_kernel") {
source_target = "${target_name}__source"
defconfig_target = "${target_name}__defconfig"
+ prebuilt_target = "${target_name}__prebuilt"
# Args to build/make.py to start the Linux build.
shared_args = [
@@ -90,6 +91,18 @@
":${source_target}",
]
}
+
+ # Subtarget for a prebuilt image, if defined.
+ if (defined(invoker.prebuilt)) {
+ copy(prebuilt_target) {
+ sources = [
+ invoker.prebuilt,
+ ]
+ outputs = [
+ "${target_out_dir}/${prebuilt_target}.bin",
+ ]
+ }
+ }
}
template("linux_kernel_module") {