Hold a cgo file's directory whole: its preamble may include from below it (hq ADR 0267, review)
mesh/delivery delivered
mesh/merge-gate pass: builds build-agent, mesh-controller, route-proxy → ace, g14, novox, shanks; no bus step; every machine composes with the change as it…
mesh/repo-check pass: its merge-check.sh passed

This commit is contained in:
jochen
2026-10-10 03:20:35 +02:00
parent abe5f7dc17
commit de55c63e12
2 changed files with 14 additions and 0 deletions
+2
View File
@@ -351,6 +351,8 @@ func goFileReads(file string) (imports, embeds []string, err error) {
}
}
}
// A cgo file may include from below its directory: the directory is held whole.
embeds = append(embeds, ".")
continue
}
imports = append(imports, ip)
+12
View File
@@ -304,3 +304,15 @@ func TestNativeSourcesHoldTheirDirectoryWhole(t *testing.T) {
}
}
}
// A cgo file may include from below its directory with nothing native beside it: its directory is held whole.
func TestACgoFileHoldsItsDirectoryWhole(t *testing.T) {
got, err := GoBuildSource(aGoTree(t, map[string]string{"go.mod": "module x\n",
"p/main.go": "package main\n\n// #include \"inc/x.h\"\nimport \"C\"\n", "p/inc/x.h": ""}), "p")
if err != nil {
t.Fatal(err)
}
if !SourceHolds(got, "p/inc/x.h") {
t.Fatalf("a header a cgo preamble includes is not held: %v", got)
}
}