Code Monkey home page Code Monkey logo

Comments (5)

automactic avatar automactic commented on August 25, 2024

Here is my code snippet for doing this for iOS:

import subprocess
import distutils.dir_util
import os


def generate_fat_libs(root: str, archs: [str], output: str):
    def get_lib_names(dir: str) -> [str]:
        libs = []
        for file in os.listdir(dir):
            if file.endswith('.dylib') and not os.path.islink(dir + '/' + file):
                libs.append(file)
            if file.endswith('.a'):
                libs.append(file)
        return libs

    def lipo(root: str, archs: [str], output: str, lib_name: str):
        cmd = ['lipo', '-create']
        for arch in archs:
            cmd.append('{arch}/INSTALL/lib/{lib}'.format(arch=arch, lib=lib_name))
        cmd.append('-output')
        cmd.append('{output}/INSTALL/lib/{lib}'.format(output=output, lib=lib_name))
        subprocess.run(cmd, cwd=root)

    def copy_headers(root: str, arch: str, output: str):
        source = '{root}/{arch}/INSTALL/include'.format(root=root, arch=arch)
        destination = '{root}/{output}/INSTALL/include'.format(root=root, output=output)
        distutils.dir_util.copy_tree(source, destination)

    if len(archs) < 2:
        return

    subprocess.run(['mkdir', '-p', '{}/INSTALL/lib'.format(output)], cwd=root)
    copy_headers(root, archs[0], output)
    libs = get_lib_names('{}/{}/INSTALL/lib'.format(root, archs[0]))
    for lib in libs:
        lipo(root, archs, output, lib)

generate_fat_libs('/Users/chrisli/Developer/kiwix-build',
                  ['BUILD_iOS_arm64', 'BUILD_iOS_armv7s', 'BUILD_iOS_x86_64'],
                  'BUILD_iOS_Shared')

from kiwix-build.

kelson42 avatar kelson42 commented on August 25, 2024

Not quite sure if this should be put in the kiwix-lib repo!?

from kiwix-build.

kelson42 avatar kelson42 commented on August 25, 2024

@automactic @mgautierfr status?

from kiwix-build.

automactic avatar automactic commented on August 25, 2024

not done. I still need to manually run the above script to generate a fat lib.

from kiwix-build.

kelson42 avatar kelson42 commented on August 25, 2024

@mgautierfr We definitly need to finish the ios/macos port of kiwixlib

from kiwix-build.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.