A compiled artifact names the binary a machine will run
novox/hq 04-ISSUES/142. The name a machine runs a binary by is not always the name of the package that built it. The host's command is cmd/mesh-host and every machine runs it as nox-mesh-host — the path it is installed at, the name in its unit, and the name its launcher looks for inside a delivered version. So the first delivered host version landed as `mesh-host`, the host reported "created /usr/lib/nox-mesh-host/versions/2681d936b949: 1 file(s)", everything said success, and the launcher would never have seen it. Found by listing the directory instead of believing the line. An artifact may now say what its executable is called. Saying nothing keeps what the compiler would have chosen — the package's name — so nothing that worked before changes.
This commit is contained in:
@@ -878,7 +878,16 @@ func compile(ctx context.Context, run Runner, tree string, chain Toolchain,
|
||||
}
|
||||
invocation = append(invocation, chain.Compile...)
|
||||
if chain.OutputFlag != "" {
|
||||
invocation = append(invocation, chain.OutputFlag, out)
|
||||
// A compiler pointed at a package is told the file to write, not the directory: the name a
|
||||
// machine runs it by is not always the name of the package that built it. The host's command
|
||||
// is `cmd/mesh-host` and every machine runs it as `nox-mesh-host` — so a bundle carrying the
|
||||
// package's name lands correctly, reports success, and is invisible to whatever looks for it
|
||||
// (novox/hq 04-ISSUES/142).
|
||||
target := out
|
||||
if chain.Unit == UnitPackage {
|
||||
target = filepath.Join(out, binaryName(a))
|
||||
}
|
||||
invocation = append(invocation, chain.OutputFlag, target)
|
||||
}
|
||||
// What to compile. Named by the module rather than discovered, so adding a file does not
|
||||
// silently change what a build produces.
|
||||
@@ -1067,3 +1076,15 @@ func readBy(manifest catalogue.Manifest) []catalogue.ArtifactContext {
|
||||
})
|
||||
return out
|
||||
}
|
||||
|
||||
// binaryName is what a compiled bundle's executable is called: what the artifact says, or the name of
|
||||
// the package it is built from, which is what a compiler would have chosen anyway.
|
||||
func binaryName(a catalogue.Artifact) string {
|
||||
if name := strings.TrimSpace(a.Binary); name != "" {
|
||||
return name
|
||||
}
|
||||
if from := strings.Trim(a.From, "./"); from != "" {
|
||||
return filepath.Base(from)
|
||||
}
|
||||
return a.Name
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user