// Copyright (c) 2024, Intel Corporation

// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:

// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.

package {
    default_applicable_licenses: ["external_gmmlib_license"],
}

license {
    name: "external_gmmlib_license",
    visibility: [":__subpackages__"],
    license_text: [
        "LICENSE.md",
    ],
}

cc_library_shared {
    name: "libigdgmm_android",
    vendor: true,
    srcs: [
        "Source/GmmLib/CachePolicy/GmmCachePolicy.cpp",
        "Source/GmmLib/CachePolicy/GmmCachePolicyCommon.cpp",
        "Source/GmmLib/CachePolicy/GmmGen10CachePolicy.cpp",
        "Source/GmmLib/CachePolicy/GmmGen11CachePolicy.cpp",
        "Source/GmmLib/CachePolicy/GmmGen12CachePolicy.cpp",
        "Source/GmmLib/CachePolicy/GmmGen12dGPUCachePolicy.cpp",
        "Source/GmmLib/CachePolicy/GmmGen8CachePolicy.cpp",
        "Source/GmmLib/CachePolicy/GmmGen9CachePolicy.cpp",
        "Source/GmmLib/CachePolicy/GmmXe2_LPGCachePolicy.cpp",
        "Source/GmmLib/CachePolicy/GmmXe_LPGCachePolicy.cpp",
        "Source/GmmLib/GlobalInfo/GmmClientContext.cpp",
        "Source/GmmLib/GlobalInfo/GmmInfo.cpp",
        "Source/GmmLib/GlobalInfo/GmmLibDllMain.cpp",
        "Source/GmmLib/Platform/GmmGen10Platform.cpp",
        "Source/GmmLib/Platform/GmmGen11Platform.cpp",
        "Source/GmmLib/Platform/GmmGen12Platform.cpp",
        "Source/GmmLib/Platform/GmmGen8Platform.cpp",
        "Source/GmmLib/Platform/GmmGen9Platform.cpp",
        "Source/GmmLib/Platform/GmmPlatform.cpp",
        "Source/GmmLib/Resource/GmmResourceInfo.cpp",
        "Source/GmmLib/Resource/GmmResourceInfoCommon.cpp",
        "Source/GmmLib/Resource/GmmResourceInfoCommonEx.cpp",
        "Source/GmmLib/Resource/GmmRestrictions.cpp",
        "Source/GmmLib/Resource/Linux/GmmResourceInfoLinCWrapper.cpp",
        "Source/GmmLib/Texture/GmmGen10Texture.cpp",
        "Source/GmmLib/Texture/GmmGen11Texture.cpp",
        "Source/GmmLib/Texture/GmmGen12Texture.cpp",
        "Source/GmmLib/Texture/GmmGen7Texture.cpp",
        "Source/GmmLib/Texture/GmmGen8Texture.cpp",
        "Source/GmmLib/Texture/GmmGen9Texture.cpp",
        "Source/GmmLib/Texture/GmmTexture.cpp",
        "Source/GmmLib/Texture/GmmTextureAlloc.cpp",
        "Source/GmmLib/Texture/GmmTextureOffset.cpp",
        "Source/GmmLib/Texture/GmmTextureSpecialCases.cpp",
        "Source/GmmLib/Texture/GmmXe_LPGTexture.cpp",
        "Source/GmmLib/TranslationTable/GmmAuxTable.cpp",
        "Source/GmmLib/TranslationTable/GmmPageTableMgr.cpp",
        "Source/GmmLib/TranslationTable/GmmUmdTranslationTable.cpp",
        "Source/GmmLib/Utility/CpuSwizzleBlt/CpuSwizzleBlt.c",
        "Source/GmmLib/Utility/GmmLog/GmmLog.cpp",
        "Source/GmmLib/Utility/GmmUtility.cpp",
        "Source/Common/AssertTracer/AssertTracer.cpp",
    ],

    cflags: [
        "-DGMM_LIB_DLL",
        "-DGMM_LIB_DLL_EXPORTS",
        "-DGMM_UNIFIED_LIB",
        "-DGMM_UNIFY_DAF_API",
        "-DISTDLIB_UMD",
        "-DSMALL_POOL_ALLOC",
        "-DUNUSED_ISTDLIB_MT",
        "-D_ATL_NO_WIN_SUPPORT",
        "-D_RELEASE",
        "-D_X64",
        "-D__GFX_MACRO_C__",
        "-D__GMM",
        "-D__STDC_CONSTANT_MACROS",
        "-D__STDC_LIMIT_MACROS",
        "-D__UMD",
        "-Digfx_gmmumd_dll_EXPORTS",
        "-fvisibility=hidden",
        "-fno-omit-frame-pointer",
        "-march=corei7",
        "-Werror",
        "-Wno-logical-op-parentheses",
        "-Wno-shift-negative-value",
        "-Wno-unused-parameter",
    ],

    cppflags: [
        "-Wno-implicit-fallthrough",
        "-Wno-missing-braces",
        "-Wno-unknown-pragmas",
        "-Wno-parentheses",
        "-Wno-pragma-pack",
        "-fexceptions",
        "-std=c++11",
        "-fvisibility-inlines-hidden",
        "-fno-use-cxa-atexit",
        "-fno-rtti",
        "-fcheck-new",
        "-pthread",
    ],

    local_include_dirs: [
        "Source/GmmLib",
        "Source/GmmLib/Utility/GmmLog",
        "Source/GmmLib/inc",
        "Source/GmmLib/Utility",
        "Source/GmmLib/GlobalInfo",
        "Source/GmmLib/Texture",
        "Source/GmmLib/Resource",
        "Source/GmmLib/Platform",
        "Source/util",
        "Source/inc",
        "Source/inc/common",
        "Source/inc/umKmInc",
    ],

    enabled: false,
    arch: {
        x86_64: {
            enabled: true,
        },
    },
}

cc_library_headers {
    name: "libigdgmm_headers",
    vendor: true,
    export_include_dirs: [
        "Source/GmmLib/inc",
        "Source/inc",
        "Source/inc/common",
    ],

    enabled: false,
    arch: {
        x86_64: {
            enabled: true,
        },
    },
}
