5

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.

2 Answers 2

4

tensorflow-io contains bazel build files here:

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.

Sign up to request clarification or add additional context in comments.

Comments

1
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",
    ]
)

1 Comment

I am not sure this works. For example, running this with dynamodb instead of s3 gives: ``` ERROR: /path/to/BUILD:3:6: output 'ext/aws/lib/libaws-cpp-sdk-core.so' was not created ERROR: /path/to/BUILD:3:6: output 'ext/aws/lib/libaws-cpp-sdk-dynamodb.so' was not created ERROR: /path/to/BUILD:3:6: Foreign Cc - CMake: Building aws failed: not all outputs were created or valid ```

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.