readDescFile :: FilePath -> IO LibDesc
readDescFile fp = do
    wdump FD.Progress $ putErrLn $ "Reading: " ++ show fp
    let doYaml opt = do
            lbs <- LBS.readFile fp
            dt <- preprocess opt fp lbs
            desc <- iocatch (parseYamlBytes $ BS.concat (LBS.toChunks dt))
                (\e -> putErrDie $ "Error parsing desc file '" ++ fp ++ "'\n" ++ show e)
            when verbose2 $ do
                yaml <- emitYaml desc
                putStrLn yaml
            return $ procYaml desc
        doCabal = do
            fc <- readFile fp
            case parseLibraryDescription fc of
                Left err -> fail $ "Error reading library description file: " ++ show fp ++ " " ++ err
                Right ps -> return $ procCabal ps
    case FP.splitExtension fp of
        (_,".cabal") -> doCabal
        (_,".yaml") -> doYaml options
        (FP.takeExtension -> ".yaml",".m4") -> doYaml options { optFOptsSet = FO.M4 `Set.insert` optFOptsSet options }
        _ -> putErrDie $ "Do not recoginize description file type: " ++ fp
readDescFile :: FilePath -> IO LibDesc
readDescFile fp = do
    wdump FD.Progress $ putErrLn $ "Reading: " ++ show fp
    let doYaml opt = do
            lbs <- LBS.readFile fp
            dt <- preprocess opt fp lbs
            desc <- iocatch (parseYamlBytes $ BS.concat (LBS.toChunks dt))
                (\e -> putErrDie $ "Error parsing desc file '" ++ fp ++ "'\n" ++ show e)
            when verbose2 $ do
                yaml <- emitYaml desc
                putStrLn yaml
            return $ procYaml desc
        doCabal = do
            fc <- readFile fp
            case parseLibraryDescription fc of
                Left err -> fail $ "Error reading library description file: " ++ show fp ++ " " ++ err
                Right ps -> return $ procCabal ps
    case FP.splitExtension fp of
        (_,".cabal") -> doCabal
        (_,".yaml") -> doYaml options
        (FP.takeExtension -> ".yaml",".m4") -> doYaml options { optFOptsSet = FO.M4 `Set.insert` optFOptsSet options }
        _ -> putErrDie $ "Do not recoginize description file type: " ++ fp
readDescFile fp = do
    wdump FD.Progress $ putErrLn $ "Reading: " ++ show fp
    let doYaml opt = do
            lbs <- LBS.readFile fp
            dt <- preprocess opt fp lbs
            desc <- iocatch (parseYamlBytes $ BS.concat (LBS.toChunks dt))
                (\e -> putErrDie $ "Error parsing desc file '" ++ fp ++ "'\n" ++ show e)
            when verbose2 $ do
                yaml <- emitYaml desc
                putStrLn yaml
            return $ procYaml desc
        doCabal = do
            fc <- readFile fp
            case parseLibraryDescription fc of
                Left err -> fail $ "Error reading library description file: " ++ show fp ++ " " ++ err
                Right ps -> return $ procCabal ps
    case FP.splitExtension fp of
        (_,".cabal") -> doCabal
        (_,".yaml") -> doYaml options
        (FP.takeExtension -> ".yaml",".m4") -> doYaml options { optFOptsSet = FO.M4 `Set.insert` optFOptsSet options }
        _ -> putErrDie $ "Do not recoginize description file type: " ++ fp