mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-18 11:33:59 +00:00
builder: order embedded files deterministically
This commit is contained in:
+9
-4
@@ -19,6 +19,7 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"slices"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -281,9 +282,13 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
|
|||||||
allFiles[file.Name] = append(allFiles[file.Name], file)
|
allFiles[file.Name] = append(allFiles[file.Name], file)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for name, files := range allFiles {
|
// Sort embedded files by name to maintain output determinism.
|
||||||
name := name
|
embedNames := make([]string, 0, len(allFiles))
|
||||||
files := files
|
for _, files := range allFiles {
|
||||||
|
embedNames = append(embedNames, files[0].Name)
|
||||||
|
}
|
||||||
|
slices.Sort(embedNames)
|
||||||
|
for _, name := range embedNames {
|
||||||
job := &compileJob{
|
job := &compileJob{
|
||||||
description: "make object file for " + name,
|
description: "make object file for " + name,
|
||||||
run: func(job *compileJob) error {
|
run: func(job *compileJob) error {
|
||||||
@@ -298,7 +303,7 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
|
|||||||
sum := sha256.Sum256(data)
|
sum := sha256.Sum256(data)
|
||||||
hexSum := hex.EncodeToString(sum[:16])
|
hexSum := hex.EncodeToString(sum[:16])
|
||||||
|
|
||||||
for _, file := range files {
|
for _, file := range allFiles[name] {
|
||||||
file.Size = uint64(len(data))
|
file.Size = uint64(len(data))
|
||||||
file.Hash = hexSum
|
file.Hash = hexSum
|
||||||
if file.NeedsData {
|
if file.NeedsData {
|
||||||
|
|||||||
Reference in New Issue
Block a user