Skip to content

Commit

Permalink
[workspace] Add boost_internal
Browse files Browse the repository at this point in the history
Also add com_github_nelhage_rules_boost_internal for its BUILD file.

These two repositories are not enabled by default.
They are only used when --WITH_USD=ON is enabled.
  • Loading branch information
jwnimmer-tri committed Feb 25, 2024
1 parent b1fb486 commit de4fd16
Show file tree
Hide file tree
Showing 10 changed files with 117 additions and 10 deletions.
3 changes: 3 additions & 0 deletions tools/workspace/boost_internal/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
load("//tools/lint:lint.bzl", "add_lint_tests")

add_lint_tests()
21 changes: 21 additions & 0 deletions tools/workspace/boost_internal/repository.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
load("//tools/workspace:github.bzl", "github_release_attachments")

def boost_internal_repository(
name,
mirrors = None):
github_release_attachments(
name = name,
repository = "boostorg/boost",
commit = "boost-1.84.0",
attachments = {
"boost-1.84.0.tar.xz": "2e64e5d79a738d0fa6fb546c6e5c2bd28f88d268a2a080546f74e5ff98f29d0e", # noqa
},
strip_prefix = {
"boost-1.84.0.tar.xz": "boost-1.84.0",
},
build_file = "@com_github_nelhage_rules_boost_internal//:boost.BUILD",
mirrors = mirrors,
repo_mapping = {
"@com_github_nelhage_rules_boost": "@com_github_nelhage_rules_boost_internal", # noqa
},
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
load("//tools/lint:lint.bzl", "add_lint_tests")

add_lint_tests()
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[com_github_nelhage_rules_boost] Disable iostreams deps

OpenUSD uses :multi_index which depends on :serialization which
depends on :iostreams which depends on some compression libraries.

In Drake, we don't expect to use any of those compression features,
so we'll cut away the extra dependencies for simplicity.

Since this is a Drake-specific customization, we don't plan on
upstreaming this patch.


--- boost.BUILD
+++ boost.BUILD
@@ -1131,10 +1131,13 @@
":type",
":type_traits",
":utility",
- "@com_github_facebook_zstd//:zstd",
- "@org_bzip_bzip2//:bz2lib",
- "@org_lzma_lzma//:lzma",
- "@zlib",
+ ],
+ exclude_src = [
+ "libs/iostreams/src/bzip2.cpp",
+ "libs/iostreams/src/gzip.cpp",
+ "libs/iostreams/src/lzma.cpp",
+ "libs/iostreams/src/zlib.cpp",
+ "libs/iostreams/src/zstd.cpp",
],
)

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
load("//tools/workspace:github.bzl", "github_archive")

def com_github_nelhage_rules_boost_internal_repository(
name,
mirrors = None):
github_archive(
name = name,
repository = "nelhage/rules_boost",
commit = "f621ad7bec2abf5a597ed1271fd823d2761943b2",
sha256 = "eb2cadbeb990785d8004d7063cac5fba72518cee7bdd2b9f7597affdced7524e", # noqa
patches = [
":patches/iostreams.patch",
],
mirrors = mirrors,
)
6 changes: 6 additions & 0 deletions tools/workspace/default.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ load("//tools/workspace/abseil_cpp_internal:repository.bzl", "abseil_cpp_interna
load("//tools/workspace/bazelisk:repository.bzl", "bazelisk_repository")
load("//tools/workspace/bazel_skylib:repository.bzl", "bazel_skylib_repository") # noqa
load("//tools/workspace/blas:repository.bzl", "blas_repository")
load("//tools/workspace/boost_internal:repository.bzl", "boost_internal_repository") # noqa
load("//tools/workspace/build_bazel_apple_support:repository.bzl", "build_bazel_apple_support_repository") # noqa
load("//tools/workspace/buildifier:repository.bzl", "buildifier_repository")
load("//tools/workspace/cc:repository.bzl", "cc_repository")
Expand All @@ -12,6 +13,7 @@ load("//tools/workspace/clang_cindex_python3_internal:repository.bzl", "clang_ci
load("//tools/workspace/clarabel_cpp_internal:repository.bzl", "clarabel_cpp_internal_repository") # noqa
load("//tools/workspace/clp_internal:repository.bzl", "clp_internal_repository") # noqa
load("//tools/workspace/coinutils_internal:repository.bzl", "coinutils_internal_repository") # noqa
load("//tools/workspace/com_github_nelhage_rules_boost_internal:repository.bzl", "com_github_nelhage_rules_boost_internal_repository") # noqa
load("//tools/workspace/com_jidesoft_jide_oss:repository.bzl", "com_jidesoft_jide_oss_repository") # noqa
load("//tools/workspace/common_robotics_utilities:repository.bzl", "common_robotics_utilities_repository") # noqa
load("//tools/workspace/commons_io:repository.bzl", "commons_io_repository")
Expand Down Expand Up @@ -122,6 +124,8 @@ def add_default_repositories(excludes = [], mirrors = DEFAULT_MIRRORS):
bazel_skylib_repository(name = "bazel_skylib", mirrors = mirrors)
if "blas" not in excludes:
blas_repository(name = "blas")
if "boost_internal" not in excludes:
boost_internal_repository(name = "boost_internal", mirrors = mirrors)
if "build_bazel_apple_support" not in excludes:
build_bazel_apple_support_repository(name = "build_bazel_apple_support", mirrors = mirrors) # noqa
if "buildifier" not in excludes:
Expand All @@ -140,6 +144,8 @@ def add_default_repositories(excludes = [], mirrors = DEFAULT_MIRRORS):
coinutils_internal_repository(name = "coinutils_internal", mirrors = mirrors) # noqa
if "com_jidesoft_jide_oss" not in excludes:
com_jidesoft_jide_oss_repository(name = "com_jidesoft_jide_oss", mirrors = mirrors) # noqa
if "com_github_nelhage_rules_boost_internal" not in excludes:
com_github_nelhage_rules_boost_internal_repository(name = "com_github_nelhage_rules_boost_internal", mirrors = mirrors) # noqa
if "common_robotics_utilities" not in excludes:
common_robotics_utilities_repository(name = "common_robotics_utilities", mirrors = mirrors) # noqa
if "commons_io" not in excludes:
Expand Down
26 changes: 21 additions & 5 deletions tools/workspace/github.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ def github_release_attachments(
repository = None,
commit = None,
attachments = None,
strip_prefix = None,
build_file = None,
mirrors = None,
upgrade_advice = None,
Expand All @@ -418,6 +419,9 @@ def github_release_attachments(
commit: required commit is the tag name to download.
attachments: required dict whose keys are the filenames (attachment
names) to download and values are the expected SHA-256 checksums.
strip_prefix: optional dict whose keys are the filenames and values are
indicate that the attachment should be extracted (e.g., `*.tar.gz`
files) and in that case what prefix to strip when doing so.
build_file: required build file is the BUILD file label to use for
building this external. As a Drake-specific abbreviation, when
provided as a relative label (e.g., ":package.BUILD.bazel"), it
Expand Down Expand Up @@ -450,6 +454,7 @@ def github_release_attachments(
repository = repository,
commit = commit,
attachments = attachments,
strip_prefix = strip_prefix,
build_file = build_file,
mirrors = mirrors,
upgrade_advice = upgrade_advice,
Expand Down Expand Up @@ -478,6 +483,7 @@ _github_release_attachments_real = repository_rule(
"attachments": attr.string_dict(
mandatory = True,
),
"strip_prefix": attr.string_dict(),
"build_file": attr.label(
mandatory = True,
),
Expand All @@ -502,6 +508,7 @@ def setup_github_release_attachments(repository_ctx):
repository = repository_ctx.attr.repository
commit = repository_ctx.attr.commit
attachments = repository_ctx.attr.attachments
strip_prefix = getattr(repository_ctx.attr, "strip_prefix", dict())
mirrors = repository_ctx.attr.mirrors
upgrade_advice = getattr(repository_ctx.attr, "upgrade_advice", "")
patterns = mirrors.get("github_release_attachments")
Expand All @@ -517,11 +524,19 @@ def setup_github_release_attachments(repository_ctx):
)
for pattern in patterns
]
repository_ctx.download(
urls,
output = filename,
sha256 = _sha256(sha256),
)
should_strip_prefix = strip_prefix.get(filename, None)
if should_strip_prefix != None:
repository_ctx.download_and_extract(
urls,
stripPrefix = should_strip_prefix,
sha256 = _sha256(sha256),
)
else:
repository_ctx.download(
urls,
output = filename,
sha256 = _sha256(sha256),
)
downloads.append(dict(
urls = urls,
sha256 = sha256,
Expand All @@ -537,6 +552,7 @@ def setup_github_release_attachments(repository_ctx):
repository = repository,
commit = commit,
attachments = attachments,
strip_prefix = strip_prefix,
downloads = downloads,
upgrade_advice = upgrade_advice,
)
Expand Down
1 change: 1 addition & 0 deletions tools/workspace/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def read_repository_metadata(repositories=None):
# NOTE: At this time, we are skipping the rust_toolchain repositories;
# see TODO in tools/workspace/rust_toolchain/repository.bzl.
repositories.add("bazel_skylib")
repositories.add("com_github_nelhage_rules_boost_internal")

# Make sure all of the repository_rule results are up-to-date.
subprocess.check_call(["bazel", "fetch", "//..."])
Expand Down
4 changes: 0 additions & 4 deletions tools/workspace/openusd_internal/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ sh_test(
"//conditions:default": ["empty.sh"],
}),
args = ["--help"],
tags = [
# TODO(jwnimmer-tri) Re-enable this once we fix Boost problems.
"manual",
],
)

add_lint_tests()
16 changes: 15 additions & 1 deletion tools/workspace/openusd_internal/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,22 @@ def pxr_library(
]
deps = attrs["LIBRARIES"] + [
":pxr_h",
"@boost_internal//:any",
"@boost_internal//:functional",
"@boost_internal//:function",
"@boost_internal//:intrusive_ptr",
"@boost_internal//:mpl",
"@boost_internal//:multi_index",
"@boost_internal//:noncopyable",
"@boost_internal//:none",
"@boost_internal//:numeric_conversion",
"@boost_internal//:optional",
"@boost_internal//:preprocessor",
"@boost_internal//:ptr_container",
"@boost_internal//:smart_ptr",
"@boost_internal//:variant",
"@boost_internal//:vmd",
"@onetbb_internal//:tbb",
# TODO(jwnimmer-tri) We also need to list some @boost here.
]
cc_library(
name = name,
Expand Down

0 comments on commit de4fd16

Please sign in to comment.