[add --annotate-source option to spit out annotated, preprocessed source code for use by other tools
John Meacham <john@repetae.net>**20090825030331
 Ignore-this: ca1455f77508744f6f0d90c01c6113dc
] hunk ./src/Ho/Build.hs 174
-            hmod <- parseHsSource fn lbs
+            (hmod,_) <- parseHsSource fn lbs
hunk ./src/Ho/Build.hs 178
-            return (Right hmod,m,ds)
+            case optAnnotate options of
+                Just _ -> return (Left lbs,m,ds)
+                _ -> return (Right hmod,m,ds)
hunk ./src/Ho/Build.hs 227
-    | CompProcessed [SourceCode]
hunk ./src/Ho/Build.hs 244
-    | SourceProcessed  { sourceInfo :: !SourceInfo, sourceLBS :: LBS.ByteString }
hunk ./src/Ho/Build.hs 394
+    if isJust (optAnnotate options) then exitSuccess else do
hunk ./src/Ho/Build.hs 529
+                        let mods = sort $ map (sourceModName . sourceInfo) sc
hunk ./src/Ho/Build.hs 531
-                            SourceParsed { sourceInfo = SI { .. }, .. } -> return (sourceHash,sourceModule)
+                            SourceParsed { sourceInfo = SI { .. }, .. } -> return (sourceHash,sourceModule, error "SourceParsed in AnnotateSource")
hunk ./src/Ho/Build.hs 533
-                                mod <- parseHsSource sourceFP sourceLBS
-                                return (sourceHash,mod)
-                        showProgress (snds modules)
-                        (htc,tidata) <- doModules' ctc (snds modules)
+                                (mod,lbs') <- parseHsSource sourceFP sourceLBS
+                                case optAnnotate options of
+                                    Just fp -> do
+                                        let ann = LBSU.fromString $ unlines [
+                                                "{- --ANNOTATE--", 
+                                                "Module: " ++ show sourceModName, 
+                                                "Deps: " ++ show (sort sourceDeps), 
+                                                "Siblings: " ++ show mods,
+                                                "-}"]
+                                        LBS.writeFile (fp ++ "/" ++ show (hsModuleName mod) ++ ".hs") (ann `LBS.append` lbs')
+                                    _ -> return ()
+                                return (sourceHash,mod,lbs')
+                        showProgress (map snd3 modules)
+                        (htc,tidata) <- doModules' ctc (map snd3 modules)
hunk ./src/Ho/Build.hs 548
-                        writeIORef ref (CompTcCollected ctc' (CompTCed ((htc,tidata,modules,map (sourceHoName . sourceInfo) sc))))
+                        writeIORef ref (CompTcCollected ctc' (CompTCed ((htc,tidata,[ (x,y) | (x,y,_) <- modules],map (sourceHoName . sourceInfo) sc))))
hunk ./src/Ho/Build.hs 672
-parseHsSource :: String -> LBS.ByteString -> IO HsModule
+parseHsSource :: String -> LBS.ByteString -> IO (HsModule,LBS.ByteString)
hunk ./src/Ho/Build.hs 686
-                      ParseOk ws e -> processErrors ws >> return e
+                      ParseOk ws e -> processErrors ws >> return (e,LBSU.fromString s')
hunk ./src/Options.hs 135
-data Mode = BuildHl String  -- ^ Build the specified hl-file given a description file.
-          | Interactive     -- ^ Run interactively.
-          | Version         -- ^ Print version and die.
-          | VersionCtx      -- ^ Print version context and die.
-          | ShowHelp        -- ^ Show help message and die.
-          | ShowConfig      -- ^ Show configuration info.
-          | CompileHo       -- ^ Compile ho
-          | CompileHoGrin   -- ^ Compile ho and grin
-          | CompileExe      -- ^ Compile executable
-          | ShowHo String   -- ^ Show ho-file.
-          | ListLibraries   -- ^ List libraries
-          | PrintHscOptions -- ^ Print options for hsc2hs
-          | Preprocess      -- ^ Filter through preprocessor
+data Mode = BuildHl FilePath         -- ^ Build the specified hl-file given a description file.
+          | Interactive              -- ^ Run interactively.
+          | Version                  -- ^ Print version and die.
+          | VersionCtx               -- ^ Print version context and die.
+          | ShowHelp                 -- ^ Show help message and die.
+          | ShowConfig               -- ^ Show configuration info.
+          | CompileHo                -- ^ Compile ho
+          | CompileHoGrin            -- ^ Compile ho and grin
+          | CompileExe               -- ^ Compile executable
+          | ShowHo String            -- ^ Show ho-file.
+          | ListLibraries            -- ^ List libraries
+          | PrintHscOptions          -- ^ Print options for hsc2hs
+          | Preprocess               -- ^ Filter through preprocessor
hunk ./src/Options.hs 164
+    optAnnotate    ::  Maybe FilePath,
hunk ./src/Options.hs 192
+    optAnnotate    = Nothing,
hunk ./src/Options.hs 253
+    , Option []    ["annotate-source"]  (ReqArg (optAnnotate_s . Just) "<dir>") "Write preprocessed and annotated source code to the directory specified"