Skip to content

Commit 7319793

Browse files
committed
gen.go: fix breakage due to changes in core
Changes: src/vendor/golang_org moved to src/internal/x Change-Id: I3791fd633534f15f5e2698ad01ae8d226128181e Reviewed-on: https://go-review.googlesource.com/c/154438 Run-TryBot: Marcel van Lohuizen <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ross Light <[email protected]>
1 parent e6919f6 commit 7319793

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

gen.go

+12-8
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ pkg unicode, var <new script or property> *RangeTable
138138
copyExported("golang.org/x/net/idna")
139139

140140
if updateCore {
141-
copyVendored()
141+
copyInternal()
142142
}
143143

144144
if hasErrors {
@@ -236,9 +236,9 @@ func copyExported(p string) {
236236
p)
237237
}
238238

239-
// copyVendored copies packages used by Go core into the vendored directory.
240-
func copyVendored() {
241-
root := filepath.Join(build.Default.GOROOT, filepath.FromSlash("src/vendor/golang_org/x"))
239+
// copyInternal copies packages used by Go core into the internal directory.
240+
func copyInternal() {
241+
root := filepath.Join(build.Default.GOROOT, filepath.FromSlash("src/internal/x"))
242242

243243
err := filepath.Walk(root, func(dir string, info os.FileInfo, err error) error {
244244
if err != nil || !info.IsDir() || root == dir {
@@ -253,7 +253,7 @@ func copyVendored() {
253253
// Copy the vendored package if it exists in the export directory.
254254
src = filepath.Join("internal", "export", filepath.Base(src))
255255
}
256-
copyPackage(src, dir, "golang.org", "golang_org")
256+
copyPackage(src, dir, "golang.org", "internal")
257257
return nil
258258
})
259259
if err != nil {
@@ -279,18 +279,22 @@ func copyPackage(dirSrc, dirDst, search, replace string) {
279279
filepath.Dir(file) != dirSrc {
280280
return nil
281281
}
282+
if strings.HasPrefix(base, "tables") {
283+
if !strings.HasSuffix(base, gen.UnicodeVersion()+".go") {
284+
return nil
285+
}
286+
base = "tables.go"
287+
}
282288
b, err := ioutil.ReadFile(file)
283289
if err != nil || bytes.Contains(b, []byte("\n// +build ignore")) {
284290
return err
285291
}
286292
// Fix paths.
287293
b = bytes.Replace(b, []byte(search), []byte(replace), -1)
294+
b = bytes.Replace(b, []byte("internal/export"), []byte(""), -1)
288295
// Remove go:generate lines.
289296
b = goGenRE.ReplaceAllLiteral(b, nil)
290297
comment := "// Code generated by running \"go generate\" in golang.org/x/text. DO NOT EDIT.\n\n"
291-
if *doCore {
292-
comment = "// Code generated by running \"go run gen.go -core\" in golang.org/x/text. DO NOT EDIT.\n\n"
293-
}
294298
if !bytes.HasPrefix(b, []byte(comment)) {
295299
b = append([]byte(comment), b...)
296300
}

0 commit comments

Comments
 (0)