Search in sources :

Example 1 with AbstractBottomUpTraversal

use of com.facebook.buck.graph.AbstractBottomUpTraversal in project buck by facebook.

the class ProjectGeneratorTest method getBuildRuleResolverNodeFunction.

private Function<TargetNode<?, ?>, BuildRuleResolver> getBuildRuleResolverNodeFunction(final TargetGraph targetGraph) {
    BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
    AbstractBottomUpTraversal<TargetNode<?, ?>, RuntimeException> bottomUpTraversal = new AbstractBottomUpTraversal<TargetNode<?, ?>, RuntimeException>(targetGraph) {

        @Override
        @SuppressWarnings("PMD.EmptyCatchBlock")
        public void visit(TargetNode<?, ?> node) {
            try {
                resolver.requireRule(node.getBuildTarget());
            } catch (Exception e) {
            // NOTE(agallagher): A large number of the tests appear to setup their target nodes
            // incorrectly, causing action graph creation to fail with lots of missing expected
            // Apple C/C++ platform flavors.  This is gross, but to support tests that need a
            // complete sub-action graph, just skip over the errors.
            }
        }
    };
    bottomUpTraversal.traverse();
    return input -> resolver;
}
Also used : ProjectGeneratorTestUtils.assertTargetExistsAndReturnTarget(com.facebook.buck.apple.project_generator.ProjectGeneratorTestUtils.assertTargetExistsAndReturnTarget) SourceTreePath(com.facebook.buck.apple.xcode.xcodeproj.SourceTreePath) AppleBundleExtension(com.facebook.buck.apple.AppleBundleExtension) CoreMatchers.startsWith(org.hamcrest.CoreMatchers.startsWith) AppleLibraryBuilder(com.facebook.buck.apple.AppleLibraryBuilder) InternalFlavor(com.facebook.buck.model.InternalFlavor) CoreMatchers.instanceOf(org.hamcrest.CoreMatchers.instanceOf) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) FlavorDomain(com.facebook.buck.model.FlavorDomain) FluentIterable(com.google.common.collect.FluentIterable) Map(java.util.Map) ReactNativeBuckConfig(com.facebook.buck.js.ReactNativeBuckConfig) Path(java.nio.file.Path) CxxDescriptionEnhancer(com.facebook.buck.cxx.CxxDescriptionEnhancer) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) NSDictionary(com.dd.plist.NSDictionary) FileAttribute(java.nio.file.attribute.FileAttribute) BuildTarget(com.facebook.buck.model.BuildTarget) IsCollectionWithSize.hasSize(org.hamcrest.collection.IsCollectionWithSize.hasSize) SettableFakeClock(com.facebook.buck.timing.SettableFakeClock) Assert.assertFalse(org.junit.Assert.assertFalse) StringWithMacrosUtils(com.facebook.buck.rules.macros.StringWithMacrosUtils) ByteStreams(com.google.common.io.ByteStreams) CxxLibraryBuilder(com.facebook.buck.cxx.CxxLibraryBuilder) CxxBuckConfig(com.facebook.buck.cxx.CxxBuckConfig) BuckEventBus(com.facebook.buck.event.BuckEventBus) PBXSourcesBuildPhase(com.facebook.buck.apple.xcode.xcodeproj.PBXSourcesBuildPhase) Iterables(com.google.common.collect.Iterables) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) PBXHeadersBuildPhase(com.facebook.buck.apple.xcode.xcodeproj.PBXHeadersBuildPhase) SourcePath(com.facebook.buck.rules.SourcePath) Either(com.facebook.buck.model.Either) XCBuildConfiguration(com.facebook.buck.apple.xcode.xcodeproj.XCBuildConfiguration) PosixFilePermissions(java.nio.file.attribute.PosixFilePermissions) NoSuchBuildTargetException(com.facebook.buck.parser.NoSuchBuildTargetException) HalideLibraryDescription(com.facebook.buck.halide.HalideLibraryDescription) BuildTargetFactory(com.facebook.buck.model.BuildTargetFactory) AppleBinaryBuilder(com.facebook.buck.apple.AppleBinaryBuilder) PBXBuildPhase(com.facebook.buck.apple.xcode.xcodeproj.PBXBuildPhase) StringWithMacros(com.facebook.buck.rules.macros.StringWithMacros) ImmutableSortedMap(com.google.common.collect.ImmutableSortedMap) Before(org.junit.Before) AppleAssetCatalogBuilder(com.facebook.buck.apple.AppleAssetCatalogBuilder) ImmutableSortedSet(com.google.common.collect.ImmutableSortedSet) Assert.assertTrue(org.junit.Assert.assertTrue) ProductType(com.facebook.buck.apple.xcode.xcodeproj.ProductType) AppleResourceBuilder(com.facebook.buck.apple.AppleResourceBuilder) Test(org.junit.Test) IOException(java.io.IOException) PBXResourcesBuildPhase(com.facebook.buck.apple.xcode.xcodeproj.PBXResourcesBuildPhase) SceneKitAssetsBuilder(com.facebook.buck.apple.SceneKitAssetsBuilder) CxxSource(com.facebook.buck.cxx.CxxSource) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) HalideLibraryBuilder(com.facebook.buck.halide.HalideLibraryBuilder) Paths(java.nio.file.Paths) AppleLibraryDescription(com.facebook.buck.apple.AppleLibraryDescription) PBXShellScriptBuildPhase(com.facebook.buck.apple.xcode.xcodeproj.PBXShellScriptBuildPhase) Assert.assertEquals(org.junit.Assert.assertEquals) IosReactNativeLibraryBuilder(com.facebook.buck.js.IosReactNativeLibraryBuilder) CoreMatchers.is(org.hamcrest.CoreMatchers.is) AppleDependenciesCache(com.facebook.buck.apple.AppleDependenciesCache) CoreMatchers.hasItem(org.hamcrest.CoreMatchers.hasItem) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) PatternMatchedCollection(com.facebook.buck.rules.coercer.PatternMatchedCollection) XcodePostbuildScriptBuilder(com.facebook.buck.apple.XcodePostbuildScriptBuilder) Matchers.hasKey(org.hamcrest.Matchers.hasKey) CoreMatchers.notNullValue(org.hamcrest.CoreMatchers.notNullValue) PBXBuildFile(com.facebook.buck.apple.xcode.xcodeproj.PBXBuildFile) Assert.assertThat(org.junit.Assert.assertThat) AppleConfig(com.facebook.buck.apple.AppleConfig) BuckConfig(com.facebook.buck.cli.BuckConfig) CxxPlatformUtils(com.facebook.buck.cxx.CxxPlatformUtils) PBXFileReference(com.facebook.buck.apple.xcode.xcodeproj.PBXFileReference) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) Cell(com.facebook.buck.rules.Cell) SwiftBuckConfig(com.facebook.buck.swift.SwiftBuckConfig) Function(com.google.common.base.Function) ImmutableSet(com.google.common.collect.ImmutableSet) PosixFilePermission(java.nio.file.attribute.PosixFilePermission) AppleBundleBuilder(com.facebook.buck.apple.AppleBundleBuilder) ImmutableMap(com.google.common.collect.ImmutableMap) TargetGraph(com.facebook.buck.rules.TargetGraph) Collection(java.util.Collection) Platform(com.facebook.buck.util.environment.Platform) PBXGroup(com.facebook.buck.apple.xcode.xcodeproj.PBXGroup) XcodePrebuildScriptBuilder(com.facebook.buck.apple.XcodePrebuildScriptBuilder) List(java.util.List) AlwaysFoundExecutableFinder(com.facebook.buck.io.AlwaysFoundExecutableFinder) SourceWithFlags(com.facebook.buck.rules.SourceWithFlags) HalideBuckConfig(com.facebook.buck.halide.HalideBuckConfig) FakeAppleRuleDescriptions(com.facebook.buck.apple.FakeAppleRuleDescriptions) IncrementingFakeClock(com.facebook.buck.timing.IncrementingFakeClock) PathSourcePath(com.facebook.buck.rules.PathSourcePath) ExportFileDescription(com.facebook.buck.shell.ExportFileDescription) Optional(java.util.Optional) Assume.assumeTrue(org.junit.Assume.assumeTrue) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) Pattern(java.util.regex.Pattern) CoreMatchers.not(org.hamcrest.CoreMatchers.not) FrameworkPath(com.facebook.buck.rules.coercer.FrameworkPath) AbstractBottomUpTraversal(com.facebook.buck.graph.AbstractBottomUpTraversal) PBXVariantGroup(com.facebook.buck.apple.xcode.xcodeproj.PBXVariantGroup) BuckEventBusFactory(com.facebook.buck.event.BuckEventBusFactory) FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) ImmutableList(com.google.common.collect.ImmutableList) AllExistingProjectFilesystem(com.facebook.buck.testutil.AllExistingProjectFilesystem) NSString(com.dd.plist.NSString) PBXTarget(com.facebook.buck.apple.xcode.xcodeproj.PBXTarget) ExpectedException(org.junit.rules.ExpectedException) MoreCollectors(com.facebook.buck.util.MoreCollectors) Assert.assertNotNull(org.junit.Assert.assertNotNull) TargetNode(com.facebook.buck.rules.TargetNode) ExportFileBuilder(com.facebook.buck.shell.ExportFileBuilder) Matchers(org.hamcrest.Matchers) PBXProject(com.facebook.buck.apple.xcode.xcodeproj.PBXProject) PBXReference(com.facebook.buck.apple.xcode.xcodeproj.PBXReference) CxxPlatform(com.facebook.buck.cxx.CxxPlatform) HumanReadableException(com.facebook.buck.util.HumanReadableException) DefaultBuildTargetSourcePath(com.facebook.buck.rules.DefaultBuildTargetSourcePath) TimeUnit(java.util.concurrent.TimeUnit) PBXCopyFilesBuildPhase(com.facebook.buck.apple.xcode.xcodeproj.PBXCopyFilesBuildPhase) Rule(org.junit.Rule) Ordering(com.google.common.collect.Ordering) TargetGraphFactory(com.facebook.buck.testutil.TargetGraphFactory) AppleTestBuilder(com.facebook.buck.apple.AppleTestBuilder) TestCellBuilder(com.facebook.buck.rules.TestCellBuilder) CoreDataModelBuilder(com.facebook.buck.apple.CoreDataModelBuilder) CopyFilePhaseDestinationSpec(com.facebook.buck.apple.xcode.xcodeproj.CopyFilePhaseDestinationSpec) Flavor(com.facebook.buck.model.Flavor) HeaderMap(com.facebook.buck.apple.clang.HeaderMap) InputStream(java.io.InputStream) TargetNode(com.facebook.buck.rules.TargetNode) AbstractBottomUpTraversal(com.facebook.buck.graph.AbstractBottomUpTraversal) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) NoSuchBuildTargetException(com.facebook.buck.parser.NoSuchBuildTargetException) IOException(java.io.IOException) ExpectedException(org.junit.rules.ExpectedException) HumanReadableException(com.facebook.buck.util.HumanReadableException)

Example 2 with AbstractBottomUpTraversal

use of com.facebook.buck.graph.AbstractBottomUpTraversal in project buck by facebook.

the class ActionGraphCache method createActionGraph.

private static ActionGraphAndResolver createActionGraph(final BuckEventBus eventBus, TargetNodeToBuildRuleTransformer transformer, TargetGraph targetGraph) {
    final BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, transformer, eventBus);
    AbstractBottomUpTraversal<TargetNode<?, ?>, RuntimeException> bottomUpTraversal = new AbstractBottomUpTraversal<TargetNode<?, ?>, RuntimeException>(targetGraph) {

        @Override
        public void visit(TargetNode<?, ?> node) {
            try {
                resolver.requireRule(node.getBuildTarget());
            } catch (NoSuchBuildTargetException e) {
                throw new HumanReadableException(e);
            }
        }
    };
    bottomUpTraversal.traverse();
    return ActionGraphAndResolver.builder().setActionGraph(new ActionGraph(resolver.getBuildRules())).setResolver(resolver).build();
}
Also used : HumanReadableException(com.facebook.buck.util.HumanReadableException) NoSuchBuildTargetException(com.facebook.buck.parser.NoSuchBuildTargetException) AbstractBottomUpTraversal(com.facebook.buck.graph.AbstractBottomUpTraversal)

Aggregations

NSDictionary (com.dd.plist.NSDictionary)1 NSString (com.dd.plist.NSString)1 AppleAssetCatalogBuilder (com.facebook.buck.apple.AppleAssetCatalogBuilder)1 AppleBinaryBuilder (com.facebook.buck.apple.AppleBinaryBuilder)1 AppleBundleBuilder (com.facebook.buck.apple.AppleBundleBuilder)1 AppleBundleExtension (com.facebook.buck.apple.AppleBundleExtension)1 AppleConfig (com.facebook.buck.apple.AppleConfig)1 AppleDependenciesCache (com.facebook.buck.apple.AppleDependenciesCache)1 AppleLibraryBuilder (com.facebook.buck.apple.AppleLibraryBuilder)1 AppleLibraryDescription (com.facebook.buck.apple.AppleLibraryDescription)1 AppleResourceBuilder (com.facebook.buck.apple.AppleResourceBuilder)1 AppleTestBuilder (com.facebook.buck.apple.AppleTestBuilder)1 CoreDataModelBuilder (com.facebook.buck.apple.CoreDataModelBuilder)1 FakeAppleRuleDescriptions (com.facebook.buck.apple.FakeAppleRuleDescriptions)1 SceneKitAssetsBuilder (com.facebook.buck.apple.SceneKitAssetsBuilder)1 XcodePostbuildScriptBuilder (com.facebook.buck.apple.XcodePostbuildScriptBuilder)1 XcodePrebuildScriptBuilder (com.facebook.buck.apple.XcodePrebuildScriptBuilder)1 HeaderMap (com.facebook.buck.apple.clang.HeaderMap)1 ProjectGeneratorTestUtils.assertTargetExistsAndReturnTarget (com.facebook.buck.apple.project_generator.ProjectGeneratorTestUtils.assertTargetExistsAndReturnTarget)1 CopyFilePhaseDestinationSpec (com.facebook.buck.apple.xcode.xcodeproj.CopyFilePhaseDestinationSpec)1