Skip to content
Snippets Groups Projects
Commit c1131ef5 authored by Thai Duong's avatar Thai Duong
Browse files

Using a single protobuf dependency for CC, Java and ObjC.

This hopefully reduces compilation time which is accounting
for more than 70% of running time of presubmit tests on Kokoro.

Change-Id: I3e6e0505c247f71589ceba009b38e17bf03acb39
ORIGINAL_AUTHOR=Thai Duong <thaidn@google.com>
GitOrigin-RevId: dc2cb661d02b1fe045b6785bb6e62182d1d04b5e
parent ee6b44b1
No related branches found
No related tags found
No related merge requests found
......@@ -13,8 +13,8 @@ http_archive(
#-----------------------------------------------------------------------------
http_archive(
name = "io_bazel_rules_go",
strip_prefix = "rules_go-551e1f46cbeb470fe9d085e873c3bb83f075e18c",
url = "https://github.com/bazelbuild/rules_go/archive/551e1f46cbeb470fe9d085e873c3bb83f075e18c.zip",
strip_prefix = "rules_go-master",
url = "https://github.com/bazelbuild/rules_go/archive/master.zip",
)
#-----------------------------------------------------------------------------
......@@ -36,51 +36,25 @@ http_archive(
#-----------------------------------------------------------------------------
# proto
#-----------------------------------------------------------------------------
# proto_library rules implicitly depend on @com_google_protobuf//:protoc,
# which is the proto-compiler.
# proto_library, cc_proto_library and java_proto_library rules implicitly depend
# on @com_google_protobuf//:proto, @com_google_protobuf//:cc_toolchain and
# @com_google_protobuf//:java_toolchain, respectively.
# This statement defines the @com_google_protobuf repo.
http_archive(
name = "com_google_protobuf",
strip_prefix = "protobuf-3.4.0",
urls = ["https://github.com/google/protobuf/releases/download/v3.4.0/protobuf-cpp-3.4.0.tar.gz"],
sha256 = "71434f6f836a1e479c44008bb033b2a8b2560ff539374dcdefb126be739e1635",
strip_prefix = "protobuf-3.4.1",
urls = ["https://github.com/google/protobuf/archive/v3.4.1.zip"],
)
# cc_proto_library rules implicitly depend on @com_google_protobuf_cc//:cc_toolchain,
# which is the C++ proto runtime (base classes and common utilities).
http_archive(
name = "com_google_protobuf_cc",
strip_prefix = "protobuf-3.4.0",
urls = ["https://github.com/google/protobuf/releases/download/v3.4.0/protobuf-cpp-3.4.0.tar.gz"],
sha256 = "71434f6f836a1e479c44008bb033b2a8b2560ff539374dcdefb126be739e1635",
)
# java_proto_library rules implicitly depend on @com_google_protobuf_java//:java_toolchain,
# which is the Java proto runtime (base classes and common utilities).
http_archive(
name = "com_google_protobuf_java",
strip_prefix = "protobuf-3.4.0",
urls = ["https://github.com/google/protobuf/releases/download/v3.4.0/protobuf-java-3.4.0.tar.gz"],
sha256 = "7c61081cc2346542070cd35db7d15c7f24aeeefcd3afac08ec88fec03c45d698",
)
# java_lite_proto_library rules implicitly depend on @com_google_protobuf_javalite//:javalite_toolchain,
# which is the JavaLite proto runtime (base classes and common utilities).
# java_lite_proto_library rules implicitly depend on
# @com_google_protobuf_javalite//:javalite_toolchain, which is the JavaLite proto
# runtime (base classes and common utilities).
http_archive(
name = "com_google_protobuf_javalite",
strip_prefix = "protobuf-javalite",
urls = ["https://github.com/google/protobuf/archive/javalite.zip"],
)
# objc_proto_library rules from @org_pubref_rules_protobuf require the objective
# runtime files to build correctly. Therefore, we add a newer version of
# google/protobuf that has the @com_google_protobuf_objc//:objectivec target.
http_archive(
name = "com_google_protobuf_objc",
strip_prefix = "protobuf-286f0598422a70639e587b5329bd3037f5ee76b0",
urls = ["https://github.com/google/protobuf/archive/286f0598422a70639e587b5329bd3037f5ee76b0.zip"],
)
#-----------------------------------------------------------------------------
# java
#-----------------------------------------------------------------------------
......@@ -530,8 +504,8 @@ java_import_external(
http_archive(
name = "build_bazel_rules_apple",
strip_prefix = "rules_apple-7ea05576182ba82ea9b951fa3d42ecdb3dc8dc59",
url = "https://github.com/bazelbuild/rules_apple/archive/7ea05576182ba82ea9b951fa3d42ecdb3dc8dc59.zip",
strip_prefix = "rules_apple-master",
url = "https://github.com/bazelbuild/rules_apple/archive/master.zip",
)
load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains")
......
......@@ -9,7 +9,7 @@ java_binary(
]),
main_class = "com.helloworld.HelloWorld",
runtime_deps = [
"@com_google_protobuf_java//:protobuf_java",
"@com_google_protobuf//:protobuf_java",
"@org_json",
],
deps = [
......
......@@ -71,7 +71,7 @@ java_library(
"//java/src/main/java/com/google/crypto/tink/subtle",
"@com_google_code_findbugs_jsr305",
"@com_google_errorprone_error_prone_annotations",
"@com_google_protobuf_java//:protobuf_java",
"@com_google_protobuf//:protobuf_java",
"@org_json",
] + FULL_PROTOS,
)
......
......@@ -3,3 +3,6 @@
build_file: "tink/kokoro/gcp_ubuntu/presubmit.sh"
gfile_resources: "/x20/teams/ise-crypto/tink/kokoro/jdk-8u152-linux-x64.tar.gz"
gfile_resources: "/x20/teams/ise-crypto/tink/kokoro/bazel-88157011af4ddac21e404e9deea0d78668a71a99-linux-x86_64"
......@@ -24,17 +24,18 @@ set -x
# Workaround for some unknown issue in Kokoro.
rm -f ~/.bazelrc
# Upgrading bazel to the latest version
# TODO(b/68000006): removing these lines after Kokoro has upgraded its copy
sudo apt-get update
sudo apt-get -y install bazel
BAZEL_BIN="/usr/bin/bazel"
# Using Bazel at commit 88157011af4ddac21e404e9deea0d78668a71a99.
# In this version, {java,cc}_proto_library now look for dependencies in
# @com_google_protobuf, instead of in @com_google_protobuf_$LANG.
# See https://github.com/cgrushko/proto_library/issues/4.
BAZEL_BIN="${KOKORO_GFILE_DIR}/bazel-88157011af4ddac21e404e9deea0d78668a71a99-linux-x86_64"
DISABLE_SANDBOX="--strategy=GenRule=standalone --strategy=Turbine=standalone \
--strategy=CppCompile=standalone --strategy=ProtoCompile=standalone \
--strategy=GenProto=standalone --strategy=GenProtoDescriptorSet=standalone"
chmod +x "${BAZEL_BIN}"
echo "using bazel binary: ${BAZEL_BIN}"
${BAZEL_BIN} version
......
......@@ -4,4 +4,4 @@ build_file: "tink/kokoro/macos_external/presubmit.sh"
gfile_resources: "/x20/teams/ise-crypto/tink/kokoro/jdk-8u131-macosx-x64.tgz"
gfile_resources: "/x20/teams/ise-crypto/tink/kokoro/bazel-c6122b6ad35ebbed61036b0a2bcfea92b10adb8f-darwin-x86_64"
gfile_resources: "/x20/teams/ise-crypto/tink/kokoro/bazel-88157011af4ddac21e404e9deea0d78668a71a99-darwin-x86_64"
......@@ -25,7 +25,7 @@ set -x
: "${IOS_SDK_VERSION:=10.2}"
: "${XCODE_VERSION:=8.2.1}"
BAZEL_BIN="${KOKORO_GFILE_DIR}/bazel-c6122b6ad35ebbed61036b0a2bcfea92b10adb8f-darwin-x86_64"
BAZEL_BIN="${KOKORO_GFILE_DIR}/bazel-88157011af4ddac21e404e9deea0d78668a71a99-darwin-x86_64"
DISABLE_SANDBOX="--strategy=GenRule=standalone --strategy=Turbine=standalone \
--strategy=CppCompile=standalone --strategy=ProtoCompile=standalone \
......@@ -58,11 +58,10 @@ java -version
cd github/tink/
time bazel fetch ...
time ${BAZEL_BIN} fetch ...
# Build all the iOS targets.
time ${BAZEL_BIN} build \
$DISABLE_SANDBOX \
time ${BAZEL_BIN} build $DISABLE_SANDBOX \
--compilation_mode=dbg \
--dynamic_mode=off \
--cpu=ios_x86_64 \
......@@ -72,14 +71,14 @@ time ${BAZEL_BIN} build \
--ios_sdk_version="${IOS_SDK_VERSION}" \
--xcode_version="${XCODE_VERSION}" \
--verbose_failures \
//objc/... || \
( ls -l ; df -h / ; exit 1 )
//objc/... || ( ls -l ; df -h / ; exit 1 )
echo "bazel obj-c passed"
# Test all targets except iOS.
# bazel sandbox doesn't work with Kokoro's MacOS image, see b/38040081.
time ${BAZEL_BIN} test --sandbox_tmpfs_path=$TMP $DISABLE_SANDBOX -- //... \
-//objc/... || ( ls -l ; df -h / ; exit 1 )
time ${BAZEL_BIN} test $DISABLE_SANDBOX \
--sandbox_tmpfs_path=$TMP -- \
//... -//objc/... || ( ls -l ; df -h / ; exit 1 )
echo "bazel non objc-c passed"
......@@ -37,6 +37,6 @@ def tink_objc_proto_library(name, srcs, **kwargs):
srcs = [ ":%s_srcs" % name ],
hdrs = [ ":%s_hdrs" % name ],
copts = [ "-fno-objc-arc" ],
deps = [ "@com_google_protobuf_objc//:objectivec" ],
deps = [ "@com_google_protobuf//:objectivec" ],
**kwargs
)
......@@ -21,7 +21,7 @@ java_library(
"//java:protos",
"@args4j//jar",
"@com_google_guava//jar",
"@com_google_protobuf_java//:protobuf_java",
"@com_google_protobuf//:protobuf_java",
],
)
......@@ -58,7 +58,7 @@ java_library(
"//java:test_util",
"//java:testonly",
"@com_fasterxml_jackson_core//jar",
"@com_google_protobuf_java//:protobuf_java",
"@com_google_protobuf//:protobuf_java",
"@com_google_truth//jar",
"@junit",
],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment