/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * This file was created using the `create_project.py` script located in the
 * `<AndroidX root>/development/project-creator` directory.
 *
 * Please use that script when creating a new project, rather than copying an existing project and
 * modifying its settings.
 */
import androidx.build.LibraryType

plugins {
    id("AndroidXPlugin")
    id("com.android.library")
    id("kotlin-android")
}

dependencies {
    api(libs.kotlinStdlib)

    implementation("androidx.core:core:1.12.0")

    androidTestImplementation("androidx.annotation:annotation:1.8.1")
    androidTestImplementation("androidx.core:core-ktx:1.12.0")
    androidTestImplementation("androidx.test:core:1.5.0@aar")
    androidTestImplementation(libs.testExtJunit)
    androidTestImplementation(libs.testCore)
    androidTestImplementation(libs.testRunner)
    androidTestImplementation(libs.testRules)
    androidTestImplementation(libs.truth)
}

android {
    namespace = "androidx.graphics.path"

    defaultConfig {
        externalNativeBuild {
            cmake {
                cppFlags.addAll([
                    "-std=c++17",
                    "-Wno-unused-command-line-argument",
                    "-Wl,--hash-style=both", // Required to support API levels below 23
                    "-fno-exceptions",
                    "-fno-unwind-tables",
                    "-fno-asynchronous-unwind-tables",
                    "-fno-rtti",
                    "-ffast-math",
                    "-ffp-contract=fast",
                    "-fvisibility-inlines-hidden",
                    "-fvisibility=hidden",
                    "-fomit-frame-pointer",
                    "-ffunction-sections",
                    "-fdata-sections",
                    "-Wl,--gc-sections",
                    "-Wl,-Bsymbolic-functions",
                    "-nostdlib++"
                ])
            }
        }
        consumerProguardFiles "proguard-rules.pro"
    }

    externalNativeBuild {
        cmake {
            path file('src/main/cpp/CMakeLists.txt')
            version = libs.versions.cmake.get()
        }
    }
}

androidx {
    name = "Android Graphics Path"
    type = LibraryType.PUBLISHED_LIBRARY
    mavenVersion = LibraryVersions.GRAPHICS_PATH
    inceptionYear = "2022"
    description = "Query segment data for android.graphics.Path objects"
    legacyDisableKotlinStrictApiMode = true
}
