load("@rules_cc//cc:cc_import.bzl", "cc_import")
load("@rules_cc//cc:cc_library.bzl", "cc_library")

package_group(
    name = "android_cuttlefish",
    packages = [
        "//...",
    ],
)

package(
    default_visibility = ["//:android_cuttlefish"],
)

exports_files([
    ".clang-format",
    ".clang-tidy",
])

genrule(
    name = "build_compilation_mode_txt",
    outs = ["build/compilation_mode.txt"],
    cmd = "echo $(COMPILATION_MODE) > $@",
)

filegroup(
    name = "clang_tidy_config",
    srcs = [
        ".clang-tidy",
        "//cuttlefish/io:.clang-tidy",
        "//cuttlefish/common/libs/key_equals_value:.clang-tidy",
        "//cuttlefish/host/commands/assemble_cvd/android_build:.clang-tidy",
        "//cuttlefish/host/commands/cvd/cli/commands:.clang-tidy",
        "//cuttlefish/host/commands/kernel_log_monitor:.clang-tidy",
        "//cuttlefish/host/commands/mkenvimage_slim:.clang-tidy",
        "//cuttlefish/host/commands/run_cvd:.clang-tidy",
        "//cuttlefish/host/libs/config:.clang-tidy",
        "//cuttlefish/host/libs/config/esp:.clang-tidy",
        "//cuttlefish/host/libs/web:.clang-tidy",
        "//cuttlefish/host/libs/zip:.clang-tidy",
        "//cuttlefish/host/libs/zip/libzip_cc:.clang-tidy",
    ],
)

# for crosvm/jail. Has to be in the base repository, as the @crosvm repository isn't visible.
#
# Collections of python files can be combined into a zip file. The python
# interpreter can execute these zip files. Zip files are identified by a suffix
# rather than a prefix, so we can prepend '#!/usr/bin/python' to make the zip
# archive into an executable that automatically invokes the system python to
# run it.
genrule(
    name = "compile_seccomp_policy_exe",
    srcs = ["@crosvm//:compile_seccomp_policy_zip"],
    outs = ["compile_seccomp_policy.py"],
    cmd = "cat <(echo \"#!/usr/bin/python3\n\") $(location @crosvm//:compile_seccomp_policy_zip) > \"$@\"",
    executable = True,
    visibility = ["//visibility:public"],
)

# for crosvm/third_party/minijail/rust/minijail
alias(
    name = "minijail_sources",
    actual = "@crosvm//:minijail_sources",
    visibility = ["//visibility:public"],
)

# Create an alias so that crosvm's rutabaga_gfx crate has visibility into the
# gfxstream repository.
alias(
    name = "gfxstream_backend",
    actual = "@gfxstream//host:gfxstream_backend",
    visibility = ["//visibility:public"],
)

# Useful for `rust_library()`s which can not directly depend on a `cc_shared_library()`.
# TODO: remove after ag/33719949 and update alias above to reference directly.
cc_import(
    name = "gfxstream_backend_import",
    shared_library = ":gfxstream_backend",
    visibility = ["//visibility:public"],
)
