help-global
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can Global reference files by absolute path?


From: Shigio YAMAGUCHI
Subject: Re: Can Global reference files by absolute path?
Date: Sat, 11 Jul 2015 00:04:39 +0900

Hi,
Global works by project base not file base. That's different from ctags.
Gtags must be invoked at the project root directory.
And tag files basically should be put on the same directory.
'GTAGS' has a role of a mark of the project.

$ cd /usr/include
$ gtags
$ ls G*
GPATH GRTAGS GTAGS

However, you wouldn't want to make tag files at a shared directory
like '/usr/include'. Instead, you can use 'obj' directory.
Please try the following.

1. make an obj directory

$ mkdir $HOME/obj
$ export MAKEOBJDIRPREFIX=$HOME/obj

2. make tag files

$ cd /usr/include
$ gtags -O # -O: use obj directory
$ cd <your project>
$ gtags -O
$ export GTAGSLIBPATH=/usr/include
$ global -xa printf

Tag files are made in the obj directory.

Regards,
Shigio


2015-07-10 22:49 GMT+09:00 Raffaele Ricciardi <address@hidden>:
Hello,

I am trying to use Global to lookup tags for each C library that a
project may use, by using GTAGSLIBPATH.  The caveat is that I would like
to generate Global files out of source, while discriminating libraries
that may share their directory (this is what happens in */usr/include/*).

So far, I have generated Global files successfully, but `global' doesn't
reference the original files correctly.  For instance, for the standard
C library, this is what happens when I run `global' from the directory
of a project:

    $ global -xs printf
    Warning: source file './stdio.h' is not available.
    printf            362 stdio.h
    ...

That is: `global' expects to find library files in the directory of the
project, instead of their own directory.  In this case, I would have
expected *stdio.h* to be referenced as */usr/include/stdio.h* instead.

I am going to describe what I have done.  I am using Global 6.5
(compiled with Exuberant Ctags 5.8) and the last version of Pygments.

First, I have created a directory to cache the Global files for the
standard C library:

    $ mkdir --parents ~/.cache/gtags/standard-c
    $ cd ~/.cache/gtags/standard-c

In this directory, I have generated a file with the list of headers that
`gtags' will parse:

    $ find /usr/include/*.h -type f > gtags.file
    $ cat gtags.file
    /usr/include/aio.h
    ...

Now, I would have expected `gtags' to be able to process `gtags.file'
from here, because it contains absolute paths, but `gtags' warns that it
is ignoring all those files because they are "out of source tree".
Apparently, I must move to the directory that contains those files
beforehand (indeed, this is the approach followed by the Tutorial).
Therefore:

    $ pushd /usr/include/
    /usr/include ~/.cache/gtags/standard-c
    $ gtags -c -f  ~/.cache/gtags/standard-c/gtags.file ~/.cache/gtags/standard-c
    $ popd

Let's check that `gtags' has worked:

    $ ls
    GPATH  GRTAGS  GTAGS  gtags.file

OK.  Let's lookup a symbol:

    $ global -xs printf
    Warning: source file './stdio.h' is not available.
    printf            362 stdio.h
    ...

Why *./stdio.h* instead of */usr/include/stdio.h*?  Thank you.

_______________________________________________
Help-global mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/help-global



--
Shigio YAMAGUCHI <address@hidden>
PGP fingerprint: D1CB 0B89 B346 4AB6 5663  C4B6 3CA5 BBB3 57BE DDA3

reply via email to

[Prev in Thread] Current Thread [Next in Thread]