File: add-multilib-section.sh

package info (click to toggle)
ldc 1%3A1.30.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 59,248 kB
  • sloc: cpp: 61,598; ansic: 14,545; sh: 1,014; makefile: 972; asm: 510; objc: 135; exp: 48; python: 12
file content (45 lines) | stat: -rwxr-xr-x 1,025 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env bash

set -euo pipefail

if [ "$#" -ne 6 ]; then
  echo "Usage: $0 <path/to/ldc2> <32|64> <path/to/multilib-dir> <rpath> <path/to/input.conf> <path/to/output.conf>"
  exit 1
fi

ldc=$1
bitness=$2
libdir=$3
rpath=$4
input_conf=$5
output_conf=$6

# parse multilib triple from `-v` output
set +e
# extract `config    /path/to/ldc2.conf (i686-unknown-linux-gnu)`
triple="$(echo "module object;" | $ldc -m$bitness -v -o- -conf=$input_conf - | grep -m 1 '^config')"
triple="${triple##* (}" # `i686-unknown-linux-gnu)`
triple="${triple%)}"    # `i686-unknown-linux-gnu`
if [ "${triple//[^-]/}" = "---" ]; then
  # ignore vendor => `i686-.*-linux-gnu`
  triple="$(echo "$triple" | sed -e 's/-[^-]*/-.*/')"
fi
set -e

cp $input_conf $output_conf

if [ -z "$triple" ]; then
  echo "Error: failed to parse triple from \"$ldc -m$bitness -v\" output"
  exit 1
fi

# append config file section
section="
\"$triple\":
{
    lib-dirs = [
        \"$libdir\",
    ];
    rpath = \"$rpath\";
};"
echo "$section" >> $output_conf