module(name = "net_eagle0")

# Version constants
SCALA_VERSION = "3.7.2"

NETTY_VERSION = "4.1.110.Final"

SCALAPB_VERSION = "1.0.0-alpha.1"

AWS_SDK_VERSION = "2.28.1"

#
# Core Build Tools
#

bazel_dep(name = "bazel_skylib", version = "1.8.1")
bazel_dep(name = "rules_pkg", version = "1.1.0")

#
# Language Support - Scala
#

bazel_dep(name = "rules_scala", version = "7.1.1")

scala_config = use_extension(
    "@rules_scala//scala/extensions:config.bzl",
    "scala_config",
)

scala_config.settings(scala_version = SCALA_VERSION)

scala_deps = use_extension(
    "@rules_scala//scala/extensions:deps.bzl",
    "scala_deps",
)

scala_deps.scala()

scala_deps.scalatest()

scala_deps.scala_proto()

#
# Language Support - C++
#

bazel_dep(name = "toolchains_llvm", version = "1.4.0")

llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm")

llvm.toolchain(
    name = "llvm_toolchain",
    llvm_version = "20.1.2",
)

use_repo(llvm, "llvm_toolchain")

#
# Language Support - Go
#

bazel_dep(name = "rules_go", repo_name = "io_bazel_rules_go", version = "0.56.1")
bazel_dep(name = "gazelle", repo_name = "bazel_gazelle", version = "0.45.0")

go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk")

go_sdk.download(version = "1.23.3")

go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps")

go_deps.from_file(go_mod = "//:go.mod")

use_repo(
    go_deps,
    "com_github_aws_aws_sdk_go_v2",
    "com_github_aws_aws_sdk_go_v2_config",
    "com_github_aws_aws_sdk_go_v2_credentials",
    "com_github_aws_aws_sdk_go_v2_service_s3",
    "org_golang_google_protobuf",
)

#
# Platform Support - Apple/iOS
#

bazel_dep(name = "apple_support", repo_name = "build_bazel_apple_support", version = "1.21.1")
bazel_dep(name = "rules_apple", repo_name = "build_bazel_rules_apple", version = "3.16.1")
bazel_dep(name = "rules_swift", repo_name = "build_bazel_rules_swift", version = "2.3.1")

#
# Protocol Buffers & RPC
#

bazel_dep(name = "protobuf", repo_name = "com_google_protobuf", version = "29.2")
bazel_dep(name = "grpc", version = "1.71.0")
bazel_dep(name = "grpc-java", version = "1.71.0")
bazel_dep(name = "flatbuffers", version = "25.2.10")

#
# Testing
#

bazel_dep(name = "googletest", version = "1.17.0")

#
# Java/Scala Dependencies
#

bazel_dep(name = "rules_jvm_external", version = "6.3")

maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")

maven.install(
    artifacts = [
        # Netty
        "io.netty:netty-codec:%s" % NETTY_VERSION,
        "io.netty:netty-codec-http:%s" % NETTY_VERSION,
        "io.netty:netty-codec-socks:%s" % NETTY_VERSION,
        "io.netty:netty-codec-http2:%s" % NETTY_VERSION,
        "io.netty:netty-handler:%s" % NETTY_VERSION,
        "io.netty:netty-buffer:%s" % NETTY_VERSION,
        "io.netty:netty-transport:%s" % NETTY_VERSION,
        "io.netty:netty-resolver:%s" % NETTY_VERSION,
        "io.netty:netty-common:%s" % NETTY_VERSION,
        "io.netty:netty-handler-proxy:%s" % NETTY_VERSION,

        # ScalaPB
        "com.thesamet.scalapb:lenses_3:%s" % SCALAPB_VERSION,
        "com.thesamet.scalapb:scalapb-json4s_3:%s" % SCALAPB_VERSION,
        "com.thesamet.scalapb:scalapb-runtime_3:%s" % SCALAPB_VERSION,
        "com.thesamet.scalapb:scalapb-runtime-grpc_3:%s" % SCALAPB_VERSION,
        "com.thesamet.scalapb:compilerplugin_3:%s" % SCALAPB_VERSION,
        "com.thesamet.scalapb:protoc-bridge_3:0.9.9",

        # JSON
        "org.json4s:json4s-ast_3:4.1.0-M8",
        "org.json4s:json4s-core_3:4.1.0-M8",
        "org.json4s:json4s-native_3:4.1.0-M8",

        # Testing
        "org.scalamock:scalamock_3:7.4.1",

        # AWS SDK
        "software.amazon.awssdk:s3-transfer-manager:%s" % AWS_SDK_VERSION,
        "software.amazon.awssdk:s3:%s" % AWS_SDK_VERSION,
        "software.amazon.awssdk:regions:%s" % AWS_SDK_VERSION,
        "software.amazon.awssdk:aws-core:%s" % AWS_SDK_VERSION,
        "software.amazon.awssdk:sdk-core:%s" % AWS_SDK_VERSION,
        "software.amazon.awssdk:utils:%s" % AWS_SDK_VERSION,
        "software.amazon.awssdk:http-client-spi:%s" % AWS_SDK_VERSION,

        # AWS Lambda
        "com.amazonaws:aws-lambda-java-core:1.2.3",
        "com.amazonaws:aws-lambda-java-events:3.13.0",

        # Logging
        "org.slf4j:slf4j-api:2.0.16",
        "org.slf4j:slf4j-simple:2.0.16",

        # Other
        "org.reactivestreams:reactive-streams:1.0.4",
        "javax.xml.bind:jaxb-api:2.3.1",
    ],
    duplicate_version_warning = "error",
    fail_if_repin_required = True,
    lock_file = "//:maven_install.json",
    repositories = [
        "https://repo1.maven.org/maven2",
    ],
)

use_repo(maven, "maven", "unpinned_maven")

#
# External Libraries
#

http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# GTL (for parallel_hashmap)
GTL_VERSION = "1.2.0"

GTL_SHA = "1969c45dd76eac0dd87e9e2b65cffe358617f4fe1bcd203f72f427742537913a"

http_archive(
    name = "gtl",
    build_file = "@//external:BUILD.gtl",
    sha256 = GTL_SHA,
    strip_prefix = "gtl-%s" % GTL_VERSION,
    url = "https://github.com/greg7mdp/gtl/archive/refs/tags/v%s.zip" % GTL_VERSION,
)

# Unity GoDice Plugin
UNITY_GODICE_COMMIT = "18d6823991592e4d45fcc0f22692db849dea9063"

UNITY_GODICE_SHA = "04e6ae4155965aab3372592e04061eba1256bb6ea7ccffd0d83f27574e5b3349"

http_archive(
    name = "net_eagle0_unity_godice",
    sha256 = UNITY_GODICE_SHA,
    strip_prefix = "godice-framework-%s" % UNITY_GODICE_COMMIT,
    urls = [
        "https://github.com/nolen777/godice-framework/archive/%s.zip" % UNITY_GODICE_COMMIT,
    ],
)

#
# Toolchain Registration
#

register_toolchains(
    "//tools:unused_dependency_checker_error_and_opts_toolchain",
    "@rules_scala//testing:scalatest_toolchain",
)

# Set dev_dependency so we can turn this off for swift MacOS builds
register_toolchains(
    "@llvm_toolchain//:all",
    dev_dependency = True,
)
