-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.py
executable file
·50 lines (43 loc) · 1.89 KB
/
build.py
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
#!/usr/bin/env python3
import subprocess
import argparse
def run(project, ghcjs, cmd):
subprocess.check_call([
"nix-shell", "build.nix", "-A", project + ".env",
"--arg", "ghcjs", "true" if ghcjs else "false",
"--run", "cd " + project + " && runhaskell Setup.hs " + cmd])
def configure(project, ghcjs):
print("### Configuring project {}, ".format(project) + ("using GHCjs." if ghcjs else "using GHC."))
run(project, ghcjs, "configure" + (" --ghcjs" if ghcjs else ""))
def build(project, ghcjs):
print("### Configuring project {}, ".format(project) + ("using GHCjs." if ghcjs else "using GHC."))
run(project, ghcjs, "build")
def repl(project, ghcjs):
print("### REPLing project {}, ".format(project) + ("using GHCjs." if ghcjs else "using GHC."))
run(project, ghcjs, "repl --ghc-options='-fobject-code -O0'")
def build_nix(project, ghcjs):
print("### Building project {} (nix), ".format(project) + ("using GHCjs." if ghcjs else "using GHC."))
subprocess.check_call(
["nix-build", "build.nix", "-A", project,
"--arg", "ghcjs", "true" if ghcjs else "false"])
parser = argparse.ArgumentParser()
parser.add_argument("--ghc", help = "Use GHC rather than GHCjs", action = "store_true")
action = parser.add_mutually_exclusive_group()
action.add_argument("--configure", help = "Only configure", action = "store_true")
action.add_argument("--repl", help = "Run repl", action = "store_true")
parser.add_argument("project", metavar = "PROJECT", nargs = "?")
args = parser.parse_args()
if args.project:
if args.configure:
configure(args.project, not args.ghc)
elif args.repl:
configure(args.project, False)
repl(args.project, False)
else:
configure(args.project, not args.ghc)
build(args.project, not args.ghc)
else:
for ghcjs in [True, False]:
projects = ["anapo", "anapo-test-app", "js-framework-benchmark"]
for project in projects:
build_nix(project, ghcjs)