1import Distribution.Simple
2import Distribution.Simple.LocalBuildInfo
3import Distribution.Simple.Setup
4import Distribution.PackageDescription
11-- Add a post-build callout.
12-- We need to build the runtime.js after we've built elm,
13-- but before cabal does the install file copy step
16main = defaultMainWithHooks simpleUserHooks { postBuild = myPostBuild }
18-- Care! This appears to be based on an unstable API
19-- See: http://www.haskell.org/cabal/release/cabal-latest/doc/API/Cabal/Distribution-Simple.html#2
21myPostBuild :: Args -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO ()
22myPostBuild as bfs pd lbi = do
23 putStrLn "Custom build step started"
26 postBuild simpleUserHooks as bfs pd lbi
28-- put js file in dist folder so git doesn't notice
29rtsDir = "dist" </> "data"
31rts = rtsDir </> "elm-runtime.js"
32types = rtsDir </> "docs.json"
34-- buildDir with LocalBuildInfo points to "dist/build" (usually)
35elm lbi = (buildDir lbi) </> "elm" </> "elm"
36elm_doc lbi = (buildDir lbi) </> "elm-doc" </> "elm-doc"
40 contents <- map (dir </>) `fmap` getDirectoryContents dir
41 let files = filter (\f -> takeExtension f == ext) contents
42 dirs = filter (not . hasExtension) contents
43 filess <- mapM (getFiles ext) dirs
44 return (files ++ concat filess)
47 putStrLn (dropExtension file)
49 length str `seq` return ()
52appendElm lbi file = do
53 system (elm lbi ++ " --only-js " ++ file)
54 let jsFile = replaceExtension file ".js"
59 createDirectoryIfMissing False rtsDir -- dist should already exist
60 writeFile rts "Elm = {}; Elm.Native = {}; Elm.Native.Graphics = {};\n\
61 \Elm.Graphics = {}; ElmRuntime = {}; ElmRuntime.Render = {}\n"
62 mapM_ appendJS =<< getFiles ".js" "libraries"
63 mapM_ (appendElm lbi) =<< getFiles ".elm" "libraries"
64 mapM_ appendJS =<< getFiles ".js" "runtime"
65 putStrLn "\n+------------------------------------------+\
66 \\n| Success building runtime and libraries! |\
67 \\n+------------------------------------------+\n"
70 files <- getFiles ".elm" "libraries"
71 system (elm_doc lbi ++ " " ++ unwords files ++ " > " ++ types)
72 putStrLn "Custom build step completed: elm-doc"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list