My directory structure is as follows:
main | WORKSPACE | external > | BUILD I have a single BUILD file under external. My workspace file pulls the AWS SDK:
load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies") rules_foreign_cc_dependencies() _ALL_CONTENT = """\ filegroup( name = "all_srcs", srcs = glob(["**"]), visibility = ["//visibility:public"], ) """ new_git_repository( name = "aws_sdk", remote = "https://github.com/aws/aws-sdk-cpp", branch = "master", build_file_content = _ALL_CONTENT, init_submodules = True, recursive_init_submodules = True, ) and my BUILD file builds it:
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake") cmake( name = "aws", cache_entries = { "CMAKE_BUILD_TYPE": "Release", "BUILD_ONLY": "dynamodb", "BUILD_SHARED_LIBS": "ON", "ENABLE_TESTING": "OFF", }, lib_source = "@aws_sdk//:all_srcs", out_shared_libs = [ "libaws-cpp-sdk-core.so", "libaws-cpp-sdk-dynamodb.so", ] ) However, when I try and run bazel build //external:aws --verbose_failures, I get this error:
ERROR: Skipping '//external:aws': no such target '//external:aws': target 'aws' not declared in package 'external' defined by /path/to/WORKSPACE WARNING: Target pattern parsing failed. I'm really not sure why this error is coming up. Is there something I'm missing?
EDIT: I found that it is because I changed the BUILD directory from library to external. It seems to build when I change it back to library; is there a way I can get it to build using a new directory name?