Skip to content

Commit 56f255a

Browse files
committed
clean up our mx commands
1 parent 6d5e7d4 commit 56f255a

File tree

1 file changed

+45
-33
lines changed

1 file changed

+45
-33
lines changed

mx.graalpython/mx_graalpython.py

Lines changed: 45 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ def nativeclean(args):
173173

174174

175175
def python3_unittests(args):
176+
"""run the cPython stdlib unittests"""
176177
mx.run(["python3", "graalpython/com.oracle.graal.python.test/src/python_unittests.py", "-v"] + args)
177178

178179

@@ -189,9 +190,10 @@ class GraalPythonTags(object):
189190
cpyext_managed = 'python-cpyext-managed'
190191
cpyext_sandboxed = 'python-cpyext-sandboxed'
191192
svmunit = 'python-svm-unittest'
192-
downstream = 'python-downstream'
193193
graalvm = 'python-graalvm'
194194
license = 'python-license'
195+
so = 'python-so'
196+
svm = 'python-svm'
195197

196198

197199
def python_gate(args):
@@ -204,6 +206,9 @@ def python_gate(args):
204206
return mx.command_function("gate")(args)
205207

206208

209+
python_gate.__doc__ = 'Custom gates are %s' % ", ".join([getattr(GraalPythonTags, t) for t in dir(GraalPythonTags) if not t.startswith("__")])
210+
211+
207212
def find_jdt():
208213
pardir = os.path.abspath(os.path.join(SUITE.dir, ".."))
209214
for f in [os.path.join(SUITE.dir, f) for f in os.listdir(SUITE.dir)] + [os.path.join(pardir, f) for f in os.listdir(pardir)]:
@@ -243,6 +248,7 @@ def python_svm(args):
243248
out = mx.OutputCapture()
244249
mx.run_mx(_SVM_ARGS + ["graalvm-home"], out=mx.TeeOutputCapture(out))
245250
svm_image = os.path.join(out.data.strip(), "bin", "graalpython")
251+
print(svm_image)
246252
mx.run([svm_image] + args)
247253
return svm_image
248254

@@ -342,13 +348,13 @@ def graalpython_gate_runner(args, tasks):
342348

343349
with Task('GraalPython license header update', tasks, tags=[GraalPythonTags.license]) as task:
344350
if task:
345-
python_checkcopyrights([])
351+
python_checkcopyrights(["--fix"])
346352

347-
with Task('GraalPython GraalVM shared-library build', tasks, tags=[GraalPythonTags.downstream, GraalPythonTags.graalvm]) as task:
353+
with Task('GraalPython GraalVM shared-library build', tasks, tags=[GraalPythonTags.so, GraalPythonTags.graalvm]) as task:
348354
if task:
349355
run_shared_lib_test()
350356

351-
with Task('GraalPython GraalVM build', tasks, tags=[GraalPythonTags.downstream, GraalPythonTags.graalvm]) as task:
357+
with Task('GraalPython GraalVM build', tasks, tags=[GraalPythonTags.svm, GraalPythonTags.graalvm]) as task:
352358
if task:
353359
svm_image = python_svm(["--version"])
354360
benchmark = os.path.join(PATH_MESO, "image-magix.py")
@@ -603,25 +609,37 @@ def update_import(name, rev="origin/master", callback=None):
603609

604610

605611
def update_import_cmd(args):
612+
"""Update our mx imports"""
613+
if "sulong" in args or "regex" in args or "truffle" in args:
614+
join = os.path.join
615+
callback = lambda: shutil.copy(
616+
join(SUITE_SULONG.dir, "include", "truffle.h"),
617+
join(SUITE.dir, "graalpython", "com.oracle.graal.python.cext", "include", "truffle.h")
618+
) and shutil.copy(
619+
join(mx.dependency("SULONG_LIBS").output, "polyglot.h"),
620+
join(SUITE.dir, "graalpython", "com.oracle.graal.python.cext", "include", "polyglot.h")
621+
)
622+
update_import("sulong", callback=callback)
623+
update_import("regex")
624+
try: args.remove("sulong")
625+
except ValueError: pass
626+
try: args.remove("truffle")
627+
except ValueError: pass
628+
try: args.remove("regex")
629+
except ValueError: pass
630+
606631
for name in args:
607-
callback = None
608-
if name == "sulong":
609-
join = os.path.join
610-
callback = lambda: shutil.copy(
611-
join(SUITE_SULONG.dir, "include", "truffle.h"),
612-
join(SUITE.dir, "graalpython", "com.oracle.graal.python.cext", "include", "truffle.h")
613-
) and shutil.copy(
614-
join(mx.dependency("SULONG_LIBS").output, "polyglot.h"),
615-
join(SUITE.dir, "graalpython", "com.oracle.graal.python.cext", "include", "polyglot.h")
616-
)
617-
# make sure that sulong and regex are the same version
618-
if name == "regex":
619-
update_import("sulong", callback=callback)
620-
elif name == "sulong":
621-
update_import("regex", callback=callback)
622632
update_import(name, callback=callback)
623633

624634

635+
def python_style_checks(args):
636+
python_checkcopyrights(["--fix"])
637+
if not os.environ.get("ECLIPSE_EXE"):
638+
find_eclipse()
639+
mx.command_function("eclipseformat")()
640+
mx.command_function("spotbugs")()
641+
642+
625643
def python_checkcopyrights(args):
626644
# we wan't to ignore lib-python/3, because that's just crazy
627645
listfilename = tempfile.mktemp()
@@ -860,7 +878,7 @@ def mx_post_parse_cmd_line(namespace):
860878

861879

862880
def python_coverage(args):
863-
mx.run_mx(['--jacoco-whitelist-package', 'com.oracle.graal.python', '--primary', 'gate', '--tags', 'python-junit', '--jacocout', 'html'])
881+
mx.run_mx(['--jacoco-whitelist-package', 'com.oracle.graal.python', '--primary', 'gate', '--tags', args[0] if args else 'python-junit', '--jacocout', 'html'])
864882

865883

866884
# ----------------------------------------------------------------------------------------------------------------------
@@ -872,19 +890,13 @@ def python_coverage(args):
872890
'python': [python, '[Python args|@VM options]'],
873891
'python3': [python, '[Python args|@VM options]'],
874892
'deploy-binary-if-master': [deploy_binary_if_master, ''],
875-
'python-gate': [python_gate, ''],
876-
'python-update-import': [update_import_cmd, 'import name'],
877-
'delete-graalpython-if-testdownstream': [delete_self_if_testdownstream, ''],
878-
'python-checkcopyrights': [python_checkcopyrights, 'Make sure code files have copyright notices'],
879-
'python-build-svm': [python_build_svm, 'build svm image if it is outdated'],
880-
'python-svm': [python_svm, 'run python svm image (building it if it is outdated'],
881-
'punittest': [punittest, ''],
882-
'python3-unittests': [python3_unittests, 'run the cPython stdlib unittests'],
883-
'python-unittests': [python3_unittests, 'run the cPython stdlib unittests'],
884-
'python-gate-unittests': [gate_unittests, ''],
893+
'python-gate': [python_gate, '--tags [gates]'],
894+
'python-update-import': [update_import_cmd, '[import-name, default: truffle]'],
895+
'python-style': [python_style_checks, ''],
896+
'python-svm': [python_svm, ''],
897+
'python-unittests': [python3_unittests, ''],
885898
'nativebuild': [nativebuild, ''],
886899
'nativeclean': [nativeclean, ''],
887-
'python-so-test': [run_shared_lib_test, ''],
888-
'python-src-import': [import_python_sources, ''],
889-
'python-coverage': [python_coverage, ''],
900+
'python-src-import': [import_python_sources, 'Update the inlined files from PyPy and CPython'],
901+
'python-coverage': [python_coverage, 'Generate coverage report either running python-junit gate or the gate passed as argument'],
890902
})

0 commit comments

Comments
 (0)