@@ -54,40 +54,70 @@ def defined_function_list(object):
54
54
help = 'path to libstdc++ DSO directory' ,
55
55
default = '/usr/lib/x86_64-linux-gnu' )
56
56
57
+ p .add_option ('--only-explicit-files' , action = 'store_true' ,
58
+ dest = 'only_explicit_files' , default = False ,
59
+ help = 'Only process --lib-file, not the default libc libraries.' )
60
+ p .add_option ('--lib-file' , action = 'append' , metavar = 'PATH' ,
61
+ help = 'Specific library files to add.' ,
62
+ default = [])
63
+
64
+ p .add_option ('--error-missing-lib' , action = 'store_true' ,
65
+ help = 'Make this script exit with an error code if any library is missing.' ,
66
+ dest = 'error_missing_lib' , default = False )
67
+
57
68
(options , args ) = p .parse_args ()
58
69
59
- libs = [os .path .join (options .libc_dso_path , name ) for name in
60
- ['ld-linux-x86-64.so.2' ,
61
- 'libanl.so.1' ,
62
- 'libBrokenLocale.so.1' ,
63
- 'libcidn.so.1' ,
64
- 'libcrypt.so.1' ,
65
- 'libc.so.6' ,
66
- 'libdl.so.2' ,
67
- 'libm.so.6' ,
68
- 'libnsl.so.1' ,
69
- 'libpthread.so.0' ,
70
- 'libresolv.so.2' ,
71
- 'librt.so.1' ,
72
- 'libthread_db.so.1' ,
73
- 'libutil.so.1' ]]
74
- libs += [os .path .join (options .libc_archive_path , name ) for name in
75
- ['libc_nonshared.a' ,
76
- 'libpthread_nonshared.a' ]]
77
-
78
- libs .append (os .path .join (options .libgcc_dso_path , 'libgcc_s.so.1' ))
79
- libs .append (os .path .join (options .libgcc_archive_path , 'libgcc.a' ))
80
-
81
- if options .with_libstdcxx :
82
- libs .append (os .path .join (options .libstdcxx_dso_path , 'libstdc++.so.6' ))
70
+ def build_libs_list ():
71
+ libs = [os .path .join (options .libc_dso_path , name ) for name in
72
+ ['ld-linux-x86-64.so.2' ,
73
+ 'libanl.so.1' ,
74
+ 'libBrokenLocale.so.1' ,
75
+ 'libcidn.so.1' ,
76
+ 'libcrypt.so.1' ,
77
+ 'libc.so.6' ,
78
+ 'libdl.so.2' ,
79
+ 'libm.so.6' ,
80
+ 'libnsl.so.1' ,
81
+ 'libpthread.so.0' ,
82
+ 'libresolv.so.2' ,
83
+ 'librt.so.1' ,
84
+ 'libthread_db.so.1' ,
85
+ 'libutil.so.1' ]]
86
+ libs += [os .path .join (options .libc_archive_path , name ) for name in
87
+ ['libc_nonshared.a' ,
88
+ 'libpthread_nonshared.a' ]]
89
+
90
+ libs .append (os .path .join (options .libgcc_dso_path , 'libgcc_s.so.1' ))
91
+ libs .append (os .path .join (options .libgcc_archive_path , 'libgcc.a' ))
92
+
93
+ if options .with_libstdcxx :
94
+ libs .append (os .path .join (options .libstdcxx_dso_path , 'libstdc++.so.6' ))
83
95
96
+ return libs
97
+
98
+ libs = []
99
+ if options .only_explicit_files :
100
+ libs = options .lib_file
101
+ if not libs :
102
+ print >> sys .stderr , 'No libraries provided.'
103
+ exit (1 )
104
+ else :
105
+ libs = build_libs_list ()
106
+ libs .extend (options .lib_file )
107
+
108
+ missing_lib = False
84
109
functions = []
85
110
for l in libs :
86
111
if os .path .exists (l ):
87
112
functions += defined_function_list (l )
88
113
else :
114
+ missing_lib = True
89
115
print >> sys .stderr , 'warning: library %s not found' % l
90
116
117
+ if options .error_missing_lib and missing_lib :
118
+ print >> sys .stderr , 'Exiting with failure code due to missing library.'
119
+ exit (1 )
120
+
91
121
functions = list (set (functions ))
92
122
functions .sort ()
93
123
0 commit comments