File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
copilot-c99/src/Copilot/Compile/C99 Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ module Copilot.Compile.C99.Compile.Internal
77import Text.PrettyPrint (render )
88import Data.List (nub )
99import Data.Maybe (catMaybes )
10+ import System.Directory (createDirectoryIfMissing )
11+ import System.FilePath ((</>) )
1012
1113import Language.C99.Pretty (pretty )
1214import qualified Language.C99.Simple as C
@@ -41,8 +43,14 @@ compileWith cSettings prefix spec = do
4143 , " "
4244 ]
4345
44- writeFile (prefix ++ " .c" ) $ cmacros ++ cfile
45- writeFile (prefix ++ " .h" ) hfile
46+ case cSettingsOutputDirectory cSettings of
47+ Nothing ->
48+ do writeFile (prefix ++ " .c" ) $ cmacros ++ cfile
49+ writeFile (prefix ++ " .h" ) hfile
50+ Just dir ->
51+ do createDirectoryIfMissing True dir
52+ writeFile (dir </> prefix ++ " .c" ) $ cmacros ++ cfile
53+ writeFile (dir </> prefix ++ " .h" ) hfile
4654
4755-- | Compile a specification to a .h and a .c file.
4856--
Original file line number Diff line number Diff line change @@ -4,8 +4,9 @@ module Copilot.Compile.C99.Settings.Internal where
44-- | Settings used to customize the code generated.
55data CSettings = CSettings
66 { cSettingsStepFunctionName :: String
7+ , cSettingsOutputDirectory :: Maybe FilePath
78 }
89
910-- | Default settings with a step function called @step@.
1011mkDefaultCSettings :: CSettings
11- mkDefaultCSettings = CSettings " step"
12+ mkDefaultCSettings = CSettings " step" Nothing
You can’t perform that action at this time.
0 commit comments