Making a tool exportable
How to make a tool exportable with the export
goal.
Backends that implement the export
goal can indicate binaries that should be exported. These will have their contents exported to a subfolder in the dist/bins
directory, and the binary itself will be linked in dist/bin
.
Downloadable Tools
Subclasses of ExternalTool
(including TemplatedExternalTool
) have the logic for exporting implemented. Tools are marked for export as follows:
-
Implement
ExternalTool.generate_exe
if the default is not correct. For instance, a tool downloaded might include a binary, a readme, and a license. This method will point to the binary within the downloaded files. -
Register a
UnionRule
withExportableTool
. For example,UnionRule(ExportableTool, FortranLint)
Implementing for new backends
Backends need to implement:
- A subclass of
ExportRequest
@dataclass(frozen=True)
class ExportExternalToolRequest(ExportRequest):
pass
- A rule from this subclass to
ExportResults
@rule
async def export_external_tools(
request: ExportExternalToolRequest, export: ExportSubsystem
) -> ExportResults:
- Inside of that rule, fill the
ExportResult.exported_binaries
field.
ExportResult(
description=f"Export tool {req.resolve}",
reldir=dest,
digest=downloaded_tool.digest,
resolve=req.resolve,
exported_binaries=(ExportedBinary(name=Path(exe).name, path_in_export=exe),),
)
- For every tool, mark it for export registering a
UnionRule
withExportableTool
.
def rules():
return [
...,
`UnionRule(ExportableTool, FortranLint)`,
]