Merge "ANDROID: build: Replace genrules with write_file where possible"
This commit is contained in:
commit
3881c58a58
@ -1,17 +1,17 @@
|
||||
load("@bazel_skylib//rules:write_file.bzl", "write_file")
|
||||
|
||||
def define_top_level_config(target):
|
||||
"""Define common top-level variables in build.config"""
|
||||
rule_name = "{}_top_level_config".format(target)
|
||||
native.genrule(
|
||||
write_file(
|
||||
name = rule_name,
|
||||
srcs = [],
|
||||
outs = ["build.config.bazel.top.level.{}".format(target)],
|
||||
cmd_bash = """
|
||||
cat << 'EOF' > "$@"
|
||||
# === define_top_level_config ===
|
||||
BUILDING_WITH_BAZEL=true
|
||||
# === end define_top_level_config ===
|
||||
EOF
|
||||
""",
|
||||
out = "build.config.bazel.top.level.{}".format(target),
|
||||
content = [
|
||||
"# === define_top_level_config ===",
|
||||
"BUILDING_WITH_BAZEL=true",
|
||||
"# === end define_top_level_config ===",
|
||||
"", # Needed for newline at end of file
|
||||
],
|
||||
)
|
||||
|
||||
return ":{}".format(rule_name)
|
||||
|
@ -21,6 +21,7 @@ load(
|
||||
"get_gki_ramdisk_prebuilt_binary",
|
||||
"get_vendor_ramdisk_binaries",
|
||||
)
|
||||
load("@bazel_skylib//rules:write_file.bzl", "write_file")
|
||||
load(":msm_common.bzl", "define_top_level_config", "gen_config_without_source_lines", "get_out_dir")
|
||||
load(":msm_dtc.bzl", "define_dtc_dist")
|
||||
load(":msm_abl.bzl", "define_abl_dist")
|
||||
@ -45,50 +46,30 @@ def _define_build_config(
|
||||
variant: variant of kernel to build (e.g. "gki")
|
||||
"""
|
||||
|
||||
gen_config_command = """
|
||||
cat << 'EOF' > "$@"
|
||||
KERNEL_DIR="msm-kernel"
|
||||
VARIANTS=(%s)
|
||||
MSM_ARCH=%s
|
||||
VARIANT=%s
|
||||
ABL_SRC=bootable/bootloader/edk2
|
||||
BOOT_IMAGE_HEADER_VERSION=%d
|
||||
BASE_ADDRESS=0x%X
|
||||
PAGE_SIZE=%d
|
||||
BUILD_VENDOR_DLKM=1
|
||||
PREPARE_SYSTEM_DLKM=1
|
||||
SUPER_IMAGE_SIZE=0x%X
|
||||
TRIM_UNUSED_MODULES=1
|
||||
BUILD_INIT_BOOT_IMG=1
|
||||
LZ4_RAMDISK=%d
|
||||
[ -z "$$DT_OVERLAY_SUPPORT" ] && DT_OVERLAY_SUPPORT=1
|
||||
|
||||
if [ "$$KERNEL_CMDLINE_CONSOLE_AUTO" != "0" ]; then
|
||||
KERNEL_VENDOR_CMDLINE+=' earlycon=%s '
|
||||
fi
|
||||
|
||||
KERNEL_VENDOR_CMDLINE+=' %s '
|
||||
VENDOR_BOOTCONFIG+='androidboot.first_stage_console=1 androidboot.hardware=qcom_kp'
|
||||
EOF
|
||||
""" % (
|
||||
" ".join(la_variants),
|
||||
msm_target.replace("-", "_"),
|
||||
variant.replace("-", "_"),
|
||||
boot_image_opts.boot_image_header_version,
|
||||
boot_image_opts.base_address,
|
||||
boot_image_opts.page_size,
|
||||
boot_image_opts.super_image_size,
|
||||
int(boot_image_opts.lz4_ramdisk),
|
||||
boot_image_opts.earlycon_addr,
|
||||
" ".join(boot_image_opts.kernel_vendor_cmdline_extras),
|
||||
)
|
||||
|
||||
# Generate the build config
|
||||
native.genrule(
|
||||
write_file(
|
||||
name = "{}_build_config_bazel".format(target),
|
||||
srcs = [],
|
||||
outs = ["build.config.msm.{}.generated".format(target)],
|
||||
cmd_bash = gen_config_command,
|
||||
out = "build.config.msm.{}.generated".format(target),
|
||||
content = [
|
||||
'KERNEL_DIR="msm-kernel"',
|
||||
"VARIANTS=({})".format(" ".join(la_variants)),
|
||||
"MSM_ARCH={}".format(msm_target.replace("-", "_")),
|
||||
"VARIANT={}".format(variant.replace("-", "_")),
|
||||
"ABL_SRC=bootable/bootloader/edk2",
|
||||
"BOOT_IMAGE_HEADER_VERSION={}".format(boot_image_opts.boot_image_header_version),
|
||||
"BASE_ADDRESS=0x%X" % boot_image_opts.base_address,
|
||||
"PAGE_SIZE={}".format(boot_image_opts.page_size),
|
||||
"BUILD_VENDOR_DLKM=1",
|
||||
"PREPARE_SYSTEM_DLKM=1",
|
||||
"SUPER_IMAGE_SIZE=0x%X" % boot_image_opts.super_image_size,
|
||||
"TRIM_UNUSED_MODULES=1",
|
||||
"BUILD_INIT_BOOT_IMG=1",
|
||||
"LZ4_RAMDISK={}".format(int(boot_image_opts.lz4_ramdisk)),
|
||||
'[ -z "$DT_OVERLAY_SUPPORT" ] && DT_OVERLAY_SUPPORT=1',
|
||||
'[ "$KERNEL_CMDLINE_CONSOLE_AUTO" != "0" ] && KERNEL_VENDOR_CMDLINE+=\' earlycon={} \''.format(boot_image_opts.earlycon_addr),
|
||||
"KERNEL_VENDOR_CMDLINE+=' {} '".format(" ".join(boot_image_opts.kernel_vendor_cmdline_extras)),
|
||||
"VENDOR_BOOTCONFIG+='androidboot.first_stage_console=1 androidboot.hardware=qcom_kp'",
|
||||
"", # Needed for newline at end of file
|
||||
],
|
||||
)
|
||||
|
||||
top_level_config = define_top_level_config(target)
|
||||
@ -112,22 +93,18 @@ EOF
|
||||
|
||||
board_cmdline_extras = " ".join(boot_image_opts.board_kernel_cmdline_extras)
|
||||
if board_cmdline_extras:
|
||||
native.genrule(
|
||||
write_file(
|
||||
name = "{}_extra_cmdline".format(target),
|
||||
outs = ["board_extra_cmdline_{}".format(target)],
|
||||
cmd_bash = """
|
||||
echo {} > "$@"
|
||||
""".format(board_cmdline_extras),
|
||||
out = "board_extra_cmdline_{}".format(target),
|
||||
content = [board_cmdline_extras, ""],
|
||||
)
|
||||
|
||||
board_bc_extras = " ".join(boot_image_opts.board_bootconfig_extras)
|
||||
if board_bc_extras:
|
||||
native.genrule(
|
||||
write_file(
|
||||
name = "{}_extra_bootconfig".format(target),
|
||||
outs = ["board_extra_bootconfig_{}".format(target)],
|
||||
cmd_bash = """
|
||||
echo {} > "$@"
|
||||
""".format(board_bc_extras),
|
||||
out = "board_extra_bootconfig_{}".format(target),
|
||||
content = [board_bc_extras, ""],
|
||||
)
|
||||
|
||||
def _define_kernel_build(
|
||||
|
@ -18,6 +18,7 @@ load(
|
||||
"get_dtstree",
|
||||
"get_vendor_ramdisk_binaries",
|
||||
)
|
||||
load("@bazel_skylib//rules:write_file.bzl", "write_file")
|
||||
load(":msm_common.bzl", "define_top_level_config", "gen_config_without_source_lines", "get_out_dir")
|
||||
load(":msm_dtc.bzl", "define_dtc_dist")
|
||||
load(":msm_abl.bzl", "define_abl_dist")
|
||||
@ -41,42 +42,27 @@ def _define_build_config(
|
||||
variant: variant of kernel to build (e.g. "gki")
|
||||
"""
|
||||
|
||||
gen_config_command = """
|
||||
cat << 'EOF' > "$@"
|
||||
KERNEL_DIR="msm-kernel"
|
||||
VARIANTS=(%s)
|
||||
MSM_ARCH=%s
|
||||
VARIANT=%s
|
||||
ABL_SRC=bootable/bootloader/edk2
|
||||
BOOT_IMAGE_HEADER_VERSION=%d
|
||||
BASE_ADDRESS=0x%X
|
||||
PAGE_SIZE=%d
|
||||
TARGET_HAS_SEPARATE_RD=1
|
||||
PREFERRED_USERSPACE=le
|
||||
BUILD_BOOT_IMG=1
|
||||
SKIP_UNPACKING_RAMDISK=1
|
||||
BUILD_INITRAMFS=1
|
||||
[ -z "$${DT_OVERLAY_SUPPORT}" ] && DT_OVERLAY_SUPPORT=1
|
||||
|
||||
if [ "$${KERNEL_CMDLINE_CONSOLE_AUTO}" != "0" ]; then
|
||||
KERNEL_VENDOR_CMDLINE+=' console=ttyMSM0,115200n8 earlycon=qcom_geni,0x00a9C000 qcom_geni_serial.con_enabled=1 '
|
||||
fi
|
||||
EOF
|
||||
""" % (
|
||||
" ".join([v.replace("-", "_") for v in le_variants]), # VARIANTS
|
||||
msm_target.replace("-", "_"),
|
||||
variant.replace("-", "_"),
|
||||
boot_image_opts.boot_image_header_version,
|
||||
boot_image_opts.base_address,
|
||||
boot_image_opts.page_size,
|
||||
)
|
||||
|
||||
# Generate the build config
|
||||
native.genrule(
|
||||
write_file(
|
||||
name = "{}_build_config_bazel".format(target),
|
||||
srcs = [],
|
||||
outs = ["build.config.msm.{}.generated".format(target)],
|
||||
cmd_bash = gen_config_command,
|
||||
out = "build.config.msm.{}.generated".format(target),
|
||||
content = [
|
||||
'KERNEL_DIR="msm-kernel"',
|
||||
"VARIANTS=({})".format(" ".join([v.replace("-", "_") for v in le_variants])),
|
||||
"MSM_ARCH={}".format(msm_target.replace("-", "_")),
|
||||
"VARIANT={}".format(variant.replace("-", "_")),
|
||||
"ABL_SRC=bootable/bootloader/edk2",
|
||||
"BOOT_IMAGE_HEADER_VERSION={}".format(boot_image_opts.boot_image_header_version),
|
||||
"BASE_ADDRESS=0x%X" % boot_image_opts.base_address,
|
||||
"PAGE_SIZE={}".format(boot_image_opts.page_size),
|
||||
"TARGET_HAS_SEPARATE_RD=1",
|
||||
"PREFERRED_USERSPACE=le",
|
||||
"BUILD_BOOT_IMG=1",
|
||||
"SKIP_UNPACKING_RAMDISK=1",
|
||||
"BUILD_INITRAMFS=1",
|
||||
'[ -z "$DT_OVERLAY_SUPPORT" ] && DT_OVERLAY_SUPPORT=1',
|
||||
'[ "$KERNEL_CMDLINE_CONSOLE_AUTO" != "0" ] && KERNEL_VENDOR_CMDLINE+=\' console=ttyMSM0,115200n8 earlycon=qcom_geni,0x00a9C000 qcom_geni_serial.con_enabled=1 \'',
|
||||
"", # Needed for newline at end of file
|
||||
],
|
||||
)
|
||||
|
||||
top_level_config = define_top_level_config(target)
|
||||
|
@ -19,6 +19,7 @@ load(
|
||||
"get_dtstree",
|
||||
"get_vendor_ramdisk_binaries",
|
||||
)
|
||||
load("@bazel_skylib//rules:write_file.bzl", "write_file")
|
||||
load(":msm_common.bzl", "define_top_level_config", "gen_config_without_source_lines", "get_out_dir")
|
||||
load(":msm_dtc.bzl", "define_dtc_dist")
|
||||
load(":msm_abl.bzl", "define_abl_dist")
|
||||
@ -41,40 +42,28 @@ def _define_build_config(
|
||||
variant: variant of kernel to build (e.g. "gki")
|
||||
"""
|
||||
|
||||
gen_config_command = """
|
||||
cat << 'EOF' > "$@"
|
||||
KERNEL_DIR="msm-kernel"
|
||||
SOC_NAME="monaco_auto"
|
||||
VARIANTS=(%s)
|
||||
MSM_ARCH=%s
|
||||
VARIANT=%s
|
||||
ABL_SRC=bootable/bootloader/edk2
|
||||
BOOT_IMAGE_HEADER_VERSION=%d
|
||||
BASE_ADDRESS=0x%X
|
||||
PAGE_SIZE=%d
|
||||
TARGET_HAS_SEPARATE_RD=1
|
||||
PREFERRED_USERSPACE=lxc
|
||||
BUILD_BOOT_IMG=1
|
||||
SKIP_UNPACKING_RAMDISK=1
|
||||
BUILD_INITRAMFS=1
|
||||
[ -z "$${DT_OVERLAY_SUPPORT}" ] && DT_OVERLAY_SUPPORT=1
|
||||
KERNEL_VENDOR_CMDLINE+=' console=ttyMSM0,115200n8 earlycon=qcom_geni,0x99c000 qcom_geni_serial.con_enabled=1 loglevel=8 nokaslr printk.devkmsg=on root=/dev/ram0 rw rootwait'
|
||||
EOF
|
||||
""" % (
|
||||
" ".join([v.replace("-", "_") for v in lxc_variants]), # VARIANTS
|
||||
msm_target.replace("-", "_"),
|
||||
variant.replace("-", "_"),
|
||||
boot_image_opts.boot_image_header_version,
|
||||
boot_image_opts.base_address,
|
||||
boot_image_opts.page_size,
|
||||
)
|
||||
|
||||
# Generate the build config
|
||||
native.genrule(
|
||||
write_file(
|
||||
name = "{}_build_config_bazel".format(target),
|
||||
srcs = [],
|
||||
outs = ["build.config.msm.{}.generated".format(target)],
|
||||
cmd_bash = gen_config_command,
|
||||
out = "build.config.msm.{}.generated".format(target),
|
||||
content = [
|
||||
'KERNEL_DIR="msm-kernel"',
|
||||
'SOC_NAME="monaco_auto"',
|
||||
"VARIANTS=({})".format(" ".join([v.replace("-", "_") for v in lxc_variants])),
|
||||
"MSM_ARCH={}".format(msm_target.replace("-", "_")),
|
||||
"VARIANT={}".format(variant.replace("-", "_")),
|
||||
"ABL_SRC=bootable/bootloader/edk2",
|
||||
"BOOT_IMAGE_HEADER_VERSION={}".format(boot_image_opts.boot_image_header_version),
|
||||
"BASE_ADDRESS=0x%X" % boot_image_opts.base_address,
|
||||
"PAGE_SIZE={}".format(boot_image_opts.page_size),
|
||||
"TARGET_HAS_SEPARATE_RD=1",
|
||||
"PREFERRED_USERSPACE=lxc",
|
||||
"BUILD_BOOT_IMG=1",
|
||||
"SKIP_UNPACKING_RAMDISK=1",
|
||||
"BUILD_INITRAMFS=1",
|
||||
'[ -z "$DT_OVERLAY_SUPPORT" ] && DT_OVERLAY_SUPPORT=1',
|
||||
"KERNEL_VENDOR_CMDLINE+=' console=ttyMSM0,115200n8 earlycon=qcom_geni,0x99c000 qcom_geni_serial.con_enabled=1 loglevel=8 nokaslr printk.devkmsg=on root=/dev/ram0 rw rootwait '",
|
||||
"", # Needed for newline at end of file
|
||||
],
|
||||
)
|
||||
|
||||
top_level_config = define_top_level_config(target)
|
||||
|
@ -19,6 +19,7 @@ load(
|
||||
"get_dtstree",
|
||||
"get_vendor_ramdisk_binaries",
|
||||
)
|
||||
load("@bazel_skylib//rules:write_file.bzl", "write_file")
|
||||
load(":msm_common.bzl", "define_top_level_config", "gen_config_without_source_lines", "get_out_dir")
|
||||
load(":msm_dtc.bzl", "define_dtc_dist")
|
||||
load(":image_opts.bzl", "vm_image_opts")
|
||||
@ -64,45 +65,24 @@ def _define_build_config(
|
||||
else:
|
||||
msm_arch = msm_target.replace("-", "_")
|
||||
|
||||
gen_config_command = """
|
||||
cat << 'EOF' > "$@"
|
||||
KERNEL_DIR="msm-kernel"
|
||||
VARIANTS=(%s)
|
||||
MSM_ARCH=%s
|
||||
VARIANT=%s
|
||||
|
||||
PREFERRED_USERSPACE=%s
|
||||
VM_DTB_IMG_CREATE=%d
|
||||
|
||||
KERNEL_OFFSET=0x%X
|
||||
DTB_OFFSET=0x%X
|
||||
RAMDISK_OFFSET=0x%X
|
||||
CMDLINE_CPIO_OFFSET=0x%X
|
||||
|
||||
VM_SIZE_EXT4=%d
|
||||
DUMMY_IMG_SIZE=%d
|
||||
|
||||
EOF
|
||||
""" % (
|
||||
" ".join([v.replace("-", "_") for v in vm_variants]), # VARIANTS
|
||||
msm_arch, # MSM_ARCH
|
||||
variant.replace("-", "_"), # VARIANT
|
||||
vm_image_opts.preferred_usespace, # PREFERED_USERSPACE
|
||||
int(vm_image_opts.vm_dtb_img_create), # VM_DTB_IMG_CREATE
|
||||
vm_image_opts.kernel_offset, # KERNEL_OFFSET
|
||||
vm_image_opts.dtb_offset, # DTB_OFFSET
|
||||
vm_image_opts.ramdisk_offset, # RAMDISK_OFFSET
|
||||
vm_image_opts.cmdline_cpio_offset, # CMDLINE_CPIO_OFFSET
|
||||
vm_image_opts.vm_size_ext4, # VM_SIZE_EXT4
|
||||
vm_image_opts.dummy_img_size, # DUMMY_IMG_SIZE
|
||||
)
|
||||
|
||||
# Generate the build config
|
||||
native.genrule(
|
||||
write_file(
|
||||
name = "{}_build_config_bazel".format(target),
|
||||
srcs = [],
|
||||
outs = ["build.config.msm.{}.generated".format(target)],
|
||||
cmd_bash = gen_config_command,
|
||||
out = "build.config.msm.{}.generated".format(target),
|
||||
content = [
|
||||
'KERNEL_DIR="msm-kernel"',
|
||||
"VARIANTS=({})".format(" ".join([v.replace("-", "_") for v in vm_variants])),
|
||||
"MSM_ARCH={}".format(msm_arch),
|
||||
"VARIANT={}".format(variant.replace("-", "_")),
|
||||
"PREFERRED_USERSPACE={}".format(vm_image_opts.preferred_usespace),
|
||||
"VM_DTB_IMG_CREATE={}".format(int(vm_image_opts.vm_dtb_img_create)),
|
||||
"KERNEL_OFFSET=0x%X" % vm_image_opts.kernel_offset,
|
||||
"DTB_OFFSET=0x%X" % vm_image_opts.dtb_offset,
|
||||
"RAMDISK_OFFSET=0x%X" % vm_image_opts.ramdisk_offset,
|
||||
"CMDLINE_CPIO_OFFSET=0x%X" % vm_image_opts.cmdline_cpio_offset,
|
||||
"VM_SIZE_EXT4={}".format(vm_image_opts.vm_size_ext4),
|
||||
"DUMMY_IMG_SIZE={}".format(vm_image_opts.dummy_img_size),
|
||||
"", # Needed for newline at end of file
|
||||
],
|
||||
)
|
||||
|
||||
top_level_config = define_top_level_config(target)
|
||||
|
Loading…
Reference in New Issue
Block a user