/** * Performs the initial phases 0-2 of the build: Setup, Loading and Analysis. * * <p>Postcondition: On success, populates the BuildRequest's set of targets to build. * * @return null if loading / analysis phases were successful; a useful error message if loading or * analysis phase errors were encountered and request.keepGoing. * @throws InterruptedException if the current thread was interrupted. * @throws ViewCreationFailedException if analysis failed for any reason. */ private AnalysisResult runAnalysisPhase( BuildRequest request, LoadingResult loadingResult, BuildConfigurationCollection configurations) throws InterruptedException, ViewCreationFailedException { Stopwatch timer = Stopwatch.createStarted(); if (!request.getBuildOptions().performAnalysisPhase) { getReporter().handle(Event.progress("Loading complete.")); LOG.info("No analysis requested, so finished"); return AnalysisResult.EMPTY; } getReporter().handle(Event.progress("Loading complete. Analyzing...")); Profiler.instance().markPhase(ProfilePhase.ANALYZE); AnalysisResult analysisResult = getView() .update( loadingResult, configurations, request.getAspects(), request.getViewOptions(), request.getTopLevelArtifactContext(), getReporter(), getEventBus()); // TODO(bazel-team): Merge these into one event. getEventBus() .post( new AnalysisPhaseCompleteEvent( analysisResult.getTargetsToBuild(), getView().getTargetsVisited(), timer.stop().elapsed(TimeUnit.MILLISECONDS))); getEventBus() .post( new TestFilteringCompleteEvent( analysisResult.getTargetsToBuild(), analysisResult.getTargetsToTest())); // Check licenses. // We check licenses if the first target configuration has license checking enabled. Right now, // it is not possible to have multiple target configurations with different settings for this // flag, which allows us to take this short cut. boolean checkLicenses = configurations.getTargetConfigurations().get(0).checkLicenses(); if (checkLicenses) { Profiler.instance().markPhase(ProfilePhase.LICENSE); validateLicensingForTargets( analysisResult.getTargetsToBuild(), request.getViewOptions().keepGoing); } return analysisResult; }
/** * Ensure the runfiles tree exists and is consistent with the TestAction's manifest * ($0.runfiles_manifest), bringing it into consistency if not. The contents of the output file * $0.runfiles/MANIFEST, if it exists, are used a proxy for the set of existing symlinks, to avoid * the need for recursion. */ private static void updateLocalRunfilesDirectory( TestRunnerAction testAction, Path runfilesDir, ActionExecutionContext actionExecutionContext, BinTools binTools, ImmutableMap<String, String> shellEnvironment, boolean enableRunfiles) throws ExecException, InterruptedException { Executor executor = actionExecutionContext.getExecutor(); TestTargetExecutionSettings execSettings = testAction.getExecutionSettings(); try { // Avoid rebuilding the runfiles directory if the manifest in it matches the input manifest, // implying the symlinks exist and are already up to date. if (Arrays.equals( runfilesDir.getRelative("MANIFEST").getMD5Digest(), execSettings.getInputManifest().getPath().getMD5Digest())) { return; } } catch (IOException e1) { // Ignore it - we will just try to create runfiles directory. } executor .getEventHandler() .handle( Event.progress( "Building runfiles directory for '" + execSettings.getExecutable().prettyPrint() + "'.")); new SymlinkTreeHelper(execSettings.getInputManifest().getPath(), runfilesDir, false) .createSymlinks( testAction, actionExecutionContext, binTools, shellEnvironment, enableRunfiles); executor.getEventHandler().handle(Event.progress(testAction.getProgressMessage())); }
private static void deserializeEvent(StoredEventHandler eventHandler, Build.Event event) { String message = event.getMessage(); switch (event.getKind()) { case ERROR: eventHandler.handle(Event.error(message)); break; case WARNING: eventHandler.handle(Event.warn(message)); break; case INFO: eventHandler.handle(Event.info(message)); break; case PROGRESS: eventHandler.handle(Event.progress(message)); break; default: break; // Ignore } }