Skip to content

Commit

Permalink
Fix handling of PKG_CONFIG_SYSROOT_DIR
Browse files Browse the repository at this point in the history
This fixes the handling of the PKG_CONFIG_SYSROOT_DIR environmental
variable which was previously ignored.

Change-Id: I18f33f0ebd00527190e8eb0360bdc6e9d6155cc3
  • Loading branch information
JoshuaWatt committed Jun 24, 2015
1 parent 737b6a8 commit 814b0ab
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions pykg_config/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,20 +191,25 @@ def _process_props(self, global_variables):
self.properties['requires']
self.properties['conflicts'] = \
parse_package_spec_list(props['conflicts'])
self._parse_cflags(props['cflags'])
self._parse_libs(props['libs'])
self._parse_libs(props['libs.private'], dest='private.')
self._parse_cflags(props['cflags'], global_variables)
self._parse_libs(props['libs'], global_variables)
self._parse_libs(props['libs.private'], global_variables, dest='private.')

def _parse_cflags(self, value):
def _parse_cflags(self, value, global_variables):
flags = shlex.split(value, posix=False)
for flag in flags:
if flag.startswith('-I'):
if flag[2:] not in \
Options().get_option('forbidden_cflags'):
# Prepend pc_sysrootdir if necessary
pc_sysrootdir = Options().get_option('pc_sysrootdir')
pc_sysrootdir = global_variables['pc_sysrootdir']
if pc_sysrootdir:
include_dir = join(pc_sysrootdir, flag[2:].strip())
# Strip the leading slashes from the flag path
# because os.path.join() will ignore
# pc_sysrootdir if it thinks the flag is an
# absolute path
include_dir = join(pc_sysrootdir,
flag[2:].strip().lstrip('/'))
else:
include_dir = flag[2:].strip()
if Options().get_option('full_compatibility') and \
Expand All @@ -222,7 +227,7 @@ def _parse_cflags(self, value):
self.properties['other_cflags'].append(flag.strip())


def _parse_libs(self, value, dest=''):
def _parse_libs(self, value, global_variables, dest=''):
# Parse lib flags
libs = shlex.split(value)
skip_next = False
Expand All @@ -238,9 +243,14 @@ def _parse_libs(self, value, dest=''):
if lib[2:] not in \
Options().get_option('forbidden_libdirs'):
# Prepend pc_sysrootdir if necessary
pc_sysrootdir = Options().get_option('pc_sysrootdir')
pc_sysrootdir = global_variables['pc_sysrootdir']
if pc_sysrootdir:
libpath = join(pc_sysrootdir, lib[2:].strip())
# Strip the leading slashes from the flag path
# because os.path.join() will ignore
# pc_sysrootdir if it thinks the flag is an
# absolute path
libpath = join(pc_sysrootdir,
lib[2:].strip().lstrip('/'))
else:
libpath = lib[2:].strip()
if Options().get_option('full_compatibility'):
Expand Down

0 comments on commit 814b0ab

Please sign in to comment.