Skip to content

Fix gcc locations and installation #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion gcc-c-api/gcc-location.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion gccutils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down