// This step is only required for ARM. MIPS uses intrinsics exclusively and x86
// requires 'yasm' to pre-process its assembly files.
// The ARM assembly sources must be converted from ADS to GAS compatible format.
gensrcs {
    name: "libvpx_arm_neon_asm_srcs_converted",
    srcs: libvpx_arm_neon_asm_srcs,
    tool_files: [
        "libvpx/build/make/ads2gas.pl",
        "libvpx/build/make/thumb.pm",
    ],
    output_extension: "asm.S",
    cmd: "cat $(in) | perl $(location libvpx/build/make/ads2gas.pl) > $(out)",
    export_include_dirs: ["libvpx"],
}

cc_library_static {
    name: "libvpx",
    vendor_available: true,

    arch: {
        arm: {
            // Clang arm assembler cannot compile libvpx .S files yet.
            clang_asflags: ["-no-integrated-as"],

            // Want arm, not thumb, optimized
            instruction_set: "arm",

            srcs: libvpx_arm_c_srcs,
            local_include_dirs: ["config/arm"],

            neon: {
                exclude_srcs: libvpx_arm_neon_exclude_c_srcs,
                srcs: libvpx_arm_neon_c_srcs,
                generated_sources: ["libvpx_arm_neon_asm_srcs_converted"],
                local_include_dirs: ["config/arm-neon"],
            },
        },

        arm64: {
            srcs: libvpx_arm64_c_srcs,
            local_include_dirs: ["config/arm64"],
        },

        mips: {
            srcs: libvpx_mips32_c_srcs,
            local_include_dirs: ["config/mips32"],

            dspr2: {
                exclude_srcs: libvpx_mips32_dspr2_exclude_c_srcs,
                srcs: libvpx_mips32_dspr2_c_srcs,
                local_include_dirs: ["config/mips32-dspr2"],
            },

            msa: {
                exclude_srcs: libvpx_mips32_msa_exclude_c_srcs,
                srcs: libvpx_mips32_msa_c_srcs,
                local_include_dirs: ["config/mips32-msa"],
            },
        },

        mips64: {
            srcs: libvpx_mips64_c_srcs,
            local_include_dirs: ["config/mips64"],

            msa: {
                exclude_srcs: libvpx_mips64_msa_exclude_c_srcs,
                srcs: libvpx_mips64_msa_c_srcs,
                local_include_dirs: ["config/mips64-msa"],
            },
        },

        x86: {
            srcs: libvpx_x86_c_srcs + libvpx_x86_asm_srcs,
            local_include_dirs: ["config/x86"],
        },

        x86_64: {
            //srcs: libvpx_x86_64_c_srcs + libvpx_x86_64_asm_srcs,
            //local_include_dirs: ["config/x86_64"],
            srcs: libvpx_generic_c_srcs,
            local_include_dirs: ["config/generic"],
        },
    },

    cflags: [
        "-O3",
        "-Wno-unused-parameter",
    ],

    export_include_dirs: ["libvpx"],

    sanitize: {
        cfi: true,
        diag: {
            cfi: true,
        },
        blacklist: "cfi_blacklist.txt",
    },
}

subdirs = [
    "libwebm",
]