fx ide-queryThis document outlines the design for verifying that source files and their generated dependencies are correctly built. This ensures that IDEs have access to fresh artifacts (like FIDL-generated headers) before performing analysis.
To provide a consistent and isolated analysis environment, ide-query uses a dedicated “shadow” build directory. This prevents IDE-triggered builds from interfering with, locking, or dirtying the user's primary build directory.
The tool will use a specific directory for all analysis-related builds:
out/.ide-analysis (relative to the Fuchsia root).The build verification process follows these steps:
Before any build is attempted, the shadow directory must be configured to match the user's current build environment:
args.gn: Find the args.gn file in the user's primary BuildDir (as determined by WORKSPACE_CONTEXT_DESIGN.md).args.gn is missing in the primary build directory (indicating the user has not configured a build with fx set), the tool will report an AnalysisError.args.gn:${BuildDir}/args.gn with out/.ide-analysis/args.gn.args.gn to the shadow directory.fx --dir out/.ide-analysis gen to regenerate the Ninja files.The tool identifies the GN labels for all requested files as described in BUILD_TARGETS_DESIGN.md.
To accurately report build failures for each file, targets are built individually. The tool iterates through each unique target and executes fx --dir out/.ide-analysis build <target>. While this is less parallel than a single multi-target build, it prevents a single failing target from obscuring the status of other targets.
fx --dir out/.ide-analysis build <target>.The results are reported back to the IDE via two fields in the FileEntry structure.
AnalysisError (string)This field is used for terminal errors that prevent the tool from progressing to the build phase. If this is set, the AnalysisResult is typically omitted.
Scenarios:
args.gn missing in the primary build directory.compile_commands.json is missing or unreadable.fx gen).AnalysisResult (object)This field captures the outcome of the build attempt for a specific file.
type AnalysisStatus string
const (
StatusOk AnalysisStatus = "OK"
StatusNotFound AnalysisStatus = "NOT_FOUND"
StatusBuildFailed AnalysisStatus = "BUILD_FAILED"
StatusUnknown AnalysisStatus = "UNKNOWN"
)
type AnalysisResult struct {
Status AnalysisStatus `json:"status"`
Message string `json:"message,omitempty"`
}
Status Mapping:
OK: The building of the target(s) associated with the file succeeded.NOT_FOUND: The file itself does not exist on disk.BUILD_FAILED: Ninja reported an error specifically while building the targets for this file."File failed to build."UNKNOWN: The file was not found in compile_commands.json and heuristics failed to identify a target.--dir out/.ide-analysis to fx commands, we ensure that no side effects impact the user's primary development workflow.