@@ -84,6 +84,15 @@ scriptCmd opts = do
84
84
, globalStackYaml = SYLNoProject $ soScriptExtraDeps opts
85
85
}
86
86
87
+ case soShouldRun opts of
88
+ YesRun -> pure ()
89
+ NoRun -> do
90
+ unless (null $ soArgs opts) $ throwString " --no-run incompatible with arguments"
91
+ case soCompile opts of
92
+ SEInterpret -> throwString " --no-run requires either --compile or --optimize"
93
+ SECompile -> pure ()
94
+ SEOptimize -> pure ()
95
+
87
96
-- Optimization: if we're compiling, and the executable is newer
88
97
-- than the source file, run it immediately.
89
98
local (over globalOptsL modifyGO) $
@@ -93,11 +102,16 @@ scriptCmd opts = do
93
102
SEOptimize -> shortCut file scriptDir
94
103
95
104
where
105
+ runCompiled file = do
106
+ let exeName = toExeName $ toFilePath file
107
+ case soShouldRun opts of
108
+ YesRun -> exec exeName (soArgs opts)
109
+ NoRun -> logInfo $ " Compilation finished, executable available at " <> fromString exeName
96
110
shortCut file scriptDir = handleIO (const $ longWay file scriptDir) $ do
97
111
srcMod <- getModificationTime file
98
112
exeMod <- Dir. getModificationTime $ toExeName $ toFilePath file
99
113
if srcMod < exeMod
100
- then exec (toExeName $ toFilePath file) (soArgs opts)
114
+ then runCompiled file
101
115
else longWay file scriptDir
102
116
103
117
longWay file scriptDir =
@@ -168,7 +182,7 @@ scriptCmd opts = do
168
182
compilerExeName
169
183
(ghcArgs ++ [toFilePath file])
170
184
(void . readProcessStdout_)
171
- exec (toExeName $ toFilePath file) (soArgs opts)
185
+ runCompiled file
172
186
173
187
toPackageName = reverse . drop 1 . dropWhile (/= ' -' ) . reverse
174
188
0 commit comments