Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 5

Qt-interest Archive, July 2007
Using qmake project knowledge to start (g)vim


Message 1 in thread

I find this script handy. There probably not much to change to make it
work with emacs.

Benjamin.

[bsergean@marge1 bin]$ cat work.sh
#!/bin/sh
# $Id: work.sh 150 2007-07-25 18:22:06Z bsergean $
# Author: bsergean@xxxxxxxxx
#
# Open your favorite editor (vi) using relevant information from the
current folder Qt project file
# - Passing the list of source and header files, plus the .pro project
file as args
# - Listing the includes list and setting vim path to find those
include file using vim 'gf'
#
# The magic number 21 and 26 might depends on your qmake version
(works fine with QMake version 2.01a (4.3.0))
#
# TODO: Maybe extract the sources dir from SOURCES (and HEADERS) and
run ctags on it
#       Open the resource file ?
#
# If you have shell variables evaluated within qmake variables,
# it won't work.
# Replace
# SOURCES = $HOME/foo.c
# with:
# HOME=$$system(echo $HOME)
# SOURCES = $${HOME}/foo.c
#

tmp=/tmp/work.$$
qmake -d -d -d > $tmp 2>&1

# DEBUG 1: SOURCES ===
getVar()
{
egrep 'DEBUG 1: SOURCES' $tmp | tail -n 1 | cut -c 21- | tr -d ':'
egrep 'DEBUG 1: HEADERS' $tmp | tail -n 1 | cut -c 21- | tr -d ':'

# Project file
echo `basename $PWD`.pro
}

getInc()
{
egrep 'DEBUG 1: INCLUDEPATH' $tmp | tail -n 1 | cut -c 26- | tr -d ':'
}
files=`getVar`
incs=`getInc | sed 's/ /,/g'`

rm -f $tmp
gvim --cmd "set path=$incs" $files

--
 [ signature omitted ]