Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f75e711

Browse files
committed
Kotlin: Make the build noisier
We need to capture output for some commands we run during the build, but this ended up being refactored so that we ate the output for all commands. This means that we don't see warnings from the compiler. Now we not only show the output, but we also print what commands we are running.
1 parent 05c062d commit f75e711

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

java/kotlin-extractor/build.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,19 @@ def is_windows():
3333
return True
3434
return False
3535

36-
def run_process(cmd):
36+
def run_process(cmd, capture_output=False):
3737
try:
38-
# print("Running command: " + shlex.join(cmd))
38+
print("Running command: " + shlex.join(cmd))
3939
# TODO: `shell=True` is a workaround to get CI working on Windows. It breaks the build on Linux.
40-
return subprocess.run(cmd, check=True, capture_output=True, shell=is_windows())
40+
return subprocess.run(cmd, check=True, capture_output=capture_output, shell=is_windows())
4141
except subprocess.CalledProcessError as e:
4242
print("In: " + os.getcwd(), file=sys.stderr)
4343
print("Command failed: " + shlex.join(cmd), file=sys.stderr)
44-
print("stdout output:\n" + e.stdout.decode(encoding='UTF-8',
45-
errors='replace'), file=sys.stderr)
46-
print("stderr output:\n" + e.stderr.decode(encoding='UTF-8',
47-
errors='replace'), file=sys.stderr)
44+
if capture_output:
45+
print("stdout output:\n" + e.stdout.decode(encoding='UTF-8',
46+
errors='replace'), file=sys.stderr)
47+
print("stderr output:\n" + e.stderr.decode(encoding='UTF-8',
48+
errors='replace'), file=sys.stderr)
4849
raise e
4950

5051

@@ -86,7 +87,7 @@ def find_sources(path):
8687

8788

8889
def get_kotlin_lib_folder():
89-
x = run_process([kotlinc, '-version', '-verbose'])
90+
x = run_process([kotlinc, '-version', '-verbose'], capture_output=True)
9091
output = x.stderr.decode(encoding='UTF-8', errors='strict')
9192
m = re.match(
9293
r'.*\nlogging: using Kotlin home directory ([^\n]+)\n.*', output)
@@ -98,7 +99,7 @@ def get_kotlin_lib_folder():
9899

99100

100101
def get_gradle_lib_folder():
101-
x = run_process(['gradle', 'getHomeDir'])
102+
x = run_process(['gradle', 'getHomeDir'], capture_output=True)
102103
output = x.stdout.decode(encoding='UTF-8', errors='strict')
103104
m = re.search(r'(?m)^> Task :getHomeDir\n([^\n]+)$', output)
104105
if m is None:

0 commit comments

Comments
 (0)