Skip to content

Commit 68b2548

Browse files
committed
don't hardcode zdl.go
1 parent 51aadf9 commit 68b2548

File tree

4 files changed

+8
-13
lines changed

4 files changed

+8
-13
lines changed

cmd/mkcgo/generate.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -696,16 +696,16 @@ func needsAssembly(src *mkcgo.Source) bool {
696696
}
697697

698698
// generateNocgoGo generates Go source file for nocgo mode from src.
699-
func generateNocgoGo(src *mkcgo.Source, w io.Writer, isZdlFile bool) {
699+
func generateNocgoGo(src *mkcgo.Source, w io.Writer) {
700700
// Output header notice and package declaration.
701701
printHeader(w)
702702

703703
// Set build tag based on whether this is a zdl file
704-
if isZdlFile {
705-
fmt.Fprintf(w, "//go:build !cgo && unix\n\n")
706-
} else {
707-
fmt.Fprintf(w, "//go:build !cgo\n\n")
704+
tags := "!cgo"
705+
if *extratags != "" {
706+
tags += " && (" + *extratags + ")"
708707
}
708+
fmt.Fprintf(w, "//go:build %s\n\n", tags)
709709

710710
fmt.Fprintf(w, "package %s\n\n", *packageName)
711711

cmd/mkcgo/main.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ var (
2222
mode = flag.String("mode", "dynamic", "symbol load mode: dynamic, dynload")
2323
private = flag.Bool("private", false, "all Go generated symbols are kept unexported")
2424
noerrors = flag.Bool("noerrors", false, "disable error handling")
25+
extratags = flag.String("tags", "", "tags to add to the generated files")
2526
)
2627

2728
func usage() {
@@ -76,11 +77,10 @@ func main() {
7677
} else {
7778
baseNameForCheck = strings.TrimSuffix(baseNameForCheck, ".go")
7879
}
79-
isZdlFile := strings.HasPrefix(baseNameForCheck, "zdl")
8080

8181
// Generate nocgo mode files
8282
var nocgoGoBuffer, assemblyBuffer bytes.Buffer
83-
generateNocgoGo(&src, &nocgoGoBuffer, isZdlFile)
83+
generateNocgoGo(&src, &nocgoGoBuffer)
8484

8585
// Only generate assembly if needed (i.e., not all functions are static)
8686
needsAsm := needsAssembly(&src)
@@ -94,11 +94,6 @@ func main() {
9494
// Determine suffix based on the base name
9595
suffix := "_nocgo.go"
9696

97-
// Special case for zdl files - use _nocgo_unix.go suffix
98-
if isZdlFile {
99-
suffix = "_nocgo_unix.go"
100-
}
101-
10297
files := []struct {
10398
suffix string
10499
data []byte

internal/ossl/ossl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package ossl
33

44
//go:generate go run ../../cmd/mkcgo -out zossl.go -mode dynload -package ossl shims.h
55
//go:generate go run ../../cmd/mkcgo -out zossl.go -nocgo -mode dynload -package ossl shims.h
6-
//go:generate go run ../../cmd/mkcgo -out zdl.go -nocgo -mode dynamic -noerrors -package ossl dl.h
6+
//go:generate go run ../../cmd/mkcgo -out zdl.go -nocgo -mode dynamic -noerrors -package ossl -tags unix dl.h
77

88
import "unsafe"
99

File renamed without changes.

0 commit comments

Comments
 (0)