Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Rules Foreign CC to Build AWS C++ SDK with Bazel

Is there a way to do this? I'm trying to build parts of the AWS SDK (s3 and rds) to use in my Bazel project. I've heard that rules_foreign_cc can be used to integrate CMake projects with Bazel.

like image 635
user15507541 Avatar asked Sep 10 '25 01:09

user15507541


2 Answers

tensorflow-io contains bazel build files here:

  • WORKSPACE
  • BUILD file

Might be slightly cleaner to adopt these vs using rules_foreign_cc. Note that above links refer to a specific hash in the repo - the files might have changed upstream.

like image 90
Sebastian Avatar answered Sep 13 '25 07:09

Sebastian


load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")

rules_foreign_cc_dependencies()

AWS_BUILD = """\
filegroup(
    name = "sdk",
    srcs = glob(["**"]),
    visibility = ["//visibility:public"],
)
"""

new_git_repository(
    name = "aws_sdk",
    build_file_content = _ALL_CONTENT,
    commit = "2550901e1011e0ee1dc1bae44b42e1a2c6947c24",
    recursive_init_submodules = True,
    remote = "https://github.com/aws/aws-sdk-cpp",
    shallow_since = "1628277923 +0000",
)

Then you can reference the binaries from within the BUILD file. Just build the aws-sdk using cmake.

load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")

cmake(
    name = "aws_sdk",
    cache_entries = {
        "CMAKE_BUILD_TYPE": "Release",
        "BUILD_ONLY": "s3",
        "BUILD_SHARED_LIBS": "ON", 
        "ENABLE_TESTING": "OFF",
    },
    install = True,
    lib_source = "@aws_sdk//:sdk",
    out_shared_libs = [
        "libaws-cpp-sdk-core.so",
        "libaws-cpp-sdk-s3.so",
    ]
)
like image 41
Jakkie555 Avatar answered Sep 13 '25 07:09

Jakkie555