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
7
7
import Text.PrettyPrint (render )
8
8
import Data.List (nub )
9
9
import Data.Maybe (catMaybes )
10
+ import System.Directory (createDirectoryIfMissing )
11
+ import System.FilePath ((</>) )
10
12
11
13
import Language.C99.Pretty (pretty )
12
14
import qualified Language.C99.Simple as C
@@ -41,8 +43,14 @@ compileWith cSettings prefix spec = do
41
43
, " "
42
44
]
43
45
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
46
54
47
55
-- | Compile a specification to a .h and a .c file.
48
56
--
Original file line number Diff line number Diff line change @@ -4,8 +4,9 @@ module Copilot.Compile.C99.Settings.Internal where
4
4
-- | Settings used to customize the code generated.
5
5
data CSettings = CSettings
6
6
{ cSettingsStepFunctionName :: String
7
+ , cSettingsOutputDirectory :: Maybe FilePath
7
8
}
8
9
9
10
-- | Default settings with a step function called @step@.
10
11
mkDefaultCSettings :: CSettings
11
- mkDefaultCSettings = CSettings " step"
12
+ mkDefaultCSettings = CSettings " step" Nothing
You can’t perform that action at this time.
0 commit comments