1111from modules import Module
1212import workflows .promises as promises
1313import workflows
14+ import os .path
1415from os_utils import locate_exec_on_path
1516from gs_utils .console_process import Console_Process
1617
@@ -224,11 +225,11 @@ def build_and_run(main_name, in_console=True):
224225 except RuntimeError :
225226 return
226227
227- # Get the name of the generated binary
228- bin_name = GPS .File ( main_name ). executable_path . path
228+ # Get the path of the generated binary, computing it from the root project.
229+ exec_file = GPS .Project . root (). get_executable_file ( GPS . File ( main_name ))
229230
230231 # STEP 2 launch with Emulator
231- yield GNATemulator .run_gnatemu ([bin_name ], in_console )
232+ yield GNATemulator .run_gnatemu ([exec_file . path ], in_console )
232233
233234 @staticmethod
234235 def build_and_debug (main_name ):
@@ -249,7 +250,9 @@ def build_and_debug(main_name):
249250 # Build error, we stop there
250251 return
251252
252- binary = GPS .File (main_name ).executable_path .path
253+ # Get the executable path
254+ exe = GPS .Project .root ().get_executable_file (GPS .File (main_name )).path
255+
253256 # STEP 2 Switch to the "Debug" perspective To have GNATemu console in
254257 # the debugger perspective.
255258
@@ -266,14 +269,14 @@ def build_and_debug(main_name):
266269
267270 yield GNATemulator .run_gnatemu (["--freeze-on-startup" ,
268271 "--gdb=%s" % debug_port ,
269- binary ])
272+ exe ])
270273
271274 log ("... done." )
272275
273276 # STEP 3 launch the debugger
274277 try :
275278 debugger_promise = promises .DebuggerWrapper (
276- GPS .File (binary ),
279+ GPS .File (exe ),
277280 remote_target = "localhost:" + debug_port ,
278281 remote_protocol = "remote" )
279282 except Exception :
0 commit comments