-
Notifications
You must be signed in to change notification settings - Fork 1
/
build-all.py
74 lines (56 loc) · 2.1 KB
/
build-all.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import os
from pathlib import Path
from subprocess import run
import shutil
import json
root=os.path.abspath(".")
print("root", root)
# todo: find path to elm binary dynamically
# todo: clear elm-stuff automatically if it exists
def clearElmStuffs(path):
rmDirs = []
for dirName, subdirList, fileList in os.walk(path):
if dirName.endswith("elm-stuff"):
rmDirs += [dirName]
for d in rmDirs:
shutil.rmtree(d)
def walkElmPkgs():
for dirName, subdirList, fileList in os.walk("./all-elm-pkg-sources/", topdown=True):
if dirName.count("/") - root.count("/") > 2:
#print("break", dirName)
continue
if os.path.exists(dirName + "/elm.json"):
parts = dirName.split("/")
vsn = parts[-1]
pkgName = parts[-2]
authorName = parts[-3]
print()
print("#", authorName + "/" + pkgName + "/" + vsn)
#print(authorName, pkgName, vsn, "###", dirName, fileList, fileList)
elmFiles = findElmFilesIn(dirName)
#print("elmFiles", elmFiles)
args = ["/Users/drathier/.local/bin/elm", "make"] + elmFiles
print("args", args)
res = run(args, env={"ELM_HOME": root+"/elm-home"}, capture_output=True, cwd=dirName)
res.stdout and print(res.stdout.decode("utf-8"))
res.stderr and print(res.stderr.decode("utf-8"))
#exit(1)
def findElmFilesIn(path):
# find elm.json and parse exposed modules
with open(path + "/elm.json") as f:
s = json.load(f)
#print("s", s)
modules = s["exposed-modules"]
mpath = ["src/" + m.replace(".", "/") + ".elm" for m in modules]
#print(mpath)
return mpath
#exit(42)
def findElmFilesIn2(relativeTo, path):
res = []
for dirName, subdirList, fileList in os.walk(path):
res += [str(Path(dirName).relative_to(Path(relativeTo))) + "/" + f for f in fileList if f.endswith("elm")]
return res
#print("cleaning elm-stuff/ dirs")
#clearElmStuffs(root + "/all-elm-pkg-sources")
print("walking")
walkElmPkgs()