2 # Copyright (C) 2021-2022 Free Software Foundation, Inc.
3 # This file is part of the GNU C Library.
5 # The GNU C Library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
10 # The GNU C Library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with the GNU C Library; if not, see
17 # <https://www.gnu.org/licenses/>.
19 def get_glibc_shared_code(path
):
20 """ Get glibc shared code information from a file
22 The input file must have project names in their own line ending with a colon
23 and all shared files in the project on their own lines following the project
24 name. Whitespaces are ignored. Lines with # as the first non-whitespace
25 character are ignored.
28 path: The path to file containing shared code information.
31 A dictionary with project names as key and lists of files as values.
35 with
open(path
, 'r') as f
:
36 for line
in f
.readlines():
38 if len(line
) == 0 or line
[0] == '#':
44 projects
[cur
].append(line
)
50 from os
import EX_NOINPUT
51 from os
.path
import exists
54 if __name__
== '__main__':
55 if len(sys
.argv
) != 2:
56 print('Usage: %s <file name>' % sys
.argv
[0])
57 print('Run this script from the base glibc source directory')
60 print('Testing get_glibc_shared_code with %s:\n' % sys
.argv
[1])
61 r
= get_glibc_shared_code(sys
.argv
[1])
66 print('%s does not exist' % f
)