module Development.Shake.CCJS ( ccjs
) where
import Development.Shake
import Development.Shake.FilePath
import System.Directory (createDirectoryIfMissing)
ccjs :: [FilePath]
-> FilePattern
-> Rules ()
ccjs :: [FilePath] -> FilePath -> Rules ()
ccjs [FilePath]
sources FilePath
fp =
FilePath
fp Located => FilePath -> (FilePath -> Action ()) -> Rules ()
FilePath -> (FilePath -> Action ()) -> Rules ()
%> \FilePath
out -> do
Located => [FilePath] -> Action ()
[FilePath] -> Action ()
need [FilePath]
sources
(Stdout FilePath
sout) <- [CmdOption] -> FilePath -> [FilePath] -> Action (Stdout FilePath)
forall r.
(Located, CmdResult r) =>
[CmdOption] -> FilePath -> [FilePath] -> Action r
command [CmdOption]
forall a. Monoid a => a
mempty FilePath
"ccjs" ([FilePath]
sources [FilePath] -> [FilePath] -> [FilePath]
forall a. Semigroup a => a -> a -> a
<> [FilePath
"--externs=node"])
IO () -> Action ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> Action ()) -> IO () -> Action ()
forall a b. (a -> b) -> a -> b
$ Bool -> FilePath -> IO ()
createDirectoryIfMissing Bool
True (FilePath -> FilePath
takeDirectory FilePath
out)
IO () -> Action ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> Action ()) -> IO () -> Action ()
forall a b. (a -> b) -> a -> b
$ FilePath -> FilePath -> IO ()
writeFile FilePath
out FilePath
sout