build script: remove libs keyword update for .pc file

This commit is contained in:
alexey.lysiuk 2020-12-12 11:59:59 +02:00
parent efb613729e
commit 3d90ee852e

View file

@ -89,8 +89,7 @@ class Target(BaseTarget):
self.prefix = None self.prefix = None
self.environment = os.environ self.environment = os.environ
self.options = CommandLineOptions() self.options = CommandLineOptions()
# Mapping of .pc files' base names to extra libraries' names self.pkg_proc = None
self.pkg_libs = {}
def initialize(self, builder: 'Builder'): def initialize(self, builder: 'Builder'):
self.prefix = builder.deps_path + self.name self.prefix = builder.deps_path + self.name
@ -142,7 +141,7 @@ class Target(BaseTarget):
self.update_pc_files(builder) self.update_pc_files(builder)
@staticmethod @staticmethod
def update_pc_file(path: str, extra_libs: str = None, processor: typing.Callable = None): def update_pc_file(path: str, processor: typing.Callable = None):
with open(path, 'r') as f: with open(path, 'r') as f:
content = f.readlines() content = f.readlines()
@ -155,16 +154,9 @@ class Target(BaseTarget):
if line.startswith(prefix): if line.startswith(prefix):
# Clear prefix variable # Clear prefix variable
patched_line = prefix + os.linesep patched_line = prefix + os.linesep
elif extra_libs and line.startswith('Libs:'):
# Append extra libraries to link with
if extra_libs not in line:
patched_line = line.rstrip('\n') + ' ' + extra_libs + os.linesep
elif line.startswith('Libs.private:'):
# Remove private libraries
continue
if processor: if processor:
patched_line = processor(patched_line) patched_line = processor(path, patched_line)
if not patched_line: if not patched_line:
continue continue
@ -179,9 +171,7 @@ class Target(BaseTarget):
for filename in files: for filename in files:
if filename.endswith('.pc'): if filename.endswith('.pc'):
file_path = root + os.sep + filename file_path = root + os.sep + filename
filename = os.path.splitext(filename)[0] Target.update_pc_file(file_path, self.pkg_proc)
extra_libs = self.pkg_libs[filename] if filename in self.pkg_libs else None
Target.update_pc_file(file_path, extra_libs)
class MakeTarget(Target): class MakeTarget(Target):
@ -709,7 +699,6 @@ class FlacTarget(ConfigureMakeStaticDependencyTarget):
def __init__(self, name='flac'): def __init__(self, name='flac'):
super().__init__(name) super().__init__(name)
self.options['--enable-cpplibs'] = 'no' self.options['--enable-cpplibs'] = 'no'
self.pkg_libs = {'flac': '-logg'}
def prepare_source(self, builder: 'Builder'): def prepare_source(self, builder: 'Builder'):
builder.download_source( builder.download_source(
@ -741,10 +730,6 @@ class GettextTarget(ConfigureMakeStaticDependencyTarget):
class GlibTarget(Target): class GlibTarget(Target):
def __init__(self, name='glib'): def __init__(self, name='glib'):
super().__init__(name) super().__init__(name)
self.pkg_libs = {
'glib-2.0': '-lffi -lpcre -framework CoreFoundation -framework Foundation',
'gobject-2.0': '-lffi'
}
def prepare_source(self, builder: 'Builder'): def prepare_source(self, builder: 'Builder'):
builder.download_source( builder.download_source(
@ -962,8 +947,8 @@ class OggTarget(ConfigureMakeStaticDependencyTarget):
class OpenALTarget(CMakeStaticDependencyTarget): class OpenALTarget(CMakeStaticDependencyTarget):
def __init__(self, name='openal'): def __init__(self, name='openal'):
super().__init__(name) super().__init__(name)
self.pkg_libs = {'openal': '-framework ApplicationServices -framework AudioToolbox ' self.pkg_proc = OpenALTarget._pkg_proc
'-framework AudioUnit -framework CoreAudio'}
opts = self.options opts = self.options
opts['ALSOFT_EXAMPLES'] = 'NO' opts['ALSOFT_EXAMPLES'] = 'NO'
opts['ALSOFT_UTILS'] = 'NO' opts['ALSOFT_UTILS'] = 'NO'
@ -976,6 +961,17 @@ class OpenALTarget(CMakeStaticDependencyTarget):
def detect(self, builder: 'Builder') -> bool: def detect(self, builder: 'Builder') -> bool:
return os.path.exists(builder.source_path + 'openal.pc.in') return os.path.exists(builder.source_path + 'openal.pc.in')
@staticmethod
def _pkg_proc(_, line: str):
libs_private = 'Libs.private:'
if line.startswith(libs_private):
# Fix full paths to OS frameworks
return libs_private + ' -framework ApplicationServices -framework AudioToolbox'\
' -framework AudioUnit -framework CoreAudio' + os.linesep
else:
return line
class OpusTarget(ConfigureMakeStaticDependencyTarget): class OpusTarget(ConfigureMakeStaticDependencyTarget):
def __init__(self, name='opus'): def __init__(self, name='opus'):
@ -995,7 +991,6 @@ class OpusFileTarget(ConfigureMakeStaticDependencyTarget):
def __init__(self, name='opusfile'): def __init__(self, name='opusfile'):
super().__init__(name) super().__init__(name)
self.options['--enable-http'] = 'no' self.options['--enable-http'] = 'no'
self.pkg_libs = {'opusfile': '-lopus -logg'}
def prepare_source(self, builder: 'Builder'): def prepare_source(self, builder: 'Builder'):
builder.download_source( builder.download_source(
@ -1044,7 +1039,6 @@ class PkgConfigTarget(ConfigureMakeDependencyTarget):
class SndFileTarget(CMakeStaticDependencyTarget): class SndFileTarget(CMakeStaticDependencyTarget):
def __init__(self, name='sndfile'): def __init__(self, name='sndfile'):
super().__init__(name) super().__init__(name)
self.pkg_libs = {'sndfile': '-lopus -lFLAC -lvorbisenc -lvorbis -logg'}
opts = self.options opts = self.options
opts['BUILD_REGTEST'] = 'NO' opts['BUILD_REGTEST'] = 'NO'
@ -1062,11 +1056,6 @@ class SndFileTarget(CMakeStaticDependencyTarget):
class VorbisTarget(ConfigureMakeStaticDependencyTarget): class VorbisTarget(ConfigureMakeStaticDependencyTarget):
def __init__(self, name='vorbis'): def __init__(self, name='vorbis'):
super().__init__(name) super().__init__(name)
self.pkg_libs = {
'vorbis': '-logg',
'vorbisenc': '-lvorbis -logg',
'vorbisfile': '-lvorbis -logg',
}
def prepare_source(self, builder: 'Builder'): def prepare_source(self, builder: 'Builder'):
builder.download_source( builder.download_source(