Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Teach drake bazel rules to play nicely when drake is an external bazel project #6190

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@

workspace(name = "drake")

load("//tools/third_party/kythe/tools/build_rules/config:pkg_config.bzl", "pkg_config_package")
load("//tools:bitbucket.bzl", "bitbucket_archive")
load("//tools:github.bzl", "github_archive")
load('@bazel_tools//tools/build_defs/repo:git.bzl', 'git_repository')

local_repository(
name = "kythe",
path = "tools/third_party/kythe",
)
load("@kythe//tools/build_rules/config:pkg_config.bzl", "pkg_config_package")

pkg_config_package(
name = "glib",
modname = "glib-2.0",
Expand Down
2 changes: 1 addition & 1 deletion tools/bot_core_lcmtypes.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

package(default_visibility = ["//visibility:public"])

load("@//tools:lcm.bzl", "lcm_cc_library", "lcm_py_library")
load("@drake//tools:lcm.bzl", "lcm_cc_library", "lcm_py_library")

lcm_cc_library(
name = "bot_core_lcmtypes",
Expand Down
2 changes: 1 addition & 1 deletion tools/ccd.BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- python -*-

load("@//tools:cmake_configure_file.bzl", "cmake_configure_file")
load("@drake//tools:cmake_configure_file.bzl", "cmake_configure_file")

# Generates config.h based on the defines= we want in Drake.
cmake_configure_file(
Expand Down
8 changes: 4 additions & 4 deletions tools/eigen.BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- python -*-

load("@//tools:install.bzl", "install", "install_files")
load("@//tools:python_lint.bzl", "python_lint")
load("@drake//tools:install.bzl", "install", "install_files")
load("@drake//tools:python_lint.bzl", "python_lint")
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")

package(
Expand All @@ -25,8 +25,8 @@ cc_library(

py_binary(
name = "create-cps",
srcs = ["@//tools:eigen-create-cps.py"],
main = "@//tools:eigen-create-cps.py",
srcs = ["@drake//tools:eigen-create-cps.py"],
main = "@drake//tools:eigen-create-cps.py",
visibility = ["//visibility:private"],
)

Expand Down
2 changes: 1 addition & 1 deletion tools/fcl.BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- python -*-

load("@//tools:cmake_configure_file.bzl", "cmake_configure_file")
load("@drake//tools:cmake_configure_file.bzl", "cmake_configure_file")

# Generates config.h based on the version numbers in CMake code.
cmake_configure_file(
Expand Down
4 changes: 2 additions & 2 deletions tools/gtest.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ cc_library(
"googletest/include",
],
linkopts = select({
"@//tools:linux": ["-pthread"],
"@//conditions:default": [],
"@drake//tools:linux": ["-pthread"],
"@//conditions:default": [], # This is a bazel-default rule, and does not need @drake//
}),
linkstatic = 1,
visibility = ["//visibility:public"],
Expand Down
2 changes: 1 addition & 1 deletion tools/ignition_math.BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- python -*-

load("@//tools:cmake_configure_file.bzl", "cmake_configure_file")
load("@drake//tools:cmake_configure_file.bzl", "cmake_configure_file")

# Generates config.hh based on the version numbers in CMake code.
cmake_configure_file(
Expand Down
8 changes: 4 additions & 4 deletions tools/ipopt.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,16 @@ genrule(
cmd = " ".join([
"(",
"env",
"cdexec=$(location @//tools/third_party/kythe/tools/cdexec:cdexec)",
"cdexec=$(location @kythe//tools/cdexec:cdexec)",
"top_builddir=$(@D)",
"tools/ipopt_build_with_autotools.sh",
"$(location @drake//tools:ipopt_build_with_autotools.sh)",
" 2>&1 > ipopt_build_with_autotools.log",
")",
"|| (cat ipopt_build_with_autotools.log && false)",
]),
tools = [
"@//tools:ipopt_build_with_autotools.sh",
"@//tools/third_party/kythe/tools/cdexec:cdexec",
"@drake//tools:ipopt_build_with_autotools.sh",
"@kythe//tools/cdexec:cdexec",
],
visibility = ["//visibility:private"],
)
Expand Down
12 changes: 6 additions & 6 deletions tools/lcm.BUILD
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- python -*-

load("@//tools:drake.bzl", "drake_generate_file")
load("@//tools:generate_export_header.bzl", "generate_export_header")
load("@//tools:install.bzl", "install", "install_files")
load("@//tools:python_lint.bzl", "python_lint")
load("@drake//tools:drake.bzl", "drake_generate_file")
load("@drake//tools:generate_export_header.bzl", "generate_export_header")
load("@drake//tools:install.bzl", "install", "install_files")
load("@drake//tools:python_lint.bzl", "python_lint")
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")

package(default_visibility = ["//visibility:public"])
Expand Down Expand Up @@ -200,8 +200,8 @@ pkg_tar(

py_binary(
name = "create-cps",
srcs = ["@//tools:lcm-create-cps.py"],
main = "@//tools:lcm-create-cps.py",
srcs = ["@drake//tools:lcm-create-cps.py"],
main = "@drake//tools:lcm-create-cps.py",
visibility = ["//visibility:private"],
)

Expand Down
2 changes: 1 addition & 1 deletion tools/libbot.BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- python -*-

load("@//tools:lcm.bzl", "lcm_java_library", "lcm_py_library")
load("@drake//tools:lcm.bzl", "lcm_java_library", "lcm_py_library")

package(default_visibility = ["//visibility:public"])

Expand Down
6 changes: 3 additions & 3 deletions tools/nlopt.BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- python -*-

load("@//tools:cmake_configure_file.bzl", "cmake_configure_file")
load("@drake//tools:cmake_configure_file.bzl", "cmake_configure_file")

# Chooses the nlopt preprocessor substitutions that we want to use from Bazel.
cmake_configure_file(
Expand Down Expand Up @@ -50,9 +50,9 @@ genrule(
"api/nlopt.h",
],
outs = ["api/nlopt.hpp"],
cmd = "$(location @//tools:nlopt-gen-hpp.sh) $(SRCS) $(OUTS) 2>&1 1>log" +
cmd = "$(location @drake//tools:nlopt-gen-hpp.sh) $(SRCS) $(OUTS) 2>&1 1>log" +
" || (cat log && false)",
tools = ["@//tools:nlopt-gen-hpp.sh"],
tools = ["@drake//tools:nlopt-gen-hpp.sh"],
)

cc_library(
Expand Down
2 changes: 1 addition & 1 deletion tools/robotlocomotion_lcmtypes.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

package(default_visibility = ["//visibility:public"])

load("@//tools:lcm.bzl", "lcm_cc_library", "lcm_py_library")
load("@drake//tools:lcm.bzl", "lcm_cc_library", "lcm_py_library")

lcm_cc_library(
name = "robotlocomotion_lcmtypes",
Expand Down
2 changes: 1 addition & 1 deletion tools/sdformat.BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- python -*-

load("@//tools:cmake_configure_file.bzl", "cmake_configure_file")
load("@drake//tools:cmake_configure_file.bzl", "cmake_configure_file")

# Generates sdf_config.h based on the version numbers in CMake code.
cmake_configure_file(
Expand Down
2 changes: 1 addition & 1 deletion tools/semantic_version.BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- python -*-

load("@//tools:drake.bzl", "drake_generate_file")
load("@drake//tools:drake.bzl", "drake_generate_file")

py_library(
name = "semantic_version",
Expand Down
4 changes: 2 additions & 2 deletions tools/spdlog.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ cc_library(
],
includes = ["include"],
linkopts = select({
"@//tools:linux": ["-pthread"],
"@//conditions:default": [],
"@drake//tools:linux": ["-pthread"],
"@//conditions:default": [], # This is a bazel-default rule, and does not need @drake//
}),
deps = ["@fmt"],
)
Expand Down
6 changes: 6 additions & 0 deletions tools/third_party/kythe/WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- python -*-

# This file marks a workspace root for the Bazel build system. see
# http://bazel.io/ .

workspace(name = "kythe")
2 changes: 1 addition & 1 deletion tools/third_party/kythe/tools/build_rules/config/local.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ local_cc_library_configure = repository_rule(
"default": attr.string(),
"defines": attr.string_list(),
"build_file_template": attr.label(
default = Label("@//tools/third_party/kythe/tools/build_rules/config:BUILD.tpl"),
default = Label("@kythe//tools/build_rules/config:BUILD.tpl"),
single_file = True,
allow_files = True,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ pkg_config_package = repository_rule(
"max_version": attr.string(),
"exact_version": attr.string(),
"build_file_template": attr.label(
default = Label("@//tools/third_party/kythe/tools/build_rules/config:BUILD.tpl"),
default = Label("@kythe//tools/build_rules/config:BUILD.tpl"),
single_file = True,
allow_files = True,
),
Expand Down
8 changes: 4 additions & 4 deletions tools/third_party/kythe/tools/build_rules/config/system.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ cc_system_package:
repository, whose `:lib` target is then bound to '{name}'.
"""

load("@//tools/third_party/kythe/tools/build_rules/config:wrapped_ctx.bzl", "wrapctx")
load("@//tools/third_party/kythe/tools/build_rules/config:local.bzl", "setup_local_cc_library")
load("@//tools/third_party/kythe/tools/build_rules/config:pkg_config.bzl", "setup_pkg_config_package")
load("@kythe//tools/build_rules/config:wrapped_ctx.bzl", "wrapctx")
load("@kythe//tools/build_rules/config:local.bzl", "setup_local_cc_library")
load("@kythe//tools/build_rules/config:pkg_config.bzl", "setup_pkg_config_package")

def try_local_library(repo_ctx):
if repo_ctx.attr.envvar and repo_ctx.attr.envvar in repo_ctx.os.environ:
Expand Down Expand Up @@ -58,7 +58,7 @@ cc_system_package_configure = repository_rule(
"default": attr.string(),
"defines": attr.string_list(),
"build_file_template": attr.label(
default = Label("@//tools/third_party/kythe/tools/build_rules/config:BUILD.tpl"),
default = Label("@kythe//tools/build_rules/config:BUILD.tpl"),
single_file = True,
allow_files = True,
),
Expand Down