[SVN] Makefile bundle: better support for multi-Makefile projects (in multiple directories)
Anthony Collins
aecollins1 at gmail.com
Wed Apr 29 02:43:07 UTC 2009
Hi All,
Firstly, there is an obvious bug introduced in r10873, where there is
a hard-coded directory belonging to one of the developers. This causes
the bundle command to not work at all. The fix is:
-#Dir.chdir(ENV["TM_PROJECT_DIRECTORY"]) unless
ENV["TM_PROJECT_DIRECTORY"].nil?
-Dir.chdir("/Users/duff/Oak/avian")
+Dir.chdir(ENV["TM_PROJECT_DIRECTORY"]) unless
ENV["TM_PROJECT_DIRECTORY"].nil?
The current Makefile bundle has poor support for projects that have
distributed Makefiles (for example, an Automake project that has
source code in multiple sub-directories, with a Makefile in each sub-
directory). The current Build command works fine, but the compiler
output will not be hyperlinked because the source files are only
looked for in the root project directory, not the directory that is
currently being built.
Here is one solution to this (patch for Commands/Run.plist, including
the fix for the bug mentioned above):
20c18
< flags = []
---
> flags = ["-w"]
27,28c25
< #Dir.chdir(ENV["TM_PROJECT_DIRECTORY"]) unless
ENV["TM_PROJECT_DIRECTORY"].nil?
< Dir.chdir("/Users/duff/Oak/avian")
---
> Dir.chdir(ENV["TM_PROJECT_DIRECTORY"]) unless
ENV["TM_PROJECT_DIRECTORY"].nil?
31c28,33
< if line =~ /^(.*?):(?:(\d+):)?\s*(.*?)$/ and not $1.nil? and
File.exists?($1)
---
> if line =~ /^make.*?: Entering directory `(.*?)'$/ and not
$1.nil? and File.directory?($1)
> Dir.chdir($1)
> ""
> elsif line =~ /^make.*?: Leaving directory `(.*?)'$/
> ""
> elsif line =~ /^(.*?):(?:(\d+):)?\s*(.*?)$/ and not $1.nil? and
File.exists?($1)
The -w flag passed to make tells it to output information about its
current working directory. This is then parsed, and then chdir is
called to change to it while Executor is running. This means that the
later call to File.expand_path($1) works for files that aren't in the
root project folder (where the master Makefile is located). The
additional output created by -w is then hidden from the user, so that
the output is not unnecessarily verbose.
In a multi-Makefile project, it is also useful to be able to build
just the current directory you are working with. To achieve this,
simply duplicate the current Build command (with the above patch), and
remove:
Dir.chdir(ENV["TM_PROJECT_DIRECTORY"]) unless
ENV["TM_PROJECT_DIRECTORY"].nil?
This means that the current working directory remains to be
TM_FILEPATH, and only the Makefile in that directory will be run. This
is handy. I call my command "Build Directory of Current File".
It would be great to see these included in the Makefile bundle.
Thanks!
Anthony Collins
More information about the textmate-dev
mailing list