Friday, April 1, 2011

Streamline building linux applications on Mac with Textmate

Most of the work I do on a daily basis is developing and building middleware on a Linux system. However, I also like to write code with Textmate on my Macbook. The major reason I like Textmate is its extensibility and the keyboard shortcuts.

On the other hand, writing code with Textmate on the Mac and then upload it Linux machine to compile  is tedious and painful. Two things needs to be automated. First, I don't want to upload the code to the Linux machine every time I make some modification to the code. I tried to use MacFuse and sshfs to mount a remote directory on my Mac, but there was a serious performance issue when I tried to edit files in the mounted directories with Textmate. Second, I want a feature in which clicking on the error messages generated by the compiler would link to the corresponding line in the source file.  The C bundle in Textmate already provide this feature, but it only works for compiling code on the local machine.

To achieve these goals, I modified the make command in Textmate C bundle so that when a project contains a Makefile.tm file, it will use the file instead of the regular Makefile. The Makefile.tm file then uses rsync to upload files and then invokes the make command remotely via ssh. 

However, that still doesn't solve the error message linking problem. That is because the user home directory in Linux usually starts with "/home" while  in OS X it starts with "/Users".  It would be simple if we could directly use "ln -s /Users/huangming /home" to link my home directory in OS X under "/home".  Unfortunately,  it is not quite as easy as that. OS X reserves "/home" for auto-mounting NFS directories. Typing the "ln" command in the terminal won't work.

If you don't use NFS,  this issue can be solved by modifying "/etc/auto_master" file, comment the line starting with "/home", save the file and restart the system.  Afterwards, using the "ln" command to link home directory under "/home" will work.

With the above modification, the process of developing applications for Linux on a Mac can be greatly streamlined.


No comments:

Post a Comment