Skip to content

Commit 7580c6e

Browse files
jupjtklauser
authored andcommitted
unix: factor out mkmerge into a proper package
Factor mkmerge.go and mkmerge_test.go into package internal/mkmerge. Due to ignore constraints, mkmerge_test.go wasn't run by the Go builders and failing tests were unnoticed. Factoring mkmerge into its own package and removing ignore constraints makes the tests run automatically by the Go builders. Fixes golang/go#49484 Change-Id: I56a0b7220e40d1d7e5193490cb547cad4202f9ac Reviewed-on: https://go-review.googlesource.com/c/sys/+/363334 Run-TryBot: Tobias Klauser <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]> Reviewed-by: Tobias Klauser <[email protected]> Trust: Bryan C. Mills <[email protected]> TryBot-Result: Go Bot <[email protected]>
1 parent 7c45f0c commit 7580c6e

File tree

7 files changed

+14
-23
lines changed

7 files changed

+14
-23
lines changed

unix/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ To add a constant, add the header that includes it to the appropriate variable.
149149
Then, edit the regex (if necessary) to match the desired constant. Avoid making
150150
the regex too broad to avoid matching unintended constants.
151151

152-
### mkmerge.go
152+
### internal/mkmerge
153153

154154
This program is used to extract duplicate const, func, and type declarations
155155
from the generated architecture-specific files listed below, and merge these

unix/mkmerge.go renamed to unix/internal/mkmerge/mkmerge.go

+9-12
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,22 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build ignore
6-
// +build ignore
7-
8-
// mkmerge.go parses generated source files and merges common
5+
// The mkmerge command parses generated source files and merges common
96
// consts, funcs, and types into a common source file, per GOOS.
107
//
118
// Usage:
12-
// $ go run mkmerge.go -out MERGED FILE [FILE ...]
9+
// $ mkmerge -out MERGED FILE [FILE ...]
1310
//
1411
// Example:
1512
// # Remove all common consts, funcs, and types from zerrors_linux_*.go
1613
// # and write the common code into zerrors_linux.go
17-
// $ go run mkmerge.go -out zerrors_linux.go zerrors_linux_*.go
14+
// $ mkmerge -out zerrors_linux.go zerrors_linux_*.go
1815
//
19-
// mkmerge.go performs the merge in the following steps:
20-
// 1. Construct the set of common code that is idential in all
21-
// architecture-specific files.
22-
// 2. Write this common code to the merged file.
23-
// 3. Remove the common code from all architecture-specific files.
16+
// mkmerge performs the merge in the following steps:
17+
// 1. Construct the set of common code that is idential in all
18+
// architecture-specific files.
19+
// 2. Write this common code to the merged file.
20+
// 3. Remove the common code from all architecture-specific files.
2421
package main
2522

2623
import (
@@ -464,7 +461,7 @@ func merge(mergedFile string, archFiles ...string) error {
464461
}
465462

466463
buf := bufio.NewWriter(f)
467-
fmt.Fprintln(buf, "// Code generated by mkmerge.go; DO NOT EDIT.")
464+
fmt.Fprintln(buf, "// Code generated by mkmerge; DO NOT EDIT.")
468465
fmt.Fprintln(buf)
469466
fmt.Fprintf(buf, "//go:build %s\n", goos)
470467
fmt.Fprintf(buf, "// +build %s\n", goos)

unix/mkmerge_test.go renamed to unix/internal/mkmerge/mkmerge_test.go

-6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build ignore
6-
// +build ignore
7-
8-
// Test cases for mkmerge.go.
9-
// Usage:
10-
// $ go test mkmerge.go mkmerge_test.go
115
package main
126

137
import (

unix/linux/mkall.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ func mergeFiles() error {
572572

573573
// Merge each of the four type of files
574574
for _, ztyp := range []string{"zerrors", "zsyscall", "zsysnum", "ztypes"} {
575-
cmd := makeCommand("go", "run", "mkmerge.go", "-out", fmt.Sprintf("%s_%s.go", ztyp, GOOS), fmt.Sprintf("%s_%s_*.go", ztyp, GOOS))
575+
cmd := makeCommand("go", "run", "./internal/mkmerge", "-out", fmt.Sprintf("%s_%s.go", ztyp, GOOS), fmt.Sprintf("%s_%s_*.go", ztyp, GOOS))
576576
err := cmd.Run()
577577
if err != nil {
578578
return fmt.Errorf("could not merge %s files: %w", ztyp, err)

unix/zerrors_linux.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

unix/zsyscall_linux.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

unix/ztypes_linux.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)