Sort variables by name when writing ninja files
Regenerating build.ninja.in was non-deterministic, sort the maps of name, value pairs before writing them. Change-Id: I825734162b1adebc88ddb19d912751108322091e
This commit is contained in:
parent
fbb27fe2d9
commit
add65dd4c1
1 changed files with 22 additions and 4 deletions
|
@ -3,6 +3,7 @@ package blueprint
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
@ -202,8 +203,14 @@ func (r *ruleDef) WriteTo(nw *ninjaWriter, name string,
|
|||
}
|
||||
}
|
||||
|
||||
for name, value := range r.Variables {
|
||||
err = nw.ScopedAssign(name, value.Value(pkgNames))
|
||||
var keys []string
|
||||
for k := range r.Variables {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
|
||||
for _, name := range keys {
|
||||
err = nw.ScopedAssign(name, r.Variables[name].Value(pkgNames))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -301,9 +308,20 @@ func (b *buildDef) WriteTo(nw *ninjaWriter, pkgNames map[*PackageContext]string)
|
|||
return err
|
||||
}
|
||||
|
||||
args := make(map[string]string)
|
||||
|
||||
for argVar, value := range b.Args {
|
||||
name := argVar.fullName(pkgNames)
|
||||
err = nw.ScopedAssign(name, value.Value(pkgNames))
|
||||
args[argVar.fullName(pkgNames)] = value.Value(pkgNames)
|
||||
}
|
||||
|
||||
var keys []string
|
||||
for k := range args {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
|
||||
for _, name := range keys {
|
||||
err = nw.ScopedAssign(name, args[name])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue