mirror of https://github.com/zachjs/sv2v.git
Add file output write mode
This commit is contained in:
parent
c0cb401abe
commit
5eef44c8f4
|
|
@ -26,6 +26,7 @@ data Exclude
|
||||||
data Write
|
data Write
|
||||||
= Stdout
|
= Stdout
|
||||||
| Adjacent
|
| Adjacent
|
||||||
|
| File
|
||||||
deriving (Show, Typeable, Data, Eq)
|
deriving (Show, Typeable, Data, Eq)
|
||||||
|
|
||||||
instance Default Write where
|
instance Default Write where
|
||||||
|
|
@ -66,7 +67,8 @@ defaultJob = Job
|
||||||
, verbose = nam "verbose" &= help "Retain certain conversion artifacts"
|
, verbose = nam "verbose" &= help "Retain certain conversion artifacts"
|
||||||
, write = nam_ "write" &= name "w" &= typ "MODE"
|
, write = nam_ "write" &= name "w" &= typ "MODE"
|
||||||
&= help ("How to write output; default is 'stdout'; use 'adjacent' to"
|
&= help ("How to write output; default is 'stdout'; use 'adjacent' to"
|
||||||
++ " create a .v file next to each input")
|
++ " create a .v file next to each input; use 'file' to create a"
|
||||||
|
++ " sv2v_output.v file")
|
||||||
}
|
}
|
||||||
&= program "sv2v"
|
&= program "sv2v"
|
||||||
&= summary ("sv2v " ++ version)
|
&= summary ("sv2v " ++ version)
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,9 @@ writeOutput _ [] [] =
|
||||||
hPutStrLn stderr "Warning: No input files specified (try `sv2v --help`)"
|
hPutStrLn stderr "Warning: No input files specified (try `sv2v --help`)"
|
||||||
writeOutput Stdout _ asts =
|
writeOutput Stdout _ asts =
|
||||||
hPrint stdout $ concat asts
|
hPrint stdout $ concat asts
|
||||||
|
writeOutput File _ asts =
|
||||||
|
writeFile f $ show $ concat asts
|
||||||
|
where f = "sv2v_output.v"
|
||||||
writeOutput Adjacent inPaths asts = do
|
writeOutput Adjacent inPaths asts = do
|
||||||
outPaths <- mapM rewritePath inPaths
|
outPaths <- mapM rewritePath inPaths
|
||||||
badPaths <- filterM doesFileExist outPaths
|
badPaths <- filterM doesFileExist outPaths
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue