use of com.facebook.buck.rules.PathSourcePath in project buck by facebook.
the class ProjectGeneratorTest method testResolvingExportFile.
@Test
public void testResolvingExportFile() throws IOException {
BuildTarget source1Target = BuildTarget.builder(rootPath, "//Vendor", "source1").build();
BuildTarget source2Target = BuildTarget.builder(rootPath, "//Vendor", "source2").build();
BuildTarget source2RefTarget = BuildTarget.builder(rootPath, "//Vendor", "source2ref").build();
BuildTarget source3Target = BuildTarget.builder(rootPath, "//Vendor", "source3").build();
BuildTarget headerTarget = BuildTarget.builder(rootPath, "//Vendor", "header").build();
BuildTarget libTarget = BuildTarget.builder(rootPath, "//Libraries", "foo").build();
TargetNode<ExportFileDescription.Arg, ?> source1 = ExportFileBuilder.newExportFileBuilder(source1Target).setSrc(new PathSourcePath(projectFilesystem, Paths.get("Vendor/sources/source1"))).build();
TargetNode<ExportFileDescription.Arg, ?> source2 = ExportFileBuilder.newExportFileBuilder(source2Target).setSrc(new PathSourcePath(projectFilesystem, Paths.get("Vendor/source2"))).build();
TargetNode<ExportFileDescription.Arg, ?> source2Ref = ExportFileBuilder.newExportFileBuilder(source2RefTarget).setSrc(new DefaultBuildTargetSourcePath(source2Target)).build();
TargetNode<ExportFileDescription.Arg, ?> source3 = ExportFileBuilder.newExportFileBuilder(source3Target).build();
TargetNode<ExportFileDescription.Arg, ?> header = ExportFileBuilder.newExportFileBuilder(headerTarget).build();
TargetNode<AppleLibraryDescription.Arg, ?> library = AppleLibraryBuilder.createBuilder(libTarget).setConfigs(ImmutableSortedMap.of("Debug", ImmutableMap.of())).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new DefaultBuildTargetSourcePath(source1Target)), SourceWithFlags.of(new DefaultBuildTargetSourcePath(source2RefTarget)), SourceWithFlags.of(new DefaultBuildTargetSourcePath(source3Target)))).setPrefixHeader(Optional.of(new DefaultBuildTargetSourcePath(headerTarget))).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(source1, source2, source2Ref, source3, header, library));
projectGenerator.createXcodeProjects();
PBXTarget target = assertTargetExistsAndReturnTarget(projectGenerator.getGeneratedProject(), libTarget.toString());
assertHasSingletonSourcesPhaseWithSourcesAndFlags(target, ImmutableMap.of("Vendor/sources/source1", Optional.empty(), "Vendor/source2", Optional.empty(), "Vendor/source3", Optional.empty()));
ImmutableMap<String, String> settings = getBuildSettings(libTarget, target, "Debug");
assertEquals("../Vendor/header", settings.get("GCC_PREFIX_HEADER"));
}
use of com.facebook.buck.rules.PathSourcePath in project buck by facebook.
the class NewNativeTargetProjectMutatorTest method testScriptBuildPhaseWithReactNative.
@Test
public void testScriptBuildPhaseWithReactNative() throws NoSuchBuildTargetException {
NewNativeTargetProjectMutator mutator = mutatorWithCommonDefaults();
BuildTarget depBuildTarget = BuildTargetFactory.newInstance("//foo:dep");
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<?, ?> reactNativeNode = IosReactNativeLibraryBuilder.builder(depBuildTarget, buckConfig).setBundleName("Apps/Foo/FooBundle.js").setEntryPath(new PathSourcePath(filesystem, Paths.get("js/FooApp.js"))).build();
mutator.setPostBuildRunScriptPhasesFromTargetNodes(ImmutableList.of(reactNativeNode));
NewNativeTargetProjectMutator.Result result = mutator.buildTargetAndAddToProject(generatedProject, true);
PBXShellScriptBuildPhase phase = getSingletonPhaseByType(result.target, PBXShellScriptBuildPhase.class);
String shellScript = phase.getShellScript();
assertThat(shellScript, startsWith("BASE_DIR=${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}\n" + "JS_OUT=${BASE_DIR}/Apps/Foo/FooBundle.js\n" + "SOURCE_MAP=${TEMP_DIR}/rn_source_map/Apps/Foo/FooBundle.js.map\n"));
}
use of com.facebook.buck.rules.PathSourcePath in project buck by facebook.
the class CxxCollectAndLogInferDependenciesStepTest method createCaptureRule.
private CxxInferCapture createCaptureRule(BuildRuleParams buildRuleParams, SourcePathResolver sourcePathResolver, ProjectFilesystem filesystem, InferBuckConfig inferBuckConfig) throws Exception {
RuleKeyAppendableFunction<FrameworkPath, Path> defaultFrameworkPathSearchPathFunction = new RuleKeyAppendableFunction<FrameworkPath, Path>() {
@Override
public void appendToRuleKey(RuleKeyObjectSink sink) {
// Do nothing.
}
@Override
public Path apply(FrameworkPath input) {
return Paths.get("test", "framework", "path", input.toString());
}
};
SourcePath preprocessor = new PathSourcePath(filesystem, Paths.get("preprocessor"));
Tool preprocessorTool = new CommandTool.Builder().addInput(preprocessor).build();
PreprocessorDelegate preprocessorDelegate = new PreprocessorDelegate(sourcePathResolver, CxxPlatformUtils.DEFAULT_COMPILER_DEBUG_PATH_SANITIZER, CxxPlatformUtils.DEFAULT_PLATFORM.getHeaderVerification(), Paths.get("whatever"), new GccPreprocessor(preprocessorTool), PreprocessorFlags.builder().build(), defaultFrameworkPathSearchPathFunction, Optional.empty(), /* leadingIncludePaths */
Optional.empty());
return new CxxInferCapture(buildRuleParams, CxxToolFlags.of(), CxxToolFlags.of(), new FakeSourcePath("src.c"), AbstractCxxSource.Type.C, Paths.get("src.o"), preprocessorDelegate, inferBuckConfig, CxxPlatformUtils.DEFAULT_COMPILER_DEBUG_PATH_SANITIZER);
}
use of com.facebook.buck.rules.PathSourcePath in project buck by facebook.
the class CxxBinaryDescriptionTest method staticPicLinkStyle.
@Test
public void staticPicLinkStyle() throws Exception {
BuildTarget target = BuildTargetFactory.newInstance("//foo:bar");
BuildRuleResolver resolver = new BuildRuleResolver(prepopulateWithSandbox(target), new DefaultTargetNodeToBuildRuleTransformer());
ProjectFilesystem filesystem = new FakeProjectFilesystem();
new CxxBinaryBuilder(target, cxxBuckConfig).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new PathSourcePath(filesystem, Paths.get("test.cpp"))))).build(resolver, filesystem);
}
use of com.facebook.buck.rules.PathSourcePath in project buck by facebook.
the class CxxPreprocessAndCompileTest method compilerAndPreprocessorAreAlwaysReturnedFromGetInputsAfterBuildingLocally.
@Test
public void compilerAndPreprocessorAreAlwaysReturnedFromGetInputsAfterBuildingLocally() throws Exception {
ProjectFilesystem filesystem = FakeProjectFilesystem.createJavaOnlyFilesystem();
SourcePath preprocessor = new PathSourcePath(filesystem, Paths.get("preprocessor"));
Tool preprocessorTool = new CommandTool.Builder().addInput(preprocessor).build();
SourcePath compiler = new PathSourcePath(filesystem, Paths.get("compiler"));
Tool compilerTool = new CommandTool.Builder().addInput(compiler).build();
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
BuildTarget target = BuildTargetFactory.newInstance("//foo:bar");
BuildRuleParams params = new FakeBuildRuleParamsBuilder(target).setProjectFilesystem(filesystem).build();
BuildContext context = FakeBuildContext.withSourcePathResolver(pathResolver);
filesystem.writeContentsToPath("test.o: " + pathResolver.getRelativePath(DEFAULT_INPUT) + " ", filesystem.getPath("test.o.dep"));
CxxPreprocessAndCompile cxxPreprocess = CxxPreprocessAndCompile.preprocessAndCompile(params, new PreprocessorDelegate(pathResolver, CxxPlatformUtils.DEFAULT_COMPILER_DEBUG_PATH_SANITIZER, CxxPlatformUtils.DEFAULT_PLATFORM.getHeaderVerification(), DEFAULT_WORKING_DIR, new GccPreprocessor(preprocessorTool), PreprocessorFlags.builder().build(), DEFAULT_FRAMEWORK_PATH_SEARCH_PATH_FUNCTION, Optional.empty(), /* leadingIncludePaths */
Optional.empty()), new CompilerDelegate(pathResolver, CxxPlatformUtils.DEFAULT_COMPILER_DEBUG_PATH_SANITIZER, DEFAULT_COMPILER, CxxToolFlags.of()), DEFAULT_OUTPUT, DEFAULT_INPUT, DEFAULT_INPUT_TYPE, Optional.empty(), CxxPlatformUtils.DEFAULT_COMPILER_DEBUG_PATH_SANITIZER, CxxPlatformUtils.DEFAULT_ASSEMBLER_DEBUG_PATH_SANITIZER, Optional.empty());
assertThat(cxxPreprocess.getInputsAfterBuildingLocally(context), hasItem(preprocessor));
CxxPreprocessAndCompile cxxCompile = CxxPreprocessAndCompile.compile(params, new CompilerDelegate(pathResolver, CxxPlatformUtils.DEFAULT_COMPILER_DEBUG_PATH_SANITIZER, new GccCompiler(compilerTool), CxxToolFlags.of()), DEFAULT_OUTPUT, DEFAULT_INPUT, DEFAULT_INPUT_TYPE, CxxPlatformUtils.DEFAULT_COMPILER_DEBUG_PATH_SANITIZER, CxxPlatformUtils.DEFAULT_ASSEMBLER_DEBUG_PATH_SANITIZER, Optional.empty());
assertThat(cxxCompile.getInputsAfterBuildingLocally(context), hasItem(compiler));
}
Aggregations