Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. import subprocess
  2. import distutils.dir_util
  3. import os
  4.  
  5.  
  6. def generate_fat_libs(root: str, archs: [str], output: str):
  7. def get_lib_names(dir: str) -> [str]:
  8. libs = []
  9. for file in os.listdir(dir):
  10. if file.endswith('.dylib') and not os.path.islink(dir + '/' + file):
  11. libs.append(file)
  12. if file.endswith('.a'):
  13. libs.append(file)
  14. return libs
  15.  
  16. def lipo(root: str, archs: [str], output: str, lib_name: str):
  17. cmd = ['lipo', '-create']
  18. for arch in archs:
  19. cmd.append('{arch}/INSTALL/lib/{lib}'.format(arch=arch, lib=lib_name))
  20. cmd.append('-output')
  21. cmd.append('{output}/INSTALL/lib/{lib}'.format(output=output, lib=lib_name))
  22. subprocess.run(cmd, cwd=root)
  23.  
  24. def copy_headers(root: str, arch: str, output: str):
  25. source = '{root}/{arch}/INSTALL/include'.format(root=root, arch=arch)
  26. destination = '{root}/{output}/INSTALL/include'.format(root=root, output=output)
  27. distutils.dir_util.copy_tree(source, destination)
  28.  
  29. if len(archs) < 2:
  30. return
  31.  
  32. subprocess.run(['mkdir', '-p', '{}/INSTALL/lib'.format(output)], cwd=root)
  33. copy_headers(root, archs[0], output)
  34. libs = get_lib_names('{}/{}/INSTALL/lib'.format(root, archs[0]))
  35. for lib in libs:
  36. lipo(root, archs, output, lib)
  37.  
  38. generate_fat_libs('/Volumes/Data/Developer/kiwix-build',
  39. ['BUILD_iOS_arm64', 'BUILD_iOS_armv7s', 'BUILD_iOS_x86_64'],
  40. 'BUILD_iOS_Shared')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement