Skip to content

Commit 6a5319a

Browse files
committed
Improve compilation screen
1 parent 9f4becd commit 6a5319a

File tree

1 file changed

+35
-32
lines changed

1 file changed

+35
-32
lines changed

Diff for: tools/config_editor/compile.py

+35-32
Original file line numberDiff line numberDiff line change
@@ -25,46 +25,49 @@ def print_output(self, renderable: RenderableType) -> None:
2525
def compile_libs(self) -> None:
2626
# Compile the libraries
2727

28-
# Get the Arduino path from the command line arguments or use the default path
29-
arduino_path = ""
30-
if len(sys.argv) > 1:
31-
arduino_path = sys.argv[1]
32-
else:
33-
arduino_path = "/arduino-esp32"
34-
3528
label = self.query_one("#compile-title", Static)
3629
self.child_process = None
3730
target = self.app.setting_target
3831

39-
if os.path.exists(arduino_path):
40-
print("Starting compilation process. Using Arduino path: " + arduino_path)
32+
print("Compiling for " + target.upper())
33+
label.update("Compiling for " + target.upper())
34+
self.print_output("======== Compiling for " + target.upper() + " ========")
4135

42-
print("Compiling for " + target.upper())
43-
if target == "all":
44-
command = ["./build.sh", "-c", arduino_path]
36+
command = ["./build.sh", "-t", target, "-D", self.app.setting_debug_level]
37+
#command.append("--help") # For testing without compiling
38+
39+
if self.app.setting_enable_copy:
40+
if os.path.isdir(self.app.setting_arduino_path):
41+
command.extend(["-c", self.app.setting_arduino_path])
4542
else:
46-
command = ["./build.sh", "-c", arduino_path, "-t", target]
47-
#command.append("--help") # For testing without compiling
48-
49-
label.update("Compiling for " + target.upper())
50-
self.print_output("======== Compiling for " + target.upper() + " ========")
51-
self.print_output("Running: " + " ".join(command) + "\n")
52-
print("Running: " + " ".join(command))
53-
self.child_process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, shell=True)
54-
for output in self.child_process.stdout:
55-
if output == '' and self.child_process.poll() is not None:
56-
print("Child process finished")
57-
break
58-
if output:
59-
self.print_output(output.strip()) # Update RichLog widget with subprocess output
60-
self.child_process.stdout.close()
61-
else:
62-
print("Arduino path does not exist: " + arduino_path)
63-
self.print_output("Arduino path does not exist: " + arduino_path)
43+
print("Invalid path to Arduino core: " + self.app.setting_arduino_path)
44+
self.print_output("Invalid path to Arduino core: " + self.app.setting_arduino_path)
45+
label.update("Invalid path to Arduino core")
46+
return
47+
48+
if self.app.setting_arduino_branch:
49+
command.extend(["-A", self.app.setting_arduino_branch])
50+
51+
if self.app.setting_idf_branch:
52+
command.extend(["-I", self.app.setting_idf_branch])
53+
54+
if self.app.setting_idf_commit:
55+
command.extend(["-i", self.app.setting_idf_commit])
56+
57+
self.print_output("Running: " + " ".join(command) + "\n")
58+
print("Running: " + " ".join(command))
59+
self.child_process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, shell=True)
60+
for output in self.child_process.stdout:
61+
if output == '' and self.child_process.poll() is not None:
62+
print("Child process finished")
63+
break
64+
if output:
65+
self.print_output(output.strip()) # Update RichLog widget with subprocess output
66+
self.child_process.stdout.close()
6467

6568
if not self.child_process:
66-
print("Compilation failed for " + target.upper() + ". Invalid path to Arduino core.")
67-
label.update("Compilation failed for " + target.upper() + ". Invalid path to Arduino core.")
69+
print("Compilation failed for " + target.upper() + "Child process failed to start")
70+
label.update("Compilation failed for " + target.upper() + "Child process failed to start")
6871
elif self.child_process.returncode != 0:
6972
print("Compilation failed for " + target.upper() + ". Return code: " + str(self.child_process.returncode))
7073
self.print_output("Compilation failed for " + target.upper() + ". Return code: " + str(self.child_process.returncode))

0 commit comments

Comments
 (0)