Skip to content

Commit 888f031

Browse files
committed
add tamago build in ci
1 parent 0e52130 commit 888f031

File tree

2 files changed

+72
-3
lines changed

2 files changed

+72
-3
lines changed

build/checksums.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ e94732c94f149690aa0ab11c26090577211b4a988137cb2c03ec0b54e750402e go1.25.1.plan9
4949
1261dfad7c4953c0ab90381bc1242dc54e394db7485c59349428d532b2273343 go1.25.1.solaris-amd64.tar.gz
5050
04bc3c078e9e904c4d58d6ac2532a5bdd402bd36a9ff0b5949b3c5e6006a05ee go1.25.1.windows-arm64.zip
5151

52+
# version:tamago 1.25.6
53+
# https://github.com/usbarmory/tamago-go/releases/download/tamago-go1.25.6/
54+
fbab70549e5977150d9095829608b5b8c7a6226930f91beb8edd614f2a71348e tamago-go1.25.6.linux-amd64.tar.gz
55+
8bfc5a4f2ff54625c3a26a1b8749a6639d9f85dbd2f687c41c932517c0814368 tamago-go1.25.6.linux-armv7l.tar.gz
56+
5257
# version:golangci 2.4.0
5358
# https://github.com/golangci/golangci-lint/releases/
5459
# https://github.com/golangci/golangci-lint/releases/download/v2.4.0/

build/ci.go

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ var (
107107
Tags: "ziren",
108108
Env: map[string]string{"GOMIPS": "softfloat", "CGO_ENABLED": "0"},
109109
},
110+
{
111+
Name: "tamago",
112+
GOOS: "tamago",
113+
GOARCH: "riscv64",
114+
Tags: "tamago",
115+
Env: map[string]string{"CGO_ENABLED": "0"},
116+
},
110117
{
111118
Name: "wasm-js",
112119
GOOS: "js",
@@ -281,16 +288,37 @@ func doInstallKeeper(cmdline []string) {
281288
flag.CommandLine.Parse(cmdline)
282289
env := build.Env()
283290

284-
// Configure the toolchain.
291+
var (
292+
csdb *download.ChecksumDB
293+
tamagoRoot string
294+
)
285295
tc := build.GoToolchain{}
286296
if *dlgo {
287-
csdb := download.MustLoadChecksums("build/checksums.txt")
288-
tc.Root = build.DownloadGo(csdb)
297+
csdb = download.MustLoadChecksums("build/checksums.txt")
289298
}
290299

291300
for _, target := range keeperTargets {
292301
log.Printf("Building keeper-%s", target.Name)
293302

303+
// Configure the toolchain.
304+
if target.Name == "tamago" {
305+
if runtime.GOOS != "linux" {
306+
log.Printf("Skipping keeper-%s (tamago builds are only supported on linux hosts)", target.Name)
307+
continue
308+
}
309+
if !*dlgo {
310+
log.Printf("Skipping keeper-%s (tamago build requires -dlgo)", target.Name)
311+
continue
312+
}
313+
314+
if tamagoRoot == "" {
315+
tamagoRoot = downloadTamago(csdb)
316+
}
317+
tc.Root = tamagoRoot
318+
} else if *dlgo {
319+
tc.Root = build.DownloadGo(csdb)
320+
}
321+
294322
// Configure the build.
295323
tc.GOARCH = target.GOARCH
296324
tc.GOOS = target.GOOS
@@ -447,6 +475,42 @@ func downloadSpecTestFixtures(csdb *download.ChecksumDB, cachedir string) string
447475
return filepath.Join(cachedir, base)
448476
}
449477

478+
// downloadTamago downloads the tamago-go toolchain and returns its GOROOT.
479+
func downloadTamago(csdb *download.ChecksumDB) string {
480+
version, err := csdb.FindVersion("tamago")
481+
if err != nil {
482+
log.Fatal(err)
483+
}
484+
if runtime.GOOS != "linux" {
485+
log.Printf("Skipping tamago toolchain download (unsupported host os: %s)", runtime.GOOS)
486+
return ""
487+
}
488+
arch := runtime.GOARCH
489+
if arch == "arm" {
490+
arch = "armv7l"
491+
}
492+
file := fmt.Sprintf("tamago-go%s.%s-%s.tar.gz", version, runtime.GOOS, arch)
493+
494+
ucache, err := os.UserCacheDir()
495+
if err != nil {
496+
log.Fatal(err)
497+
}
498+
dst := filepath.Join(ucache, file)
499+
if err := csdb.DownloadFileFromKnownURL(dst); err != nil {
500+
log.Fatal(err)
501+
}
502+
503+
toolRoot := filepath.Join(ucache, fmt.Sprintf("geth-tamago-go-%s-%s-%s", version, runtime.GOOS, arch))
504+
if err := build.ExtractArchive(dst, toolRoot); err != nil {
505+
log.Fatal(err)
506+
}
507+
goroot, err := filepath.Abs(filepath.Join(toolRoot, "go"))
508+
if err != nil {
509+
log.Fatal(err)
510+
}
511+
return goroot
512+
}
513+
450514
// doCheckGenerate ensures that re-generating generated files does not cause
451515
// any mutations in the source file tree.
452516
func doCheckGenerate() {

0 commit comments

Comments
 (0)