BUILD: Add useful go_path target

Change-Id: Ibd6d8a1a63826af6e62a0f0669f8f0866c8091b4
PiperOrigin-RevId: 242037969
This commit is contained in:
Adin Scannell 2019-04-04 17:04:30 -07:00 committed by Shentubot
parent e9508967b0
commit 75c8ac38e0
3 changed files with 36 additions and 1 deletions

17
BUILD
View File

@ -1,3 +1,7 @@
package(licenses = ["notice"]) # Apache 2.0
load("@io_bazel_rules_go//go:def.bzl", "go_path")
# The sandbox filegroup is used for sandbox-internal dependencies.
package_group(
name = "sandbox",
@ -5,3 +9,16 @@ package_group(
"//...",
],
)
# gopath defines a directory that is structured in a way that is compatible
# with standard Go tools. Things like godoc, editors and refactor tools should
# work as expected.
#
# The files in this tree are symlinks to the true sources.
go_path(
name = "gopath",
mode = "link",
deps = [
"//runsc",
],
)

View File

@ -12,6 +12,24 @@ You generally only need to submit a CLA once, so if you've already submitted one
(even if it was for a different project), you probably don't need to do it
again.
### Using GOPATH
Some editors may require the code to be structured in a `GOPATH` directory tree.
In this case, you may use the `:gopath` target to generate a directory tree with
symlinks to the original source files.
```
bazel build :gopath
```
You can then set the `GOPATH` in your editor to `bazel-bin/gopath`.
If you use this mechanism, keep in mind that the generated tree is not the
canonical source. You will still need to build and test with `bazel`. New files
will need to be added to the appropriate `BUILD` files, and the `:gopath` target
will need to be re-run to generate appropriate symlinks in the `GOPATH`
directory tree.
### Coding Guidelines
All code should conform to the [Go style guidelines][gostyle].

View File

@ -35,7 +35,7 @@ func Uname(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.Syscall
copy(u.Nodename[:], uts.HostName())
copy(u.Release[:], version.Release)
copy(u.Version[:], version.Version)
copy(u.Machine[:], "x86_64") // +build tag above.
copy(u.Machine[:], "x86_64") // build tag above.
copy(u.Domainname[:], uts.DomainName())
// Copy out the result.