-
Notifications
You must be signed in to change notification settings - Fork 2
/
.graal-git-repo
executable file
·70 lines (55 loc) · 2.46 KB
/
.graal-git-repo
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
#!/usr/bin/python
# This is a self-updating script encoding the Graal+Truffle and mx repos and
# revision used for testing on CI. We don't use submodules to avoid a hard
# dependency that might bloat the repository of users of BlackDiamonds
#
# To checkout the repos, at the specified version for this version of the code,
# run `./graal-git-repo checkout`
# To update this script, so its revisions point to the latest versions of the
# configured repos, run `./graal-git-repo update-script-revs`
import sys
import os
# We use the following repositories
GRAAL_REPO_URL = "https://github.com/oracle/graal.git"
MX_REPO_URL = "https://github.com/graalvm/mx.git"
# And these are the repo revisions we test against
GRAAL_REPO_REV = "91b68c2bcb9a0f41c0f437b6d7adf736786f36b6"
MX_REPO_REV = "65c6727a0080515696c25934f3da02ef7a1aa43a"
def update(lines, var, val):
for idx, line in enumerate(lines):
if line.startswith(var):
print("Updating " + var + " to " + val)
lines[idx] = var.ljust(15) + '= "' + val + '"\n'
break
def run(cmd):
print(cmd)
return os.popen(cmd).read()
if len(sys.argv) == 1:
print("To checkout the Graal+Truffle and MX dependencies use:")
print(" " + __file__ + " checkout")
print("To update the dependencies in this script use:")
print(" " + __file__ + " update-script-revs")
quit()
if sys.argv[1] == "update-script-revs":
graal_head_data = run("git ls-remote " + GRAAL_REPO_URL + " HEAD")
graal_head_rev = graal_head_data.split("\t")[0]
mx_head_data = run("git ls-remote " + MX_REPO_URL + " HEAD")
mx_head_rev = mx_head_data.split("\t")[0]
with open(__file__, 'r') as script_file:
content = script_file.readlines()
update(content, 'GRAAL_REPO_REV', graal_head_rev)
update(content, 'MX_REPO_REV', mx_head_rev)
with open(__file__, 'w') as script_file:
script_file.writelines(content)
def update_repo(folder, repo, rev):
folder = os.path.realpath(folder)
if not os.path.isdir(folder):
print("cloning " + repo)
print(run("git clone --depth 5000 " + repo + " " + folder))
run("git --git-dir=" + folder + "/.git --work-tree=" + folder +
" fetch --depth 5000")
print(run("git --git-dir=" + folder + "/.git --work-tree=" + folder +
" reset --hard " + rev))
if sys.argv[1] == "checkout":
update_repo("graal", GRAAL_REPO_URL, GRAAL_REPO_REV)
update_repo("mx", MX_REPO_URL, MX_REPO_REV)