logo

overlay

My own overlay for experimentations, use with caution, no support is provided git clone https://hacktivis.me/git/overlay.git
commit: 4e08efb7ee592458fe84a1a7a716a06498bbc66c
parent a214a5a51575819aa5f5e4d729eba0d3b054c03d
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Wed, 17 Mar 2021 16:16:29 +0100

gstreamer-meson.eclass: Port _gstreamer_get_target_filename script to perl

Diffstat:

Meclass/gstreamer-meson.eclass43+++++++++++++++++++++++++++----------------
1 file changed, 27 insertions(+), 16 deletions(-)

diff --git a/eclass/gstreamer-meson.eclass b/eclass/gstreamer-meson.eclass @@ -120,6 +120,7 @@ RDEPEND=" BDEPEND=" >=sys-apps/sed-4 virtual/pkgconfig + virtual/perl-JSON-PP " # Export common multilib phases. @@ -237,26 +238,36 @@ gstreamer_multilib_src_configure() { # @FUNCTION: _gstreamer_get_target_filename # @INTERNAL # @DESCRIPTION: -# Extracts build and target filenames from meson-data for given submatch +# Looks for first argument being present as a substring in install targets +# Got ported from python to perl for greater language-stability _gstreamer_get_target_filename() { - cat >"${WORKDIR}/_gstreamer_get_target_filename.py" <<"EOF" -import json -import sys - -with open("meson-info/intro-targets.json", "r") as targets_file: - data = json.load(targets_file) - -for i in range(len(data)): - target = data[i] - if target['installed']: - if sys.argv[1] in target['filename'][0]: - print(target['filename'][0] + ':' + target['install_filename'][0]) + cat >"${WORKDIR}/_gstreamer_get_target_filename.pl" <<"EOF" +#!/usr/bin/env perl +use strict; +use utf8; +use JSON::PP; + +open(my $targets_file, '<:encoding(UTF-8)', 'meson-info/intro-targets.json') || die $!; +my $data = decode_json <$targets_file>; +close($targets_file) || die $!; + +if(!$ARGV[0]) { + die "Requires a target as argument"; +} + +foreach my $target (@{$data}) { + if($target->{'installed'} + and (index($target->{'filename'}[0], $ARGV[0]) != -1) + ) { + printf "%s:%s\n", $target->{'filename'}[0], $target->{'install_filename'}[0]; + } +} EOF - chmod +x "${WORKDIR}/_gstreamer_get_target_filename.py" || die + chmod +x "${WORKDIR}/_gstreamer_get_target_filename.pl" || die - ${EPYTHON} "${WORKDIR}/_gstreamer_get_target_filename.py" $@ \ - || die "Failed to extract target filenames from meson-data" + perl "${WORKDIR}/_gstreamer_get_target_filename.pl" $@ \ + || die "Failed to extract target filenames from meson-info" } # @FUNCTION: gstreamer_multilib_src_compile