use of com.google.devtools.build.lib.util.io.TimestampGranularityMonitor in project bazel by bazelbuild.
the class SkylarkFileContentHashTests method getHash.
/**
* Returns the hash code of the rule target defined by the pkg and the target name parameters.
* Asserts that the targets and it's Skylark dependencies were loaded properly.
*/
private String getHash(String pkg, String name) throws Exception {
PackageCacheOptions packageCacheOptions = Options.getDefaults(PackageCacheOptions.class);
packageCacheOptions.defaultVisibility = ConstantRuleVisibility.PUBLIC;
packageCacheOptions.showLoadingProgress = true;
packageCacheOptions.globbingThreads = 7;
getSkyframeExecutor().preparePackageLoading(new PathPackageLocator(outputBase, ImmutableList.of(rootDirectory)), packageCacheOptions, "", UUID.randomUUID(), ImmutableMap.<String, String>of(), ImmutableMap.<String, String>of(), new TimestampGranularityMonitor(BlazeClock.instance()));
SkyKey pkgLookupKey = PackageValue.key(PackageIdentifier.parse("@//" + pkg));
EvaluationResult<PackageValue> result = SkyframeExecutorTestUtils.evaluate(getSkyframeExecutor(), pkgLookupKey, /*keepGoing=*/
false, reporter);
assertFalse(result.hasError());
Collection<Target> targets = result.get(pkgLookupKey).getPackage().getTargets();
for (Target target : targets) {
if (target.getName().equals(name)) {
return ((Rule) target).getRuleClassObject().getRuleDefinitionEnvironment().getTransitiveContentHashCode();
}
}
throw new IllegalStateException("target not found: " + name);
}
use of com.google.devtools.build.lib.util.io.TimestampGranularityMonitor in project bazel by bazelbuild.
the class SkylarkImportLookupFunctionTest method preparePackageLoading.
@Before
public final void preparePackageLoading() throws Exception {
Path alternativeRoot = scratch.dir("/root_2");
PackageCacheOptions packageCacheOptions = Options.getDefaults(PackageCacheOptions.class);
packageCacheOptions.defaultVisibility = ConstantRuleVisibility.PUBLIC;
packageCacheOptions.showLoadingProgress = true;
packageCacheOptions.globbingThreads = 7;
getSkyframeExecutor().preparePackageLoading(new PathPackageLocator(outputBase, ImmutableList.of(rootDirectory, alternativeRoot)), packageCacheOptions, "", UUID.randomUUID(), ImmutableMap.<String, String>of(), ImmutableMap.<String, String>of(), new TimestampGranularityMonitor(BlazeClock.instance()));
}
use of com.google.devtools.build.lib.util.io.TimestampGranularityMonitor in project bazel by bazelbuild.
the class ConfigurationTestCase method initializeSkyframeExecutor.
@Before
public final void initializeSkyframeExecutor() throws Exception {
workspace = rootDirectory;
analysisMock = getAnalysisMock();
ConfiguredRuleClassProvider ruleClassProvider = analysisMock.createRuleClassProvider();
PathPackageLocator pkgLocator = new PathPackageLocator(outputBase, ImmutableList.of(rootDirectory));
final PackageFactory pkgFactory;
BlazeDirectories directories = new BlazeDirectories(outputBase, outputBase, rootDirectory, analysisMock.getProductName());
pkgFactory = analysisMock.getPackageFactoryForTesting().create(ruleClassProvider, scratch.getFileSystem());
AnalysisTestUtil.DummyWorkspaceStatusActionFactory workspaceStatusActionFactory = new AnalysisTestUtil.DummyWorkspaceStatusActionFactory(directories);
skyframeExecutor = SequencedSkyframeExecutor.create(pkgFactory, directories, BinTools.forUnitTesting(directories, analysisMock.getEmbeddedTools()), workspaceStatusActionFactory, ruleClassProvider.getBuildInfoFactories(), ImmutableList.<DiffAwareness.Factory>of(), Predicates.<PathFragment>alwaysFalse(), Preprocessor.Factory.Supplier.NullSupplier.INSTANCE, analysisMock.getSkyFunctions(), ImmutableList.<PrecomputedValue.Injected>of(), ImmutableList.<SkyValueDirtinessChecker>of(), analysisMock.getProductName(), CrossRepositoryLabelViolationStrategy.ERROR, ImmutableList.of(BuildFileName.BUILD_DOT_BAZEL, BuildFileName.BUILD));
PackageCacheOptions packageCacheOptions = Options.getDefaults(PackageCacheOptions.class);
packageCacheOptions.showLoadingProgress = true;
packageCacheOptions.globbingThreads = 7;
skyframeExecutor.preparePackageLoading(pkgLocator, packageCacheOptions, ruleClassProvider.getDefaultsPackageContent(analysisMock.getInvocationPolicyEnforcer().getInvocationPolicy()), UUID.randomUUID(), ImmutableMap.<String, String>of(), ImmutableMap.<String, String>of(), new TimestampGranularityMonitor(BlazeClock.instance()));
mockToolsConfig = new MockToolsConfig(rootDirectory);
analysisMock.setupMockClient(mockToolsConfig);
analysisMock.setupMockWorkspaceFiles(directories.getEmbeddedBinariesRoot());
configurationFactory = analysisMock.createConfigurationFactory();
buildOptionClasses = ruleClassProvider.getConfigurationOptions();
}
use of com.google.devtools.build.lib.util.io.TimestampGranularityMonitor in project bazel by bazelbuild.
the class PackageCacheTest method setUpSkyframe.
private void setUpSkyframe(PackageCacheOptions packageCacheOptions) {
PathPackageLocator pkgLocator = PathPackageLocator.create(null, packageCacheOptions.packagePath, reporter, rootDirectory, rootDirectory);
packageCacheOptions.showLoadingProgress = true;
packageCacheOptions.globbingThreads = 7;
skyframeExecutor.preparePackageLoading(pkgLocator, packageCacheOptions, analysisMock.getDefaultsPackageContent(), UUID.randomUUID(), ImmutableMap.<String, String>of(), ImmutableMap.<String, String>of(), new TimestampGranularityMonitor(BlazeClock.instance()));
skyframeExecutor.setDeletedPackages(ImmutableSet.copyOf(packageCacheOptions.getDeletedPackages()));
}
use of com.google.devtools.build.lib.util.io.TimestampGranularityMonitor in project bazel by bazelbuild.
the class AnalysisTestCase method useRuleClassProvider.
/**
* Changes the rule class provider to be used for the loading and the analysis phase.
*/
protected void useRuleClassProvider(ConfiguredRuleClassProvider ruleClassProvider) throws Exception {
this.ruleClassProvider = ruleClassProvider;
PackageFactory pkgFactory = analysisMock.getPackageFactoryForTesting().create(ruleClassProvider, scratch.getFileSystem());
BinTools binTools = BinTools.forUnitTesting(directories, analysisMock.getEmbeddedTools());
skyframeExecutor = SequencedSkyframeExecutor.create(pkgFactory, directories, binTools, workspaceStatusActionFactory, ruleClassProvider.getBuildInfoFactories(), ImmutableList.<DiffAwareness.Factory>of(), Predicates.<PathFragment>alwaysFalse(), Preprocessor.Factory.Supplier.NullSupplier.INSTANCE, analysisMock.getSkyFunctions(), getPrecomputedValues(), ImmutableList.<SkyValueDirtinessChecker>of(), analysisMock.getProductName(), CrossRepositoryLabelViolationStrategy.ERROR, ImmutableList.of(BuildFileName.BUILD_DOT_BAZEL, BuildFileName.BUILD));
PackageCacheOptions packageCacheOptions = Options.getDefaults(PackageCacheOptions.class);
packageCacheOptions.showLoadingProgress = true;
packageCacheOptions.globbingThreads = 3;
skyframeExecutor.preparePackageLoading(pkgLocator, packageCacheOptions, ruleClassProvider.getDefaultsPackageContent(analysisMock.getInvocationPolicyEnforcer().getInvocationPolicy()), UUID.randomUUID(), ImmutableMap.<String, String>of(), ImmutableMap.<String, String>of(), new TimestampGranularityMonitor(BlazeClock.instance()));
packageManager = skyframeExecutor.getPackageManager();
loadingPhaseRunner = skyframeExecutor.getLoadingPhaseRunner(pkgFactory.getRuleClassNames(), defaultFlags().contains(Flag.SKYFRAME_LOADING_PHASE));
buildView = new BuildView(directories, ruleClassProvider, skyframeExecutor, null);
useConfiguration();
}
Aggregations