Lorenz Brun | adb98f9 | 2022-07-04 14:09:41 +0000 | [diff] [blame] | 1 | This adds support for workspace-relative Go embeds. |
| 2 | |
| 3 | diff --git a/go/tools/builders/compilepkg.go b/go/tools/builders/compilepkg.go |
| 4 | index 09e3ef6e..4623f803 100644 |
| 5 | --- a/go/tools/builders/compilepkg.go |
| 6 | +++ b/go/tools/builders/compilepkg.go |
| 7 | @@ -379,6 +379,13 @@ func compileArchive( |
| 8 | } |
| 9 | } |
| 10 | } |
| 11 | + // Sort by length descenting to not get wrong roots |
| 12 | + sort.Slice(embedRoots, func(i, j int) bool { |
| 13 | + return len(embedRoots[i]) > len(embedRoots[j]) |
| 14 | + }) |
| 15 | + for _, root := range embedRoots { |
| 16 | + embedRootDirs = append(embedRootDirs, abs(root)) |
| 17 | + } |
| 18 | embedcfgPath, err := buildEmbedcfgFile(srcs.goSrcs, embedSrcs, embedRootDirs, workDir) |
| 19 | if err != nil { |
| 20 | return err |