forked from RobotLocomotion/drake
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[workspace] Add OpenUSD as an optional dependency (RobotLocomotion#20923
- Loading branch information
1 parent
9560a0a
commit 84cc25a
Showing
15 changed files
with
2,700 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# -*- bazel -*- | ||
|
||
cc_library( | ||
name = "tbb", | ||
hdrs = glob([ | ||
"include/oneapi/*.h", | ||
"include/oneapi/tbb/*.h", | ||
"include/oneapi/tbb/detail/*.h", | ||
]), | ||
includes = [ | ||
"include/oneapi", | ||
], | ||
deps = [ | ||
# TODO(jwnimmer-tri) This should just be the TBB runtime, not the | ||
# entirety of MOSEK. We'll need to clean that up before we enable | ||
# WITH_USD in Drake's installed packages. | ||
"@mosek", | ||
], | ||
visibility = ["//visibility:public"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
load("//tools/workspace:github.bzl", "github_archive") | ||
|
||
def onetbb_internal_repository( | ||
name, | ||
mirrors = None): | ||
github_archive( | ||
name = name, | ||
repository = "oneapi-src/oneTBB", | ||
commit = "v2021.8.0", | ||
# TODO(jwnimmer-tri) We are using the TBB headers from this repository, | ||
# but the TBB library from MOSEK's binary release. We'll probably need | ||
# some tooling to keep all of that in sync, but for now we'll just pin. | ||
commit_pin = 1, | ||
sha256 = "eee380323bb7ce864355ed9431f85c43955faaae9e9bce35c62b372d7ffd9f8b", # noqa | ||
build_file = ":package.BUILD.bazel", | ||
mirrors = mirrors, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
load("//tools/workspace:generate_file.bzl", "generate_file") | ||
load("//tools/lint:lint.bzl", "add_lint_tests") | ||
|
||
# TODO(jwnimmer-tri) To prove that the @openusd_internal build system is | ||
# working properly, here we perform a smoke test of `usdcat --help`. Once | ||
# we have enough real unit tests in Drake that call into USD and prove out | ||
# the build, we should remove this simple smoke test. | ||
|
||
alias( | ||
name = "usdcat", | ||
actual = "@openusd_internal//:usdcat", | ||
tags = [ | ||
# Only compile this binary when the usdcat_help test needs it. | ||
"manual", | ||
], | ||
) | ||
|
||
generate_file( | ||
name = "empty.sh", | ||
# When WITH_USD is off, this serves as a test stub dummy. | ||
content = "echo 'WITH_USD is not ON'", | ||
) | ||
|
||
sh_test( | ||
name = "usdcat_help", | ||
srcs = select({ | ||
"//tools:with_usd": [":usdcat"], | ||
"//conditions:default": ["empty.sh"], | ||
}), | ||
args = ["--help"], | ||
) | ||
|
||
add_lint_tests() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
load("@drake//tools/skylark:cc.bzl", "cc_library") | ||
load("@drake//tools/workspace/openusd_internal:lock/files.bzl", "FILES") | ||
|
||
def pxr_library( | ||
name, | ||
*, | ||
subdir): | ||
"""Defines a cc_library in the spirit of OpenUSD's pxr_library CMake macro. | ||
The srcs, hdrs, and deps are not passed as an argument to this function. | ||
Instead, they are loaded from the `lock/files.bzl` database. | ||
Args: | ||
name: Matches the upstream name (the first argument in CMake). | ||
subdir: The subdirectory under `OpenUSD/pxr` (e.g. "base/arch"). | ||
""" | ||
attrs = FILES[subdir] | ||
srcs = [ | ||
subdir + "/" + x + ".cpp" | ||
for x in attrs["PUBLIC_CLASSES"] + attrs["PRIVATE_CLASSES"] | ||
] + [ | ||
subdir + "/" + x | ||
for x in attrs["CPPFILES"] | ||
] | ||
hdrs = [ | ||
subdir + "/" + x + ".h" | ||
for x in attrs["PUBLIC_CLASSES"] + attrs["PRIVATE_CLASSES"] | ||
] + [ | ||
subdir + "/" + x | ||
for x in attrs["PUBLIC_HEADERS"] + attrs["PRIVATE_HEADERS"] | ||
] | ||
defines = [ | ||
# In Drake we use the oneAPI flavor of TBB, which is not the default | ||
# in OpenUSD, so we need to opt-in. | ||
"PXR_ONETBB_SUPPORT_ENABLED", | ||
# OpenUSD still has calls to deprecated TBB functions, so we need to | ||
# opt-in to some vestigial parts of TBB. | ||
"TBB_ALLOCATOR_TRAITS_BROKEN", | ||
] | ||
deps = attrs["LIBRARIES"] + [ | ||
":pxr_h", | ||
"@onetbb_internal//:tbb", | ||
# TODO(jwnimmer-tri) We also need to list some @boost here. | ||
] | ||
cc_library( | ||
name = name, | ||
srcs = srcs, | ||
hdrs = hdrs, | ||
defines = defines, | ||
copts = ["-w"], | ||
deps = deps, | ||
) |
Oops, something went wrong.