Search in sources :

Example 56 with PathSourcePath

use of com.facebook.buck.rules.PathSourcePath in project buck by facebook.

the class PrebuiltJarSymbolsFinder method extractSymbols.

@Override
public Symbols extractSymbols() throws IOException {
    if (!(binaryJar instanceof PathSourcePath)) {
        return Symbols.EMPTY;
    }
    PathSourcePath sourcePath = (PathSourcePath) binaryJar;
    ProjectFilesystem filesystem = sourcePath.getFilesystem();
    Path absolutePath = filesystem.resolve(sourcePath.getRelativePath());
    final Set<String> providedSymbols = new HashSet<>();
    new ZipFileTraversal(absolutePath) {

        @Override
        public void visit(ZipFile zipFile, ZipEntry zipEntry) throws IOException {
            String name = zipEntry.getName();
            if (!name.endsWith(CLASS_SUFFIX) || name.contains("$")) {
                return;
            }
            String fullyQualifiedName = name.substring(0, name.length() - CLASS_SUFFIX.length()).replace('/', '.');
            providedSymbols.add(fullyQualifiedName);
        }
    }.traverse();
    return new Symbols(providedSymbols, ImmutableList.of(), ImmutableList.of());
}
Also used : PathSourcePath(com.facebook.buck.rules.PathSourcePath) SourcePath(com.facebook.buck.rules.SourcePath) Path(java.nio.file.Path) ZipFile(java.util.zip.ZipFile) ZipEntry(java.util.zip.ZipEntry) PathSourcePath(com.facebook.buck.rules.PathSourcePath) ZipFileTraversal(com.facebook.buck.util.ZipFileTraversal) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) IOException(java.io.IOException) HashSet(java.util.HashSet)

Example 57 with PathSourcePath

use of com.facebook.buck.rules.PathSourcePath in project buck by facebook.

the class PrebuiltJarSymbolsFinder method appendToRuleKey.

@Override
public void appendToRuleKey(RuleKeyObjectSink sink) {
    if (binaryJar instanceof PathSourcePath) {
        PathSourcePath sourcePath = (PathSourcePath) binaryJar;
        sink.setReflectively("binaryJar", sourcePath);
    }
}
Also used : PathSourcePath(com.facebook.buck.rules.PathSourcePath)

Example 58 with PathSourcePath

use of com.facebook.buck.rules.PathSourcePath in project buck by facebook.

the class ProjectGeneratorTest method testAppleBundleRuleWithRNLibraryDependency.

@Test
public void testAppleBundleRuleWithRNLibraryDependency() throws IOException {
    BuildTarget rnLibraryTarget = BuildTarget.builder(rootPath, "//foo", "rn_library").addFlavors(DEFAULT_FLAVOR).build();
    ProjectFilesystem filesystem = new AllExistingProjectFilesystem();
    ReactNativeBuckConfig buckConfig = new ReactNativeBuckConfig(FakeBuckConfig.builder().setSections(ImmutableMap.of("react-native", ImmutableMap.of("packager_worker", "react-native/packager.sh"))).setFilesystem(filesystem).build());
    TargetNode<?, ?> rnLibraryNode = IosReactNativeLibraryBuilder.builder(rnLibraryTarget, buckConfig).setBundleName("Apps/Foo/FooBundle.js").setEntryPath(new PathSourcePath(filesystem, Paths.get("js/FooApp.js"))).build();
    BuildTarget sharedLibraryTarget = BuildTarget.builder(rootPath, "//dep", "shared").addFlavors(CxxDescriptionEnhancer.SHARED_FLAVOR).build();
    TargetNode<?, ?> sharedLibraryNode = AppleLibraryBuilder.createBuilder(sharedLibraryTarget).build();
    BuildTarget bundleTarget = BuildTarget.builder(rootPath, "//foo", "bundle").build();
    TargetNode<?, ?> bundleNode = AppleBundleBuilder.createBuilder(bundleTarget).setExtension(Either.ofLeft(AppleBundleExtension.BUNDLE)).setInfoPlist(new FakeSourcePath("Info.plist")).setBinary(sharedLibraryTarget).setDeps(ImmutableSortedSet.of(rnLibraryTarget)).build();
    ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(rnLibraryNode, sharedLibraryNode, bundleNode));
    projectGenerator.createXcodeProjects();
    PBXProject project = projectGenerator.getGeneratedProject();
    PBXTarget target = assertTargetExistsAndReturnTarget(project, "//foo:bundle");
    assertThat(target.getName(), equalTo("//foo:bundle"));
    assertThat(target.isa(), equalTo("PBXNativeTarget"));
    PBXShellScriptBuildPhase shellScriptBuildPhase = ProjectGeneratorTestUtils.getSingletonPhaseByType(target, PBXShellScriptBuildPhase.class);
    assertThat(shellScriptBuildPhase.getShellScript(), startsWith("BASE_DIR="));
}
Also used : FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) PBXTarget(com.facebook.buck.apple.xcode.xcodeproj.PBXTarget) ReactNativeBuckConfig(com.facebook.buck.js.ReactNativeBuckConfig) PBXShellScriptBuildPhase(com.facebook.buck.apple.xcode.xcodeproj.PBXShellScriptBuildPhase) BuildTarget(com.facebook.buck.model.BuildTarget) PathSourcePath(com.facebook.buck.rules.PathSourcePath) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) AllExistingProjectFilesystem(com.facebook.buck.testutil.AllExistingProjectFilesystem) PBXProject(com.facebook.buck.apple.xcode.xcodeproj.PBXProject) AllExistingProjectFilesystem(com.facebook.buck.testutil.AllExistingProjectFilesystem) Test(org.junit.Test)

Example 59 with PathSourcePath

use of com.facebook.buck.rules.PathSourcePath in project buck by facebook.

the class PrebuiltCxxLibraryDescriptionTest method addsLibsToAndroidPackageableCollector.

@Test
public void addsLibsToAndroidPackageableCollector() throws Exception {
    BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
    ProjectFilesystem filesystem = new AllExistingProjectFilesystem();
    PrebuiltCxxLibraryBuilder libBuilder = new PrebuiltCxxLibraryBuilder(TARGET);
    TargetGraph targetGraph = TargetGraphFactory.newInstance(libBuilder.build());
    PrebuiltCxxLibrary lib = (PrebuiltCxxLibrary) libBuilder.build(resolver, filesystem, targetGraph);
    PrebuiltCxxLibraryDescription.Arg arg = libBuilder.build().getConstructorArg();
    assertEquals(ImmutableMap.<String, SourcePath>of(getSharedLibrarySoname(arg), new PathSourcePath(filesystem, getSharedLibraryPath(arg))), lib.getSharedLibraries(CXX_PLATFORM));
}
Also used : PathSourcePath(com.facebook.buck.rules.PathSourcePath) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) AllExistingProjectFilesystem(com.facebook.buck.testutil.AllExistingProjectFilesystem) TargetGraph(com.facebook.buck.rules.TargetGraph) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) AllExistingProjectFilesystem(com.facebook.buck.testutil.AllExistingProjectFilesystem) Test(org.junit.Test)

Example 60 with PathSourcePath

use of com.facebook.buck.rules.PathSourcePath in project buck by facebook.

the class HeaderPathNormalizerTest method managedHeader.

@Test
public void managedHeader() {
    SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
    Path header = filesystem.getPath("foo/bar.h");
    SourcePath headerPath = new PathSourcePath(filesystem, header);
    HeaderPathNormalizer normalizer = new HeaderPathNormalizer.Builder(pathResolver).addHeader(headerPath).build();
    assertThat(normalizer.getAbsolutePathForUnnormalizedPath(pathResolver.getAbsolutePath(headerPath)), Matchers.equalTo(Optional.of(pathResolver.getAbsolutePath(headerPath))));
    assertThat(normalizer.getSourcePathForAbsolutePath(pathResolver.getAbsolutePath(headerPath)), Matchers.equalTo(headerPath));
}
Also used : SourcePath(com.facebook.buck.rules.SourcePath) PathSourcePath(com.facebook.buck.rules.PathSourcePath) Path(java.nio.file.Path) SourcePath(com.facebook.buck.rules.SourcePath) PathSourcePath(com.facebook.buck.rules.PathSourcePath) PathSourcePath(com.facebook.buck.rules.PathSourcePath) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) Test(org.junit.Test)

Aggregations

PathSourcePath (com.facebook.buck.rules.PathSourcePath)114 Test (org.junit.Test)82 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)69 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)68 SourcePath (com.facebook.buck.rules.SourcePath)65 Path (java.nio.file.Path)63 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)60 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)58 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)56 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)52 BuildTarget (com.facebook.buck.model.BuildTarget)51 TargetGraph (com.facebook.buck.rules.TargetGraph)37 BuildRule (com.facebook.buck.rules.BuildRule)26 FakeSourcePath (com.facebook.buck.rules.FakeSourcePath)23 DefaultBuildTargetSourcePath (com.facebook.buck.rules.DefaultBuildTargetSourcePath)21 StackedFileHashCache (com.facebook.buck.util.cache.StackedFileHashCache)16 RuleKey (com.facebook.buck.rules.RuleKey)15 DefaultFileHashCache (com.facebook.buck.util.cache.DefaultFileHashCache)15 BuildRuleParams (com.facebook.buck.rules.BuildRuleParams)14 ImmutableList (com.google.common.collect.ImmutableList)14