%YAML 1.2
--- |
    // swift-tools-version:5.5
    // The swift-tools-version declares the minimum version of Swift required to build this package.
    import PackageDescription
    import Foundation

    let basePath = "third_party/boringssl-with-bazel"
    let privacyInfoPath = "../../src/objective-c/PrivacyInfo.xcprivacy"
    let testPath = "test/boringssl_spm_build"
    


    let package = Package(
      name: "BoringSSL-GRPC",
      products: [
        .library(
          name: "openssl_grpc",
          targets: ["openssl_grpc"]
        )
      ],
    
      targets: [
        .target(
          name: "openssl_grpc",
          path: basePath,
          exclude: [
          ],
        <%
          def remove_prefix(s, prefix):
            return s[len(prefix):] if s.startswith(prefix) else s
          files = []
          lib_maps = {lib.name: lib for lib in libs}
          for dep in swift_boringssl_package.get('deps', []):
            lib = lib_maps[dep]
            files.extend(lib.src)
          files = sorted(set({remove_prefix(file, "third_party/boringssl-with-bazel/"): file for file in files}))
        %>
          sources: [
            % for file in files:
            "${file}",
            % endfor
          ],
          resources: [
            .copy(privacyInfoPath),
          ],
          publicHeadersPath: "src/include",

          cSettings: [
            .define("OPENSSL_NO_ASM", to: "1"),
            .headerSearchPath("./"),
            .headerSearchPath("include/"),
          ]
        ),
        .testTarget(
          name: "build-test",
          dependencies: [
            "openssl_grpc",
          ],
          path: testPath
        ),
      ],
      cxxLanguageStandard: .cxx14
    )