From 218551185bc1724caffbb15e0b428b726e6fd253 Mon Sep 17 00:00:00 2001 From: Allan Odgaard Date: Wed, 15 Aug 2012 17:42:33 +0200 Subject: [PATCH] Add gdb targets to build.ninja MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since ninja run each build job with its own stdin/out/err we can’t launch gdb itself in a build job, so we use osascript to launch gdb in a new window. I used Terminal for this only because it is simpler to script than iTerm2. --- bin/gen_build | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/bin/gen_build b/bin/gen_build index b923187b..a4b79cd5 100755 --- a/bin/gen_build +++ b/bin/gen_build @@ -444,10 +444,12 @@ def static_executable(target) libs = prepend('-l', all_values_for_key(target, 'LIBS')) res << " RAVE_FLAGS = #{fws} #{libs}\n" - res << "build #{dst}.run: run_executable #{dst}\n" + res << "build #{dst}.run: run_executable #{dst}\n" + res << "build #{dst}.debug: debug_executable #{dst}\n" - res << "build #{target[:name]}: phony #{dst}\n" - res << "build #{target[:name]}/run: phony #{dst}.run\n" + res << "build #{target[:name]}: phony #{dst}\n" + res << "build #{target[:name]}/run: phony #{dst}.run\n" + res << "build #{target[:name]}/debug: phony #{dst}.debug\n" res end @@ -510,12 +512,14 @@ def app_bundle(target) res << "build #{dst}: phony | #{deps.join(' ')}\n" - res << "build #{dst}.sign: sign_executable #{dst}\n" - res << "build #{dst}.run: run_application #{dst} | #{dst}.sign\n" + res << "build #{dst}.sign: sign_executable #{dst}\n" + res << "build #{dst}.run: run_application #{dst} | #{dst}.sign\n" res << " appname = #{target[:name]}\n" + res << "build #{dst}.debug: debug_executable #{dst}/Contents/MacOS/#{target[:name]}\n" - res << "build #{target[:name]}: phony #{dst}.sign\n" - res << "build #{target[:name]}/run: phony #{dst}.run\n" + res << "build #{target[:name]}: phony #{dst}.sign\n" + res << "build #{target[:name]}/run: phony #{dst}.run\n" + res << "build #{target[:name]}/debug: phony #{dst}.debug\n" target[:rsrc_info] = all_files @@ -662,6 +666,7 @@ open("#{builddir}/build.ninja", "w") do |io| io << "\n" io << "build run: phony #{variables.find { |k, _| k == 'APP_NAME' }.last}/run\n" io << "build deploy: phony #{variables.find { |k, _| k == 'APP_NAME' }.last}/deploy\n" + io << "build debug: phony #{variables.find { |k, _| k == 'APP_NAME' }.last}/debug\n" io << "default run\n" end @@ -712,6 +717,10 @@ rule run_executable command = $in description = Run ‘$in’… +rule debug_executable + command = osascript >/dev/null -e $$'tell app "Terminal" \n activate \n do script "gdb $in" \n end tell' + description = Debug ‘$in’… + rule run_application command = { $ if pgrep -q "$appname"; then $