use of com.facebook.buck.io.ProjectFilesystem in project buck by facebook.
the class SplitZipStepTest method testNonObfuscatedBuild.
@Test
public void testNonObfuscatedBuild() throws IOException {
Path proguardConfigFile = Paths.get("the/configuration.txt");
Path proguardMappingFile = Paths.get("the/mapping.txt");
ProjectFilesystem projectFilesystem = EasyMock.createMock(ProjectFilesystem.class);
EasyMock.expect(projectFilesystem.readLines(proguardConfigFile)).andReturn(ImmutableList.of("-dontobfuscate"));
EasyMock.replay(projectFilesystem);
SplitZipStep splitZipStep = new SplitZipStep(projectFilesystem, /* inputPathsToSplit */
ImmutableSet.of(), /* secondaryJarMetaPath */
Paths.get(""), /* primaryJarPath */
Paths.get(""), /* secondaryJarDir */
Paths.get(""), /* secondaryJarPattern */
"", /* additionalDexStoreJarMetaPath */
Paths.get(""), /* additionalDexStoreJarDir */
Paths.get(""), /* proguardFullConfigFile */
Optional.of(proguardConfigFile), /* proguardMappingFile */
Optional.of(proguardMappingFile), false, new DexSplitMode(/* shouldSplitDex */
true, ZipSplitter.DexSplitStrategy.MAXIMIZE_PRIMARY_DEX_SIZE, DexStore.JAR, /* linearAllocHardLimit */
4 * 1024 * 1024, /* primaryDexPatterns */
ImmutableSet.of("primary"), /* primaryDexClassesFile */
Optional.empty(), /* primaryDexScenarioFile */
Optional.empty(), /* isPrimaryDexScenarioOverflowAllowed */
false, /* secondaryDexHeadClassesFile */
Optional.empty(), /* secondaryDexTailClassesFile */
Optional.empty()), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), /* additionalDexStoreToJarPathMap */
ImmutableMultimap.of(), new APKModuleGraph(null, null, null), /* pathToReportDir */
Paths.get(""));
ProguardTranslatorFactory translatorFactory = ProguardTranslatorFactory.create(projectFilesystem, Optional.of(proguardConfigFile), Optional.of(proguardMappingFile), false);
Predicate<String> requiredInPrimaryZipPredicate = splitZipStep.createRequiredInPrimaryZipPredicate(translatorFactory, Suppliers.ofInstance(ImmutableList.of()));
assertTrue("Primary class should be in primary.", requiredInPrimaryZipPredicate.apply("primary.class"));
assertFalse("Secondary class should be in secondary.", requiredInPrimaryZipPredicate.apply("secondary.class"));
EasyMock.verify(projectFilesystem);
}
use of com.facebook.buck.io.ProjectFilesystem in project buck by facebook.
the class MergeAndroidResourcesSourcesTest method setUp.
@Before
public void setUp() throws Exception {
filesystem = new ProjectFilesystem(tmp.getRoot().toPath());
context = TestExecutionContext.newInstance();
tmp.newFolder("res_in_1");
tmp.newFolder("res_in_1", "values");
tmp.newFolder("res_in_1", "drawable");
tmp.newFile("res_in_1/drawable/one.png");
tmp.newFolder("res_in_2");
tmp.newFolder("res_in_2", "values");
tmp.newFolder("res_in_2", "drawable");
tmp.newFile("res_in_2/drawable/two.png");
filesystem.writeContentsToPath(RESOURCES_XML_HEADER + "<string name=\"override_me\">one</string>\n" + "<string name=\"only_in_first\">first</string>\n" + RESOURCES_XML_FOOTER, Paths.get("res_in_1/values/strings.xml"));
filesystem.writeContentsToPath(RESOURCES_XML_HEADER + "<string name=\"override_me\">two</string>\n" + "<string name=\"only_in_second\">second</string>\n" + RESOURCES_XML_FOOTER, Paths.get("res_in_2/values/strings.xml"));
filesystem.writeContentsToPath("png, trust me", Paths.get("res_in_1/drawable/one.png"));
filesystem.writeContentsToPath("png, trust me", Paths.get("res_in_2/drawable/two.png"));
}
use of com.facebook.buck.io.ProjectFilesystem in project buck by facebook.
the class ResourceFiltersTest method testCreateDensityFilterIncludesFallbackWhenTargetNotPresent.
@Test
public void testCreateDensityFilterIncludesFallbackWhenTargetNotPresent() throws IOException {
for (String folderName : ResourceFilters.SUPPORTED_RESOURCE_DIRECTORIES) {
if (folderName.equals("drawable")) {
// Drawables are special and we have a different method for them.
continue;
}
ProjectFilesystem filesystem = new FakeProjectFilesystem();
Path include = Paths.get(folderName).resolve("somefile");
filesystem.createNewFile(include);
Path exclude = Paths.get(String.format("%s-ldpi/somefile", folderName));
filesystem.createNewFile(exclude);
Predicate<Path> predicate = ResourceFilters.createDensityFilter(filesystem, ImmutableSet.of(Density.MDPI));
assertThat(predicate.apply(exclude), Matchers.is(false));
assertThat(predicate.apply(include), Matchers.is(true));
}
}
use of com.facebook.buck.io.ProjectFilesystem in project buck by facebook.
the class RobolectricTestRuleTest method runtimeDepsIncludeTransitiveResources.
@Test
public void runtimeDepsIncludeTransitiveResources() throws Exception {
ProjectFilesystem filesystem = new FakeProjectFilesystem(temporaryFolder.getRoot());
BuildTarget genRuleTarget = BuildTargetFactory.newInstance("//:gen");
TargetNode<?, ?> genRuleNode = GenruleBuilder.newGenruleBuilder(genRuleTarget).setOut("out").build();
BuildTarget res2RuleTarget = BuildTargetFactory.newInstance("//:res2");
TargetNode<?, ?> res2Node = AndroidResourceBuilder.createBuilder(res2RuleTarget).setRes(new DefaultBuildTargetSourcePath(genRuleTarget)).setRDotJavaPackage("foo.bar").build();
BuildTarget robolectricBuildTarget = BuildTargetFactory.newInstance("//java/src/com/facebook/base/robolectricTest:robolectricTest");
TargetNode<?, ?> robolectricTestNode = RobolectricTestBuilder.createBuilder(robolectricBuildTarget, filesystem).addDep(res2RuleTarget).build();
TargetGraph targetGraph = TargetGraphFactory.newInstance(genRuleNode, res2Node, robolectricTestNode);
BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
BuildRule genRule = resolver.requireRule(genRuleTarget);
RobolectricTest robolectricTest = (RobolectricTest) resolver.requireRule(robolectricBuildTarget);
assertThat(robolectricTest.getRuntimeDeps().collect(MoreCollectors.toImmutableSet()), Matchers.hasItem(genRule.getBuildTarget()));
}
use of com.facebook.buck.io.ProjectFilesystem in project buck by facebook.
the class CompilationDatabaseIntegrationTest method testCreateCompilationDatabaseForAppleBinaryWithDeps.
@Test
public void testCreateCompilationDatabaseForAppleBinaryWithDeps() throws IOException {
// buck build the #compilation-database.
BuildTarget target = BuildTargetFactory.newInstance("//Apps/Weather:Weather#iphonesimulator-x86_64,compilation-database");
Path compilationDatabase = workspace.buildAndReturnOutput(target.getFullyQualifiedName());
ProjectFilesystem filesystem = new FakeProjectFilesystem();
// Parse the compilation_database.json file.
Map<String, CxxCompilationDatabaseEntry> fileToEntry = CxxCompilationDatabaseUtils.parseCompilationDatabaseJsonFile(compilationDatabase);
ImmutableSet<String> frameworks = ImmutableSet.of(Paths.get("/System/Library/Frameworks/Foundation.framework").getParent().toString(), Paths.get("/System/Library/Frameworks/UIKit.framework").getParent().toString());
String pathToPrivateHeaders = BuildTargets.getGenPath(filesystem, target.withFlavors(InternalFlavor.of("iphonesimulator-x86_64"), CxxDescriptionEnhancer.HEADER_SYMLINK_TREE_FLAVOR), "%s.hmap").toString();
String pathToPublicHeaders = BuildTargets.getGenPath(filesystem, BuildTargetFactory.newInstance("//Libraries/EXExample:EXExample").withAppendedFlavors(CxxDescriptionEnhancer.EXPORTED_HEADER_SYMLINK_TREE_FLAVOR, CxxPlatformUtils.getHeaderModeForDefaultPlatform(tmp.getRoot()).getFlavor()), "%s.hmap").toString();
Iterable<String> includes = ImmutableList.of(pathToPrivateHeaders, pathToPublicHeaders, filesystem.getBuckPaths().getBuckOut().toString());
assertFlags(filesystem, "Apps/Weather/Weather/EXViewController.m", target.withFlavors(InternalFlavor.of("iphonesimulator-x86_64"), InternalFlavor.of("compile-" + sanitize("Weather/EXViewController.m.o"))), Paths.get("Weather/EXViewController.m.o"), /* isLibrary */
false, fileToEntry, frameworks, includes);
assertFlags(filesystem, "Apps/Weather/Weather/main.m", target.withFlavors(InternalFlavor.of("iphonesimulator-x86_64"), InternalFlavor.of("compile-" + sanitize("Weather/main.m.o"))), Paths.get("Weather/main.m.o"), /* isLibrary */
false, fileToEntry, frameworks, includes);
}
Aggregations