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());
}
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);
}
}
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="));
}
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));
}
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));
}
Aggregations