• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7set -e
8
9OUT=$1
10shift
11for v; do
12  # Extract all the libbrillo sublibs from 'dependencies' section of
13  # 'libbrillo-<(libbase_ver)' target in libbrillo.gypi and convert them
14  # into an array of "-lbrillo-<sublib>-<v>" flags.
15  sublibs=($(sed -n "
16     /'target_name': 'libbrillo-<(libbase_ver)'/,/target_name/ {
17       /dependencies/,/],/ {
18         /libbrillo/ {
19           s:[',]::g
20           s:<(libbase_ver):${v}:g
21           s:libbrillo:-lbrillo:
22           p
23         }
24       }
25     }" libbrillo.gypi))
26
27  echo "GROUP ( AS_NEEDED ( ${sublibs[@]} ) )" > "${OUT}"/lib/libbrillo-${v}.so
28
29  deps=$(<"${OUT}"/gen/libbrillo-${v}-deps.txt)
30  pc="${OUT}"/lib/libbrillo-${v}.pc
31
32  sed \
33    -e "s/@BSLOT@/${v}/g" \
34    -e "s/@PRIVATE_PC@/${deps}/g" \
35    "libbrillo.pc.in" > "${pc}"
36
37  deps_test=$(<"${OUT}"/gen/libbrillo-test-${v}-deps.txt)
38  deps_test+=" libbrillo-${v}"
39  sed \
40    -e "s/@BSLOT@/${v}/g" \
41    -e "s/@PRIVATE_PC@/${deps_test}/g" \
42    "libbrillo-test.pc.in" > "${OUT}/lib/libbrillo-test-${v}.pc"
43
44
45  deps_glib=$(<"${OUT}"/gen/libbrillo-glib-${v}-deps.txt)
46  pc_glib="${OUT}"/lib/libbrillo-glib-${v}.pc
47
48  sed \
49    -e "s/@BSLOT@/${v}/g" \
50    -e "s/@PRIVATE_PC@/${deps_glib}/g" \
51    "libbrillo-glib.pc.in" > "${pc_glib}"
52done
53