ghc-stdin 0.1.1.1 → 0.2.0.0
raw patch · 4 files changed
+14/−13 lines, 4 filesdep +safePVP ok
version bump matches the API change (PVP)
Dependencies added: safe
API changes (from Hackage documentation)
Files
- Changelog.md +4/−0
- GhcStdin.hs +6/−8
- README.md +1/−3
- ghc-stdin.cabal +3/−2
Changelog.md view
@@ -1,3 +1,7 @@+### 0.2.0.0++- Using function *shell* to properly pass the plugin's options.+ ### 0.1.1.0 - Using bytestrings when reading from stdin and writing to the temporary file.
GhcStdin.hs view
@@ -27,6 +27,7 @@ import System.IO.Temp import System.Process import System.Exit+import Safe -- | Frontend plugin for GHC to compile source code from the standard input. --@@ -66,9 +67,7 @@ -- Internally, the plugin creates a temporary directory with a temporary source -- file inside it with the contents read from the standard input. Then it spawns -- another GHC process to compile this file with the options passed in--- /-ffrontend-opt/. Note that the options get collected by 'words' without--- passing them to a shell preprocessor which means that it is not possible to--- escape spaces in their values with quotes or backslashes.+-- /-ffrontend-opt/. frontendPlugin :: FrontendPlugin frontendPlugin = defaultFrontendPlugin { frontend = compileCodeFromStdin } @@ -78,11 +77,10 @@ withTempFile dir "ghc-stdin.hs" $ \src hsrc -> do contents <- B.getContents B.hPutStr hsrc contents >> hFlush hsrc- -- FIXME: wordsOfHead won't hide spaces inside quotes correctly,- -- but using spaces does not seem to be an often case in GHC options- (_, _, _, h) <- createProcess $ proc ghc $ src : wordsOfHead flags+ (_, _, _, h) <- createProcess $+ shell $ q ghc ++ spc (q src) ++ spc (headDef "" flags) r <- waitForProcess h unless (r == ExitSuccess) $ exitWith r- where wordsOfHead [] = []- wordsOfHead (x : _) = words x+ where q s = let q' = '\'' in q' : s ++ pure q'+ spc = (' ' :)
README.md view
@@ -40,7 +40,5 @@ Internally, the plugin creates a temporary directory with a temporary source file inside it with the contents read from the standard input. Then it spawns another GHC process to compile this file with the options passed in-*-ffrontend-opt*. Note that the options get collected by *words* without-passing them to a shell preprocessor which means that it is not possible to-escape spaces in their values with quotes or backslashes.+*-ffrontend-opt*.
ghc-stdin.cabal view
@@ -1,5 +1,5 @@ name: ghc-stdin-version: 0.1.1.1+version: 0.2.0.0 synopsis: Compile source code from the standard input description: A frontend plugin for GHC to compile source code from the standard input.@@ -27,7 +27,8 @@ ghc-paths, bytestring, temporary,- process+ process,+ safe exposed-modules: GhcStdin