forked from ndmitchell/nsis
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.hs
More file actions
57 lines (50 loc) · 1.9 KB
/
Main.hs
File metadata and controls
57 lines (50 loc) · 1.9 KB
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
52
53
54
55
56
57
module Main where
import Control.Monad
import Data.List
import Data.Maybe
import System.Cmd
import System.Environment
import System.Exit
import System.Info
import Development.NSIS
import Examples.Base64
import Examples.Example1
import Examples.Example2
import Examples.Finish
import Examples.Primes
import Examples.Taskbar
examples = let (*) = (,) in
["base64" * base64, "example1" * example1, "example2" * example2
,"finish" * finish, "primes" * primes, "taskbar" * taskbar]
main = do
args <- getArgs
let (flags,names) = partition ("-" `isPrefixOf`) args
when ("--help" `elem` flags) $ do
putStr $ unlines
["nsis-test [FLAGS] [EXAMPLES]"
,"Examples:"
," " ++ unwords (map fst examples)
,"Flags:"
," --help Show this message"
," --nowrite Don't write out the scripts"
," --nobuild Don't build"
," --run Run the result"
]
exitSuccess
when (null args) $ do
putStrLn "*****************************************************************"
putStrLn "** Running nsis test suite, run with '--help' to see arguments **"
putStrLn "*****************************************************************"
names <- return $ if null names then map fst examples else names
forM_ names $ \name -> do
let script = fromMaybe (error $ "Unknown example: " ++ name) $ lookup name examples
unless ("--nowrite" `elem` flags) $ writeFile (name ++ ".nsi") $ nsis script
unless ("--nobuild" `elem` flags) $
if os == "mingw32" then do
r <- system $ "makensis " ++ name ++ ".nsi"
when (r /= ExitSuccess) $ error "NSIS FAILED"
else
putStrLn "Not building because not on Windows"
when ("--run" `elem` flags) $ do
system $ name ++ ".exe"
return ()