@@ -40,8 +40,9 @@ def file_to_symbols(lib_file, is_shared_lib):
4040 # run c++filt to demangle output from nm
4141 cppfilt_command = ['c++filt' , '-r' ]
4242 cppfilt_process_result = subprocess .run (cppfilt_command , stdout = subprocess .PIPE , stderr = subprocess .STDOUT , input = nm_process_result .stdout )
43- cppfilt_process_output_std = cppfilt_process_result .stdout .decode ('utf-8' )
43+ return cppfilt_process_result .stdout .decode ('utf-8' )
4444
45+ def find_api_symbols (symbols ):
4546 ignore_list = [
4647 # ignore ramses internal and Impl
4748 r'ramses::internal::' ,
@@ -53,22 +54,44 @@ def file_to_symbols(lib_file, is_shared_lib):
5354 # 0000000000001d30 T ramses::Appearance::unbindInput(ramses::UniformInput const&)
5455 symbol_regex = re .compile (rf"^([0-9A-Fa-f]+)(\s+)[TB](\s+)({ ignore_regex } .*)" , re .MULTILINE )
5556
56- lib_symbols = [s .group (4 ) for s in re .finditer (symbol_regex , cppfilt_process_output_std )]
57+ return [s .group (4 ) for s in re .finditer (symbol_regex , symbols )]
58+
59+ def check_missing_api_symbols (static_lib_symbols , shared_lib_symbols ):
60+ static_lib_symbols = find_api_symbols (static_lib_symbols )
61+ shared_lib_symbols = find_api_symbols (shared_lib_symbols )
62+ missing_symbols = [s for s in static_lib_symbols if s not in shared_lib_symbols ]
63+ if len (static_lib_symbols ) == 0 :
64+ raise Exception ("No API symbols found in static lib (internal error)" )
65+ if len (shared_lib_symbols ) == 0 :
66+ raise Exception ("No API symbols found in shared lib (internal error)" )
67+ if len (missing_symbols ) > 0 :
68+ raise Exception (f"FOUND MISSING SYMBOLS: { missing_symbols } " )
69+
70+ def check_unique_exports (headless , full ):
71+ # check interface between headless and full shared lib
72+ symbols = [
73+ 'ramses::internal::ErrorReporting' ,
74+ 'ramses::internal::FrameworkFactoryRegistry' ,
75+ 'ramses::internal::RamsesFrameworkImpl' ,
76+ 'ramses::internal::GetRamsesLogger' ,
77+ ]
78+ for s in symbols :
79+ if s not in headless :
80+ raise Exception (f"Symbol missing in headless-shared-lib: { s } " )
81+ if s in full :
82+ raise Exception (f"Unexpected symbol in full-shared-lib:: { s } " )
5783
58- return lib_symbols
84+ static_lib_headless_symbols = file_to_symbols (client_static_lib_dir , False )
85+ static_lib_headless_symbols += file_to_symbols (framework_static_lib_dir , False )
86+ shared_lib_headless_symbols = file_to_symbols (headless_shared_lib_dir , True )
5987
60- static_lib_symbols = file_to_symbols (client_static_lib_dir , False )
61- static_lib_symbols += file_to_symbols (framework_static_lib_dir , False )
62- if not headless_only :
63- static_lib_symbols += file_to_symbols (renderer_static_lib_dir , False )
88+ check_missing_api_symbols (static_lib_headless_symbols , shared_lib_headless_symbols )
6489
65- shared_lib_symbols = file_to_symbols (headless_shared_lib_dir , True )
6690 if not headless_only :
67- shared_lib_symbols += file_to_symbols (full_shared_lib_dir , True )
68-
69- missing_symbols = [s for s in static_lib_symbols if s not in shared_lib_symbols ]
70- if len (missing_symbols ) > 0 :
71- raise Exception (f"FOUND MISSING SYMBOLS: { missing_symbols } " )
91+ static_lib_symbols = file_to_symbols (renderer_static_lib_dir , False )
92+ shared_lib_symbols = file_to_symbols (full_shared_lib_dir , True )
93+ check_missing_api_symbols (static_lib_symbols , shared_lib_symbols )
94+ check_unique_exports (shared_lib_headless_symbols , shared_lib_symbols )
7295
7396
7497if __name__ == "__main__" :
0 commit comments