Skip to content

Commit

Permalink
cxgo: Allow overriding glob configs.
Browse files Browse the repository at this point in the history
  • Loading branch information
dennwc committed Jul 2, 2023
1 parent 52ac65b commit 38570a8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmd/cxgo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,12 @@ func run(cmd *cobra.Command, args []string) error {
}
c.SysInclude[i] = filepath.Join(c.Root, c.SysInclude[i])
}
seen := make(map[string]struct{})
processFile := func(f *File) error {
if _, ok := seen[f.Name]; ok {
return fmt.Errorf("ducplicate entry for file: %q", f.Name)
}
seen[f.Name] = struct{}{}
if f.Content != "" {
data := []byte(f.Content)
if fdata, err := format.Source(data); err == nil {
Expand Down Expand Up @@ -320,6 +325,7 @@ func run(cmd *cobra.Command, args []string) error {
}
for _, f := range c.Files {
if f.Disabled {
seen[f.Name] = struct{}{}
continue
}
if strings.Contains(f.Name, "*") {
Expand All @@ -332,6 +338,9 @@ func run(cmd *cobra.Command, args []string) error {
if err != nil {
return fmt.Errorf("%s: %w", path, err)
}
if _, ok := seen[rel]; ok {
continue
}
f2 := *f
f2.Name = rel
if err := processFile(&f2); err != nil {
Expand Down

0 comments on commit 38570a8

Please sign in to comment.