Allow using tagetContents for modules needing preprocessing
This allows GHC API clients, most notably tooling such as Haskell-IDE-Engine, to pass unsaved files to GHC more easily. Currently when targetContents is used but the module requires preprocessing 'preprocessFile' simply throws an error because the pipeline does not support passing a buffer. This change extends `runPipeline` to allow passing the input buffer into the pipeline. Before proceeding with the actual pipeline loop the input buffer is immediately written out to a new tempfile. I briefly considered refactoring the pipeline at large to pass around in-memory buffers instead of files, but this seems needlessly complicated since no pipeline stages other than Hsc could really support this at the moment.
Showing
- compiler/main/DriverPipeline.hs 35 additions, 12 deletionscompiler/main/DriverPipeline.hs
- compiler/main/GhcMake.hs 3 additions, 25 deletionscompiler/main/GhcMake.hs
- compiler/main/HscTypes.hs 5 additions, 1 deletioncompiler/main/HscTypes.hs
- testsuite/tests/ghc-api/target-contents/TargetContents.hs 150 additions, 0 deletionstestsuite/tests/ghc-api/target-contents/TargetContents.hs
- testsuite/tests/ghc-api/target-contents/TargetContents.stderr 45 additions, 0 deletions...suite/tests/ghc-api/target-contents/TargetContents.stderr
- testsuite/tests/ghc-api/target-contents/all.T 4 additions, 0 deletionstestsuite/tests/ghc-api/target-contents/all.T
Loading
Please register or sign in to comment