On 17/04/2014 0:25, Suresh Kumar wrote:
> But when I try to use it for C# code (by setting GTAGSLABEL=ctags), I
> run into a problem where it is not able to find gtags parser library
> (I get something like "gtags: cannot open shared object
> '/usr/local/lib/gtags/exuberant-ctags.la'"). I am wondering if
> anybody using similar setup and can share some details.
That's the default path for Unix; for Windows, I configure with
--prefix=c:/usr (where I've installed various GNU utilities). However,
there's another problem, since gtags.conf doesn't escape the colon; not
sure where I should handle that - atm you'll have to DIY. You also need
a patch, so it will compile and build a DLL (Windows needs the -no-undefined
option, not sure how that affects Unix). BTW, shouldn't terminate_ctags
free argv[1]?
> Also, can someone share their ./configure option for compiling global
> under Windows? --with-exuberant-ctags=/c/bin/ctags.exe
No, that won't work, as you're building a native tool, so you need a
native path - "c:" instead of "/c" is what you want. And as mentioned
above, you probably want something for --prefix (which is the only option
I use, but I build with stock MinGW).
--
Jason.
diff -pur global-6.2.11/libparser/parser.c global-6.2-11/libparser/parser.c
--- global-6.2.11/libparser/parser.c 2014-03-12 12:49:34 +1000
+++ global-6.2-11/libparser/parser.c 2014-04-17 17:24:49 +1000
@@ -171,6 +171,11 @@ load_plugin_parser(const char *pluginspe
if (p != NULL)
*p++ = '\0';
q = strchr(lt_dl_name, ':');
+#ifdef _WIN32
+ /* Assume a single-character name is a drive letter. */
+ if (q == lt_dl_name + 1)
+ q = strchr(q + 1, ':');
+#endif
if (q == NULL) {
parser_name = "parser";
} else {
diff -pur global-6.2.11/plugin-factory/exuberant-ctags.c
global-6.2-11/plugin-factory/exuberant-ctags.c
--- global-6.2.11/plugin-factory/exuberant-ctags.c 2014-03-12 12:49:34
+1000
+++ global-6.2-11/plugin-factory/exuberant-ctags.c 2014-04-17 17:48:27
+1000
@@ -22,9 +22,6 @@
#include <config.h>
#endif
#include <sys/types.h>
-#if !defined(_WIN32) || defined(__CYGWIN__)
-#include <sys/wait.h>
-#endif
#include <assert.h>
#include <ctype.h>
#include <errno.h>
@@ -51,24 +48,15 @@
#define LANGMAP_OPTION "--langmap="
#define INITIAL_BUFSIZE 1024
-static char *argv[] = {
- EXUBERANT_CTAGS,
- NULL,
-#ifdef USE_TYPE_STRING
- "--gtags",
-#endif
- "-xu",
- "--filter",
- "--filter-terminator=" TERMINATOR "\n",
- "--format=1",
- NULL
-};
-static pid_t pid;
static FILE *ip, *op;
static char *linebuf;
static size_t bufsize;
static char *ctagsnotfound = "Exuberant Ctags not found. Please see
./configure --help.";
+#ifdef __GNUC__
+static void terminate_ctags(void) __attribute__((destructor));
+#endif
+
static void
copy_langmap_converting_cpp(char *dst, const char *src)
{
@@ -89,6 +77,88 @@ copy_langmap_converting_cpp(char *dst, c
strcpy(dst, src);
}
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <fcntl.h>
+static HANDLE pid;
+static char argv[] = "ctags "
+#ifdef USE_TYPE_STRING
+ "--gtags "
+#endif
+ "-xu --filter --filter-terminator=" TERMINATOR "\n "
+ "--format=1 " LANGMAP_OPTION;
+static void
+start_ctags(const struct parser_param *param)
+{
+ HANDLE opipe[2], ipipe[2];
+ SECURITY_ATTRIBUTES sa;
+ STARTUPINFO si;
+ PROCESS_INFORMATION pi;
+ char* arg;
+
+ if (strlen(EXUBERANT_CTAGS) == 0 || !strcmp(EXUBERANT_CTAGS, "no"))
+ param->die(ctagsnotfound);
+ arg = malloc(sizeof(argv) + strlen(param->langmap));
+ if (arg == NULL)
+ param->die("short of memory.");
+ strcpy(arg, argv);
+ copy_langmap_converting_cpp(arg + sizeof(argv) - 1, param->langmap);
+
+ sa.nLength = sizeof(sa);
+ sa.bInheritHandle = TRUE;
+ sa.lpSecurityDescriptor = NULL;
+ if (!CreatePipe(&opipe[0], &opipe[1], &sa, 0) ||
+ !CreatePipe(&ipipe[0], &ipipe[1], &sa, 0))
+ param->die("CreatePipe failed.");
+ SetHandleInformation(opipe[1], HANDLE_FLAG_INHERIT, 0);
+ SetHandleInformation(ipipe[0], HANDLE_FLAG_INHERIT, 0);
+ ZeroMemory(&si, sizeof(si));
+ si.cb = sizeof(si);
+ si.hStdInput = opipe[0];
+ si.hStdOutput = ipipe[1];
+ si.hStdError = GetStdHandle(STD_ERROR_HANDLE);
+ si.dwFlags = STARTF_USESTDHANDLES;
+ CreateProcess(EXUBERANT_CTAGS, arg, NULL, NULL, TRUE, 0, NULL, NULL,
&si, &pi);
+ CloseHandle(opipe[0]);
+ CloseHandle(ipipe[1]);
+ CloseHandle(pi.hThread);
+ pid = pi.hProcess;
+ op = fdopen(_open_osfhandle((long)opipe[1], _O_WRONLY), "w");
+ ip = fdopen(_open_osfhandle((long)ipipe[0], _O_RDONLY), "r");
+ if (ip == NULL || op == NULL)
+ param->die("fdopen failed.");
+
+ bufsize = INITIAL_BUFSIZE;
+ linebuf = malloc(bufsize);
+ if (linebuf == NULL)
+ param->die("short of memory.");
+}
+static void
+terminate_ctags(void) {
+ if (op == NULL)
+ return;
+ free(linebuf);
+ fclose(op);
+ fclose(ip);
+ WaitForSingleObject(pid, INFINITE);
+ CloseHandle(pid);
+}
+#else
+#include <sys/wait.h>
+static pid_t pid;
+static char *argv[] = {
+ EXUBERANT_CTAGS,
+ NULL,
+#ifdef USE_TYPE_STRING
+ "--gtags",
+#endif
+ "-xu",
+ "--filter",
+ "--filter-terminator=" TERMINATOR "\n",
+ "--format=1",
+ NULL
+};
static void
start_ctags(const struct parser_param *param)
{
@@ -134,10 +204,6 @@ start_ctags(const struct parser_param *p
param->die("short of memory.");
}
-#ifdef __GNUC__
-static void terminate_ctags(void) __attribute__((destructor));
-#endif
-
static void
terminate_ctags(void)
{
@@ -149,6 +215,7 @@ terminate_ctags(void)
while (waitpid(pid, NULL, 0) < 0 && errno == EINTR)
;
}
+#endif
static char *
get_line(const struct parser_param *param)
diff -pur global-6.2.11/plugin-factory/Makefile.in
global-6.2-11/plugin-factory/Makefile.in
--- global-6.2.11/plugin-factory/Makefile.in 2014-03-12 12:49:44 +1000
+++ global-6.2-11/plugin-factory/Makefile.in 2014-04-17 16:40:10 +1000
@@ -362,11 +362,11 @@ top_srcdir = @top_srcdir@
plugindir = ${libdir}/gtags
plugin_LTLIBRARIES = exuberant-ctags.la user-custom.la
exuberant_ctags_la_SOURCES = exuberant-ctags.c
-exuberant_ctags_la_LDFLAGS = -module -avoid-version
+exuberant_ctags_la_LDFLAGS = -module -avoid-version -no-undefined
# skeleton
user_custom_la_SOURCES = user-custom.c
-user_custom_la_LDFLAGS = -module -avoid-version
+user_custom_la_LDFLAGS = -module -avoid-version -no-undefined
gtagsdir = ${datadir}/gtags
gtags_DATA = PLUGIN_HOWTO
EXTRA_DIST = $(gtags_DATA)
_______________________________________________
Bug-global mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-global