Skip to content

Commit

Permalink
Port util.py away from the find_resource sentinel
Browse files Browse the repository at this point in the history
Instead, use a more-appropriate top-level file `.bazelproject`, better
in tune with the purpose of this tool.  (The find_resource sentinel is
undergoing a shuffle due to 6996.)
  • Loading branch information
jwnimmer-tri committed Nov 10, 2017
1 parent 206c270 commit bbf84cf
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ package(

exports_files([
"CPPLINT.cfg",
".bazelproject",
".clang-format",
".drake-resource-sentinel",
])
Expand Down
2 changes: 1 addition & 1 deletion tools/lint/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ drake_py_library(
drake_py_library(
name = "util",
srcs = ["util.py"],
data = ["//:.drake-resource-sentinel"],
data = ["//:.bazelproject"],
visibility = ["//visibility:private"],
)

Expand Down
2 changes: 1 addition & 1 deletion tools/lint/test/util_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_find(self):

# Sanity-check relpaths.
self.assertGreater(len(relpaths), 1000)
self.assertTrue('.drake-resource-sentinel' in relpaths)
self.assertTrue('.bazelproject' in relpaths)
self.assertTrue('setup/ubuntu/16.04/install_prereqs.sh' in relpaths)
THIRD_PARTY_SOURCES_ALLOWED_TO_BE_FOUND = [
"third_party/BUILD.bazel",
Expand Down
6 changes: 3 additions & 3 deletions tools/lint/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def find_all_sources():
"""
# Our outermost `myprogram.runfiles` directory will contain a file named
# MANIFEST. Because this py_library declares a `data=[]` dependency on
# Drake's top-level sentinel file, the manifest will cite the original
# Drake's top-level .bazelproject file, the manifest will cite the original
# location of that file, which we can abuse to find the absolute path to
# the root of the source tree.
workspace_root = None
Expand All @@ -29,13 +29,13 @@ def find_all_sources():
with open(manifest, "r") as infile:
lines = infile.readlines()
for one_line in lines:
if not one_line.startswith("drake/.drake-resource-sentinel"):
if not one_line.startswith("drake/.bazelproject"):
continue
_, source_sentinel = one_line.split(" ")
workspace_root = os.path.dirname(source_sentinel)
break
if not workspace_root:
raise RuntimeError("Cannot find .drake-resource-sentinel in MANIFEST")
raise RuntimeError("Cannot find .bazelproject in MANIFEST")
# Make sure we found the right place.
workspace_file = os.path.join(workspace_root, "WORKSPACE")
if not os.path.exists(workspace_file):
Expand Down

0 comments on commit bbf84cf

Please sign in to comment.