Add default build rules and reduce duplication
Bug: 263697604
Test: launch_cvd with checking wifi for x86_64 and arm64
Change-Id: I561e7ad0c798f68f6a7bcbc70c44152dbf14fe8c
diff --git a/Android.bp b/Android.bp
index 8f77b67..eebf86a 100644
--- a/Android.bp
+++ b/Android.bp
@@ -38,116 +38,113 @@
],
}
+genrule_defaults {
+ name: "openwrt_rootfs_base_defaults",
+ cmd: "cp $(in) $(genDir) && gzip -d $(genDir)/* && cp $(genDir)/* $(out)",
+}
+
genrule {
- name: "openwrt_rootfs_base_img_x86_64",
+ name: "openwrt_rootfs_base_x86_64",
srcs: [
"x86_64/images/openwrt-22.03.2-x86-64-generic-squashfs-rootfs.img.gz",
],
- out: ["base_rootfs_x86_64.img"],
- cmd: "cp $(in) $(genDir) && gzip -d $(genDir)/* && cp $(genDir)/* $(out)",
+ out: ["openwrt_rootfs_base_x86_64.img"],
+ defaults: ["openwrt_rootfs_base_defaults"],
}
genrule {
- name: "openwrt_rootfs_base_img_aarch64",
+ name: "openwrt_rootfs_base_aarch64",
srcs: [
"arm64/images/openwrt-22.03.2-armvirt-64-rootfs-squashfs.img.gz",
],
- out: ["base_rootfs_aarch64.img"],
- cmd: "cp $(in) $(genDir) && gzip -d $(genDir)/* && cp $(genDir)/* $(out)",
+ out: ["openwrt_rootfs_base_aarch64.img"],
+ defaults: ["openwrt_rootfs_base_defaults"],
}
-genrule {
- name: "openwrt_customization_x86_64",
+genrule_defaults {
+ name: "openwrt_rootfs_customization_defaults",
tools: [
"make_f2fs",
"sload_f2fs",
],
srcs: [
":openwrt_license_files",
+ "shared/uci-defaults/*",
+ "shared/config/*",
+ ],
+ cmd: "mkdir -p $(genDir)/root/upper/etc/uci-defaults && " +
+ "mkdir -p $(genDir)/root/upper/ipks && " +
+ "mkdir -p $(genDir)/root/upper/etc/config && " +
+ "cp $(in) $(genDir)/ && " +
+ "mv $(genDir)/*.ipk $(genDir)/root/upper/ipks && " +
+ "mv $(genDir)/LICENSE $(genDir)/HOW_TO_GET_SOURCE_CODE $(genDir)/root/upper && " +
+ "mv $(genDir)/0_default_config $(genDir)/root/upper/etc/uci-defaults && " +
+ "find $(genDir) -maxdepth 1 -type f -exec mv {} $(genDir)/root/upper/etc/config \\; && " +
+ "ln -s 2 $(genDir)/root/.fs_state && " +
+ "truncate -s 128M $(out) && " +
+ "$(location make_f2fs) $(out) && " +
+ "$(location sload_f2fs) -f $(genDir)/root -t / $(out)",
+}
+
+genrule {
+ name: "openwrt_rootfs_customization_x86_64",
+ srcs: [
"x86_64/kmods/*",
"x86_64/packages/*",
- "shared/uci-defaults/*",
- "shared/config/*",
],
- out: ["customization_x86_64.img"],
- cmd: "mkdir -p $(genDir)/root/upper/etc/uci-defaults && " +
- "mkdir -p $(genDir)/root/upper/ipks && " +
- "mkdir -p $(genDir)/root/upper/etc/config && " +
- "cp $(in) $(genDir)/ && " +
- "mv $(genDir)/*.ipk $(genDir)/root/upper/ipks && " +
- "mv $(genDir)/LICENSE $(genDir)/HOW_TO_GET_SOURCE_CODE $(genDir)/root/upper && " +
- "mv $(genDir)/0_default_config $(genDir)/root/upper/etc/uci-defaults && " +
- "find $(genDir) -maxdepth 1 -type f -exec mv {} $(genDir)/root/upper/etc/config \\; && " +
- "ln -s 2 $(genDir)/root/.fs_state && " +
- "truncate -s 128M $(out) && " +
- "$(location make_f2fs) $(out) && " +
- "$(location sload_f2fs) -f $(genDir)/root -t / $(out)",
+ out: ["openwrt_rootfs_customization_x86_64.img"],
+ defaults: ["openwrt_rootfs_customization_defaults"],
}
genrule {
- name: "openwrt_customization_aarch64",
- tools: [
- "make_f2fs",
- "sload_f2fs",
- ],
+ name: "openwrt_rootfs_customization_aarch64",
srcs: [
- ":openwrt_license_files",
"arm64/kmods/*",
"arm64/packages/*",
- "shared/uci-defaults/*",
- "shared/config/*",
],
- out: ["customization_aarch64.img"],
- cmd: "mkdir -p $(genDir)/root/upper/etc/uci-defaults && " +
- "mkdir -p $(genDir)/root/upper/ipks && " +
- "mkdir -p $(genDir)/root/upper/etc/config && " +
- "cp $(in) $(genDir)/ && " +
- "mv $(genDir)/*.ipk $(genDir)/root/upper/ipks && " +
- "mv $(genDir)/LICENSE $(genDir)/HOW_TO_GET_SOURCE_CODE $(genDir)/root/upper && " +
- "mv $(genDir)/0_default_config $(genDir)/root/upper/etc/uci-defaults && " +
- "find $(genDir) -maxdepth 1 -type f -exec mv {} $(genDir)/root/upper/etc/config \\; && " +
- "ln -s 2 $(genDir)/root/.fs_state && " +
- "truncate -s 128M $(out) && " +
- "$(location make_f2fs) $(out) && " +
- "$(location sload_f2fs) -f $(genDir)/root -t / $(out)",
+ out: ["openwrt_rootfs_customization_aarch64.img"],
+ defaults: ["openwrt_rootfs_customization_defaults"],
}
-genrule {
- name: "combined_openwrt_rootfs_x86_64",
+genrule_defaults {
+ name: "openwrt_rootfs_combined_defaults",
tools: [
"append_squashfs_overlay",
],
- srcs: [
- ":openwrt_rootfs_base_img_x86_64",
- ":openwrt_customization_x86_64",
- ],
- out: ["openwrt_rootfs_x86_64.img"],
cmd: "$(location append_squashfs_overlay) $(in) $(out) -w",
}
genrule {
- name: "combined_openwrt_rootfs_aarch64",
- tools: [
- "append_squashfs_overlay",
- ],
+ name: "openwrt_rootfs_combined_x86_64",
srcs: [
- ":openwrt_rootfs_base_img_aarch64",
- ":openwrt_customization_aarch64",
+ ":openwrt_rootfs_base_x86_64",
+ ":openwrt_rootfs_customization_x86_64",
],
- out: ["openwrt_rootfs_aarch64.img"],
- cmd: "$(location append_squashfs_overlay) $(in) $(out) -w",
+ out: ["openwrt_rootfs_combined_x86_64.img"],
+ defaults: ["openwrt_rootfs_combined_defaults"],
+
+}
+
+genrule {
+ name: "openwrt_rootfs_combined_aarch64",
+ srcs: [
+ ":openwrt_rootfs_base_aarch64",
+ ":openwrt_rootfs_customization_aarch64",
+ ],
+ out: ["openwrt_rootfs_combined_aarch64.img"],
+ defaults: ["openwrt_rootfs_combined_defaults"],
}
prebuilt_etc_host {
name: "openwrt_rootfs_x86_64",
- src: ":combined_openwrt_rootfs_x86_64",
+ src: ":openwrt_rootfs_combined_x86_64",
sub_dir: "openwrt/images",
visibility: ["//device/google/cuttlefish/build"],
}
prebuilt_etc_host {
name: "openwrt_rootfs_aarch64",
- src: ":combined_openwrt_rootfs_aarch64",
+ src: ":openwrt_rootfs_combined_aarch64",
sub_dir: "openwrt/images",
visibility: ["//device/google/cuttlefish/build"],
}