-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.hs
executable file
·50 lines (40 loc) · 1.29 KB
/
build.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env stack
import System.Directory
import System.Process
import System.Exit
import System.FilePath.Posix
_callCmd :: String -> [String] -> ((String,String) -> String) -> IO ()
_callCmd cmd args f = do
(exitCode, out, err) <- readProcessWithExitCode cmd args []
case exitCode of
ExitSuccess -> putStrLn out
(ExitFailure _) -> error $ f (out, err)
callCmd cmd args = _callCmd cmd args snd
stackBuild = callCmd "stack" ["build"]
stackInstall t = callCmd "stack" ["install", "--local-bin-path", t]
_checkShaders :: [FilePath] -> IO ()
_checkShaders = mapM_ glslangValidator
listAbs :: FilePath -> IO [FilePath]
listAbs path = do
files <- listDirectory path
setCurrentDirectory path
r <- mapM makeAbsolute files
setCurrentDirectory ".."
return r
checkShaders :: IO ()
checkShaders = do
shaders <- listAbs "shaders"
_checkShaders shaders
glslangValidator f = _callCmd "glslangValidator" [f] fst
copyAll :: FilePath -> FilePath -> IO ()
copyAll from to = do
absContent <- listAbs from
mapM_ (\src -> copyFile src ((to ++ "/") ++ (takeFileName src))) absContent
main :: IO ()
main = do
stackBuild
createDirectoryIfMissing False "target"
stackInstall "target"
checkShaders
copyAll "shaders" "target"
copyAll "resources" "target"