android_kernel_samsung_sm8650/msm_common.bzl
John Moon 8503690aa2 build: Add support for Bazel VM builds
Currently, only legacy build.sh support exists for VM
builds.

Add Bazel support for these builds.

Change-Id: I10b221aa4a6633240b984eff333e15f5cd8b82cd
Signed-off-by: John Moon <quic_johmoo@quicinc.com>
2022-11-14 15:05:22 -08:00

35 lines
1.0 KiB
Python

def define_top_level_config(target):
"""Define common top-level variables in build.config"""
rule_name = "{}_top_level_config".format(target)
native.genrule(
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
""",
)
return ":{}".format(rule_name)
def gen_config_without_source_lines(build_config, target):
"""Replace "." or "source" lines in build.config files with shell null operator"""
rule_name = "{}.{}".format(target, build_config)
out_file_name = rule_name + ".generated"
native.genrule(
name = rule_name,
srcs = [build_config],
outs = [out_file_name],
cmd_bash = """
sed -e 's/^ *\\. /: # &/' \
-e 's/^ *source /: # &/' \
$(location {}) > "$@"
""".format(build_config),
)
return ":" + rule_name