File: Config.hs

package info (click to toggle)
haskell-shake 0.13.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 888 kB
  • ctags: 127
  • sloc: haskell: 6,388; makefile: 35; ansic: 25; sh: 2
file content (41 lines) | stat: -rw-r--r-- 1,246 bytes parent folder | download
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

module Examples.Test.Config(main) where

import Development.Shake
import Development.Shake.FilePath
import Development.Shake.Config
import Examples.Util
import Data.Char
import Data.Maybe
import System.Directory


main = shaken test $ \args obj -> do
    want $ map obj ["hsflags.var","cflags.var","none.var"]
    usingConfigFile $ obj "config"
    obj "*.var" *> \out -> do
        cfg <- getConfig $ map toUpper $ takeBaseName out
        liftIO $ appendFile (out -<.> "times") "X"
        writeFile' out $ fromMaybe "" cfg


test build obj = do
    build ["clean"]
    createDirectoryIfMissing True $ obj ""
    writeFile (obj "config") $ unlines
        ["HEADERS_DIR = /path/to/dir"
        ,"CFLAGS = -O2 -I${HEADERS_DIR} -g"
        ,"HSFLAGS = -O2"]
    build []
    assertContents (obj "cflags.var") "-O2 -I/path/to/dir -g"
    assertContents (obj "hsflags.var") "-O2"
    assertContents (obj "none.var") ""

    appendFile (obj "config") $ unlines
        ["CFLAGS = $CFLAGS -w"]
    build []
    assertContents (obj "cflags.var") "-O2 -I/path/to/dir -g -w"
    assertContents (obj "hsflags.var") "-O2"
    assertContents (obj "cflags.times") "XX"
    assertContents (obj "hsflags.times") "X"
    assertContents (obj "none.times") "X"