summaryrefslogtreecommitdiff
path: root/grc/gui/Executor.py
diff options
context:
space:
mode:
Diffstat (limited to 'grc/gui/Executor.py')
-rw-r--r--grc/gui/Executor.py74
1 files changed, 73 insertions, 1 deletions
diff --git a/grc/gui/Executor.py b/grc/gui/Executor.py
index efed54b042..79bb29f101 100644
--- a/grc/gui/Executor.py
+++ b/grc/gui/Executor.py
@@ -44,7 +44,11 @@ class ExecFlowGraphThread(threading.Thread):
self.update_callback = callback
try:
- self.process = self.page.process = self._popen()
+ if self.flow_graph.get_option('output_language') == 'python':
+ self.process = self.page.process = self._popen()
+ elif self.flow_graph.get_option('output_language') == 'cpp':
+ self.process = self.page.process = self._cpp_popen()
+
self.update_callback()
self.start()
except Exception as e:
@@ -75,6 +79,74 @@ class ExecFlowGraphThread(threading.Thread):
shell=False, universal_newlines=True
)
+ def _cpp_run_cmake(self):
+ """
+ Generate and compile this C++ flow graph.
+ """
+ generator = self.page.get_generator()
+
+ xterm_executable = find_executable(self.xterm_executable)
+
+ dirname = generator.file_path
+ builddir = os.path.join(dirname, 'build')
+
+ run_command_args = [ 'cmake', '..' ]
+ Messages.send_start_exec(' '.join(run_command_args))
+
+ return subprocess.Popen(
+ args=run_command_args,
+ cwd=builddir,
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
+ shell=False, universal_newlines=True
+ )
+
+ def _cpp_compile(self):
+ """
+ Compile this C++ flow graph.
+ """
+ generator = self.page.get_generator()
+
+ xterm_executable = find_executable(self.xterm_executable)
+
+ dirname = generator.file_path
+ builddir = os.path.join(dirname, 'build')
+
+ run_command_args = [ 'make' ]
+ Messages.send_start_exec(' '.join(run_command_args))
+
+ return subprocess.Popen(
+ args=run_command_args,
+ cwd=builddir,
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
+ shell=False, universal_newlines=True
+ )
+
+
+ def _cpp_popen(self):
+ """
+ Execute this C++ flow graph after generating and compiling it.
+ """
+ generator = self.page.get_generator()
+ run_command = generator.file_path + '/build/' + self.flow_graph.get_option('id')
+
+ if os.path.isfile(run_command):
+ os.remove(run_command)
+
+ xterm_executable = find_executable(self.xterm_executable)
+ process = self._cpp_run_cmake()
+ process.wait()
+ process = self._cpp_compile()
+ process.wait()
+
+ run_command_args = [xterm_executable, '-e', run_command]
+ Messages.send_start_exec(' '.join(run_command_args))
+
+ return subprocess.Popen(
+ args=run_command_args,
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
+ shell=False, universal_newlines=True
+ )
+
def run(self):
"""
Wait on the executing process by reading from its stdout.