Search in sources :

Example 6 with ProjectFilesystem

use of com.facebook.buck.io.ProjectFilesystem in project buck by facebook.

the class CsharpLibrary method getBuildSteps.

@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
    ProjectFilesystem filesystem = getProjectFilesystem();
    ImmutableSortedSet<Path> sourceFiles = context.getSourcePathResolver().getAllAbsolutePaths(srcs);
    ImmutableListMultimap.Builder<Path, String> resolvedResources = ImmutableListMultimap.builder();
    for (Map.Entry<String, SourcePath> resource : resources.entrySet()) {
        resolvedResources.put(context.getSourcePathResolver().getAbsolutePath(resource.getValue()), resource.getKey());
    }
    ImmutableList<Either<Path, String>> references = resolveReferences(context.getSourcePathResolver(), refs);
    ImmutableList.Builder<Step> steps = ImmutableList.builder();
    steps.add(new MakeCleanDirectoryStep(filesystem, output.getParent()));
    steps.add(new CsharpLibraryCompile(filesystem.resolve(output), sourceFiles, references, resolvedResources.build(), version));
    return steps.build();
}
Also used : ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath) SourcePath(com.facebook.buck.rules.SourcePath) Path(java.nio.file.Path) ImmutableList(com.google.common.collect.ImmutableList) Step(com.facebook.buck.step.Step) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath) SourcePath(com.facebook.buck.rules.SourcePath) ImmutableListMultimap(com.google.common.collect.ImmutableListMultimap) Either(com.facebook.buck.model.Either) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map)

Example 7 with ProjectFilesystem

use of com.facebook.buck.io.ProjectFilesystem in project buck by facebook.

the class WriteFile method getBuildSteps.

@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
    buildableContext.recordArtifact(output);
    ProjectFilesystem projectFilesystem = getProjectFilesystem();
    return ImmutableList.of(new MkdirStep(projectFilesystem, output.getParent()), new WriteFileStep(projectFilesystem, ByteSource.wrap(fileContents), output, executable));
}
Also used : MkdirStep(com.facebook.buck.step.fs.MkdirStep) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) WriteFileStep(com.facebook.buck.step.fs.WriteFileStep)

Example 8 with ProjectFilesystem

use of com.facebook.buck.io.ProjectFilesystem in project buck by facebook.

the class JsonConcatenate method getBuildSteps.

@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
    buildableContext.recordArtifact(output);
    ProjectFilesystem projectFilesystem = getProjectFilesystem();
    return ImmutableList.<Step>builder().add(new MkdirStep(projectFilesystem, outputDirectory)).add(new JsonConcatenateStep(projectFilesystem, inputs, output, stepShortName, stepDescription)).build();
}
Also used : MkdirStep(com.facebook.buck.step.fs.MkdirStep) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem)

Example 9 with ProjectFilesystem

use of com.facebook.buck.io.ProjectFilesystem in project buck by facebook.

the class MiniAapt method verifyReferences.

@VisibleForTesting
ImmutableSet<RDotTxtEntry> verifyReferences(ProjectFilesystem filesystem, ImmutableSet<RDotTxtEntry> references) throws IOException {
    ImmutableSet.Builder<RDotTxtEntry> unresolved = ImmutableSet.builder();
    ImmutableSet.Builder<RDotTxtEntry> definitionsBuilder = ImmutableSet.builder();
    definitionsBuilder.addAll(resourceCollector.getResources());
    for (Path depRTxt : pathsToSymbolsOfDeps) {
        Iterable<String> lines = FluentIterable.from(filesystem.readLines(depRTxt)).filter(input -> !Strings.isNullOrEmpty(input)).toList();
        for (String line : lines) {
            Optional<RDotTxtEntry> entry = RDotTxtEntry.parse(line);
            Preconditions.checkState(entry.isPresent());
            definitionsBuilder.add(entry.get());
        }
    }
    Set<RDotTxtEntry> definitions = definitionsBuilder.build();
    for (RDotTxtEntry reference : references) {
        if (!definitions.contains(reference)) {
            unresolved.add(reference);
        }
    }
    return unresolved.build();
}
Also used : SourcePath(com.facebook.buck.rules.SourcePath) Path(java.nio.file.Path) BuckEventBus(com.facebook.buck.event.BuckEventBus) XPathExpressionException(javax.xml.xpath.XPathExpressionException) Step(com.facebook.buck.step.Step) XPathConstants(javax.xml.xpath.XPathConstants) SourcePath(com.facebook.buck.rules.SourcePath) XmlDomParser(com.facebook.buck.util.XmlDomParser) IdType(com.facebook.buck.android.aapt.RDotTxtEntry.IdType) XPathExpression(javax.xml.xpath.XPathExpression) ConsoleEvent(com.facebook.buck.event.ConsoleEvent) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) ExecutionContext(com.facebook.buck.step.ExecutionContext) Strings(com.google.common.base.Strings) ImmutableList(com.google.common.collect.ImmutableList) FluentIterable(com.google.common.collect.FluentIterable) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) Document(org.w3c.dom.Document) Node(org.w3c.dom.Node) Path(java.nio.file.Path) ImmutableSortedSet(com.google.common.collect.ImmutableSortedSet) PrintWriter(java.io.PrintWriter) ImmutableSet(com.google.common.collect.ImmutableSet) NodeList(org.w3c.dom.NodeList) ImmutableMap(com.google.common.collect.ImmutableMap) Collection(java.util.Collection) Set(java.util.Set) IOException(java.io.IOException) XPathFactory(javax.xml.xpath.XPathFactory) Element(org.w3c.dom.Element) Ordering(com.google.common.collect.Ordering) SAXException(org.xml.sax.SAXException) Optional(java.util.Optional) Preconditions(com.google.common.base.Preconditions) VisibleForTesting(com.google.common.annotations.VisibleForTesting) AaptStep(com.facebook.buck.android.AaptStep) StepExecutionResult(com.facebook.buck.step.StepExecutionResult) RType(com.facebook.buck.android.aapt.RDotTxtEntry.RType) Joiner(com.google.common.base.Joiner) InputStream(java.io.InputStream) ImmutableSet(com.google.common.collect.ImmutableSet) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 10 with ProjectFilesystem

use of com.facebook.buck.io.ProjectFilesystem in project buck by facebook.

the class DoctorCommand method runWithoutHelp.

@Override
public int runWithoutHelp(CommandRunnerParams params) throws IOException, InterruptedException {
    ProjectFilesystem filesystem = params.getCell().getFilesystem();
    BuildLogHelper buildLogHelper = new BuildLogHelper(filesystem, params.getObjectMapper());
    UserInput userInput = new UserInput(params.getConsole().getStdOut(), new BufferedReader(new InputStreamReader(params.getStdIn())));
    DoctorReportHelper helper = new DoctorReportHelper(params.getCell().getFilesystem(), userInput, params.getConsole(), params.getObjectMapper(), params.getBuckConfig().getView(DoctorConfig.class));
    Optional<BuildLogEntry> entry = helper.promptForBuild(new ArrayList<>(buildLogHelper.getBuildLogs()));
    if (!entry.isPresent()) {
        params.getConsole().getStdOut().println("No interesting commands found in buck-out/log.");
        return 0;
    }
    Optional<DefectSubmitResult> rageResult = generateRageReport(params, userInput, entry.get());
    if (!rageResult.isPresent()) {
        params.getConsole().printErrorText("Failed to generate report to send.");
        return 1;
    }
    DoctorEndpointRequest request = helper.generateEndpointRequest(entry.get(), rageResult.get());
    DoctorEndpointResponse response = helper.uploadRequest(request);
    helper.presentResponse(response);
    helper.presentRageResult(rageResult);
    return 0;
}
Also used : InputStreamReader(java.io.InputStreamReader) DoctorEndpointRequest(com.facebook.buck.doctor.config.DoctorEndpointRequest) DoctorReportHelper(com.facebook.buck.doctor.DoctorReportHelper) BuildLogHelper(com.facebook.buck.rage.BuildLogHelper) UserInput(com.facebook.buck.rage.UserInput) DoctorConfig(com.facebook.buck.doctor.config.DoctorConfig) BuildLogEntry(com.facebook.buck.rage.BuildLogEntry) DefectSubmitResult(com.facebook.buck.rage.DefectSubmitResult) BufferedReader(java.io.BufferedReader) DoctorEndpointResponse(com.facebook.buck.doctor.config.DoctorEndpointResponse) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem)

Aggregations

ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)654 Test (org.junit.Test)542 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)401 Path (java.nio.file.Path)324 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)207 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)204 BuildTarget (com.facebook.buck.model.BuildTarget)203 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)126 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)121 TargetGraph (com.facebook.buck.rules.TargetGraph)119 PathSourcePath (com.facebook.buck.rules.PathSourcePath)96 FakeSourcePath (com.facebook.buck.rules.FakeSourcePath)92 ProjectWorkspace (com.facebook.buck.testutil.integration.ProjectWorkspace)90 SourcePath (com.facebook.buck.rules.SourcePath)79 ExecutionContext (com.facebook.buck.step.ExecutionContext)67 AllExistingProjectFilesystem (com.facebook.buck.testutil.AllExistingProjectFilesystem)67 TestExecutionContext (com.facebook.buck.step.TestExecutionContext)63 BuildRule (com.facebook.buck.rules.BuildRule)56 RuleKey (com.facebook.buck.rules.RuleKey)43 ArchiveMemberPath (com.facebook.buck.io.ArchiveMemberPath)42