• Home
  • Raw
  • Download

Lines Matching +full:go +full:- +full:version

3 # Licensed under the Apache License, Version 2.0 (the "License");
7 # http://www.apache.org/licenses/LICENSE-2.0
16 "//go/private:common.bzl",
20 "//go/private:nogo.bzl",
24 "//go/private/skylib/lib:versions.bzl",
33 version = _detect_sdk_version(ctx, goroot)
34 _sdk_build_file(ctx, platform, version, experiments = ctx.attr.experiments)
41 "version": attr.string(),
43 doc = "Go experiments to enable via GOEXPERIMENT",
46 default = Label("//go/private:BUILD.sdk.bazel"),
57 sdk_version = kwargs.get("version"),
75 version = ctx.attr.version
80 # If version was unspecified, pick the latest version.
81 # Even if version was specified, we need to download the file list
82 # to find the SHA-256 sum. If we don't have it, Bazel won't cache
84 if not version:
85 ctx.report_progress("Finding latest Go version")
87 ctx.report_progress("Finding Go SHA-256 sums")
90 "https://go.dev/dl/?mode=json&include=all",
99 if not version:
104 # skip parse errors and pre-release versions
109 fail("did not find any Go versions in https://go.dev/dl/?mode=json")
110 version = _version_string(highest_version)
111 if version not in sdks_by_version:
112 fail("did not find version {} in https://go.dev/dl/?mode=json".format(version))
113 sdks = sdks_by_version[version]
123 if not ctx.attr.sdks and not ctx.attr.version:
124 # Returning this makes Bazel print a message that 'version' must be
132 "version": version,
144 doc = "Go experiments to enable via GOEXPERIMENT",
146 "urls": attr.string_list(default = ["https://dl.google.com/go/{}"]),
147 "version": attr.string(),
148 "strip_prefix": attr.string(default = "go"),
150 default = Label("//go/private:BUILD.sdk.bazel"),
155 def _define_version_constants(version, prefix = ""):
156 pv = parse_version(version)
158 fail("error parsing sdk version: " + version)
191 # If a sdk_version attribute is provided, use that version. This avoids
193 # no choice and must load version constants from the version.bzl file that
199 "@{sdk_repo}//:version.bzl",
247 """load("@io_bazel_rules_go//go/private:go_toolchain.bzl", "declare_bazel_toolchains")""",
312 sdk_version = kwargs.get("version"),
322 version = _detect_sdk_version(ctx, goroot)
323 _sdk_build_file(ctx, platform, version, ctx.attr.experiments)
330 "version": attr.string(),
332 doc = "Go experiments to enable via GOEXPERIMENT",
335 default = Label("//go/private:BUILD.sdk.bazel"),
346 sdk_version = kwargs.get("version"),
368 version = _detect_sdk_version(ctx, goroot)
369 _sdk_build_file(ctx, platform, version, ctx.attr.experiments)
383 "version": attr.string(),
385 doc = "Go experiments to enable via GOEXPERIMENT",
388 default = Label("//go/private:BUILD.sdk.bazel"),
399 sdk_version = kwargs.get("version"),
414 ctx.report_progress("Downloading and extracting Go toolchain")
417 # the minimum supported version of Bazel, remove the workarounds below.
419 # Go ships archives containing some non-ASCII file names, used in
420 # test cases for Go's build system. Bazel has a bug extracting these
433 if strip_prefix != "go":
440 res = ctx.execute(["tar", "-xf", "go_sdk.tar.gz", "--strip-components=1"])
442 fail("error extracting Go SDK:\n" + res.stdout + res.stderr)
446 # Development versions of Bazel have an empty version string. We assume that they are
447 # more recent than the version that introduced rename_files.
454 … "go/test/fixedbugs/issue27836.dir/\336foo.go": "go/test/fixedbugs/issue27836.dir/thfoo.go",
455 … "go/test/fixedbugs/issue27836.dir/\336main.go": "go/test/fixedbugs/issue27836.dir/thmain.go",
469 def _sdk_build_file(ctx, platform, version, experiments):
473 pv = parse_version(version)
489 "{version}": version,
495 "version.bzl",
497 content = _define_version_constants(version),
519 res = ctx.execute([executable_path(ctx, "go"), "env", "GOROOT"])
521 fail("Could not detect host go version")
524 fail("host go version failed to report it's GOROOT")
545 version_file_path = goroot + "/VERSION"
547 # VERSION file has version prefixed by go, eg. go1.18.3
548 version = ctx.read(version_file_path)[2:]
549 if ctx.attr.version and ctx.attr.version != version:
550 fail("SDK is version %s, but version %s was expected" % (version, ctx.attr.version))
551 return version
553 …# The top-level VERSION file does not exist in all Go SDK distributions, e.g. those shipped by Deb…
554 # Falling back to running "go version"
555 go_binary_path = goroot + "/bin/go"
556 result = ctx.execute([go_binary_path, "version"])
558 …fail("Could not detect SDK version: '%s version' exited with exit code %d" % (go_binary_path, resu…
560 # go version output is of the form "go version go1.18.3 linux/amd64" or "go
561 # version devel go1.19-fd1b5904ae Tue Mar 22 21:38:10 2022 +0000
563 …# - https://github.com/golang/go/blob/2bdb5c57f1efcbddab536028d053798e35de6226/src/cmd/go/internal…
564 …# - https://github.com/golang/go/blob/2bdb5c57f1efcbddab536028d053798e35de6226/src/cmd/dist/build.
567 # find the version number.
569 if len(output_parts) > 2 and output_parts[2].startswith("go"):
570 version = output_parts[2][len("go"):]
571 elif len(output_parts) > 3 and output_parts[2] == "devel" and output_parts[3].startswith("go"):
572 version = output_parts[3][len("go"):]
574 … fail("Could not parse SDK version from '%s version' output: %s" % (go_binary_path, result.stdout))
575 if parse_version(version) == None:
576 … fail("Could not parse SDK version from '%s version' output: %s" % (go_binary_path, result.stdout))
577 if ctx.attr.version and ctx.attr.version != version:
578 fail("SDK is version %s, but version %s was expected" % (version, ctx.attr.version))
579 return version
582 """Parses version metadata returned by go.dev.
586 https://go.dev/dl/?mode=json. We assume the file is valid
590 A dict mapping version strings (like "1.15.5") to dicts mapping
592 (like "go1.15.5.linux-amd64.tar.gz") and hex-encoded SHA-256 sums.
596 sdk["version"][len("go"):]: {
607 def parse_version(version):
608 """Parses a version string like "1.15.5" and returns a tuple of numbers or None"""
611 for c in version.elems():
616 parsed.append(int(version[l:r]))
625 # pre-release suffix
631 parsed.append(int(version[l:r]))
633 # first minor version, like (1, 15)
638 if r < len(version):
639 # pre-release suffix
640 parsed.append(version[r:])
659 if v[-1] == 0:
660 v = v[:-1]
668 def go_register_toolchains(version = None, nogo = None, go_version = None, experiments = None):
669 """See /go/toolchains.rst#go-register-toolchains for full documentation."""
670 if not version:
671 version = go_version # old name
680 if version and len(sdk_rules) > 0:
681 …fail("go_register_toolchains: version set after go sdk rule declared ({})".format(", ".join([r["na…
683 if not version:
684 fail('go_register_toolchains: version must be a string like "1.15.5" or "host"')
685 elif version == "host":
688 pv = parse_version(version)
690 fail('go_register_toolchains: version must be a string like "1.15.5" or "host"')
692 …print("DEPRECATED: Go versions before {} are not supported and may not work".format(_version_strin…
695 version = version,