Skip to content

Commit

Permalink
Support for go 1.20 (#2735)
Browse files Browse the repository at this point in the history
* Support for go 1.20

* Version bump

* Update release step

* Downgrade go plugin
  • Loading branch information
Tatskaari authored Mar 20, 2023
1 parent 426b94d commit 6070643
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
9 changes: 2 additions & 7 deletions .circleci/release_s3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ set -eu

VERSION=$(cat VERSION)

echo "Releasing docs website"
tar -xzf /tmp/workspace/deep-docs.tar.gz -C /tmp/workspace && aws s3 sync /tmp/workspace/docs s3://please-docs


if aws s3 ls s3://please-releases/linux_arm64/$VERSION/; then
echo "Please $VERSION has already been released, nothing to do."
exit 0
Expand Down Expand Up @@ -35,9 +31,8 @@ aws s3 cp get_plz.sh.asc s3://please-releases/get_plz.sh.asc --content-type text
aws s3 cp get_plz.sh.sig s3://please-releases/get_plz.sh.sig --content-type application/octet-stream

if [[ "$VERSION" == *"beta"* ]] || [[ "$VERSION" == *"alpha"* ]] || [[ "$VERSION" == *"prerelease"* ]]; then
echo "$VERSION is a prerelease, only setting latest_prerelease_version"
else
echo "$VERSION is not a prerelease, setting latest_version and latest_prerelease_version"
echo "$VERSION is not a prerelease, setting latest_version"
aws s3 cp VERSION s3://please-releases/latest_version --content-type text/plain
fi
aws s3 cp VERSION s3://please-releases/latest_prerelease_version --content-type text/plain

5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Version 16.28.0
---------------
* Support for Go 1.20 (#2735)


Version 16.27.5
---------------
* Exclude targets in subrepos from `plz query changes` (#2725)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.27.5
16.28.0
13 changes: 11 additions & 2 deletions rules/go_rules.build_defs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Go has a strong built-in concept of packages so it's probably a good idea to mat
rules to Go packages.
"""
def go_toolchain(name:str, url:str|dict = '', version:str = '', hashes:list = [], visibility:list = ["PUBLIC"],
architectures:list=[], strip_srcs:bool=False, tags:list=None):
architectures:list=[], strip_srcs:bool=False, tags:list=None, install_std=None):
"""
Downloads Go and exposes :<name>|go and :<name>|gofmt as entry points. To use this rule add the
following to your .plzconfig:
Expand All @@ -28,6 +28,8 @@ def go_toolchain(name:str, url:str|dict = '', version:str = '', hashes:list = []
improve performance, especially for remote execution. This doesn't work with go_get() however
it is recommended to set this to True if you're using go_module() exclusively.
tags (bool): Build tags to pass when installing the standard library.
install_std (bool): Whether we should install the standard library. This is required for go 1.20+. If not set,
Please will do whatever is appropriate based on the Go version.
"""
if url and version:
fail("Either version or url should be provided but not both")
Expand All @@ -44,7 +46,7 @@ def go_toolchain(name:str, url:str|dict = '', version:str = '', hashes:list = []
hashes = hashes,
)

cmd = 'tar -xf $SRCS && mv go $OUT && chmod +x $OUT/bin/*; rm -rf $OUT/test'
cmd = 'export GODEBUG="installgoroot=all" && tar -xf $SRCS && mv go $OUT && chmod +x $OUT/bin/*; rm -rf $OUT/test'
# If we're targeting another platform, build the std lib for that. We can't use CONFIG.OS as this is always set to
# the host OS for tools.
if CONFIG.TARGET_OS != CONFIG.HOSTOS or CONFIG.TARGET_ARCH != CONFIG.HOSTARCH:
Expand All @@ -57,6 +59,13 @@ def go_toolchain(name:str, url:str|dict = '', version:str = '', hashes:list = []
for arch in architectures:
goos, _, goarch = arch.partition("_")
cmd += f' && (export GOOS={goos} && export GOARCH={goarch} && $OUT/bin/go install{tag_flag} --trimpath std)'

if semver_check(version, ">= 1.20.0") and install_std is None:
install_std = True

if install_std:
cmd += f" && $OUT/bin/go install{tag_flag} --trimpath std"

if strip_srcs:
trim_toolchain = "mv $OUT/src src && mkdir $OUT/src && mv src/unsafe $OUT/src/unsafe"
cmd = f"{cmd} && {trim_toolchain}"
Expand Down

0 comments on commit 6070643

Please sign in to comment.