forked from randrew/electrotype
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSetup.hs
33 lines (28 loc) · 1.17 KB
/
Setup.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
import Distribution.Simple
import System.Directory
import System.IO
import System.FilePath
internalPath, bakedPath, shadersDirPath :: FilePath
internalPath = "Graphics" </> "Rendering" </> "Electrotype" </> "Internal"
bakedPath = "include"
shadersDirPath = "src" </> "shaders"
readVertAndFrag :: String -> IO (String, String)
readVertAndFrag shaderName = do
vert <- readFile $ shadersDirPath </> shaderName ++ ".vert"
frag <- readFile $ shadersDirPath </> shaderName ++ ".frag"
return (vert, frag)
showVertAndFrag :: String -> (String, String) -> String
showVertAndFrag staticName (vert, frag) = "\n"
++ staticName ++ "Vert = " ++ show vert ++ "\n"
++ staticName ++ "Frag = " ++ show frag ++ "\n"
main = do
defaultMainWithHooks $ simpleUserHooks
{ preBuild = \args buildflags -> do
putStrLn "Baking shader strings..."
shader1 <- readVertAndFrag "v3f-t2f-c4f"
shader2 <- readVertAndFrag "simple2d"
writeFile (bakedPath </> "baked.inc") $
showVertAndFrag "v3ft2fc4f" shader1 ++
showVertAndFrag "simple2d" shader2
(preBuild simpleUserHooks) args buildflags
}