all_flags.pb: Properly handle intermediate files
Bug: 343203557 Test: manual, TH Change-Id: I9a4ef39b0c2a641ccd996187ce5f7629520dffc0
This commit is contained in:
parent
585564cab2
commit
194d492d55
2 changed files with 19 additions and 6 deletions
|
@ -6,6 +6,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
rc_lib "android/soong/cmd/release_config/release_config_lib"
|
rc_lib "android/soong/cmd/release_config/release_config_lib"
|
||||||
|
rc_proto "android/soong/cmd/release_config/release_config_proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Flags struct {
|
type Flags struct {
|
||||||
|
@ -62,18 +63,17 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
flagArtifacts := rc_lib.FlagArtifactsFactory("")
|
flagArtifacts := rc_lib.FlagArtifactsFactory("")
|
||||||
|
intermediates := []*rc_proto.FlagDeclarationArtifacts{}
|
||||||
for _, intermediate := range flags.intermediates {
|
for _, intermediate := range flags.intermediates {
|
||||||
fas := rc_lib.FlagArtifactsFactory(intermediate)
|
fda := rc_lib.FlagDeclarationArtifactsFactory(intermediate)
|
||||||
for _, fa := range *fas {
|
intermediates = append(intermediates, fda)
|
||||||
(*flagArtifacts)[*fa.FlagDeclaration.Name] = fa
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for _, decl := range flags.decls {
|
for _, decl := range flags.decls {
|
||||||
fa := rc_lib.FlagArtifactFactory(decl)
|
fa := rc_lib.FlagArtifactFactory(decl)
|
||||||
(*flagArtifacts)[*fa.FlagDeclaration.Name] = fa
|
(*flagArtifacts)[*fa.FlagDeclaration.Name] = fa
|
||||||
}
|
}
|
||||||
|
|
||||||
message := flagArtifacts.GenerateFlagDeclarationArtifacts()
|
message := flagArtifacts.GenerateFlagDeclarationArtifacts(intermediates)
|
||||||
err = rc_lib.WriteFormattedMessage(flags.output, flags.format, message)
|
err = rc_lib.WriteFormattedMessage(flags.output, flags.format, message)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errorExit(err)
|
errorExit(err)
|
||||||
|
|
|
@ -102,11 +102,24 @@ func (fa *FlagArtifact) GenerateFlagDeclarationArtifact() *rc_proto.FlagDeclarat
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fas *FlagArtifacts) GenerateFlagDeclarationArtifacts() *rc_proto.FlagDeclarationArtifacts {
|
func FlagDeclarationArtifactsFactory(path string) *rc_proto.FlagDeclarationArtifacts {
|
||||||
|
ret := &rc_proto.FlagDeclarationArtifacts{}
|
||||||
|
if path != "" {
|
||||||
|
LoadMessage(path, ret)
|
||||||
|
} else {
|
||||||
|
ret.FlagDeclarationArtifacts = []*rc_proto.FlagDeclarationArtifact{}
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (fas *FlagArtifacts) GenerateFlagDeclarationArtifacts(intermediates []*rc_proto.FlagDeclarationArtifacts) *rc_proto.FlagDeclarationArtifacts {
|
||||||
ret := &rc_proto.FlagDeclarationArtifacts{FlagDeclarationArtifacts: []*rc_proto.FlagDeclarationArtifact{}}
|
ret := &rc_proto.FlagDeclarationArtifacts{FlagDeclarationArtifacts: []*rc_proto.FlagDeclarationArtifact{}}
|
||||||
for _, fa := range *fas {
|
for _, fa := range *fas {
|
||||||
ret.FlagDeclarationArtifacts = append(ret.FlagDeclarationArtifacts, fa.GenerateFlagDeclarationArtifact())
|
ret.FlagDeclarationArtifacts = append(ret.FlagDeclarationArtifacts, fa.GenerateFlagDeclarationArtifact())
|
||||||
}
|
}
|
||||||
|
for _, fda := range intermediates {
|
||||||
|
ret.FlagDeclarationArtifacts = append(ret.FlagDeclarationArtifacts, fda.FlagDeclarationArtifacts...)
|
||||||
|
}
|
||||||
slices.SortFunc(ret.FlagDeclarationArtifacts, func(a, b *rc_proto.FlagDeclarationArtifact) int {
|
slices.SortFunc(ret.FlagDeclarationArtifacts, func(a, b *rc_proto.FlagDeclarationArtifact) int {
|
||||||
return cmp.Compare(*a.Name, *b.Name)
|
return cmp.Compare(*a.Name, *b.Name)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue