build script: extract function to update prefix in shell script

This commit is contained in:
alexey.lysiuk 2020-12-15 12:38:27 +02:00
parent f9eaa08439
commit 758588f140

View file

@ -155,6 +155,18 @@ class Target(BaseTarget):
with open(path, 'w') as f:
f.writelines(patched_content)
@staticmethod
def update_prefix_shell_script(path: str):
prefix = 'prefix='
def update_prefix(line: str) -> str:
if line.startswith(prefix):
return prefix + r'"$(cd "${0%/*}/.."; pwd)"' + os.linesep
return line
Target.update_text_file(path, update_prefix)
@staticmethod
def update_pc_file(path: str, processor: typing.Callable = None):
prefix = 'prefix='
@ -1127,16 +1139,7 @@ class PngTarget(ConfigureMakeStaticDependencyTarget):
def post_build(self, builder: 'Builder'):
super().post_build(builder)
prefix = 'prefix='
def update_prefix(line: str) -> str:
if line.startswith(prefix):
return prefix + r'"$(cd "${0%/*}/.."; pwd)"' + os.linesep
return line
Target.update_text_file(builder.prefix_path + '/bin/libpng16-config', update_prefix)
Target.update_prefix_shell_script(builder.prefix_path + '/bin/libpng16-config')
class SndFileTarget(CMakeStaticDependencyTarget):