Skip to content

Commit a47d97a

Browse files
committed
Copy from graal srcipt, similart to SL.
1 parent fd240c1 commit a47d97a

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

copy_from_graal.py

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
# Since Simple Tool is not developed on this repository, we need to periodically sync this repository with the developement one.
5+
# This scipt automates cloning the source repository and copying the ST code from there to here.
6+
# Requires git to be installed.
7+
8+
import os
9+
import sys
10+
from subprocess import call
11+
12+
GRAAL_REPO = "https://github.com/oracle/graal"
13+
GRAAL_DIR = "../" + GRAAL_REPO.split('/')[-1]
14+
15+
def fail(message):
16+
""" Print message to stderr and exit script
17+
18+
"""
19+
print >> sys.stderr, message
20+
sys.exit(1)
21+
22+
def clone(repo, path = ""):
23+
""" Clones the given repo url using git
24+
25+
:repo: String containing the url
26+
27+
"""
28+
if call(["git", "clone", repo, path]) != 0:
29+
fail("Could not clone " + repo)
30+
pass
31+
32+
def checkout(path, commit, create = False):
33+
""" Checks out a new branch in SL
34+
35+
:cwd: path to the git repo
36+
:commit: String, name for the new branch
37+
:create: create new or expect it to exist
38+
39+
"""
40+
command = ["git", "checkout"]
41+
if create:
42+
command.append("-b")
43+
command.append(commit)
44+
if call(command, cwd=path) != 0:
45+
fail("Could not checkout " + commit + " from " + path)
46+
47+
def replace(source, dest):
48+
""" Replace contents of dest dir with contents of source dir
49+
50+
:source: String path to source
51+
:dest: String path do destination
52+
53+
"""
54+
call(["rm", "-rf", dest])
55+
call(["mkdir", "-p", dest])
56+
call(["cp", "-RTf", source, dest])
57+
58+
def copy_st():
59+
""" Copies ST from graal to simpletool
60+
61+
"""
62+
replace(GRAAL_DIR + "/truffle/src/com.oracle.truffle.st/src/com" , "src/main/java/com")
63+
replace(GRAAL_DIR + "/truffle/src/com.oracle.truffle.st.test/src/com" , "src/test/java/com")
64+
65+
def update_st(revision):
66+
""" Updates the SL repo from the graal repo given a revision
67+
68+
:revision: the hash of the commit in the graal repo to be used
69+
70+
"""
71+
checkout(".", "st_update_"+revision, True)
72+
if os.path.isdir(GRAAL_DIR):
73+
call(['git', 'fetch'], cwd=GRAAL_DIR)
74+
else:
75+
clone(GRAAL_REPO, GRAAL_DIR)
76+
checkout(GRAAL_DIR, revision)
77+
copy_st()
78+
print ""
79+
print "NOTE: Update the version in st, README.md and all pom.xml files!"
80+
print "NOTE: Follow the instructions in README.md and make sure mvn package executes correctly!"
81+
print "NOTE: Make sure project open correctly on the supported IDEs!"
82+
print ""
83+
84+
if __name__ == "__main__":
85+
if (len(sys.argv) != 2):
86+
fail("usage: " + sys.argv[0] + " idOfGraalCommitToUseAsBase")
87+
update_st(sys.argv[1])

0 commit comments

Comments
 (0)