Skip to content

Commit

Permalink
Merge branch 'master' into many-deps-test
Browse files Browse the repository at this point in the history
  • Loading branch information
Jay Conrod committed Aug 13, 2018
2 parents c140bfc + 2179a6e commit f40e6e7
Show file tree
Hide file tree
Showing 16 changed files with 587 additions and 38 deletions.
20 changes: 2 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ os:
- osx

env:
- V=0.15.0
- V=0.16.0

before_install:
- |
Expand All @@ -21,23 +21,7 @@ before_install:
sysctl kernel.unprivileged_userns_clone=1
OS=linux
fi
if [[ "${V}" == "HEAD" ]]; then
# Determine last successful build number. This may change while we are
# downloading, so it's important to determine ahead of time, in case
# we need to resume the download.
CI_BASE="http://ci.bazel.io/view/Bazel%20bootstrap%20and%20maintenance/job/Bazel/PLATFORM_NAME=${OS}-x86_64/"
CI_INDEX_URL="${CI_BASE}/lastSuccessfulBuild/"
wget -q -O build-index.html "${CI_INDEX_URL}"
CI_BUILD=$(grep '<title>' build-index.html | sed -e 's/^.*#\([0-9]*\).*$/\1/')
# Determine the artifact name. This is normally, bazel--installer.sh,
# but it may be, for example, bazel-0.5rc2-installer.sh before a release.
CI_ARTIFACT=$(grep -o 'bazel-[^\"-]*-installer.sh' build-index.html | head -n 1)
URL="${CI_BASE}/${CI_BUILD}/artifact/output/ci/${CI_ARTIFACT}"
rm build-index.html
else
URL="https://github.com/bazelbuild/bazel/releases/download/${V}/bazel-${V}-installer-${OS}-x86_64.sh"
fi
URL="https://github.com/bazelbuild/bazel/releases/download/${V}/bazel-${V}-installer-${OS}-x86_64.sh"
wget -O install.sh "${URL}"
chmod +x install.sh
./install.sh --user
Expand Down
12 changes: 12 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Go rules for Bazel_
.. _go_binary: go/core.rst#go_binary
.. _go_test: go/core.rst#go_test
.. _go_download_sdk: go/toolchains.rst#go_download_sdk
.. _go_rules_dependencies: go/workspace.rst#go_rules_dependencies
.. _go_register_toolchains: go/toolchains.rst#go_register_toolchains
.. _go_proto_library: proto/core.rst#go_proto_library
.. _go_proto_compiler: proto/core.rst#go_proto_compiler
Expand All @@ -32,6 +33,7 @@ Go rules for Bazel_
.. _rules_go and Gazelle roadmap: roadmap.rst
.. _Deprecation schedule: deprecation.rst
.. _Avoiding conflicts: proto/core.rst#avoiding-conflicts
.. _Overriding dependencies: go/workspace.rst#overriding-dependencies

.. ;; And now we continue with the actual content
Expand Down Expand Up @@ -528,3 +530,13 @@ How do I avoid conflicts with protocol buffers?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

See `Avoiding conflicts`_ in the proto documentation.

How do I use a specific version of golang.org/x/sys, net or text?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Several of the golang.org/x repositories are declared in
`go_rules_dependencies`_. We declare these automatically because they're needed
by gRPC.

See `Overriding dependencies`_ for an example of how to replace these
with specific commits.
9 changes: 9 additions & 0 deletions go/private/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ def go_rules_dependencies():
overlay = manifest["org_golang_x_text"],
# importpath = "golang.org/x/text",
)
_maybe(
git_repository,
name = "org_golang_x_sys",
remote = "https://github.com/golang/sys",
commit = "f0d5e33068cb57c22a181f5df0ffda885309eb5a", # master as of 2018-08-10
overlay = manifest["org_golang_x_sys"],
# importpath = "golang.org/x/sys",
# vcs = "git",
)
_maybe(
git_repository,
name = "org_golang_google_grpc",
Expand Down
11 changes: 11 additions & 0 deletions go/tools/builders/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ func run(args []string) error {
}
*outFile = abs(*outFile)

// On Windows, take the absolute path of the output file.
// This is needed on Windows because the relative path is frequently too long.
// os.Open on Windows converts absolute paths to some other path format with
// longer length limits. Absolute paths do not work on macOS for .dylib
// outputs because they get baked in as the "install path".
if goos, ok := os.LookupEnv("GOOS"); !ok {
return fmt.Errorf("GOOS not set")
} else if goos == "windows" {
*outFile = abs(*outFile)
}

// If we were given any stamp value files, read and parse them
stampmap := map[string]string{}
for _, stampfile := range stamps {
Expand Down
72 changes: 52 additions & 20 deletions go/workspace.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Go workspace rules
.. _golang.org/x/net: https://github.com/golang/net/
.. _golang.org/x/text: https://github.com/golang/text/
.. _golang.org/x/tools: https://github.com/golang/tools/
.. _golang.org/x/sys: https://github.com/golang/sys/
.. _go_library: core.rst#go_library
.. _toolchains: toolchains.rst
.. _go_register_toolchains: toolchains.rst#go_register_toolchains
Expand Down Expand Up @@ -61,32 +62,63 @@ in the bottom of your WORKSPACE file and forget about it.
The list of dependencies it adds is quite long, there are a few listed below that you are more
likely to want to know about and override, but it is by no means a complete list.

* :value:`com_google_protobuf` : An http_archive for `github.com/google/protobuf`_
* :value:`com_github_golang_protobuf` : A go_repository for `github.com/golang/protobuf`_
* :value:`org_golang_google_genproto` : A go_repository for `google.golang.org/genproto`_
* :value:`org_golang_google_grpc` : A go_repository for `google.golang.org/grpc`_
* :value:`org_golang_x_net` : A go_repository for `golang.org/x/net`_
* :value:`org_golang_x_text` : A go_repository for `golang.org/x/text`_
* :value:`org_golang_x_tools` : A go_repository for `golang.org/x/tools`_
* :value:`com_google_protobuf` : `github.com/google/protobuf`_
* :value:`com_github_golang_protobuf` : `github.com/golang/protobuf`_
* :value:`org_golang_google_genproto` : `google.golang.org/genproto`_
* :value:`org_golang_google_grpc` : `google.golang.org/grpc`_
* :value:`org_golang_x_net` : `golang.org/x/net`_
* :value:`org_golang_x_text` : `golang.org/x/text`_
* :value:`org_golang_x_tools` : `golang.org/x/tools`_
* :value:`org_golang_x_sys`: `golang.org/x/sys`_


It won't override repositories that were declared earlier, so you can replace any of these with
a different version by declaring it before calling this macro, which is why we recommend you should
put the call at the bottom of your WORKSPACE. For example:
It won't override repositories that were declared earlier, so you can replace
any of these with a different version by declaring it before calling this macro.

go_repository
~~~~~~~~~~~~~

This rule has moved. See `go_repository`_ in the Gazelle repository.

Overriding dependencies
~~~~~~~~~~~~~~~~~~~~~~~

You can override a dependency declared in ``go_rules_dependencies`` by
declaring a repository rule in WORKSPACE with the same name *before* the call
to ``go_rules_dependencies``.

For example, this is how you would override ``org_golang_x_sys``.

.. code:: bzl
go_repository(
name = "org_golang_x_net",
commit = "0744d001aa8470aaa53df28d32e5ceeb8af9bd70",
importpath = "golang.org/x/net",
)
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
go_rules_dependencies()
http_archive(
name = "io_bazel_rules_go",
urls = ["https://github.com/bazelbuild/rules_go/releases/download/0.14.0/rules_go-0.14.0.tar.gz"],
sha256 = "5756a4ad75b3703eb68249d50e23f5d64eaf1593e886b9aa931aa6e938c4e301",
)
would cause the go rules to use the specified version of x/net.
http_archive(
name = "bazel_gazelle",
urls = ["https://github.com/bazelbuild/bazel-gazelle/releases/download/0.14.0/bazel-gazelle-0.14.0.tar.gz"],
sha256 = "c0a5739d12c6d05b6c1ad56f2200cb0b57c5a70e03ebd2f7b87ce88cabf09c7b",
)
go_repository
~~~~~~~~~~~~~
load("@bazel_gazelle//:deps.bzl", "go_repository")
This rule has moved. See `go_repository`_ in the Gazelle repository.
go_repository(
name = "org_golang_x_sys",
commit = "57f5ac02873b2752783ca8c3c763a20f911e4d89",
importpath = "golang.org/x/sys",
)
load("@io_bazel_rules_go//go:def.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains()
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
gazelle_dependencies()
12 changes: 12 additions & 0 deletions third_party/manifest.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,18 @@ manifest = {
"@io_bazel_rules_go//third_party:org_golang_x_net/websocket/BUILD.bazel.in": "websocket/BUILD.bazel",
"@io_bazel_rules_go//third_party:org_golang_x_net/xsrftoken/BUILD.bazel.in": "xsrftoken/BUILD.bazel",
},
"org_golang_x_sys": {
"@io_bazel_rules_go//third_party:org_golang_x_sys/cpu/BUILD.bazel.in": "cpu/BUILD.bazel",
"@io_bazel_rules_go//third_party:org_golang_x_sys/plan9/BUILD.bazel.in": "plan9/BUILD.bazel",
"@io_bazel_rules_go//third_party:org_golang_x_sys/unix/BUILD.bazel.in": "unix/BUILD.bazel",
"@io_bazel_rules_go//third_party:org_golang_x_sys/windows/BUILD.bazel.in": "windows/BUILD.bazel",
"@io_bazel_rules_go//third_party:org_golang_x_sys/windows/registry/BUILD.bazel.in": "windows/registry/BUILD.bazel",
"@io_bazel_rules_go//third_party:org_golang_x_sys/windows/svc/BUILD.bazel.in": "windows/svc/BUILD.bazel",
"@io_bazel_rules_go//third_party:org_golang_x_sys/windows/svc/debug/BUILD.bazel.in": "windows/svc/debug/BUILD.bazel",
"@io_bazel_rules_go//third_party:org_golang_x_sys/windows/svc/eventlog/BUILD.bazel.in": "windows/svc/eventlog/BUILD.bazel",
"@io_bazel_rules_go//third_party:org_golang_x_sys/windows/svc/example/BUILD.bazel.in": "windows/svc/example/BUILD.bazel",
"@io_bazel_rules_go//third_party:org_golang_x_sys/windows/svc/mgr/BUILD.bazel.in": "windows/svc/mgr/BUILD.bazel",
},
"org_golang_x_text": {
"@io_bazel_rules_go//third_party:org_golang_x_text/BUILD.bazel.in": "BUILD.bazel",
"@io_bazel_rules_go//third_party:org_golang_x_text/cases/BUILD.bazel.in": "cases/BUILD.bazel",
Expand Down
25 changes: 25 additions & 0 deletions third_party/org_golang_x_sys/cpu/BUILD.bazel.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "go_default_library",
srcs = [
"cpu.go",
"cpu_arm.go",
"cpu_arm64.go",
"cpu_gc_x86.go",
"cpu_mips64x.go",
"cpu_mipsx.go",
"cpu_ppc64x.go",
"cpu_s390x.go",
"cpu_x86.go",
"cpu_x86.s",
],
importpath = "golang.org/x/sys/cpu",
visibility = ["//visibility:public"],
)

go_test(
name = "go_default_test",
srcs = ["cpu_test.go"],
embed = [":go_default_library"],
)
34 changes: 34 additions & 0 deletions third_party/org_golang_x_sys/plan9/BUILD.bazel.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "go_default_library",
srcs = [
"asm.s",
"asm_plan9_386.s",
"asm_plan9_amd64.s",
"asm_plan9_arm.s",
"const_plan9.go",
"dir_plan9.go",
"env_plan9.go",
"errors_plan9.go",
"pwd_go15_plan9.go",
"pwd_plan9.go",
"race.go",
"race0.go",
"str.go",
"syscall.go",
"syscall_plan9.go",
"zsyscall_plan9_386.go",
"zsyscall_plan9_amd64.go",
"zsyscall_plan9_arm.go",
"zsysnum_plan9.go",
],
importpath = "golang.org/x/sys/plan9",
visibility = ["//visibility:public"],
)

go_test(
name = "go_default_test",
srcs = ["syscall_test.go"],
embed = [":go_default_library"],
)
Loading

0 comments on commit f40e6e7

Please sign in to comment.