|
7 | 7 |
|
8 | 8 | GoCompilerInfo = provider(
|
9 | 9 | doc = "Information about how to invoke the go compiler.",
|
10 |
| - fields = ["compiler_path", "GOROOT"], |
| 10 | + fields = ["compiler_path", "GOROOT", "GOCACHE"], |
11 | 11 | )
|
12 | 12 |
|
| 13 | +def is_remote_enabled() -> bool: |
| 14 | + re_enabled = read_root_config("buck2_re_client", "enabled", "false") |
| 15 | + return re_enabled == "true" |
| 16 | + |
13 | 17 | def _go_toolchain_impl(ctx):
|
14 |
| - download = _download_toolchain(ctx) |
| 18 | + is_re_enabled = is_remote_enabled() |
| 19 | + gocache="/tmp/gocache" |
| 20 | + if is_re_enabled: |
| 21 | + return [DefaultInfo(), GoCompilerInfo(compiler_path = "go", GOROOT = "", GOCACHE=gocache)] |
| 22 | + else: |
| 23 | + download = _download_toolchain(ctx) |
15 | 24 |
|
16 |
| - compiler_dst = ctx.actions.declare_output("compiler.exe" if host_info().os.is_windows else "compiler") |
| 25 | + compiler_dst = ctx.actions.declare_output("compiler.exe" if host_info().os.is_windows else "compiler") |
17 | 26 |
|
18 |
| - cmd = cmd_args() |
19 |
| - if host_info().os.is_windows: |
20 |
| - compiler_src = cmd_args(download, format = "{}\\go\\bin\\go.exe", relative_to = (compiler_dst, 1)) |
21 |
| - cmd.add([ctx.attrs._symlink_bat, compiler_dst.as_output(), compiler_src]) |
22 |
| - else: |
23 |
| - compiler_src = cmd_args(download, format = "{}/go/bin/go", relative_to = (compiler_dst, 1)) |
24 |
| - cmd.add(["ln", "-sf", compiler_src, compiler_dst.as_output()]) |
| 27 | + cmd = cmd_args() |
| 28 | + if host_info().os.is_windows: |
| 29 | + compiler_src = cmd_args(download, format = "{}\\go\\bin\\go.exe", relative_to = (compiler_dst, 1)) |
| 30 | + cmd.add([ctx.attrs._symlink_bat, compiler_dst.as_output(), compiler_src]) |
| 31 | + else: |
| 32 | + compiler_src = cmd_args(download, format = "{}/go/bin/go", relative_to = (compiler_dst, 1)) |
| 33 | + cmd.add(["ln", "-sf", compiler_src, compiler_dst.as_output()]) |
25 | 34 |
|
26 |
| - ctx.actions.run(cmd, category = "cp_compiler") |
27 |
| - return [DefaultInfo(default_output = download), GoCompilerInfo(compiler_path = compiler_dst, GOROOT = "")] |
| 35 | + ctx.actions.run(cmd, category = "cp_compiler") |
| 36 | + return [DefaultInfo(default_output = download), GoCompilerInfo(compiler_path = compiler_dst, GOROOT = "", GOCACHE=gocache)] |
28 | 37 |
|
29 | 38 | go_toolchain = rule(
|
30 | 39 | impl = _go_toolchain_impl,
|
|
0 commit comments