From 48d0e4d813b914fc480c51de5c48903b9bcc4cc7 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Mon, 7 Jan 2019 01:46:24 -0800 Subject: [PATCH] Fixing pasta by not stripping the subdirectory. PiperOrigin-RevId: 228125275 --- third_party/pasta/BUILD.bazel | 5 +++-- third_party/pasta/build_defs.bzl | 12 ++++++++++++ third_party/pasta/workspace.bzl | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 third_party/pasta/build_defs.bzl diff --git a/third_party/pasta/BUILD.bazel b/third_party/pasta/BUILD.bazel index 6be33511e48..ade681b6069 100644 --- a/third_party/pasta/BUILD.bazel +++ b/third_party/pasta/BUILD.bazel @@ -1,5 +1,6 @@ # Description: # AST-based python refactoring. +load("@//third_party/pasta:build_defs.bzl", "copy_srcs") licenses(["notice"]) # Apache2 @@ -7,7 +8,7 @@ exports_files(["LICENSE"]) py_library( name = "pasta", - srcs = [ + srcs = copy_srcs([ "__init__.py", "augment/__init__.py", "augment/errors.py", @@ -23,7 +24,7 @@ py_library( "base/scope.py", "base/test_utils.py", "base/token_generator.py", - ], + ]), srcs_version = "PY2AND3", visibility = ["//visibility:public"], ) diff --git a/third_party/pasta/build_defs.bzl b/third_party/pasta/build_defs.bzl new file mode 100644 index 00000000000..0a5316de402 --- /dev/null +++ b/third_party/pasta/build_defs.bzl @@ -0,0 +1,12 @@ +"""Skylark makros for building pasta.""" + +def copy_srcs(srcs): + """Copies srcs from 'pasta' to parent directory.""" + for src in srcs: + native.genrule( + name = src.replace(".", "_"), + srcs = ["pasta/" + src], + outs = [src], + cmd = "mkdir -p $$(dirname $@); cp $< $@", + ) + return srcs diff --git a/third_party/pasta/workspace.bzl b/third_party/pasta/workspace.bzl index 063bdb7b986..e46cc4a45e4 100644 --- a/third_party/pasta/workspace.bzl +++ b/third_party/pasta/workspace.bzl @@ -9,7 +9,7 @@ def repo(): "https://mirror.bazel.build/github.com/google/pasta/archive/c3d72cdee6fc806251949e912510444d58d7413c.tar.gz", "https://github.com/google/pasta/archive/c3d72cdee6fc806251949e912510444d58d7413c.tar.gz", ], - strip_prefix = "pasta-c3d72cdee6fc806251949e912510444d58d7413c/pasta", + strip_prefix = "pasta-c3d72cdee6fc806251949e912510444d58d7413c", sha256 = "b5905f9cecc4b28363c563f3c4cb0545288bd35f7cc72c55066e97e53befc084", build_file = "//third_party/pasta:BUILD.bazel", system_build_file = "//third_party/pasta:BUILD.system",