1b815c7f3Sopenharmony_ci#!/usr/bin/python 2b815c7f3Sopenharmony_ci 3b815c7f3Sopenharmony_ciimport commands, os, re, string, sys, time 4b815c7f3Sopenharmony_ci 5b815c7f3Sopenharmony_cidef count_enclosed_functions (source): 6b815c7f3Sopenharmony_ci func_count = 0 7b815c7f3Sopenharmony_ci open_brace = 0 8b815c7f3Sopenharmony_ci close_brace = 0 9b815c7f3Sopenharmony_ci for ch in source: 10b815c7f3Sopenharmony_ci if ch == '{': 11b815c7f3Sopenharmony_ci open_brace += 1 12b815c7f3Sopenharmony_ci elif ch == '}': 13b815c7f3Sopenharmony_ci close_brace += 1 14b815c7f3Sopenharmony_ci if open_brace == close_brace: 15b815c7f3Sopenharmony_ci func_count += 1 16b815c7f3Sopenharmony_ci if open_brace < close_brace: 17b815c7f3Sopenharmony_ci print "count_enclosed_functions : open_brace < close_brace" 18b815c7f3Sopenharmony_ci return -1 19b815c7f3Sopenharmony_ci return func_count 20b815c7f3Sopenharmony_ci 21b815c7f3Sopenharmony_cidef find_function_prototype (source, proto_name): 22b815c7f3Sopenharmony_ci proto_re = "(^[a-zA-Z_ \t]+\s+%s[^a-zA-Z0-9_]\s*\([^\)]+\)\s+;\n)" % (proto_name) 23b815c7f3Sopenharmony_ci proto_result = re.search (proto_re, source, re.MULTILINE | re.DOTALL) 24b815c7f3Sopenharmony_ci if not proto_result: 25b815c7f3Sopenharmony_ci return None 26b815c7f3Sopenharmony_ci proto_text = proto_result.groups ()[0] 27b815c7f3Sopenharmony_ci return proto_text 28b815c7f3Sopenharmony_ci 29b815c7f3Sopenharmony_cidef find_function_definition (source, func_name): 30b815c7f3Sopenharmony_ci func_re = "(\n[a-zA-Z_ \t]+\n%s[^a-zA-Z0-9_].* /\* %s \*/\n)" % (func_name, func_name) 31b815c7f3Sopenharmony_ci func_result = re.search (func_re, source, re.MULTILINE | re.DOTALL) 32b815c7f3Sopenharmony_ci if not func_result: 33b815c7f3Sopenharmony_ci sys.exit (1) 34b815c7f3Sopenharmony_ci return None 35b815c7f3Sopenharmony_ci func_text = func_result.groups ()[0] 36b815c7f3Sopenharmony_ci 37b815c7f3Sopenharmony_ci # Now to check that we only have one enclosing function. 38b815c7f3Sopenharmony_ci func_count = count_enclosed_functions (func_text) 39b815c7f3Sopenharmony_ci if func_count != 1: 40b815c7f3Sopenharmony_ci return None 41b815c7f3Sopenharmony_ci return func_text 42b815c7f3Sopenharmony_ci 43b815c7f3Sopenharmony_cidef find_include (source, inc_name): 44b815c7f3Sopenharmony_ci inc_re = "(^#include\s+[\<\"]%s[\"\>]\s*)" % inc_name 45b815c7f3Sopenharmony_ci inc_result = re.search (inc_re, source, re.MULTILINE | re.DOTALL) 46b815c7f3Sopenharmony_ci if not inc_result: 47b815c7f3Sopenharmony_ci return None 48b815c7f3Sopenharmony_ci inc_text = inc_result.groups ()[0] 49b815c7f3Sopenharmony_ci return inc_text 50b815c7f3Sopenharmony_ci 51b815c7f3Sopenharmony_cidef find_assign_statement (source, var_name): 52b815c7f3Sopenharmony_ci var_re = "(^\s+%s\s*=[^;]+;)" % var_name 53b815c7f3Sopenharmony_ci var_result = re.search (var_re, source, re.MULTILINE | re.DOTALL) 54b815c7f3Sopenharmony_ci if not var_result: 55b815c7f3Sopenharmony_ci return None 56b815c7f3Sopenharmony_ci assign_text = var_result.groups ()[0] 57b815c7f3Sopenharmony_ci return assign_text 58b815c7f3Sopenharmony_ci 59b815c7f3Sopenharmony_ci#-------------------------------------------------------------------------------- 60b815c7f3Sopenharmony_ci 61b815c7f3Sopenharmony_cidef remove_include (source, inc_name): 62b815c7f3Sopenharmony_ci inc_text = find_include (source, inc_name) 63b815c7f3Sopenharmony_ci if not inc_text: 64b815c7f3Sopenharmony_ci print "remove_include : include '%s' not found. Exiting." % inc_name 65b815c7f3Sopenharmony_ci sys.exit (1) 66b815c7f3Sopenharmony_ci 67b815c7f3Sopenharmony_ci source = string.replace (source, inc_text, "") 68b815c7f3Sopenharmony_ci return source 69b815c7f3Sopenharmony_ci 70b815c7f3Sopenharmony_cidef remove_assign (source, assign_name): 71b815c7f3Sopenharmony_ci assign_text = find_assign (source, inc_name) 72b815c7f3Sopenharmony_ci if not inc_text: 73b815c7f3Sopenharmony_ci print "remove_include : include '%s' not found. Exiting." % inc_name 74b815c7f3Sopenharmony_ci sys.exit (1) 75b815c7f3Sopenharmony_ci 76b815c7f3Sopenharmony_ci source = string.replace (source, inc_text, "") 77b815c7f3Sopenharmony_ci return source 78b815c7f3Sopenharmony_ci 79b815c7f3Sopenharmony_cidef remove_prototype (source, proto_name): 80b815c7f3Sopenharmony_ci proto_text = find_function_prototype (source, proto_name) 81b815c7f3Sopenharmony_ci if not proto_text: 82b815c7f3Sopenharmony_ci print "remove_prototype : prototype '%s' not found. Exiting." % proto_name 83b815c7f3Sopenharmony_ci sys.exit (1) 84b815c7f3Sopenharmony_ci 85b815c7f3Sopenharmony_ci source = string.replace (source, proto_text, "") 86b815c7f3Sopenharmony_ci return source 87b815c7f3Sopenharmony_ci 88b815c7f3Sopenharmony_cidef remove_function (source, func_name): 89b815c7f3Sopenharmony_ci func_text = find_function_definition (source, func_name) 90b815c7f3Sopenharmony_ci if not func_text: 91b815c7f3Sopenharmony_ci print "remove_function : function '%s' not found. Exiting." % func_name 92b815c7f3Sopenharmony_ci sys.exit (1) 93b815c7f3Sopenharmony_ci 94b815c7f3Sopenharmony_ci source = string.replace (source, func_text, "/* Function %s() removed here. */\n" % func_name) 95b815c7f3Sopenharmony_ci return source 96b815c7f3Sopenharmony_ci 97b815c7f3Sopenharmony_cidef remove_all_assignments (source, var): 98b815c7f3Sopenharmony_ci count = 0 99b815c7f3Sopenharmony_ci while 1: 100b815c7f3Sopenharmony_ci assign_text = find_assign_statement (source, var) 101b815c7f3Sopenharmony_ci if not assign_text: 102b815c7f3Sopenharmony_ci if count != 0: 103b815c7f3Sopenharmony_ci break 104b815c7f3Sopenharmony_ci print "remove_all_assignments : variable '%s' not found. Exiting." % var 105b815c7f3Sopenharmony_ci sys.exit (1) 106b815c7f3Sopenharmony_ci 107b815c7f3Sopenharmony_ci source = string.replace (source, assign_text, "") 108b815c7f3Sopenharmony_ci count += 1 109b815c7f3Sopenharmony_ci return source 110b815c7f3Sopenharmony_ci 111b815c7f3Sopenharmony_ci 112b815c7f3Sopenharmony_ci 113b815c7f3Sopenharmony_ci#---------------------------------------------------------------- 114b815c7f3Sopenharmony_ci 115b815c7f3Sopenharmony_cidef remove_funcs_and_protos_from_file (filename, func_list): 116b815c7f3Sopenharmony_ci source_code = open (filename, 'r').read () 117b815c7f3Sopenharmony_ci 118b815c7f3Sopenharmony_ci for func in func_list: 119b815c7f3Sopenharmony_ci source_code = remove_prototype (source_code, func) ; 120b815c7f3Sopenharmony_ci source_code = remove_function (source_code, func) ; 121b815c7f3Sopenharmony_ci open (filename, 'w').write (source_code) 122b815c7f3Sopenharmony_ci 123b815c7f3Sopenharmony_cidef remove_funcs_from_file (filename, func_list): 124b815c7f3Sopenharmony_ci source_code = open (filename, 'r').read () 125b815c7f3Sopenharmony_ci 126b815c7f3Sopenharmony_ci for func in func_list: 127b815c7f3Sopenharmony_ci source_code = remove_function (source_code, func) ; 128b815c7f3Sopenharmony_ci open (filename, 'w').write (source_code) 129b815c7f3Sopenharmony_ci 130b815c7f3Sopenharmony_cidef remove_protos_from_file (filename, func_list): 131b815c7f3Sopenharmony_ci source_code = open (filename, 'r').read () 132b815c7f3Sopenharmony_ci 133b815c7f3Sopenharmony_ci for func in func_list: 134b815c7f3Sopenharmony_ci source_code = remove_prototype (source_code, func) ; 135b815c7f3Sopenharmony_ci open (filename, 'w').write (source_code) 136b815c7f3Sopenharmony_ci 137b815c7f3Sopenharmony_cidef remove_includes_from_file (filename, inc_list): 138b815c7f3Sopenharmony_ci source_code = open (filename, 'r').read () 139b815c7f3Sopenharmony_ci 140b815c7f3Sopenharmony_ci for inc in inc_list: 141b815c7f3Sopenharmony_ci source_code = remove_include (source_code, inc) ; 142b815c7f3Sopenharmony_ci open (filename, 'w').write (source_code) 143b815c7f3Sopenharmony_ci 144b815c7f3Sopenharmony_cidef remove_all_assignments_from_file (filename, var_list): 145b815c7f3Sopenharmony_ci source_code = open (filename, 'r').read () 146b815c7f3Sopenharmony_ci 147b815c7f3Sopenharmony_ci for var in var_list: 148b815c7f3Sopenharmony_ci source_code = remove_all_assignments (source_code, var) ; 149b815c7f3Sopenharmony_ci open (filename, 'w').write (source_code) 150b815c7f3Sopenharmony_ci 151b815c7f3Sopenharmony_cidef remove_comment_start_end (filename, start_comment, end_comment): 152b815c7f3Sopenharmony_ci source_code = open (filename, 'r').read () 153b815c7f3Sopenharmony_ci 154b815c7f3Sopenharmony_ci while 1: 155b815c7f3Sopenharmony_ci start_index = string.find (source_code, start_comment) 156b815c7f3Sopenharmony_ci end_index = string.find (source_code, end_comment) 157b815c7f3Sopenharmony_ci if start_index < 0 or end_index < start_index: 158b815c7f3Sopenharmony_ci break 159b815c7f3Sopenharmony_ci end_index += len (end_comment) 160b815c7f3Sopenharmony_ci source_code = source_code [:start_index-1] + source_code [end_index:] ; 161b815c7f3Sopenharmony_ci 162b815c7f3Sopenharmony_ci open (filename, 'w').write (source_code) 163b815c7f3Sopenharmony_ci 164b815c7f3Sopenharmony_cidef remove_strings_from_file (filename, str_list): 165b815c7f3Sopenharmony_ci file_text = open (filename, 'r').read () 166b815c7f3Sopenharmony_ci for current_str in str_list: 167b815c7f3Sopenharmony_ci file_text = string.replace (file_text, current_str, '') 168b815c7f3Sopenharmony_ci open (filename, 'w').write (file_text) 169b815c7f3Sopenharmony_ci 170b815c7f3Sopenharmony_cidef string_replace_in_file (filename, from_str, to_str): 171b815c7f3Sopenharmony_ci file_text = open (filename, 'r').read () 172b815c7f3Sopenharmony_ci file_text = string.replace (file_text, from_str, to_str) 173b815c7f3Sopenharmony_ci open (filename, 'w').write (file_text) 174b815c7f3Sopenharmony_ci 175b815c7f3Sopenharmony_cidef remove_regex_from_file (filename, regex_list): 176b815c7f3Sopenharmony_ci file_text = open (filename, 'r').read () 177b815c7f3Sopenharmony_ci for regex in regex_list: 178b815c7f3Sopenharmony_ci file_text = re.sub (regex, '', file_text, re.MULTILINE | re.DOTALL) 179b815c7f3Sopenharmony_ci open (filename, 'w').write (file_text) 180b815c7f3Sopenharmony_ci 181b815c7f3Sopenharmony_ci#========================================================================== 182b815c7f3Sopenharmony_ci 183b815c7f3Sopenharmony_cidef find_configure_version (filename): 184b815c7f3Sopenharmony_ci # AM_INIT_AUTOMAKE(libsndfile,0.0.21pre6) 185b815c7f3Sopenharmony_ci file = open (filename) 186b815c7f3Sopenharmony_ci while 1: 187b815c7f3Sopenharmony_ci line = file.readline () 188b815c7f3Sopenharmony_ci if re.search ("AC_INIT", line): 189b815c7f3Sopenharmony_ci x = re.sub ("[^\(]+\(", "", line) 190b815c7f3Sopenharmony_ci x = re.sub ("\).*\n", "", x) 191b815c7f3Sopenharmony_ci x = string.split (x, ",") 192b815c7f3Sopenharmony_ci package = x [0] 193b815c7f3Sopenharmony_ci version = x [1] 194b815c7f3Sopenharmony_ci break 195b815c7f3Sopenharmony_ci file.close () 196b815c7f3Sopenharmony_ci # version = re.escape (version) 197b815c7f3Sopenharmony_ci return package, version 198b815c7f3Sopenharmony_ci 199b815c7f3Sopenharmony_cidef fix_configure_ac_file (filename): 200b815c7f3Sopenharmony_ci data = open (filename, 'r').read () 201b815c7f3Sopenharmony_ci data = string.replace (data, "AM_INIT_AUTOMAKE(libsndfile,", "AM_INIT_AUTOMAKE(libsndfile_lite,", 1) 202b815c7f3Sopenharmony_ci 203b815c7f3Sopenharmony_ci file = open (filename, 'w') 204b815c7f3Sopenharmony_ci file.write (data) 205b815c7f3Sopenharmony_ci file.close () 206b815c7f3Sopenharmony_ci 207b815c7f3Sopenharmony_ci 208b815c7f3Sopenharmony_cidef make_dist_file (package, version): 209b815c7f3Sopenharmony_ci print "Making dist file." 210b815c7f3Sopenharmony_ci tar_gz_file = "%s-%s.tar.gz" % (package, version) 211b815c7f3Sopenharmony_ci if os.path.exists (tar_gz_file): 212b815c7f3Sopenharmony_ci return 213b815c7f3Sopenharmony_ci if os.system ("make dist"): 214b815c7f3Sopenharmony_ci sys.exit (1) 215b815c7f3Sopenharmony_ci return 216b815c7f3Sopenharmony_ci 217b815c7f3Sopenharmony_cidef delete_files (file_list): 218b815c7f3Sopenharmony_ci for file_name in file_list: 219b815c7f3Sopenharmony_ci os.remove (file_name) 220b815c7f3Sopenharmony_ci 221b815c7f3Sopenharmony_ci#======================================================================= 222b815c7f3Sopenharmony_ci 223b815c7f3Sopenharmony_cisource_dir = os.getcwd () 224b815c7f3Sopenharmony_ci 225b815c7f3Sopenharmony_ciconf_package, conf_version = find_configure_version ('configure.ac') 226b815c7f3Sopenharmony_ci 227b815c7f3Sopenharmony_cipackage_version = "%s-%s" % (conf_package, conf_version) 228b815c7f3Sopenharmony_cilite_version = "%s_lite-%s" % (conf_package, conf_version) 229b815c7f3Sopenharmony_ci 230b815c7f3Sopenharmony_cios.system ("rm -rf %s%s.tar.gz" % (source_dir, package_version)) 231b815c7f3Sopenharmony_ci 232b815c7f3Sopenharmony_cios.system ("make dist") 233b815c7f3Sopenharmony_ci 234b815c7f3Sopenharmony_cimake_dist_file (conf_package, conf_version) 235b815c7f3Sopenharmony_ci 236b815c7f3Sopenharmony_cios.chdir ("/tmp") 237b815c7f3Sopenharmony_ci 238b815c7f3Sopenharmony_ciprint "Uncompressing .tar.gz file." 239b815c7f3Sopenharmony_cios.system ("rm -rf %s" % package_version) 240b815c7f3Sopenharmony_ciif os.system ("tar zxf %s/%s.tar.gz" % (source_dir, package_version)): 241b815c7f3Sopenharmony_ci sys.exit (1) 242b815c7f3Sopenharmony_ci 243b815c7f3Sopenharmony_ci 244b815c7f3Sopenharmony_ciprint "Renaming to libsndfile_lite." 245b815c7f3Sopenharmony_cios.system ("rm -rf %s" % lite_version) 246b815c7f3Sopenharmony_cios.rename (package_version, lite_version) 247b815c7f3Sopenharmony_ci 248b815c7f3Sopenharmony_ciprint "Changing into libsndfile_lite directory." 249b815c7f3Sopenharmony_cios.chdir (lite_version) 250b815c7f3Sopenharmony_ci 251b815c7f3Sopenharmony_ciprint "Removing un-neeed directories." 252b815c7f3Sopenharmony_cidelete_dirs = [ 'src/G72x' ] 253b815c7f3Sopenharmony_ci 254b815c7f3Sopenharmony_cifor dir_name in delete_dirs: 255b815c7f3Sopenharmony_ci os.system ("rm -rf %s" % dir_name) 256b815c7f3Sopenharmony_ci 257b815c7f3Sopenharmony_ciprint "Removing un-needed files." 258b815c7f3Sopenharmony_cidelete_files ([ 'src/ircam.c', 'src/nist.c', 259b815c7f3Sopenharmony_ci 'src/ima_adpcm.c', 'src/ms_adpcm.c', 'src/au_g72x.c', 260b815c7f3Sopenharmony_ci 'src/mat4.c', 'src/mat5.c', 'src/dwvw.c', 'src/paf.c', 261b815c7f3Sopenharmony_ci 'src/ogg.c', 'src/pvf.c', 'src/xi.c', 'src/htk.c', 262b815c7f3Sopenharmony_ci 'src/sd2.c', 'src/rx2.c', 'src/txw.c', 'src/wve.c', 263b815c7f3Sopenharmony_ci 'src/dwd.c', 'src/svx.c', 'src/voc.c', 'src/vox_adpcm.c', 264b815c7f3Sopenharmony_ci 'src/sds.c' 265b815c7f3Sopenharmony_ci ]) 266b815c7f3Sopenharmony_ci 267b815c7f3Sopenharmony_ci 268b815c7f3Sopenharmony_ciprint "Hacking 'configure.ac' and 'src/Makefile.am'." 269b815c7f3Sopenharmony_ciremove_strings_from_file ('configure.ac', [ 'src/G72x/Makefile' ]) 270b815c7f3Sopenharmony_ciremove_strings_from_file ('src/Makefile.am', [ 'G72x/libg72x.la', 'G72x', 271b815c7f3Sopenharmony_ci 'ircam.c', 'nist.c', 'ima_adpcm.c', 'ms_adpcm.c', 'au_g72x.c', 'mat4.c', 272b815c7f3Sopenharmony_ci 'mat5.c', 'dwvw.c', 'paf.c', 'ogg.c', 'pvf.c', 'xi.c', 'htk.c', 273b815c7f3Sopenharmony_ci 'sd2.c', 'rx2.c', 'txw.c', 'wve.c', 'dwd.c', 'svx.c', 'voc.c', 274b815c7f3Sopenharmony_ci 'vox_adpcm.c', 'sds.c' 275b815c7f3Sopenharmony_ci ]) 276b815c7f3Sopenharmony_ci 277b815c7f3Sopenharmony_ci#---------------------------------------------------------------------------- 278b815c7f3Sopenharmony_ci 279b815c7f3Sopenharmony_ciprint "Hacking header files." 280b815c7f3Sopenharmony_ci 281b815c7f3Sopenharmony_ciremove_protos_from_file ('src/common.h', [ 'xi_open', 'sd2_open', 'ogg_open', 282b815c7f3Sopenharmony_ci 'dwvw_init', 'paf_open', 'svx_open', 'nist_open', 'rx2_open', 'mat4_open', 283b815c7f3Sopenharmony_ci 'voc_open', 'txw_open', 'dwd_open', 'htk_open', 'wve_open', 'mat5_open', 284b815c7f3Sopenharmony_ci 'pvf_open', 'ircam_open', 'sds_open', 285b815c7f3Sopenharmony_ci 'float32_init', 'double64_init', 'aiff_ima_init', 'vox_adpcm_init', 286b815c7f3Sopenharmony_ci 'wav_w64_ima_init', 'wav_w64_msadpcm_init' 287b815c7f3Sopenharmony_ci ]) 288b815c7f3Sopenharmony_ci 289b815c7f3Sopenharmony_ciremove_protos_from_file ('src/au.h', 290b815c7f3Sopenharmony_ci [ 'au_g72x_reader_init', 'au_g72x_writer_init' ]) 291b815c7f3Sopenharmony_ci 292b815c7f3Sopenharmony_ciremove_protos_from_file ('src/wav_w64.h', [ 'msadpcm_write_adapt_coeffs' ]) 293b815c7f3Sopenharmony_ci 294b815c7f3Sopenharmony_ci#---------------------------------------------------------------------------- 295b815c7f3Sopenharmony_ci 296b815c7f3Sopenharmony_ciprint "Hacking case statements." 297b815c7f3Sopenharmony_ci 298b815c7f3Sopenharmony_ciremove_comment_start_end ('src/sndfile.c', '/* Lite remove start */' , '/* Lite remove end */') 299b815c7f3Sopenharmony_ciremove_comment_start_end ('src/aiff.c', '/* Lite remove start */' , '/* Lite remove end */') 300b815c7f3Sopenharmony_ciremove_comment_start_end ('src/au.c', '/* Lite remove start */' , '/* Lite remove end */') 301b815c7f3Sopenharmony_ciremove_comment_start_end ('src/raw.c', '/* Lite remove start */' , '/* Lite remove end */') 302b815c7f3Sopenharmony_ciremove_comment_start_end ('src/w64.c', '/* Lite remove start */' , '/* Lite remove end */') 303b815c7f3Sopenharmony_ciremove_comment_start_end ('src/wav.c', '/* Lite remove start */' , '/* Lite remove end */') 304b815c7f3Sopenharmony_ciremove_comment_start_end ('src/double64.c', '/* Lite remove start */' , '/* Lite remove end */') 305b815c7f3Sopenharmony_ciremove_comment_start_end ('src/float32.c', '/* Lite remove start */' , '/* Lite remove end */') 306b815c7f3Sopenharmony_ci 307b815c7f3Sopenharmony_ci 308b815c7f3Sopenharmony_ci#---------------------------------------------------------------------------- 309b815c7f3Sopenharmony_ci 310b815c7f3Sopenharmony_ciprint "Hacking src/pcm.c." 311b815c7f3Sopenharmony_ciremove_funcs_from_file ('src/pcm.c', [ 312b815c7f3Sopenharmony_ci 'f2sc_array', 'f2sc_clip_array', 'f2uc_array', 'f2uc_clip_array', 313b815c7f3Sopenharmony_ci 'f2bes_array', 'f2bes_clip_array', 'f2les_array', 'f2les_clip_array', 314b815c7f3Sopenharmony_ci 'f2let_array', 'f2let_clip_array', 'f2bet_array', 'f2bet_clip_array', 315b815c7f3Sopenharmony_ci 'f2bei_array', 'f2bei_clip_array', 'f2lei_array', 'f2lei_clip_array', 316b815c7f3Sopenharmony_ci 'd2sc_array', 'd2sc_clip_array', 'd2uc_array', 'd2uc_clip_array', 317b815c7f3Sopenharmony_ci 'd2bes_array', 'd2bes_clip_array', 'd2les_array', 'd2les_clip_array', 318b815c7f3Sopenharmony_ci 'd2let_array', 'd2let_clip_array', 'd2bet_array', 'd2bet_clip_array', 319b815c7f3Sopenharmony_ci 'd2bei_array', 'd2bei_clip_array', 'd2lei_array', 'd2lei_clip_array', 320b815c7f3Sopenharmony_ci ]) 321b815c7f3Sopenharmony_ci 322b815c7f3Sopenharmony_ciremove_funcs_and_protos_from_file ('src/pcm.c', [ 323b815c7f3Sopenharmony_ci 'pcm_read_sc2f', 'pcm_read_uc2f', 'pcm_read_les2f', 'pcm_read_bes2f', 324b815c7f3Sopenharmony_ci 'pcm_read_let2f', 'pcm_read_bet2f', 'pcm_read_lei2f', 'pcm_read_bei2f', 325b815c7f3Sopenharmony_ci 'pcm_read_sc2d', 'pcm_read_uc2d', 'pcm_read_les2d', 'pcm_read_bes2d', 326b815c7f3Sopenharmony_ci 'pcm_read_let2d', 'pcm_read_bet2d', 'pcm_read_lei2d', 'pcm_read_bei2d', 327b815c7f3Sopenharmony_ci 'pcm_write_f2sc', 'pcm_write_f2uc', 'pcm_write_f2bes', 'pcm_write_f2les', 328b815c7f3Sopenharmony_ci 'pcm_write_f2bet', 'pcm_write_f2let', 'pcm_write_f2bei', 'pcm_write_f2lei', 329b815c7f3Sopenharmony_ci 'pcm_write_d2sc', 'pcm_write_d2uc', 'pcm_write_d2bes', 'pcm_write_d2les', 330b815c7f3Sopenharmony_ci 'pcm_write_d2bet', 'pcm_write_d2let', 'pcm_write_d2bei', 'pcm_write_d2lei', 331b815c7f3Sopenharmony_ci 332b815c7f3Sopenharmony_ci 'sc2f_array', 'uc2f_array', 'bes2f_array', 'les2f_array', 333b815c7f3Sopenharmony_ci 'bet2f_array', 'let2f_array', 'bei2f_array', 'lei2f_array', 334b815c7f3Sopenharmony_ci 'sc2d_array', 'uc2d_array', 'bes2d_array', 'les2d_array', 335b815c7f3Sopenharmony_ci 'bet2d_array', 'let2d_array', 'bei2d_array', 'lei2d_array' 336b815c7f3Sopenharmony_ci ]) 337b815c7f3Sopenharmony_ci 338b815c7f3Sopenharmony_ciremove_includes_from_file ('src/pcm.c', [ 'float_cast.h' ]) 339b815c7f3Sopenharmony_ciremove_all_assignments_from_file ('src/pcm.c', [ 340b815c7f3Sopenharmony_ci 'psf-\>write_float', 'psf\-\>write_double', 341b815c7f3Sopenharmony_ci 'psf-\>read_float', 'psf\-\>read_double' ]) 342b815c7f3Sopenharmony_ci 343b815c7f3Sopenharmony_ci#---------------------------------------------------------------------------- 344b815c7f3Sopenharmony_ciprint "Hacking src/ulaw.c." 345b815c7f3Sopenharmony_ciremove_funcs_and_protos_from_file ('src/ulaw.c', [ 346b815c7f3Sopenharmony_ci 'ulaw_read_ulaw2f', 'ulaw_read_ulaw2d', 347b815c7f3Sopenharmony_ci 'ulaw_write_f2ulaw', 'ulaw_write_d2ulaw', 348b815c7f3Sopenharmony_ci 'ulaw2f_array', 'ulaw2d_array', 'f2ulaw_array', 'd2ulaw_array' 349b815c7f3Sopenharmony_ci ]) 350b815c7f3Sopenharmony_ci 351b815c7f3Sopenharmony_ciremove_includes_from_file ('src/ulaw.c', [ 'float_cast.h' ]) 352b815c7f3Sopenharmony_ciremove_all_assignments_from_file ('src/ulaw.c', [ 353b815c7f3Sopenharmony_ci 'psf-\>write_float', 'psf\-\>write_double', 354b815c7f3Sopenharmony_ci 'psf-\>read_float', 'psf\-\>read_double' ]) 355b815c7f3Sopenharmony_ci 356b815c7f3Sopenharmony_ci#---------------------------------------------------------------------------- 357b815c7f3Sopenharmony_ci 358b815c7f3Sopenharmony_ciprint "Hacking src/alaw.c." 359b815c7f3Sopenharmony_ciremove_funcs_and_protos_from_file ('src/alaw.c', [ 360b815c7f3Sopenharmony_ci 'alaw_read_alaw2f', 'alaw_read_alaw2d', 361b815c7f3Sopenharmony_ci 'alaw_write_f2alaw', 'alaw_write_d2alaw', 362b815c7f3Sopenharmony_ci 'alaw2f_array', 'alaw2d_array', 'f2alaw_array', 'd2alaw_array' 363b815c7f3Sopenharmony_ci ]) 364b815c7f3Sopenharmony_ci 365b815c7f3Sopenharmony_ciremove_includes_from_file ('src/alaw.c', [ 'float_cast.h' ]) 366b815c7f3Sopenharmony_ciremove_all_assignments_from_file ('src/alaw.c', [ 367b815c7f3Sopenharmony_ci 'psf-\>write_float', 'psf\-\>write_double', 368b815c7f3Sopenharmony_ci 'psf-\>read_float', 'psf\-\>read_double' ]) 369b815c7f3Sopenharmony_ci 370b815c7f3Sopenharmony_ci#---------------------------------------------------------------------------- 371b815c7f3Sopenharmony_ci 372b815c7f3Sopenharmony_ciprint "Hacking src/gsm610.c." 373b815c7f3Sopenharmony_ciremove_funcs_and_protos_from_file ('src/gsm610.c', [ 374b815c7f3Sopenharmony_ci 'gsm610_read_f', 'gsm610_read_d', 'gsm610_write_f', 'gsm610_write_d' 375b815c7f3Sopenharmony_ci ]) 376b815c7f3Sopenharmony_ci 377b815c7f3Sopenharmony_ciremove_includes_from_file ('src/gsm610.c', [ 'float_cast.h' ]) 378b815c7f3Sopenharmony_ciremove_all_assignments_from_file ('src/gsm610.c', [ 379b815c7f3Sopenharmony_ci 'psf-\>write_float', 'psf\-\>write_double', 380b815c7f3Sopenharmony_ci 'psf-\>read_float', 'psf\-\>read_double' ]) 381b815c7f3Sopenharmony_ci 382b815c7f3Sopenharmony_ci#---------------------------------------------------------------------------- 383b815c7f3Sopenharmony_ci 384b815c7f3Sopenharmony_ciprint "Hacking src/float32.c." 385b815c7f3Sopenharmony_ci 386b815c7f3Sopenharmony_ci# string_replace_in_file ('src/float32.c', '"float_cast.h"', '<math.h>') 387b815c7f3Sopenharmony_ciremove_funcs_from_file ('src/float32.c', [ 'float32_init' ]) 388b815c7f3Sopenharmony_ci 389b815c7f3Sopenharmony_ciremove_funcs_and_protos_from_file ('src/float32.c', [ 390b815c7f3Sopenharmony_ci 'host_read_f2s', 'host_read_f2i', 'host_read_f', 'host_read_f2d', 391b815c7f3Sopenharmony_ci 'host_write_s2f', 'host_write_i2f', 'host_write_f', 'host_write_d2f', 392b815c7f3Sopenharmony_ci 'f2s_array', 'f2i_array', 'f2d_array', 's2f_array', 'i2f_array', 'd2f_array', 393b815c7f3Sopenharmony_ci 'float32_peak_update', 394b815c7f3Sopenharmony_ci 'replace_read_f2s', 'replace_read_f2i', 'replace_read_f', 'replace_read_f2d', 395b815c7f3Sopenharmony_ci 'replace_write_s2f', 'replace_write_i2f', 'replace_write_f', 'replace_write_d2f', 396b815c7f3Sopenharmony_ci 'bf2f_array', 'f2bf_array', 397b815c7f3Sopenharmony_ci 'float32_get_capability', 398b815c7f3Sopenharmony_ci ]) 399b815c7f3Sopenharmony_ci 400b815c7f3Sopenharmony_ci#---------------------------------------------------------------------------- 401b815c7f3Sopenharmony_ci 402b815c7f3Sopenharmony_ciprint "Hacking src/double64.c." 403b815c7f3Sopenharmony_ciremove_funcs_from_file ('src/double64.c', [ 'double64_init' ]) 404b815c7f3Sopenharmony_ci 405b815c7f3Sopenharmony_ciremove_funcs_and_protos_from_file ('src/double64.c', [ 406b815c7f3Sopenharmony_ci 'host_read_d2s', 'host_read_d2i', 'host_read_d2f', 'host_read_d', 407b815c7f3Sopenharmony_ci 'host_write_s2d', 'host_write_i2d', 'host_write_f2d', 'host_write_d', 408b815c7f3Sopenharmony_ci 'd2s_array', 'd2i_array', 'd2f_array', 409b815c7f3Sopenharmony_ci 's2d_array', 'i2d_array', 'f2d_array', 410b815c7f3Sopenharmony_ci 'double64_peak_update', 'double64_get_capability', 411b815c7f3Sopenharmony_ci 'replace_read_d2s', 'replace_read_d2i', 'replace_read_d2f', 'replace_read_d', 412b815c7f3Sopenharmony_ci 'replace_write_s2d', 'replace_write_i2d', 'replace_write_f2d', 'replace_write_d', 413b815c7f3Sopenharmony_ci 'd2bd_read', 'bd2d_write' 414b815c7f3Sopenharmony_ci ]) 415b815c7f3Sopenharmony_ci 416b815c7f3Sopenharmony_ci#---------------------------------------------------------------------------- 417b815c7f3Sopenharmony_ci 418b815c7f3Sopenharmony_ciprint "Hacking test programs." 419b815c7f3Sopenharmony_cidelete_files ([ 'tests/dwvw_test.c', 'tests/floating_point_test.c', 420b815c7f3Sopenharmony_ci 'tests/dft_cmp.c', 'tests/peak_chunk_test.c', 421b815c7f3Sopenharmony_ci 'tests/scale_clip_test.tpl', 'tests/scale_clip_test.def' 422b815c7f3Sopenharmony_ci ]) 423b815c7f3Sopenharmony_ci 424b815c7f3Sopenharmony_ciremove_comment_start_end ('tests/write_read_test.def', '/* Lite remove start */', '/* Lite remove end */') 425b815c7f3Sopenharmony_ciremove_comment_start_end ('tests/write_read_test.tpl', '/* Lite remove start */', '/* Lite remove end */') 426b815c7f3Sopenharmony_ci 427b815c7f3Sopenharmony_ciremove_comment_start_end ('tests/Makefile.am', '# Lite remove start', '# Lite remove end') 428b815c7f3Sopenharmony_ci 429b815c7f3Sopenharmony_ciremove_strings_from_file ('tests/Makefile.am', [ 430b815c7f3Sopenharmony_ci 'scale_clip_test.tpl', 'scale_clip_test.def', 431b815c7f3Sopenharmony_ci '\n\t./dwvw_test', 432b815c7f3Sopenharmony_ci '\n\t./floating_point_test', '\n\t./scale_clip_test', 433b815c7f3Sopenharmony_ci '\n\t./peak_chunk_test aiff', '\n\t./peak_chunk_test wav', 434b815c7f3Sopenharmony_ci '\n\t./command_test norm', '\n\t./command_test peak', 435b815c7f3Sopenharmony_ci '\n\t./lossy_comp_test wav_ima', '\n\t./lossy_comp_test wav_msadpcm', 436b815c7f3Sopenharmony_ci '\n\t./lossy_comp_test au_g721', '\n\t./lossy_comp_test au_g723', 437b815c7f3Sopenharmony_ci '\n\t./lossy_comp_test vox_adpcm', 438b815c7f3Sopenharmony_ci '\n\t./lossy_comp_test w64_ima', '\n\t./lossy_comp_test w64_msadpcm', 439b815c7f3Sopenharmony_ci 'peak_chunk_test', 'dwvw_test', 'floating_point_test', 'scale_clip_test', 440b815c7f3Sopenharmony_ci 441b815c7f3Sopenharmony_ci 'paf-tests', 'svx-tests', 'nist-tests', 'ircam-tests', 'voc-tests', 442b815c7f3Sopenharmony_ci 'mat4-tests', 'mat5-tests', 'pvf-tests', 'xi-tests', 'htk-tests', 443b815c7f3Sopenharmony_ci 'sds-tests' 444b815c7f3Sopenharmony_ci ]) 445b815c7f3Sopenharmony_ci 446b815c7f3Sopenharmony_ciremove_comment_start_end ('tests/pcm_test.c', '/* Lite remove start */', '/* Lite remove end */') 447b815c7f3Sopenharmony_ciremove_funcs_and_protos_from_file ('tests/pcm_test.c', [ 448b815c7f3Sopenharmony_ci 'pcm_test_float', 'pcm_test_double' 449b815c7f3Sopenharmony_ci ]) 450b815c7f3Sopenharmony_ci 451b815c7f3Sopenharmony_ciremove_comment_start_end ('tests/lossy_comp_test.c', '/* Lite remove start */', '/* Lite remove end */') 452b815c7f3Sopenharmony_ciremove_funcs_and_protos_from_file ('tests/lossy_comp_test.c', [ 453b815c7f3Sopenharmony_ci 'lcomp_test_float', 'lcomp_test_double', 'sdlcomp_test_float', 'sdlcomp_test_double', 454b815c7f3Sopenharmony_ci 'smoothed_diff_float', 'smoothed_diff_double' 455b815c7f3Sopenharmony_ci ]) 456b815c7f3Sopenharmony_ci 457b815c7f3Sopenharmony_ciremove_comment_start_end ('tests/multi_file_test.c', '/* Lite remove start */', '/* Lite remove end */') 458b815c7f3Sopenharmony_ci 459b815c7f3Sopenharmony_ciremove_strings_from_file ('tests/stdio_test.c', [ 460b815c7f3Sopenharmony_ci '"paf",', '"svx",', '"nist",', '"ircam",', '"voc",', '"mat4",', '"mat5",', '"pvf",' 461b815c7f3Sopenharmony_ci ]) 462b815c7f3Sopenharmony_ci 463b815c7f3Sopenharmony_ciremove_comment_start_end ('tests/pipe_test.c', '/* Lite remove start */', '/* Lite remove end */') 464b815c7f3Sopenharmony_ci 465b815c7f3Sopenharmony_ci#---------------------------------------------------------------------------- 466b815c7f3Sopenharmony_ci 467b815c7f3Sopenharmony_ciprint "Fixing configure.ac file." 468b815c7f3Sopenharmony_cifix_configure_ac_file ('configure.ac') 469b815c7f3Sopenharmony_ci 470b815c7f3Sopenharmony_ciprint "Building and testing source." 471b815c7f3Sopenharmony_ci # Try --disable-shared --disable-gcc-opt 472b815c7f3Sopenharmony_ciif os.system ("./reconfigure.mk && ./configure --disable-shared --disable-gcc-opt && make check"): 473b815c7f3Sopenharmony_ci os.system ('PS1="FIX > " bash --norc') 474b815c7f3Sopenharmony_ci sys.exit (1) 475b815c7f3Sopenharmony_ci 476b815c7f3Sopenharmony_ciprint "Making distcheck" 477b815c7f3Sopenharmony_ciif os.system ("make distcheck"): 478b815c7f3Sopenharmony_ci os.system ('PS1="FIX > " bash --norc') 479b815c7f3Sopenharmony_ci sys.exit (1) 480b815c7f3Sopenharmony_ci 481b815c7f3Sopenharmony_ciprint "Copying tarball" 482b815c7f3Sopenharmony_ciif os.system ("cp %s.tar.gz %s" % (lite_version, source_dir)): 483b815c7f3Sopenharmony_ci print "??? %s.tar.gz ???" % lite_version 484b815c7f3Sopenharmony_ci os.system ('PS1="FIX > " bash --norc') 485b815c7f3Sopenharmony_ci sys.exit (1) 486b815c7f3Sopenharmony_ci 487b815c7f3Sopenharmony_cios.chdir (source_dir) 488b815c7f3Sopenharmony_ci 489b815c7f3Sopenharmony_cios.system ("rm -rf /tmp/%s" % lite_version) 490b815c7f3Sopenharmony_ci 491b815c7f3Sopenharmony_ciprint "Done." 492