Skip to content

Commit 869d2c4

Browse files
QuLogicaykevl
authored andcommitted
Add a way to bake-in final TINYGOROOT.
This is similar to setting FINAL_GOROOT when building standard Go.
1 parent 9d35c11 commit 869d2c4

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

target.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ import (
1515
"strings"
1616
)
1717

18+
// TINYGOROOT is the path to the final location for checking tinygo files. If
19+
// unset (by a -X ldflag), then sourceDir() will fallback to the original build
20+
// directory.
21+
var TINYGOROOT string
22+
1823
// Target specification for a given target. Used for bare metal targets.
1924
//
2025
// The target specification is mostly inspired by Rust:
@@ -270,6 +275,14 @@ func sourceDir() string {
270275
return root
271276
}
272277

278+
if TINYGOROOT != "" {
279+
if !isSourceDir(TINYGOROOT) {
280+
fmt.Fprintln(os.Stderr, "error: TINYGOROOT was not set to the correct root")
281+
os.Exit(1)
282+
}
283+
return TINYGOROOT
284+
}
285+
273286
// Find root from executable path.
274287
path, err := os.Executable()
275288
if err != nil {

0 commit comments

Comments
 (0)