[Git][ghc/ghc][wip/js-staging] Don't create directory in copyWithHeader

Sylvain Henry (@hsyl20) gitlab at gitlab.haskell.org
Tue Oct 25 10:54:11 UTC 2022



Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC


Commits:
de730d37 by Sylvain Henry at 2022-10-25T12:57:34+02:00
Don't create directory in copyWithHeader

- - - - -


2 changed files:

- compiler/GHC/StgToJS/Linker/Linker.hs
- compiler/GHC/SysTools.hs


Changes:

=====================================
compiler/GHC/StgToJS/Linker/Linker.hs
=====================================
@@ -95,7 +95,7 @@ import qualified Data.Set                 as S
 import Data.Word
 
 import System.IO
-import System.FilePath ((<.>), (</>), dropExtension)
+import System.FilePath ((<.>), (</>), dropExtension, takeDirectory)
 import System.Directory ( createDirectoryIfMissing
                         , doesFileExist
                         , getCurrentDirectory
@@ -801,6 +801,8 @@ embedJsFile :: Logger -> DynFlags -> TmpFs -> UnitEnv -> FilePath -> FilePath ->
 embedJsFile logger dflags tmpfs unit_env input_fn output_fn = do
   let profiling  = False -- FIXME: add support for profiling way
 
+  createDirectoryIfMissing True (takeDirectory output_fn)
+
   -- the header lets the linker recognize processed JavaScript files
   -- But don't add JavaScript header to object files!
 


=====================================
compiler/GHC/SysTools.hs
=====================================
@@ -44,8 +44,7 @@ import GHC.Settings.IO
 import Control.Monad.Trans.Except (runExceptT)
 import System.IO
 import Foreign.Marshal.Alloc (allocaBytes)
-import System.Directory (copyFile,createDirectoryIfMissing)
-import System.FilePath
+import System.Directory (copyFile)
 
 {-
 Note [How GHC finds toolchain utilities]
@@ -156,8 +155,7 @@ copyHandle hin hout = do
 
 -- | Copy file after printing the given header
 copyWithHeader :: String -> FilePath -> FilePath -> IO ()
-copyWithHeader header from to = do
-  createDirectoryIfMissing True (takeDirectory to)
+copyWithHeader header from to =
   withBinaryFile to WriteMode $ \hout -> do
     -- write the header string in UTF-8.  The header is something like
     --   {-# LINE "foo.hs" #-}



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/de730d37c3dbc09de55ff6950113f04a157481d8

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/de730d37c3dbc09de55ff6950113f04a157481d8
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20221025/392ac11d/attachment-0001.html>


More information about the ghc-commits mailing list