diff --git a/Makefile b/Makefile index fc8bbeee..229a6383 100644 --- a/Makefile +++ b/Makefile @@ -99,6 +99,7 @@ PYTHON_CONFIG=python-config PYTHON_INCLUDES=$(shell $(PYTHON_CONFIG) --includes) PYTHON_LIBS=$(shell $(PYTHON_CONFIG) --libs) +PYTHON_SITE_DIR=$(shell $(PYTHON) -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") # Support having multiple named plugins # e.g. "python2.7" "python3.2mu" "python 3.2dmu" etc: @@ -234,6 +235,10 @@ install: $(PLUGIN_DSO) gcc-with-$(PLUGIN_NAME).1.gz cp -a gccutils $(DESTDIR)$(GCCPLUGINS_DIR)/$(PLUGIN_DIR) cp -a libcpychecker $(DESTDIR)$(GCCPLUGINS_DIR)/$(PLUGIN_DIR) + # add python dir to python search path + mkdir -p $(PYTHON_SITE_DIR) + echo "$(DESTDIR)$(GCCPLUGINS_DIR)/$(PLUGIN_DIR)" > $(PYTHON_SITE_DIR)/gcc-python-plugin.pth + # Create "gcc-with-" support script: mkdir -p $(DESTDIR)$(bindir) install -m 755 gcc-with-python $(DESTDIR)/$(bindir)/gcc-with-$(PLUGIN_NAME) diff --git a/gcc-c-api/gcc-location.c b/gcc-c-api/gcc-location.c index c3b26875..d4e1d842 100644 --- a/gcc-c-api/gcc-location.c +++ b/gcc-c-api/gcc-location.c @@ -54,7 +54,7 @@ GCC_IMPLEMENT_PUBLIC_API (int) gcc_location_get_column (gcc_location loc) GCC_PUBLIC_API (bool) gcc_location_is_unknown (gcc_location loc) { - return UNKNOWN_LOCATION == loc.inner; + return UNKNOWN_LOCATION == loc.inner || !gcc_location_get_filename(loc); } GCC_IMPLEMENT_PUBLIC_API (bool) gcc_location_get_in_system_header (gcc_location loc) diff --git a/gccutils/__init__.py b/gccutils/__init__.py index 2d3064a5..2c8c5d2f 100644 --- a/gccutils/__init__.py +++ b/gccutils/__init__.py @@ -24,7 +24,10 @@ def sorted_dict_repr(d): def get_src_for_loc(loc): # Given a gcc.Location, get the source line as a string import linecache - return linecache.getline(loc.file, loc.line).rstrip() + try: + return linecache.getline(loc.file, loc.line).rstrip() + except SyntaxError: # unrecognized encoding of file + return '' def get_field_by_name(typeobj, name): check_isinstance(typeobj,