[bazel] Add fixes for --incompatible_load_{cc,java,proto}_rules_from_bzl (Part 2)

This change adds the required loads to examples and zlib.
For full compatibility with --incompatible_load_{cc,java,proto}_rules_from_bzl,
we will need to roll gtest to a newer version.
diff --git a/BUILD b/BUILD
index 5d82fc1..a8df6d3 100644
--- a/BUILD
+++ b/BUILD
@@ -787,12 +787,9 @@
     name = "python_srcs",
     srcs = glob(
         [
-            "python/google/__init__.py",
-            "python/google/protobuf/*.py",
-            "python/google/protobuf/**/*.py",
+            "python/google/**/*.py",
         ],
         exclude = [
-            "python/google/protobuf/__init__.py",
             "python/google/protobuf/**/__init__.py",
             "python/google/protobuf/internal/*_test.py",
             "python/google/protobuf/internal/test_util.py",
diff --git a/Makefile.am b/Makefile.am
index 9d1b607..0b58adb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1230,7 +1230,6 @@
   examples/list_people.py                \
   examples/list_people_test.go           \
   examples/pubspec.yaml                  \
-  examples/third_party/zlib.BUILD        \
   protobuf.bzl                           \
   protobuf_deps.bzl                      \
   python/release/wheel/build_wheel_manylinux.sh  \
diff --git a/WORKSPACE b/WORKSPACE
index ee505d1..5e6214b 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -1,5 +1,10 @@
 workspace(name = "com_google_protobuf")
 
+local_repository(
+    name = "com_google_protobuf_examples",
+    path = "examples",
+)
+
 load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
 load("//:protobuf_deps.bzl", "protobuf_deps")
 
@@ -19,13 +24,6 @@
     urls = ["https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz#md5=34eed507548117b2ab523ab14b2f8b55"],
 )
 
-http_archive(
-    name = "bazel_skylib",
-    sha256 = "bbccf674aa441c266df9894182d80de104cabd19be98be002f6d478aaa31574d",
-    strip_prefix = "bazel-skylib-2169ae1c374aab4a09aa90e65efe1a3aad4e279b",
-    urls = ["https://github.com/bazelbuild/bazel-skylib/archive/2169ae1c374aab4a09aa90e65efe1a3aad4e279b.tar.gz"],
-)
-
 bind(
     name = "python_headers",
     actual = "//util/python:python_headers",
diff --git a/examples/BUILD b/examples/BUILD
index d5d5d9a..864b569 100644
--- a/examples/BUILD
+++ b/examples/BUILD
@@ -4,6 +4,10 @@
 # the WORKSPACE file in the same directory with this BUILD file for an
 # example.
 
+load("@rules_proto//proto:defs.bzl", "proto_library")
+load("@rules_java//java:defs.bzl", "java_binary", "java_lite_proto_library", "java_proto_library")
+load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_proto_library")
+
 # For each .proto file, a proto_library target should be defined. This target
 # is not bound to any particular language. Instead, it defines the dependency
 # graph of the .proto files (i.e., proto imports) and serves as the provider
diff --git a/examples/WORKSPACE b/examples/WORKSPACE
index 8b97e47..db86225 100644
--- a/examples/WORKSPACE
+++ b/examples/WORKSPACE
@@ -1,31 +1,24 @@
+workspace(name = "com_google_protobuf_examples")
+
 load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
 
 # This com_google_protobuf repository is required for proto_library rule.
 # It provides the protocol compiler binary (i.e., protoc).
-http_archive(
+#
+# We declare it as local_repository so we can test changes
+# before they get merged. You'll want to use the following instead:
+#
+# http_archive(
+#     name = "com_google_protobuf",
+#     strip_prefix = "protobuf-master",
+#     urls = ["https://github.com/protocolbuffers/protobuf/archive/master.zip"],
+# )
+local_repository(
     name = "com_google_protobuf",
-    strip_prefix = "protobuf-master",
-    urls = ["https://github.com/protocolbuffers/protobuf/archive/master.zip"],
+    path = "..",
 )
 
-# This com_google_protobuf_cc repository is required for cc_proto_library
-# rule. It provides protobuf C++ runtime. Note that it actually is the same
-# repo as com_google_protobuf but has to be given a different name as
-# required by bazel.
-http_archive(
-    name = "com_google_protobuf_cc",
-    strip_prefix = "protobuf-master",
-    urls = ["https://github.com/protocolbuffers/protobuf/archive/master.zip"],
-)
-
-# Similar to com_google_protobuf_cc but for Java (i.e., java_proto_library).
-http_archive(
-    name = "com_google_protobuf_java",
-    strip_prefix = "protobuf-master",
-    urls = ["https://github.com/protocolbuffers/protobuf/archive/master.zip"],
-)
-
-# Similar to com_google_protobuf_cc but for Java lite. If you are building
+# Similar to com_google_protobuf but for Java lite. If you are building
 # for Android, the lite version should be prefered because it has a much
 # smaller code size.
 http_archive(
@@ -34,17 +27,6 @@
     urls = ["https://github.com/protocolbuffers/protobuf/archive/javalite.zip"],
 )
 
-http_archive(
-    name = "bazel_skylib",
-    sha256 = "bbccf674aa441c266df9894182d80de104cabd19be98be002f6d478aaa31574d",
-    strip_prefix = "bazel-skylib-2169ae1c374aab4a09aa90e65efe1a3aad4e279b",
-    urls = ["https://github.com/bazelbuild/bazel-skylib/archive/2169ae1c374aab4a09aa90e65efe1a3aad4e279b.tar.gz"],
-)
-
 load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
 
 protobuf_deps()
-
-load("@bazel_skylib//lib:versions.bzl", "versions")
-
-versions.check(minimum_bazel_version = "0.5.4")
diff --git a/examples/third_party/zlib.BUILD b/examples/third_party/zlib.BUILD
deleted file mode 120000
index 1bbef2d..0000000
--- a/examples/third_party/zlib.BUILD
+++ /dev/null
@@ -1 +0,0 @@
-../../third_party/zlib.BUILD
\ No newline at end of file
diff --git a/protobuf.bzl b/protobuf.bzl
index e065332..5b04299 100644
--- a/protobuf.bzl
+++ b/protobuf.bzl
@@ -1,3 +1,4 @@
+load("@rules_cc//cc:defs.bzl", "cc_library")
 load("@bazel_skylib//lib:versions.bzl", "versions")
 
 def _GetPath(ctx, path):
@@ -276,7 +277,7 @@
         )
 
         # An empty cc_library to make rule dependency consistent.
-        native.cc_library(
+        cc_library(
             name = name,
             **kargs
         )
@@ -307,8 +308,7 @@
         cc_libs = cc_libs + [default_runtime]
     if use_grpc_plugin:
         cc_libs = cc_libs + ["//external:grpc_lib"]
-
-    native.cc_library(
+    cc_library(
         name = name,
         srcs = gen_srcs,
         hdrs = gen_hdrs,
diff --git a/protobuf_deps.bzl b/protobuf_deps.bzl
index 57509ee..ffa5d0a 100644
--- a/protobuf_deps.bzl
+++ b/protobuf_deps.bzl
@@ -5,6 +5,14 @@
 def protobuf_deps():
     """Loads common dependencies needed to compile the protobuf library."""
 
+    if not native.existing_rule("bazel_skylib"):
+        http_archive(
+            name = "bazel_skylib",
+            sha256 = "bbccf674aa441c266df9894182d80de104cabd19be98be002f6d478aaa31574d",
+            strip_prefix = "bazel-skylib-2169ae1c374aab4a09aa90e65efe1a3aad4e279b",
+            urls = ["https://github.com/bazelbuild/bazel-skylib/archive/2169ae1c374aab4a09aa90e65efe1a3aad4e279b.tar.gz"],
+        )
+
     if not native.existing_rule("zlib"):
         http_archive(
             name = "zlib",
diff --git a/third_party/zlib.BUILD b/third_party/zlib.BUILD
index 494082c..093dee1 100644
--- a/third_party/zlib.BUILD
+++ b/third_party/zlib.BUILD
@@ -1,4 +1,4 @@
-package(default_visibility = ["//visibility:public"])
+load("@rules_cc//cc:defs.bzl", "cc_library")
 
 licenses(["notice"])  # BSD/MIT-like license (for zlib)
 
@@ -26,7 +26,6 @@
     srcs = _ZLIB_HEADERS,
     outs = _ZLIB_PREFIXED_HEADERS,
     cmd = "cp $(SRCS) $(@D)/zlib/include/",
-    visibility = ["//visibility:private"],
 )
 
 cc_library(
@@ -60,4 +59,5 @@
         ],
     }),
     includes = ["zlib/include/"],
+    visibility = ["//visibility:public"],
 )
diff --git a/util/python/BUILD b/util/python/BUILD
index ef2238a..9ee56c8 100644
--- a/util/python/BUILD
+++ b/util/python/BUILD
@@ -1,3 +1,5 @@
+load("@rules_cc//cc:defs.bzl", "cc_library")
+
 # This is a placeholder for python headers. Projects needing to use
 # fast cpp protos in protobuf's python interface should build with
 # --define=use_fast_cpp_protos=true, and in addition, provide