예제 #1
0
    def get_env(self):
        include_dirs = [
            "-I{}/{}".format(
                self.ctx.include_dir,
                d.format(arch=self))
            for d in self.ctx.include_dirs]

        env = {}
        env["CC"] = sh.xcrun("-find", "-sdk", self.sdk, "clang").strip()
        env["AR"] = sh.xcrun("-find", "-sdk", self.sdk, "ar").strip()
        env["LD"] = sh.xcrun("-find", "-sdk", self.sdk, "ld").strip()
        env["OTHER_CFLAGS"] = " ".join(include_dirs)
        env["OTHER_LDFLAGS"] = " ".join([
            "-L{}/{}".format(self.ctx.dist_dir, "lib"),
        ])
        env["CFLAGS"] = " ".join([
            "-arch", self.arch,
            "-pipe", "-no-cpp-precomp",
            "--sysroot", self.sysroot,
            #"-I{}/common".format(self.ctx.include_dir),
            #"-I{}/{}".format(self.ctx.include_dir, self.arch),
            "-O3",
            self.version_min
        ] + include_dirs)
        env["LDFLAGS"] = " ".join([
            "-arch", self.arch,
            "--sysroot", self.sysroot,
            "-L{}/{}".format(self.ctx.dist_dir, "lib"),
            "-lsqlite3",
            self.version_min
        ])
        return env
예제 #2
0
    def get_env(self):
        include_dirs = [
            "-I{}/{}".format(
                self.ctx.include_dir,
                d.format(arch=self))
            for d in self.ctx.include_dirs]

        env = {}
        ccache = sh.which('ccache')
        cc = sh.xcrun("-find", "-sdk", self.sdk, "clang").strip()
        if ccache:
            ccache = ccache.strip()
            use_ccache = environ.get("USE_CCACHE", "1")
            if use_ccache != '1':
                env["CC"] = cc
            else:
                if not self._ccsh:
                    self._ccsh = ccsh = sh.mktemp().strip()
                    with open(ccsh, 'w') as f:
                        f.write('#!/bin/sh\n')
                        f.write(ccache + ' ' + cc + ' "$@"\n')
                    sh.chmod('+x', ccsh)
                else:
                    ccsh = self._ccsh
                env["USE_CCACHE"] = '1'
                env["CCACHE"] = ccache
                env["CC"] = ccsh

                env.update({k: v for k, v in environ.items() if k.startswith('CCACHE_')})
                env.setdefault('CCACHE_MAXSIZE', '10G')
                env.setdefault('CCACHE_HARDLINK', 'true')
                env.setdefault('CCACHE_SLOPPINESS', ('file_macro,time_macros,'
                    'include_file_mtime,include_file_ctime,file_stat_matches'))
        else:
            env["CC"] = cc
        env["AR"] = sh.xcrun("-find", "-sdk", self.sdk, "ar").strip()
        env["LD"] = sh.xcrun("-find", "-sdk", self.sdk, "ld").strip()
        env["OTHER_CFLAGS"] = " ".join(include_dirs)
        env["OTHER_LDFLAGS"] = " ".join([
            "-L{}/{}".format(self.ctx.dist_dir, "lib"),
        ])
        env["CFLAGS"] = " ".join([
            "-arch", self.arch,
            "-pipe", "-no-cpp-precomp",
            "--sysroot", self.sysroot,
            #"-I{}/common".format(self.ctx.include_dir),
            #"-I{}/{}".format(self.ctx.include_dir, self.arch),
            "-O3",
            self.version_min
        ] + include_dirs)
        env["LDFLAGS"] = " ".join([
            "-arch", self.arch,
            "--sysroot", self.sysroot,
            "-L{}/{}".format(self.ctx.dist_dir, "lib"),
            "-lsqlite3",
            self.version_min
        ])
        return env
예제 #3
0
    def get_env(self):
        include_dirs = [
            "-I{}/{}".format(
                self.ctx.include_dir,
                d.format(arch=self))
            for d in self.ctx.include_dirs]

        env = {}
        ccache = sh.which('ccache')
        cc = sh.xcrun("-find", "-sdk", self.sdk, "clang").strip()
        if ccache:
            ccache = ccache.strip()
            use_ccache = environ.get("USE_CCACHE", "1")
            if use_ccache != '1':
                env["CC"] = cc
            else:
                if not self._ccsh:
                    self._ccsh = ccsh = sh.mktemp().strip()
                    with open(ccsh, 'w') as f:
                        f.write('#!/bin/sh\n')
                        f.write(ccache + ' ' + cc + ' "$@"\n')
                    sh.chmod('+x', ccsh)
                else:
                    ccsh = self._ccsh
                env["USE_CCACHE"] = '1'
                env["CCACHE"] = ccache
                env["CC"] = ccsh

                env.update({k: v for k, v in environ.items() if k.startswith('CCACHE_')})
                env.setdefault('CCACHE_MAXSIZE', '10G')
                env.setdefault('CCACHE_HARDLINK', 'true')
                env.setdefault('CCACHE_SLOPPINESS', ('file_macro,time_macros,'
                    'include_file_mtime,include_file_ctime,file_stat_matches'))
        else:
            env["CC"] = cc
        env["AR"] = sh.xcrun("-find", "-sdk", self.sdk, "ar").strip()
        env["LD"] = sh.xcrun("-find", "-sdk", self.sdk, "ld").strip()
        env["OTHER_CFLAGS"] = " ".join(include_dirs)
        env["OTHER_LDFLAGS"] = " ".join([
            "-L{}/{}".format(self.ctx.dist_dir, "lib"),
        ])
        env["CFLAGS"] = " ".join([
            "-arch", self.arch,
            "-pipe", "-no-cpp-precomp",
            "--sysroot", self.sysroot,
            #"-I{}/common".format(self.ctx.include_dir),
            #"-I{}/{}".format(self.ctx.include_dir, self.arch),
            "-O3",
            self.version_min
        ] + include_dirs)
        env["LDFLAGS"] = " ".join([
            "-arch", self.arch,
            "--sysroot", self.sysroot,
            "-L{}/{}".format(self.ctx.dist_dir, "lib"),
            "-lsqlite3",
            self.version_min
        ])
        return env
예제 #4
0
    def build_x86_64(self):
        sdk_path = sh.xcrun("--sdk", "macosx", "--show-sdk-path").strip()
        build_env = self.ctx.env.copy()
        ccache = (build_env["CCACHE"] + ' ') if 'CCACHE' in build_env else ''
        build_env[
            "CC"] = ccache + "clang -Qunused-arguments -fcolor-diagnostics"
        build_env["LDFLAGS"] = " ".join([
            "-lsqlite3", "-lffi", "-L{}".format(
                join(self.ctx.dist_dir, "hostlibffi", "usr", "local", "lib"))
        ])
        build_env["CFLAGS"] = " ".join([
            "--sysroot={}".format(sdk_path), "-I{}".format(
                join(self.ctx.dist_dir, "hostlibffi", "usr", "local",
                     "include"))
        ])

        if "openssl.build_all" in self.ctx.state:
            build_env["CFLAGS"] += " -I{}".format(
                join(self.ctx.dist_dir, "include", "x86_64", "openssl"))

        configure = sh.Command(join(self.build_dir, "configure"))
        shprint(configure,
                "--prefix={}".format(join(self.ctx.dist_dir, "hostpython")),
                "--disable-toolbox-glue",
                "--without-gcc",
                _env=build_env)
        shprint(sh.make,
                "-C",
                self.build_dir,
                "-j4",
                "python",
                "Parser/pgen",
                _env=build_env)
        shutil.move("python", "hostpython")
        shutil.move("Parser/pgen", "Parser/hostpgen")
예제 #5
0
파일: __init__.py 프로젝트: myevan/kivy-ios
 def build_i386(self):
     sdk_path = sh.xcrun("--sdk", "macosx", "--show-sdk-path").strip()
     build_env = self.ctx.env.copy()
     build_env["CC"] = "clang -Qunused-arguments -fcolor-diagnostics"
     build_env["LDFLAGS"] = " ".join([
         "-lsqlite3", "-lffi", "-L{}".format(join(self.ctx.dist_dir, "lib"))
     ])
     build_env["CFLAGS"] = " ".join([
         "--sysroot={}".format(sdk_path),
         "-I{}".format(join(self.ctx.dist_dir, "include", "i386", "libffi"))
     ])
     configure = sh.Command(join(self.build_dir, "configure"))
     shprint(configure,
             "--prefix={}".format(join(self.ctx.dist_dir, "hostpython")),
             "--disable-toolbox-glue",
             "--without-gcc",
             _env=build_env)
     shprint(sh.make,
             "-C",
             self.build_dir,
             "-j4",
             "python.exe",
             "Parser/pgen",
             _env=build_env)
     shutil.move("python.exe", "hostpython")
     shutil.move("Parser/pgen", "Parser/hostpgen")
예제 #6
0
    def build_x86_64(self):
        sdk_path = sh.xcrun("--sdk", "macosx", "--show-sdk-path").strip()
        build_env = self.ctx.env.copy()
        ccache = (build_env["CCACHE"] + ' ') if 'CCACHE' in build_env else ''
        build_env["CC"] = ccache + "clang -Qunused-arguments -fcolor-diagnostics"
        build_env["LDFLAGS"] = " ".join([
                "-lsqlite3",
                "-lffi",
                "-L{}".format(join(self.ctx.dist_dir, "hostlibffi", "usr", "local", "lib"))
                ])
        build_env["CFLAGS"] = " ".join([
                "--sysroot={}".format(sdk_path),
                "-I{}".format(join(self.ctx.dist_dir, "hostlibffi", "usr", "local", "include"))
                ])

        if "openssl.build_all" in self.ctx.state:
            build_env["CFLAGS"] += " -I{}".format(join(self.ctx.dist_dir, "include",
                                                       "x86_64", "openssl"))

        configure = sh.Command(join(self.build_dir, "configure"))
        shprint(configure,
                "--prefix={}".format(join(self.ctx.dist_dir, "hostpython")),
                "--disable-toolbox-glue",
                "--without-gcc",
                _env=build_env)
        shprint(sh.make, "-C", self.build_dir, self.ctx.concurrent_make, "python", "Parser/pgen",
                _env=build_env)
        shutil.move("python", "hostpython")
        shutil.move("Parser/pgen", "Parser/hostpgen")
예제 #7
0
 def get_build_env(self):
     sdk_path = sh.xcrun("--sdk", "macosx", "--show-sdk-path").strip()
     build_env = self.ctx.env.copy()
     self.build_env_x86_84 = build_env
     ccache = (build_env["CCACHE"] + ' ') if 'CCACHE' in build_env else ''
     build_env[
         "CC"] = ccache + "clang -Qunused-arguments -fcolor-diagnostics"
     build_env["LDFLAGS"] = " ".join([
         "-lsqlite3", "-lffi", "-L{}".format(
             join(self.ctx.dist_dir, "hostlibffi", "usr", "local", "lib"))
     ])
     build_env["CFLAGS"] = " ".join([
         "--sysroot={}".format(sdk_path), "-arch x86_64",
         "-mmacosx-version-min=10.12", "-I{}".format(
             join(self.ctx.dist_dir, "hostlibffi", "usr", "local",
                  "include"))
     ])
     mac_ver = float('.'.join(platform.mac_ver()[0].split('.')[:2]))
     if mac_ver > 10.15:
         # Both 10.16 and 11.0 are BigSur
         build_env["LDFLAGS"] += " -L{}".format(join(
             sdk_path, "usr", "lib"))
         build_env["CFLAGS"] += " -I{}".format(
             join(sdk_path, "usr", "include"))
     return build_env
예제 #8
0
    def build_x86_64(self):
        arch = self.archs[0]
        sdk_path = sh.xcrun("--sdk", "macosx", "--show-sdk-path").strip()
        dist_dir = join(self.ctx.dist_dir, "hostopenssl")
        print("OpenSSL for host to be installed at: {}").format(dist_dir)
        sh.perl(join(self.build_dir, "Configure"), "darwin64-x86_64-cc",
                "--openssldir={}".format(dist_dir),
                "--prefix={}".format(dist_dir))

        shprint(sh.make, "clean")
        shprint(sh.make, "-j4", "build_libs")
예제 #9
0
 def get_recipe_env(self, arch):
     sdk_path = sh.xcrun("--sdk", "macosx", "--show-sdk-path").strip()
     env = super(HostCffiRecipe, self).get_recipe_env(arch)
     env["CC"] = "clang -Qunused-arguments -fcolor-diagnostics"
     env["LDFLAGS"] = " ".join([
             "-undefined dynamic_lookup",
             #"-shared",
             "-L{}".format(join(self.ctx.dist_dir, "hostlibffi", "usr", "local", "lib"))
             ])
     env["CFLAGS"] = " ".join([
             "--sysroot={}".format(sdk_path),
             "-I{}".format(join(self.ctx.dist_dir, "hostlibffi", "usr", "local", "include"))
             ])
     return env
예제 #10
0
    def get_build_env(self):
        sdk_path = sh.xcrun("--sdk", "macosx", "--show-sdk-path").strip()

        build_env = self.ctx.env.copy()
        ccache = (build_env["CCACHE"] + ' ') if 'CCACHE' in build_env else ''
        build_env["CC"] = ccache + "clang -Qunused-arguments -fcolor-diagnostics"
        build_env["LDFLAGS"] = " ".join([
                "-lsqlite3",
                "-lffi",
                ])
        build_env["CFLAGS"] = " ".join([
                "--sysroot={}".format(sdk_path),
                "-mmacosx-version-min=10.12",
                ])
        return build_env
예제 #11
0
 def build_i386(self):
     sdk_path = sh.xcrun("--sdk", "macosx", "--show-sdk-path").strip()
     build_env = self.ctx.env.copy()
     build_env["CC"] = "clang -Qunused-arguments -fcolor-diagnostics"
     build_env["LDFLAGS"] = " ".join(["-lsqlite3", "-lffi", "-L{}".format(join(self.ctx.dist_dir, "lib"))])
     build_env["CFLAGS"] = " ".join(
         ["--sysroot={}".format(sdk_path), "-I{}".format(join(self.ctx.dist_dir, "include", "i386", "libffi"))]
     )
     configure = sh.Command(join(self.build_dir, "configure"))
     shprint(
         configure,
         "--prefix={}".format(join(self.ctx.dist_dir, "hostpython")),
         "--disable-toolbox-glue",
         "--without-gcc",
         _env=build_env,
     )
     shprint(sh.make, "-C", self.build_dir, "-j4", "python.exe", "Parser/pgen", _env=build_env)
     shutil.move("python.exe", "hostpython")
     shutil.move("Parser/pgen", "Parser/hostpgen")
예제 #12
0
 def get_build_env(self):
     sdk_path = sh.xcrun("--sdk", "macosx", "--show-sdk-path").strip()
     build_env = self.ctx.env.copy()
     self.build_env_x86_84 = build_env
     ccache = (build_env["CCACHE"] + ' ') if 'CCACHE' in build_env else ''
     build_env["CC"] = ccache + "clang -Qunused-arguments -fcolor-diagnostics"
     build_env["LDFLAGS"] = " ".join([
             "-lsqlite3",
             "-lffi",
             "-L{}".format(join(self.ctx.dist_dir, "hostlibffi", "usr", "local", "lib"))
             ])
     build_env["CFLAGS"] = " ".join([
             "--sysroot={}".format(sdk_path),
             "-arch x86_64",
             "-mmacosx-version-min=10.12",
             "-I{}".format(join(self.ctx.dist_dir, "hostlibffi", "usr", "local", "include"))
             ])
     if "openssl.build_all" in self.ctx.state:
         build_env["LDFLAGS"] += " -L{}".format(join(self.ctx.dist_dir, "lib"))
         build_env["CFLAGS"] += " -I{}".format(join(self.ctx.dist_dir, "include",
                                                    "x86_64", "openssl"))
     return build_env
예제 #13
0
파일: __init__.py 프로젝트: kivy/kivy-ios
 def get_build_env(self):
     sdk_path = sh.xcrun("--sdk", "macosx", "--show-sdk-path").strip()
     build_env = self.ctx.env.copy()
     self.build_env_x86_84 = build_env
     ccache = (build_env["CCACHE"] + ' ') if 'CCACHE' in build_env else ''
     build_env["CC"] = ccache + "clang -Qunused-arguments -fcolor-diagnostics"
     build_env["LDFLAGS"] = " ".join([
             "-lsqlite3",
             "-lffi",
             "-L{}".format(join(self.ctx.dist_dir, "hostlibffi", "usr", "local", "lib"))
             ])
     build_env["CFLAGS"] = " ".join([
             "--sysroot={}".format(sdk_path),
             "-arch x86_64",
             "-mmacosx-version-min=10.12",
             "-I{}".format(join(self.ctx.dist_dir, "hostlibffi", "usr", "local", "include"))
             ])
     if "openssl.build_all" in self.ctx.state:
         build_env["LDFLAGS"] += " -L{}".format(join(self.ctx.dist_dir, "lib"))
         build_env["CFLAGS"] += " -I{}".format(join(self.ctx.dist_dir, "include",
                                                    "x86_64", "openssl"))
     return build_env
예제 #14
0
def update_pbxproj(filename):
    # list all the compiled recipes
    ctx = Context()
    pbx_libraries = []
    pbx_frameworks = []
    frameworks = []
    libraries = []
    sources = []
    for recipe in Recipe.list_recipes():
        key = "{}.build_all".format(recipe)
        if key not in ctx.state:
            continue
        recipe = Recipe.get_recipe(recipe, ctx)
        recipe.init_with_ctx(ctx)
        pbx_frameworks.extend(recipe.pbx_frameworks)
        pbx_libraries.extend(recipe.pbx_libraries)
        libraries.extend(recipe.dist_libraries)
        frameworks.extend(recipe.frameworks)
        if recipe.sources:
            sources.append(recipe.name)

    pbx_frameworks = list(set(pbx_frameworks))
    pbx_libraries = list(set(pbx_libraries))
    libraries = list(set(libraries))

    print("-" * 70)
    print("The project need to have:")
    print("iOS Frameworks: {}".format(pbx_frameworks))
    print("iOS Libraries: {}".format(pbx_libraries))
    print("iOS local Frameworks: {}".format(frameworks))
    print("Libraries: {}".format(libraries))
    print("Sources to link: {}".format(sources))

    print("-" * 70)
    print("Analysis of {}".format(filename))

    from mod_pbxproj import XcodeProject
    project = XcodeProject.Load(filename)
    sysroot = sh.xcrun("--sdk", "iphonesimulator", "--show-sdk-path").strip()

    group = project.get_or_create_group("Frameworks")
    g_classes = project.get_or_create_group("Classes")
    for framework in pbx_frameworks:
        framework_name = "{}.framework".format(framework)
        if framework_name in frameworks:
            print("Ensure {} is in the project (local)".format(framework))
            f_path = join(ctx.dist_dir, "frameworks", framework_name)
        else:
            print("Ensure {} is in the project (system)".format(framework))
            f_path = join(sysroot, "System", "Library", "Frameworks",
                          "{}.framework".format(framework))
        project.add_file_if_doesnt_exist(f_path, parent=group, tree="DEVELOPER_DIR")
    for library in pbx_libraries:
        print("Ensure {} is in the project".format(library))
        f_path = join(sysroot, "usr", "lib",
                      "{}.dylib".format(library))
        project.add_file_if_doesnt_exist(f_path, parent=group, tree="DEVELOPER_DIR")
    for library in libraries:
        print("Ensure {} is in the project".format(library))
        project.add_file_if_doesnt_exist(library, parent=group)
    for name in sources:
        print("Ensure {} sources are used".format(name))
        fn = join(ctx.dist_dir, "sources", name)
        project.add_folder(fn, parent=g_classes)


    if project.modified:
        project.backup()
        project.save()
예제 #15
0
class Arch64IOS(Arch):
    sdk = "iphoneos"
    arch = "arm64"
    triple = "aarch64-apple-darwin13"
    version_min = "-miphoneos-version-min=7.0"
    sysroot = sh.xcrun("--sdk", "iphoneos", "--show-sdk-path").strip()
예제 #16
0
class ArchIOS(Arch):
    sdk = "iphoneos"
    arch = "armv7"
    triple = "arm-apple-darwin11"
    version_min = "-miphoneos-version-min=6.0.0"
    sysroot = sh.xcrun("--sdk", "iphoneos", "--show-sdk-path").strip()
예제 #17
0
class Arch64Simulator(Arch):
    sdk = "iphonesimulator"
    arch = "x86_64"
    triple = "x86_64-apple-darwin13"
    version_min = "-miphoneos-version-min=7.0"
    sysroot = sh.xcrun("--sdk", "iphonesimulator", "--show-sdk-path").strip()
예제 #18
0
class ArchSimulator(Arch):
    sdk = "iphonesimulator"
    arch = "i386"
    triple = "i386-apple-darwin11"
    version_min = "-miphoneos-version-min=6.0.0"
    sysroot = sh.xcrun("--sdk", "iphonesimulator", "--show-sdk-path").strip()
예제 #19
0
    def get_env(self):
        include_dirs = [
            "-I{}/{}".format(self.ctx.include_dir, d.format(arch=self))
            for d in self.ctx.include_dirs
        ]

        env = {}
        ccache = sh.which('ccache')
        cc = sh.xcrun("-find", "-sdk", self.sdk, "clang").strip()
        cxx = sh.xcrun("-find", "-sdk", self.sdk, "clang++").strip()

        # we put the flags in CC / CXX as sometimes the ./configure test
        # with the preprocessor (aka CC -E) without CFLAGS, which fails for
        # cross compiled projects
        flags = " ".join([
            "--sysroot",
            self.sysroot,
            "-arch",
            self.arch,
            "-pipe",
            "-no-cpp-precomp",
        ])
        cc += " " + flags
        cxx += " " + flags
        if ccache:
            ccache = ccache.strip()
            use_ccache = environ.get("USE_CCACHE", "1")
            if use_ccache != '1':
                env["CC"] = cc
                env["CXX"] = cxx
            else:
                if not self._ccsh:
                    self._ccsh = ccsh = sh.mktemp().strip()
                    with open(ccsh, 'w') as f:
                        f.write('#!/bin/sh\n')
                        f.write(ccache + ' ' + cc + ' "$@"\n')
                    sh.chmod('+x', ccsh)
                    self._cxxsh = cxxsh = sh.mktemp().strip()
                    with open(cxxsh, 'w') as f:
                        f.write('#!/bin/sh\n')
                        f.write(ccache + ' ' + cxx + ' "$@"\n')
                    sh.chmod('+x', cxxsh)
                else:
                    ccsh = self._ccsh
                    cxxsh = self._cxxsh
                env["USE_CCACHE"] = '1'
                env["CCACHE"] = ccache
                env["CC"] = ccsh
                env["CXX"] = cxxsh

                env.update({
                    k: v
                    for k, v in environ.items() if k.startswith('CCACHE_')
                })
                env.setdefault('CCACHE_MAXSIZE', '10G')
                env.setdefault('CCACHE_HARDLINK', 'true')
                env.setdefault('CCACHE_SLOPPINESS', (
                    'file_macro,time_macros,'
                    'include_file_mtime,include_file_ctime,file_stat_matches'))
        else:
            env["CC"] = cc
            env["CXX"] = cxx
        env["AR"] = sh.xcrun("-find", "-sdk", self.sdk, "ar").strip()
        env["LD"] = sh.xcrun("-find", "-sdk", self.sdk, "ld").strip()
        env["OTHER_CFLAGS"] = " ".join(include_dirs)
        env["OTHER_LDFLAGS"] = " ".join([
            "-L{}/{}".format(self.ctx.dist_dir, "lib"),
        ])
        env["CFLAGS"] = " ".join(["-O3", self.version_min] + include_dirs)
        env["LDFLAGS"] = " ".join([
            "-arch", self.arch, "--sysroot", self.sysroot,
            "-L{}/{}".format(self.ctx.dist_dir,
                             "lib"), "-lsqlite3", self.version_min
        ])
        return env