Fix Starlark errors in protobuf.bzl in newer bazel versions
In newer bazel, `load()` statements have to be at the top.
The `REPOSITORY_NAME` and `PACKAGE_NAME` constants are also no longer
available. This patch replaces those with the equivalent `native.*`
function calls.
Change-Id: I072d5cd380053616546f34256e55adfd547e8d00
diff --git a/third_party/protobuf/protobuf.bzl b/third_party/protobuf/protobuf.bzl
index 7925d18..a125606 100644
--- a/third_party/protobuf/protobuf.bzl
+++ b/third_party/protobuf/protobuf.bzl
@@ -1,3 +1,5 @@
+load("@//tools/build_rules:select.bzl", "compiler_select")
+
def _GetPath(ctx, path):
if ctx.label.workspace_root:
return ctx.label.workspace_root + '/' + path
@@ -174,8 +176,6 @@
"/wd4514", # -Wno-unused-function
]
-load("@//tools/build_rules:select.bzl", "compiler_select")
-
COPTS = [
"-DHAVE_PTHREAD",
"-DGOOGLE_THIRD_PARTY_PROTOBUF",
@@ -302,8 +302,8 @@
Args:
srcs: the well known protos
"""
- root = Label("%s//protobuf_java" % (REPOSITORY_NAME)).workspace_root
- pkg = PACKAGE_NAME + "/" if PACKAGE_NAME else ""
+ root = Label("%s//protobuf_java" % (native.repository_name())).workspace_root
+ pkg = native.package_name() + "/" if native.package_name() else ""
if root == "":
include = " -I%ssrc " % pkg
else: