ajwillia-ms pushed a commit to branch master.

http://git.enlightenment.org/tools/edi.git/commit/?id=d03675ba71c68be163c85482d6d2a8233da2fc2d

commit d03675ba71c68be163c85482d6d2a8233da2fc2d
Author: Andy Williams <a...@andywilliams.me>
Date:   Sun Apr 12 22:25:41 2015 +0100

    clang: fix paths used in syntax lookup
    
    Pass in the edi build config to get efl params.
    Also find the correct system include for clang dynamically
---
 configure.ac                |  3 ++-
 src/bin/Makefile.am         |  4 ++++
 src/bin/editor/edi_editor.c | 11 +++++++----
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/configure.ac b/configure.ac
index 64668e0..4cb3467 100644
--- a/configure.ac
+++ b/configure.ac
@@ -132,7 +132,8 @@ fi
 if test "${have_clang}" = "no"; then
    AC_MSG_WARN([Could not find a usable libclang. Please install libclang to 
enable syntax highlighting features.])
 fi
-
+CLANG_INCLUDE=`clang -E - -v < /dev/null 2>&1 | grep "^ /usr" | grep clang`
+AC_SUBST([CLANG_INCLUDE])
 
 AC_CONFIG_FILES([
 Makefile
diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am
index 3d68962..cab5e83 100644
--- a/src/bin/Makefile.am
+++ b/src/bin/Makefile.am
@@ -2,6 +2,8 @@ MAINTAINERCLEANFILES = Makefile.in
 AUTOMAKE_OPTIONS = subdir-objects
 
 bin_PROGRAMS = edi edi_build
+efl_cflags_safe = '@EFL_CFLAGS@'
+clang_include = '$(CLANG_INCLUDE)'
 
 AM_CPPFLAGS = \
 -DPACKAGE_BIN_DIR=\"$(bindir)\" \
@@ -15,6 +17,8 @@ AM_CPPFLAGS = \
 -I$(top_srcdir)/elm_code/src/lib \
 -I$(top_builddir)/src/lib \
 -DEFL_BETA_API_SUPPORT \
+-DEFL_CFLAGS=\"$(efl_cflags_safe)\" \
+-DCLANG_INCLUDES=\"-I$(clang_include)\" \
 @EFL_CFLAGS@
 
 noinst_HEADERS = \
diff --git a/src/bin/editor/edi_editor.c b/src/bin/editor/edi_editor.c
index a932913..19c1a29 100644
--- a/src/bin/editor/edi_editor.c
+++ b/src/bin/editor/edi_editor.c
@@ -491,7 +491,9 @@ _edi_clang_setup(void *data)
 {
    Edi_Editor *editor;
    Elm_Code *code;
-   const char *path;
+   const char *path, *args;
+   char **clang_argv;
+   unsigned int clang_argc;
 
    editor = (Edi_Editor *)data;
    eo_do(editor->entry,
@@ -500,13 +502,14 @@ _edi_clang_setup(void *data)
 
    /* Clang */
    /* FIXME: index should probably be global. */
-   const char *clang_argv[] = {"-I/usr/lib/clang/3.1/include/", "-Wall", 
"-Wextra"};
-   int clang_argc = sizeof(clang_argv) / sizeof(*clang_argv);
+   args = "-I/usr/inclue/ " EFL_CFLAGS " " CLANG_INCLUDES " -Wall -Wextra";
+   clang_argv = eina_str_split_full(args, " ", 0, &clang_argc);
 
    editor->idx = clang_createIndex(0, 0);
 
    /* FIXME: Possibly activate more options? */
-   editor->tx_unit = clang_parseTranslationUnit(editor->idx, path, clang_argv, 
clang_argc, NULL, 0, clang_defaultEditingTranslationUnitOptions() | 
CXTranslationUnit_DetailedPreprocessingRecord);
+   editor->tx_unit = clang_parseTranslationUnit(editor->idx, path, (const char 
*const *)clang_argv, (int)clang_argc, NULL, 0,
+     clang_defaultEditingTranslationUnitOptions() | 
CXTranslationUnit_DetailedPreprocessingRecord);
 
    _clang_load_errors(path, editor);
    _clang_load_highlighting(path, editor);

-- 


Reply via email to