// LineageOS soong configs

bootstrap_go_package {
    name: "soong-lineage-generator",
    pkgPath: "lineage/soong/generator",
    deps: [
        "blueprint",
        "blueprint-pathtools",
        "soong",
        "soong-android",
        "soong-shared",
    ],
    srcs: [
        "generator/generator.go",
        "generator/variables.go",
    ],
    pluginFor: ["soong_build"],
}

lineage_generator {
    name: "generated_kernel_includes",

    // The headers make command
    cmd: "$(PATH_OVERRIDE_SOONG) $(KERNEL_MAKE_CMD) $(KERNEL_MAKE_FLAGS) -C $(TARGET_KERNEL_SOURCE) O=$(KERNEL_BUILD_OUT_PREFIX)$(genDir) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) headers_install && vendor/lineage/tools/clean_headers.sh $(KERNEL_BUILD_OUT_PREFIX)$(genDir)",

    // Directories that can be imported by a cc_* module generated_headers property
    export_include_dirs: [
        "usr/audio/include/uapi",
        "usr/include",
        "usr/include/audio",
        "usr/include/audio/include/uapi",
        "usr/techpack/audio/include",
    ],

    // Sources for dependency tracking
    dep_root: "$(TARGET_KERNEL_SOURCE)",
    dep_files: [
        "Makefile",
        "include/**/*",
        "arch/$(KERNEL_ARCH)/include/**/*",
        "techpack/audio/include/**/*",
    ],
}

lineage_generator {
    name: "prebuilt_kernel_includes",

    // The headers extract command
    cmd: "mkdir -p $(KERNEL_BUILD_OUT_PREFIX)$(genDir) && gzip -d < $(TARGET_PREBUILT_KERNEL_HEADERS) | tar -x -C $(KERNEL_BUILD_OUT_PREFIX)$(genDir) && vendor/lineage/tools/clean_headers.sh $(KERNEL_BUILD_OUT_PREFIX)$(genDir)",

    // Directories that can be imported by a cc_* module generated_headers property
    export_include_dirs: [
        "usr/audio/include/uapi",
        "usr/include",
        "usr/include/audio",
        "usr/include/audio/include/uapi",
        "usr/techpack/audio/include",
    ],
}

bootstrap_go_package {
    name: "soong-lineage-mkdir",
    pkgPath: "lineage/soong/mkdir",
    deps: [
        "blueprint",
        "blueprint-pathtools",
        "soong",
        "soong-android",
    ],
    srcs: [
        "mkdir/init.go",
        "mkdir/mkdir.go",
    ],
    pluginFor: ["soong_build"],
}

cc_defaults {
    name: "generated_kernel_header_defaults",
    generated_headers: ["generated_kernel_includes"],
    export_generated_headers: ["generated_kernel_includes"],
    vendor_available: true,
    recovery_available: true,
}

cc_defaults {
    name: "prebuilt_kernel_header_defaults",
    generated_headers: ["prebuilt_kernel_includes"],
    export_generated_headers: ["prebuilt_kernel_includes"],
    vendor_available: true,
    recovery_available: true,
}

cc_library_headers {
    name: "generated_kernel_headers",
    defaults: ["generated_kernel_header_defaults"],
}

cc_library_headers {
    name: "qti_kernel_headers",
    defaults: ["generated_kernel_header_defaults"],
}

cc_library_headers {
    name: "prebuilt_kernel_headers",
    defaults: ["prebuilt_kernel_header_defaults"],
}
