Skip to content

Commit cdc28e5

Browse files
committed
[GR-13829] [GR-14871] [GR-14869] Clean up mx commands, cleaning of build artifacts, and coverage gate
PullRequest: graalpython/468
2 parents d3ad596 + a617222 commit cdc28e5

File tree

17 files changed

+169
-12980
lines changed

17 files changed

+169
-12980
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ language
3434
/*.py
3535
*.o
3636
*.so
37+
*.rej
38+
.checkstyle
39+
/graalpython/com.oracle.graal.python.cext/compile_flags.txt
40+
/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/parser/antlr/*.interp
41+
/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/parser/antlr/*.tokens
42+
/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/parser/antlr/Python3*.java
3743
/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/parser/antlr/Python3.g4.stamp
3844
/mx.imports
3945
.pydevproject

ci.jsonnet

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,13 @@
246246

247247
local coverageGate = commonBuilder + {
248248
targets: TARGET.weekly,
249+
timelimit: TIME_LIMIT["2h"],
249250
run +: [
250-
// cannot run with excluded "GeneratedBy" since that would lead to "command line too long"
251-
// ['mx', '--jacoco-whitelist-package', 'com.oracle.graal.python', '--jacoco-exclude-annotation', '@GeneratedBy', '--strict-compliance', "--dynamicimports", super.dynamicImports, "--primary", 'gate', '-B=--force-deprecation-as-warning-for-dependencies', '--strict-mode', '--tags', "python-junit", '--jacocout', 'html'],
252-
// ['mx', '--jacoco-whitelist-package', 'com.oracle.graal.python', '--jacoco-exclude-annotation', '@GeneratedBy', 'sonarqube-upload', "-Dsonar.host.url=$SONAR_HOST_URL", "-Dsonar.projectKey=com.oracle.graalvm.python", "-Dsonar.projectName=GraalVM - Python", '--exclude-generated'],
253-
['mx', '--jacoco-whitelist-package', 'com.oracle.graal.python', '--strict-compliance', "--dynamicimports", super.dynamicImports, "--primary", 'gate', '-B=--force-deprecation-as-warning-for-dependencies', '--strict-mode', '--tags', "python-junit", '--jacocout', 'html'],
254-
['mx', '--jacoco-whitelist-package', 'com.oracle.graal.python', 'sonarqube-upload', "-Dsonar.host.url=$SONAR_HOST_URL", "-Dsonar.projectKey=com.oracle.graalvm.python", "-Dsonar.projectName=GraalVM - Python", '--exclude-generated'],
251+
// cannot run with excluded "GeneratedBy" since that would lead to "command line too long"
252+
// ['mx', '--jacoco-whitelist-package', 'com.oracle.graal.python', '--jacoco-exclude-annotation', '@GeneratedBy', '--strict-compliance', "--dynamicimports", super.dynamicImports, "--primary", 'gate', '-B=--force-deprecation-as-warning-for-dependencies', '--strict-mode', '--tags', "python-junit", '--jacocout', 'html'],
253+
// ['mx', '--jacoco-whitelist-package', 'com.oracle.graal.python', '--jacoco-exclude-annotation', '@GeneratedBy', 'sonarqube-upload', "-Dsonar.host.url=$SONAR_HOST_URL", "-Dsonar.projectKey=com.oracle.graalvm.python", "-Dsonar.projectName=GraalVM - Python", '--exclude-generated'],
254+
['mx', '--jacoco-whitelist-package', 'com.oracle.graal.python', '--strict-compliance', "--dynamicimports", super.dynamicImports, "--primary", 'gate', '-B=--force-deprecation-as-warning-for-dependencies', '--strict-mode', '--tags', "python-unittest,python-junit", '--jacocout', 'html'],
255+
['mx', '--jacoco-whitelist-package', 'com.oracle.graal.python', 'sonarqube-upload', "-Dsonar.host.url=$SONAR_HOST_URL", "-Dsonar.projectKey=com.oracle.graalvm.python", "-Dsonar.projectName=GraalVM - Python", '--exclude-generated'],
255256
],
256257
name: "python-coverage"
257258
} + getPlatform(platform="linux"),

graalpython/com.oracle.graal.python.cext/Makefile

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2018, Oracle and/or its affiliates.
1+
# Copyright (c) 2018, 2019, Oracle and/or its affiliates.
22
#
33
# The Universal Permissive License (UPL), Version 1.0
44
#
@@ -36,54 +36,68 @@
3636
# SOFTWARE.
3737

3838
QUIETLY$(MX_VERBOSE) = @
39-
LIBDIR=${VPATH}/../lib-graalpython
39+
LIBDIR=../lib-graalpython
4040
TARGET_LIB=${LIBDIR}/capi.bc
4141

4242

43-
SOURCE_FILES=$(wildcard ${VPATH}/src/*.c)
43+
SOURCE_FILES=$(wildcard src/*.c)
4444
OBJ_FILES=${SOURCE_FILES:%.c=%.o}
45-
INCLUDE_FILES=$(wildcard ${VPATH}/include/*.h)
45+
INCLUDE_FILES=$(wildcard include/*.h)
4646

47-
MODULE_SOURCES=$(wildcard ${VPATH}/modules/*.c)
47+
MODULE_SOURCES=$(wildcard modules/*.c)
4848
MODULE_OBJ_FILES=$(MODULE_SOURCES:%.c=%.o)
49-
MODULE_TARGETS=$(MODULE_SOURCES:${VPATH}/modules/%.c=${LIBDIR}/modules/%.bc)
49+
MODULE_TARGETS=$(MODULE_SOURCES:modules/%.c=${LIBDIR}/modules/%.bc)
5050

51-
HEADER_TARGETS=$(INCLUDE_FILES:${VPATH}/include/%.h=${VPATH}/../include/%.h)
51+
# These are just needed to allow compilation from source, because include needs
52+
# to be next to lib-graalpython
53+
HEADER_TARGETS=$(INCLUDE_FILES:include/%.h=../include/%.h)
5254

5355
.PHONY: default clean
54-
default: ${TARGET_LIB} ${MODULE_TARGETS} ${HEADER_TARGETS}
56+
default: ${TARGET_LIB} ${MODULE_TARGETS} ${HEADER_TARGETS} compile_flags.txt
5557

5658

5759
CFLAGS=${LLVM_TARGET_FLAGS} -O1 -ggdb -emit-llvm
5860
OPT_FLAGS=-mem2reg -globalopt -simplifycfg -constprop -always-inline -instcombine -dse -loop-simplify -reassociate -licm -gvn
5961
WARNINGS=-Wno-int-to-pointer-cast -Wno-int-conversion -Wno-incompatible-pointer-types-discards-qualifiers -Wno-pointer-type-mismatch
60-
INCLUDES=-I${POLYGLOT_INC} -I${VPATH}/include
62+
INCLUDES=-I${POLYGLOT_INC} -Iinclude
6163

6264

6365
rebuild:
64-
$(MAKE) -C ${VPATH} clean
65-
$(MAKE) -C ${VPATH} ${TARGET_LIB} ${MODULE_TARGETS} ${HEADER_TARGETS}
66+
$(MAKE) clean
67+
$(MAKE) default
6668

67-
${LIBDIR}/modules/%.bc: ${VPATH}/modules/%.o
69+
${LIBDIR}/modules/%.bc: modules/%.o
6870
$(QUIETLY) mkdir -p ${LIBDIR}/modules
6971
$(QUIETLY) llvm-link -o $@ $+
7072

7173
${TARGET_LIB}: ${OBJ_FILES}
7274
$(QUIETLY) llvm-link -o $@ $+
7375

74-
${VPATH}/src/%.o: ${VPATH}/src/%.c ${VPATH}/Makefile ${VPATH}/src/capi.h ${INCLUDE_FILES}
76+
src/%.o: src/%.c Makefile src/capi.h ${INCLUDE_FILES}
7577
$(QUIETLY) clang ${CFLAGS} ${WARNINGS} ${INCLUDES} -o $@ -c $<
7678
$(QUIETLY) opt -o $@ $@ ${OPT_FLAGS}
7779

78-
${VPATH}/modules/%.o: ${VPATH}/modules/%.c ${VPATH}/Makefile ${VPATH}/src/capi.h ${INCLUDE_FILES}
80+
modules/%.o: modules/%.c Makefile src/capi.h ${INCLUDE_FILES}
7981
$(QUIETLY) clang ${CFLAGS} ${WARNINGS} ${INCLUDES} -o $@ -c $<
8082
$(QUIETLY) opt -o $@ $@ ${OPT_FLAGS}
8183

82-
${VPATH}/../include/%.h: ${INCLUDE_FILES}
83-
$(QUIETLY) mkdir -p ${VPATH}/../include/
84-
$(QUIETLY) cp $(@:${VPATH}/../include/%.h=${VPATH}/include/%.h) $@
84+
../include/%.h: ${INCLUDE_FILES}
85+
$(QUIETLY) mkdir -p ../include/
86+
$(QUIETLY) cp $(@:../include/%.h=include/%.h) $@
8587

8688
clean:
8789
$(QUIETLY) rm -f ${TARGET_LIB}
88-
$(QUIETLY) rm -f ${TARGET_LIB}.bc
8990
$(QUIETLY) rm -f ${OBJ_FILES}
91+
$(QUIETLY) rm -f ${MODULE_TARGETS}
92+
$(QUIETLY) rm -f ${MODULE_OBJ_FILES}
93+
$(QUIETLY) rm -f ${HEADER_TARGETS}
94+
$(QUIETLY) rm -f compile_flags.txt
95+
ifeq ($(wildcard ../com.oracle.graal.python.test/src/tests/cpyext/*.bc),)
96+
rm -f $(wildcard ../com.oracle.graal.python.test/src/tests/cpyext/*.bc)
97+
endif
98+
99+
# compile_flags.txt is useful with clangd as language server
100+
compile_flags.txt: Makefile
101+
$(QUIETLY) rm -f $@
102+
$(QUIETLY) $(foreach var,$(WARNINGS),$(file >> $@,$(var)))
103+
$(QUIETLY) $(foreach var,$(INCLUDES),$(file >> $@,$(var)))

graalpython/com.oracle.graal.python.cext/include/truffle.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828
* OF THE POSSIBILITY OF SUCH DAMAGE.
2929
*/
3030

31+
/*
32+
* THIS HEADER FILE IS LEGACY API. IT IS INTENDED FOR INTERNAL USAGE ONLY. DO NOT SHARE OR
33+
* DEPEND ON THIS INTERFACE. IT MIGHT BE CHANGED OR REMOVED AT ANY TIME. FOR STABLE API,
34+
* REFER TO `polyglot.h`.
35+
*/
36+
3137
#ifndef TRUFFLE_H
3238
#define TRUFFLE_H
3339

graalpython/com.oracle.graal.python.parser.antlr/Makefile

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2018, Oracle and/or its affiliates.
1+
# Copyright (c) 2018, 2019, Oracle and/or its affiliates.
22
#
33
# The Universal Permissive License (UPL), Version 1.0
44
#
@@ -36,28 +36,34 @@
3636
# SOFTWARE.
3737

3838
QUIETLY$(MX_VERBOSE) = @
39-
TARGETS=${OUTPUT_PATH}/Python3BaseVisitor.java \
40-
${OUTPUT_PATH}/Python3Listener.java \
41-
${OUTPUT_PATH}/Python3BaseListener.java \
42-
${OUTPUT_PATH}/Python3Visitor.java \
43-
${OUTPUT_PATH}/Python3Parser.java \
44-
${OUTPUT_PATH}/Python3Lexer.java
39+
40+
# during clean, this isn't set
41+
PARSER_PATH ?= ../com.oracle.graal.python/src/com/oracle/graal/python/parser/antlr
42+
43+
TARGETS=${PARSER_PATH}/Python3BaseVisitor.java \
44+
${PARSER_PATH}/Python3Listener.java \
45+
${PARSER_PATH}/Python3BaseListener.java \
46+
${PARSER_PATH}/Python3Visitor.java \
47+
${PARSER_PATH}/Python3Parser.java \
48+
${PARSER_PATH}/Python3Lexer.java
4549

4650
SOURCE=${PARSER_PATH}/Python3.g4
47-
STAMP=${PARSER_PATH}/Python3.g4.stamp
51+
STAMP=${SOURCE}.stamp
4852

4953
.PHONY: default clean
50-
default: ${STAMP}
51-
52-
# postprocessing to make source compile without warnings
53-
define postprocess_file
54-
python ${POSTPROCESSOR} $(1)
55-
endef
54+
default: ${TARGETS}
5655

57-
${STAMP}: ${SOURCE}
56+
${STAMP}: ${SOURCE} ${POSTPROCESSOR}
5857
$(QUIETLY) touch $@
59-
$(QUIETLY) ${JAVA_HOME}/bin/java -cp ${ANTLR_JAR} org.antlr.v4.Tool -visitor -package ${PARSER_PKG} -o ${OUTPUT_PATH} ${SOURCE}
60-
$(foreach var,$(TARGETS),$(call postprocess_file,$(var));)
58+
$(QUIETLY) ${JAVA_HOME}/bin/java -cp ${ANTLR_JAR} org.antlr.v4.Tool -visitor -package ${PARSER_PKG} -o ${PARSER_PATH} ${SOURCE}
59+
60+
# postprocessing to make source compile without warnings
61+
${PARSER_PATH}/%.java: ${STAMP}
62+
$(QUIETLY) python ${POSTPROCESSOR} $@
6163

6264
clean:
63-
rm -f ${TARGETS}
65+
ifeq ($(wildcard ${SOURCE}),)
66+
$(error ${SOURCE} is not in the location I expected it to be, not cleaning antlr parser)
67+
endif
68+
$(QUIETLY) rm -f ${TARGETS}
69+
$(QUIETLY) rm -f ${STAMP}

graalpython/com.oracle.graal.python.parser.antlr/postprocess.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
COPYRIGHT_HEADER = """\
4545
/*
46-
* Copyright (c) 2017-2018, Oracle and/or its affiliates.
46+
* Copyright (c) 2017-2019, Oracle and/or its affiliates.
4747
* Copyright (c) 2014 by Bart Kiers
4848
*
4949
* The MIT License (MIT)
@@ -70,12 +70,12 @@
7070
* OTHER DEALINGS IN THE SOFTWARE.
7171
*/
7272
// Checkstyle: stop
73+
// JaCoCo Exclude
7374
//@formatter:off
7475
{0}
7576
"""
7677

7778
PTRN_SUPPRESS_WARNINGS = re.compile(r"@SuppressWarnings.*")
78-
PTRN_GENBY = re.compile(r"Generated from (?P<path>.*)/(?P<grammar>.*.g4)")
7979

8080

8181
def replace_suppress_warnings(line):
@@ -86,23 +86,17 @@ def replace_rulectx(line):
8686
return line.replace("(RuleContext)_localctx", "_localctx")
8787

8888

89-
def replace_genby(line):
90-
return PTRN_GENBY.sub("Generated from \g<grammar>", line)
91-
92-
9389
TRANSFORMS = [
9490
replace_suppress_warnings,
9591
replace_rulectx,
96-
replace_genby,
9792
]
9893

9994

10095
def postprocess(file):
10196
lines = []
10297
for line in file:
10398
for transform in TRANSFORMS:
104-
if hasattr(transform, '__call__'):
105-
line = transform(line)
99+
line = transform(line)
106100
lines.append(line)
107101
return ''.join(lines)
108102

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/NativeMemberNames.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public final class NativeMemberNames {
147147
@ExplodeLoop(kind = LoopExplosionKind.FULL_UNROLL)
148148
public static boolean isValid(String name) {
149149
for (int i = 0; i < values.length; i++) {
150-
if (values[i].equals(name)) {
150+
if (name.equals(values[i])) {
151151
return true;
152152
}
153153
}

0 commit comments

Comments
 (0)