Skip to content
  • Paul Johnston's avatar
    Adds cross-compilation support to rules_go. · f65818c0
    Paul Johnston authored
    - New rule 'xgo_binary' takes a list of go_binary dependencies and an
      'os_arch' string attribute.  Build output 'foo' is namespaced in
      bazel-bin/PACKAGE_NAME/_xgo/GOOS_GOARCH/foo.  Cross-compilation is
      achieved via a parameterized aspect implementation that propogates
      down the 'deps' attribute; platform target is informed by the
      'os_arch' attribute whose values are enumerated in
      //go/private/goos_goarch.bzl.
    
    - New rule 'go_root' captures the absolute path of GOROOT at the time
      of toolchain installation.  This rule is only used internally.  For
      some reason cross-compilation requires an absolute path to GOROOT.
    
    - Repository rule 'go_repositories' takes an optional environment
      variable BAZEL_GOROOT to use local go toolchain if desired.
    
    - Partitions def.bzl file into individual bzl files in go/private
      where possible.  Each file implements a single rule.  These are
      loaded by def.bzl, so end-user is unaffected.
    
    - Reorganization of def.bzl into sections: constants, utility
      functions, action functions, aspects, and rules.
    
    - Reengineered go_library_impl and go_binary_impl into functions
      go_library_build and go_binary_build that act as common entrypoints
      for the reworked *_impl functions as well the new aspect
      implementations _xgo_*_impl.  These functions are agnostic to the
      layout of the ctx argument (different for normal rules vs. aspect
      rules).  The parameter lists are longer but declare their
      requirements more explicitly.
    
    - Expanded documentation of most functions with skydoc docstrings and
      type annotations.
    
    - Cross-compilation of cgo targets is not supported.  Assembly files
      are permitted but must be consistent with the target architecture.
    f65818c0