Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add a new command “Build Target…” which shows a menu allowing a speci…

…fic target to be chosen.
  • Loading branch information...
commit 83815ab06e38bf950c63c4af04e85c188dcb06fc 1 parent c1e1a88
Alex Ross authored sorbits committed
View
66 Commands/Build Target….tmCommand
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>autoScrollOutput</key>
+ <true/>
+ <key>beforeRunningCommand</key>
+ <string>saveModifiedFiles</string>
+ <key>command</key>
+ <string>#!/usr/bin/env ruby
+
+require ENV["TM_SUPPORT_PATH"] + "/lib/tm/executor"
+require ENV["TM_SUPPORT_PATH"] + "/lib/tm/save_current_document"
+require ENV["TM_SUPPORT_PATH"] + "/lib/ui"
+require ENV["TM_SUPPORT_PATH"] + "/lib/exit_codes"
+require ENV["TM_SUPPORT_PATH"] + "/lib/escape"
+
+TextMate::Executor.make_project_master_current_document
+
+Dir.chdir(ENV["TM_PROJECT_DIRECTORY"])
+ENV["TM_MAKE_FILE"] = ENV["TM_PROJECT_DIRECTORY"] + "/Makefile" if ENV["TM_MAKE_FILE"].nil? or not File.file?(ENV["TM_MAKE_FILE"])
+
+flags = ["-w"]
+flags &lt;&lt; "-f" + File.basename(ENV["TM_MAKE_FILE"])
+flags &lt;&lt; ENV["TM_MAKE_FLAGS"] unless ENV["TM_MAKE_FLAGS"].nil?
+
+targets = `make -np|grep -B1 PHONY|grep -Ev '^(#|--|\\.)'|grep -Eo '^[^:]+'|sort -f`.split.collect{|t| {"title" =&gt; t} }
+selection = TextMate::UI.menu(targets)
+
+TextMate::exit_discard if selection == nil
+ENV["TM_MAKE_TARGET"] = selection['title']
+
+flags &lt;&lt; ENV["TM_MAKE_TARGET"] unless ENV["TM_MAKE_TARGET"].nil?
+
+ENV["TM_DISPLAYNAME"] = ENV["TM_MAKE_TARGET"].nil? ? "default" : ENV["TM_MAKE_TARGET"]
+
+Dir.chdir(File.dirname(ENV["TM_MAKE_FILE"]))
+
+dirs = [ENV['TM_PROJECT_DIRECTORY']]
+TextMate::Executor.run("make", flags, :verb =&gt; "Making") do |line, type|
+ if line =~ /^make.*?: Entering directory `(.*?)'$/ and not $1.nil? and File.directory?($1)
+ dirs.unshift($1)
+ ""
+ elsif line =~ /^make.*?: Leaving directory `(.*?)'$/ and not $1.nil? and File.directory?($1)
+ dirs.delete($1)
+ ""
+ elsif line =~ /^(.*?):(?:(\d+):)?\s*(.*?)$/ and not $1.nil?
+ expanded_path = dirs.map{ |dir| File.expand_path($1, dir) }.find{ |path| File.file?path }
+ if !expanded_path.nil?
+ "&lt;a href=\"txmt://open?url=file://#{e_url expanded_path}#{$2.nil? ? '' : "&amp;line=" + $2}\"&gt;#{htmlize $3}&lt;/a&gt;&lt;br&gt;\n"
+ end
+ end
+end
+</string>
+ <key>input</key>
+ <string>document</string>
+ <key>keyEquivalent</key>
+ <string>~@b</string>
+ <key>name</key>
+ <string>Build Target…</string>
+ <key>output</key>
+ <string>showAsHTML</string>
+ <key>uuid</key>
+ <string>6E5653CE-68E0-42E5-BF29-B3AB323BC218</string>
+</dict>
+</plist>
View
1  Commands/Run.plist
@@ -11,7 +11,6 @@
require ENV["TM_SUPPORT_PATH"] + "/lib/tm/executor"
require ENV["TM_SUPPORT_PATH"] + "/lib/tm/save_current_document"
-
require ENV["TM_SUPPORT_PATH"] + "/lib/escape"
TextMate::Executor.make_project_master_current_document
View
1  info.plist
@@ -13,6 +13,7 @@
<key>ordering</key>
<array>
<string>19F9C045-7BCC-429B-8C68-967B6BD15B84</string>
+ <string>6E5653CE-68E0-42E5-BF29-B3AB323BC218</string>
<string>FF1825E8-6B1C-11D9-B883-000D93589AF6</string>
<string>E05AF624-5BD8-4A54-A0E8-F80E8191D69E</string>
</array>
Please sign in to comment.
Something went wrong with that request. Please try again.