-
Notifications
You must be signed in to change notification settings - Fork 3
/
Setup.hs
52 lines (45 loc) · 1.47 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import Control.Monad
import Data.List (find)
import Data.Maybe
import Distribution.PackageDescription
import Distribution.Simple
import Distribution.Simple.LocalBuildInfo
import Distribution.Simple.Setup
import System.Environment (getEnvironment)
import System.Exit
import System.FilePath.Posix ((</>))
import System.Posix.Env hiding (getEnvironment)
import System.Process
main = defaultMainWithHooks $ simpleUserHooks {
preBuild = writePrelude
}
-- * Build prelude.d.ts
--
preludeDir :: FilePath
preludeDir = "./include"
preludeFiles :: [FilePath]
preludeFiles = [
"./rsc/prims.d.ts",
"./rsc/mutability.d.ts",
"./rsc/aliases.d.ts",
"./rsc/qualifiers.d.ts",
"./rsc/measures.d.ts",
"./ambient/undefined.d.ts",
"./ambient/object.d.ts",
"./ambient/array.d.ts",
"./ambient/list.d.ts",
"./ambient/boolean.d.ts",
"./ambient/function.d.ts",
"./ambient/string.d.ts",
"./ambient/number.d.ts",
"./ambient/iarguments.d.ts",
"./ambient/regexp.d.ts",
"./ambient/error.d.ts",
"./ambient/console.d.ts",
"./ambient/math.d.ts"
]
preludeName = "prelude.d.ts"
writePrelude _ _ = do
txts <- forM preludeFiles (readFile . (preludeDir </>))
_ <- writeFile (preludeDir </> preludeName) (mconcat txts)
return (Nothing, [])