Search in sources :

Example 1 with PackageFactory

use of com.google.devtools.build.lib.packages.PackageFactory in project bazel by bazelbuild.

the class DumpCommand method dumpRuleClasses.

private void dumpRuleClasses(BlazeRuntime runtime, PrintStream out) {
    PackageFactory factory = runtime.getPackageFactory();
    List<String> ruleClassNames = new ArrayList<>(factory.getRuleClassNames());
    Collections.sort(ruleClassNames);
    for (String name : ruleClassNames) {
        if (name.startsWith("$")) {
            continue;
        }
        RuleClass ruleClass = factory.getRuleClass(name);
        out.print(ruleClass + "(");
        boolean first = true;
        for (Attribute attribute : ruleClass.getAttributes()) {
            if (attribute.isImplicit()) {
                continue;
            }
            if (first) {
                first = false;
            } else {
                out.print(", ");
            }
            out.print(attribute.getName());
        }
        out.println(")");
    }
}
Also used : PackageFactory(com.google.devtools.build.lib.packages.PackageFactory) Attribute(com.google.devtools.build.lib.packages.Attribute) ArrayList(java.util.ArrayList) RuleClass(com.google.devtools.build.lib.packages.RuleClass)

Example 2 with PackageFactory

use of com.google.devtools.build.lib.packages.PackageFactory 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();
}
Also used : BinTools(com.google.devtools.build.lib.analysis.config.BinTools) PackageFactory(com.google.devtools.build.lib.packages.PackageFactory) BuildView(com.google.devtools.build.lib.analysis.BuildView) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) ConfigurationFactory(com.google.devtools.build.lib.analysis.config.ConfigurationFactory) PackageFactory(com.google.devtools.build.lib.packages.PackageFactory) SkyValueDirtinessChecker(com.google.devtools.build.lib.skyframe.SkyValueDirtinessChecker) PackageCacheOptions(com.google.devtools.build.lib.pkgcache.PackageCacheOptions) TimestampGranularityMonitor(com.google.devtools.build.lib.util.io.TimestampGranularityMonitor)

Example 3 with PackageFactory

use of com.google.devtools.build.lib.packages.PackageFactory 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();
}
Also used : MockToolsConfig(com.google.devtools.build.lib.packages.util.MockToolsConfig) ConfiguredRuleClassProvider(com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) ConfigurationFactory(com.google.devtools.build.lib.analysis.config.ConfigurationFactory) PackageFactory(com.google.devtools.build.lib.packages.PackageFactory) PackageCacheOptions(com.google.devtools.build.lib.pkgcache.PackageCacheOptions) PathPackageLocator(com.google.devtools.build.lib.pkgcache.PathPackageLocator) PackageFactory(com.google.devtools.build.lib.packages.PackageFactory) BlazeDirectories(com.google.devtools.build.lib.analysis.BlazeDirectories) SkyValueDirtinessChecker(com.google.devtools.build.lib.skyframe.SkyValueDirtinessChecker) TimestampGranularityMonitor(com.google.devtools.build.lib.util.io.TimestampGranularityMonitor) Before(org.junit.Before)

Aggregations

PackageFactory (com.google.devtools.build.lib.packages.PackageFactory)3 ConfigurationFactory (com.google.devtools.build.lib.analysis.config.ConfigurationFactory)2 PackageCacheOptions (com.google.devtools.build.lib.pkgcache.PackageCacheOptions)2 SkyValueDirtinessChecker (com.google.devtools.build.lib.skyframe.SkyValueDirtinessChecker)2 TimestampGranularityMonitor (com.google.devtools.build.lib.util.io.TimestampGranularityMonitor)2 PathFragment (com.google.devtools.build.lib.vfs.PathFragment)2 BlazeDirectories (com.google.devtools.build.lib.analysis.BlazeDirectories)1 BuildView (com.google.devtools.build.lib.analysis.BuildView)1 ConfiguredRuleClassProvider (com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider)1 BinTools (com.google.devtools.build.lib.analysis.config.BinTools)1 Attribute (com.google.devtools.build.lib.packages.Attribute)1 RuleClass (com.google.devtools.build.lib.packages.RuleClass)1 MockToolsConfig (com.google.devtools.build.lib.packages.util.MockToolsConfig)1 PathPackageLocator (com.google.devtools.build.lib.pkgcache.PathPackageLocator)1 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1