on master help sign in
Add option to set profile output path
commit5396971babb1f1a17255d3748c9d686fcd25beb4 authorMatthew Bauer <mjbauer95@gmail.com> dateTue 11 Feb 2020, 16:50 (7 years ago) parent7a58b16
2 files changed+7−6
lib/command/src/Obelisk/Command.hs+3−3 lib/command/src/Obelisk/Command/Run.hs+4−3
lib/command/src/Obelisk/Command.hs+3−3
@@ -87,7 +87,7 @@ data ObCommand
8787 = ObCommand_Init InitSource Bool
8888 | ObCommand_Deploy DeployCommand
8989 | ObCommand_Run
90− | ObCommand_Profile
90+ | ObCommand_Profile (Maybe FilePath)
9191 | ObCommand_Thunk ThunkCommand
9292 | ObCommand_Repl
9393 | ObCommand_Watch
@@ -109,7 +109,7 @@ obCommand cfg = hsubparser
109109 [ command "init" $ info (ObCommand_Init <$> initSource <*> initForce) $ progDesc "Initialize an Obelisk project"
110110 , command "deploy" $ info (ObCommand_Deploy <$> deployCommand cfg) $ progDesc "Prepare a deployment for an Obelisk project"
111111 , command "run" $ info (pure ObCommand_Run) $ progDesc "Run current project in development mode"
112− , command "profile" $ info (pure ObCommand_Profile) $ progDesc "Run current project with profiling enabled"
112+ , command "profile" $ info (ObCommand_Profile <$> optional (strOption ( long "output" <> short 'o' <> metavar "BASEPATH" ))) $ progDesc "Run current project with profiling enabled"
113113 , command "thunk" $ info (ObCommand_Thunk <$> thunkCommand) $ progDesc "Manipulate thunk directories"
114114 , command "repl" $ info (pure ObCommand_Repl) $ progDesc "Open an interactive interpreter"
115115 , command "watch" $ info (pure ObCommand_Watch) $ progDesc "Watch current project for errors and warnings"
@@ -368,7 +368,7 @@ ob = \case
368368 DeployCommand_Update -> deployUpdate "."
369369 DeployCommand_Test (platform, extraArgs) -> deployMobile platform extraArgs
370370 ObCommand_Run -> run
371− ObCommand_Profile -> profile
371+ ObCommand_Profile basePath -> profile basePath
372372 ObCommand_Thunk tc -> case tc of
373373 ThunkCommand_Update thunks config -> for_ thunks (updateThunkToLatest config)
374374 ThunkCommand_Unpack thunks -> for_ thunks unpackThunk
lib/command/src/Obelisk/Command/Run.hs+4−3
@@ -82,8 +82,9 @@ obRunImports = [ "import qualified Obelisk.Run"
8282
8383profile
8484 :: MonadObelisk m
85− => m ()
86−profile = withProjectRoot "." $ \root -> do
85+ => Maybe FilePath
86+ -> m ()
87+profile mProfileBaseName = withProjectRoot "." $ \root -> do
8788 freePort <- getFreePort
8889 assets <- findProjectAssets root
8990 putLog Debug $ "Assets impurely loaded from: " <> assets
@@ -108,7 +109,7 @@ profile = withProjectRoot "." $ \root -> do
108109 -- closure heap profiling.
109110 rtsFlags = [ "+RTS", "-p", "-po" <> profileBaseName, "-hc", "-RTS" ]
110111 profileDirectory = root </> "profile"
111− profileBaseName = profileDirectory </> time
112+ profileBaseName = fromMaybe (profileDirectory </> time) mProfileBaseName
112113 liftIO $ createDirectoryIfMissing False profileDirectory
113114 withSystemTempFile "ob-run-profiled.hs" $ \hsFname hsHandle -> withSystemTempFile "ob-run" $ \exeFname exeHandle -> do
114115 liftIO $ hPutStr hsHandle exeSource