Skip to content
This repository has been archived by the owner on Sep 15, 2021. It is now read-only.

Commit

Permalink
Use a prebuilt Stardoc release binary (#172)
Browse files Browse the repository at this point in the history
Instead of forcing users to depend on @io_bazel so that Stardoc
is built from source for each invocation, a prebuilt Stardoc binary will be included
in this repository, and updated on release cuts.

This also eliminates buggy behavior when Stardoc and @io_bazel repositories
are out of sync in a user's workspace.

Closes #170
  • Loading branch information
c-parsons authored Mar 18, 2019
1 parent f57c988 commit 45ae581
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 9 deletions.
11 changes: 10 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ node_repositories()
load("@io_bazel_rules_sass//:defs.bzl", "sass_repositories")
sass_repositories()


#######################################################################
##### MOST USERS SHOULD NOT NEED TO COPY ANYTHING BELOW THIS LINE #####
#######################################################################
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

# Needed for skydoc only (not Stardoc), which is deprecated. Users should include
Expand All @@ -22,3 +24,10 @@ git_repository(
remote = "https://github.com/protocolbuffers/protobuf.git",
commit = "7b28271a61a3da0a37f6fda399b0c4c86464e5b3", # 2018-11-16
)

# Needed for generating the Stardoc release binary.
git_repository(
name = "io_bazel",
remote = "https://github.com/bazelbuild/bazel.git",
commit = "49107ad79ef08811db22636928dfd113a9acf902", # Mar 08, 2019
)
7 changes: 0 additions & 7 deletions setup.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,6 @@ def skydoc_repositories():
remote = "https://github.com/bazelbuild/rules_sass.git",
commit = "8ccf4f1c351928b55d5dddf3672e3667f6978d60",
)
_include_if_not_defined(
git_repository,
name = "io_bazel",
remote = "https://github.com/bazelbuild/bazel.git",
# TODO: Update to a newer tagged version when available.
commit = "1488f91fec238adacbd0517fcee15d8ec0599b8d", # Feb 27, 2019
)
_include_if_not_defined(
http_archive,
name = "markupsafe_archive",
Expand Down
22 changes: 22 additions & 0 deletions stardoc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,25 @@ stardoc(
],
deps = [":stardoc_lib"],
)

java_binary(
name = "stardoc",
main_class = "com.google.devtools.build.skydoc.SkydocMain",
runtime_deps = [
":prebuilt_stardoc_binary",
],
jvm_flags = [
# quiet warnings from com.google.protobuf.UnsafeUtil,
# see: https://github.com/google/protobuf/issues/3781
# TODO(cparsons): Remove once Stardoc has the fix.
"-XX:+IgnoreUnrecognizedVMOptions",
"--add-opens=java.base/java.nio=ALL-UNNAMED",
"--add-opens=java.base/java.lang=ALL-UNNAMED",
],
)

java_import(
name = "prebuilt_stardoc_binary",
jars = ["stardoc_binary.jar"],
visibility = ["//visibility:private"],
)
2 changes: 1 addition & 1 deletion stardoc/stardoc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ non-default semantic flags required to use the given Starlark symbols.
"stardoc": attr.label(
doc = "The location of the stardoc tool.",
allow_files = True,
default = Label("@io_bazel//src/main/java/com/google/devtools/build/skydoc"),
default = Label("//stardoc:stardoc"),
cfg = "host",
executable = True,
),
Expand Down
Binary file added stardoc/stardoc_binary.jar
Binary file not shown.
29 changes: 29 additions & 0 deletions update-release-binary.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
# Copyright 2019 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Renerates the Stardoc release binary from source in @io_bazel.
#
# This should only need to be run for cutting a new Stardoc release.

set -eu

echo "** Building Stardoc from source..."
bazel build @io_bazel//src/main/java/com/google/devtools/build/skydoc:skydoc_deploy.jar

echo "** Copying Stardoc binary..."
cp bazel-bin/external/io_bazel/src/main/java/com/google/devtools/build/skydoc/skydoc_deploy.jar \
stardoc/stardoc_binary.jar

echo "** Stardoc copied."

0 comments on commit 45ae581

Please sign in to comment.