Exemplo n.º 1
0
  def build_toolchain(self):
    if self.target.is_macos():
      sdk = 'macosx'
      deploytarget = 'MACOSX_DEPLOYMENT_TARGET=' + self.deploymenttarget
    elif self.target.is_ios():
      sdk = 'iphoneos'
      deploytarget = 'IPHONEOS_DEPLOYMENT_TARGET=' + self.deploymenttarget

    platformpath = toolchain.check_output(['xcrun', '--sdk', sdk, '--show-sdk-platform-path'])
    localpath = platformpath + "/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"

    self.plist = "PATH=" + localpath + " " + toolchain.check_output(['xcrun', '--sdk', sdk, '-f', 'plutil'])
    self.xcassets = "PATH=" + localpath + " " + toolchain.check_output(['xcrun', '--sdk', sdk, '-f', 'actool'])
    self.xib = "PATH=" + localpath + " " + toolchain.check_output(['xcrun', '--sdk', sdk, '-f', 'ibtool'])
    self.dsymutil = "PATH=" + localpath + " " + toolchain.check_output(['xcrun', '--sdk', sdk, '-f', 'dsymutil'])

    self.plistcmd = 'build/ninja/plist.py --exename $exename --prodname $prodname --bundle $bundleidentifier --target $target --deploymenttarget $deploymenttarget --output $outpath $in'
    if self.target.is_macos():
      self.xcassetscmd = 'mkdir -p $outpath && $xcassets --output-format human-readable-text --output-partial-info-plist $outplist' \
                         ' --app-icon AppIcon --launch-image LaunchImage --platform macosx --minimum-deployment-target ' + self.deploymenttarget + \
                         ' --target-device mac --compress-pngs --compile $outpath $in >/dev/null'
      self.xibcmd = '$xib --target-device mac --module $module --minimum-deployment-target ' + self.deploymenttarget + \
                    ' --output-partial-info-plist $outplist --auto-activate-custom-fonts' \
                    ' --output-format human-readable-text --compile $outpath $in'
    elif self.target.is_ios():
      self.xcassetscmd = 'mkdir -p $outpath && $xcassets --output-format human-readable-text --output-partial-info-plist $outplist' \
                         ' --app-icon AppIcon --launch-image LaunchImage --platform iphoneos --minimum-deployment-target ' + self.deploymenttarget + \
                         ' --target-device iphone --target-device ipad --compress-pngs --compile $outpath $in >/dev/null'
      self.xibcmd = '$xib --target-device iphone --target-device ipad --module $module --minimum-deployment-target ' + self.deploymenttarget + \
                    ' --output-partial-info-plist $outplist --auto-activate-custom-fonts' \
                    ' --output-format human-readable-text --compile $outpath $in &> /dev/null '
    self.dsymutilcmd = '$dsymutil $in -o $outpath'
    self.codesigncmd = 'build/ninja/codesign.py --target $target --prefs codesign.json --builddir $builddir --binname $binname --config $config $outpath'
Exemplo n.º 2
0
  def initialize_toolchain(self):
    self.ndkpath = os.getenv('NDK_HOME', '')
    self.sdkpath = os.getenv('ANDROID_HOME', '')
    self.sysroot = ''
    self.platformversion = '21'
    self.gcc_toolchainversion = '4.9'
    self.javasdk = ''

    self.archname = dict()
    self.archname['x86'] = 'x86'
    self.archname['x86-64'] = 'x86_64'
    self.archname['arm6'] = 'arm'
    self.archname['arm7'] = 'arm'
    self.archname['arm64'] = 'arm64'
    self.archname['mips'] = 'mips'
    self.archname['mips64'] = 'mips64'

    self.archpath = dict()
    self.archpath['x86'] = 'x86'
    self.archpath['x86-64'] = 'x86-64'
    self.archpath['arm6'] = 'armeabi'
    self.archpath['arm7'] = 'armeabi-v7a'
    self.archpath['arm64'] = 'arm64-v8a'
    self.archpath['mips'] = 'mips'
    self.archpath['mips64'] = 'mips64'

    self.gcc_toolchainname = dict()
    self.gcc_toolchainname['x86'] = 'x86-' + self.gcc_toolchainversion
    self.gcc_toolchainname['x86-64'] = 'x86_64-' + self.gcc_toolchainversion
    self.gcc_toolchainname['arm6'] = 'arm-linux-androideabi-' + self.gcc_toolchainversion
    self.gcc_toolchainname['arm7'] = 'arm-linux-androideabi-' + self.gcc_toolchainversion
    self.gcc_toolchainname['arm64'] = 'aarch64-linux-android-' + self.gcc_toolchainversion
    self.gcc_toolchainname['mips'] = 'mipsel-linux-android-' + self.gcc_toolchainversion
    self.gcc_toolchainname['mips64'] = 'mips64el-linux-android-' + self.gcc_toolchainversion

    self.gcc_toolchainprefix = dict()
    self.gcc_toolchainprefix['x86'] = 'i686-linux-android-'
    self.gcc_toolchainprefix['x86-64'] = 'x86_64-linux-android-'
    self.gcc_toolchainprefix['arm6'] = 'arm-linux-androideabi-'
    self.gcc_toolchainprefix['arm7'] = 'arm-linux-androideabi-'
    self.gcc_toolchainprefix['arm64'] = 'aarch64-linux-android-'
    self.gcc_toolchainprefix['mips'] = 'mipsel-linux-android-'
    self.gcc_toolchainprefix['mips64'] = 'mips64el-linux-android-'

    if self.host.is_windows():
      if os.getenv('PROCESSOR_ARCHITECTURE', 'AMD64').find('64') != -1:
        self.hostarchname = 'windows-x86_64'
      else:
        self.hostarchname = 'windows-x86'
    elif self.host.is_linux():
        localarch = toolchain.check_output(['uname', '-m'])
        if localarch == 'x86_64':
          self.hostarchname = 'linux-x86_64'
        else:
          self.hostarchname = 'linux-x86'
    elif self.host.is_macos():
      self.hostarchname = 'darwin-x86_64'
Exemplo n.º 3
0
    def build_xcode_toolchain(self):
        if self.target.is_macos():
            sdk = 'macosx'
            deploytarget = 'MACOSX_DEPLOYMENT_TARGET=' + self.deploymenttarget
            self.cflags += [
                '-fasm-blocks',
                '-mmacosx-version-min=' + self.deploymenttarget, '-isysroot',
                '$sysroot'
            ]
            self.cxxflags += [
                '-fasm-blocks',
                '-mmacosx-version-min=' + self.deploymenttarget, '-isysroot',
                '$sysroot'
            ]
            self.arflags += ['-static', '-no_warning_for_no_symbols']
            self.linkflags += ['-isysroot', '$sysroot']
        elif self.target.is_ios():
            sdk = 'iphoneos'
            deploytarget = 'IPHONEOS_DEPLOYMENT_TARGET=' + self.deploymenttarget
            self.cflags += [
                '-fasm-blocks',
                '-miphoneos-version-min=' + self.deploymenttarget, '-isysroot',
                '$sysroot'
            ]
            self.cxxflags += [
                '-fasm-blocks',
                '-miphoneos-version-min=' + self.deploymenttarget, '-isysroot',
                '$sysroot'
            ]
            self.arflags += ['-static', '-no_warning_for_no_symbols']
            self.linkflags += ['-isysroot', '$sysroot']
        self.cflags += ['-fembed-bitcode-marker']

        platformpath = toolchain.check_output(
            ['xcrun', '--sdk', sdk, '--show-sdk-platform-path'])
        localpath = platformpath + "/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"

        self.sysroot = toolchain.check_output(
            ['xcrun', '--sdk', sdk, '--show-sdk-path'])

        self.ccompiler = "PATH=" + localpath + " " + toolchain.check_output(
            ['xcrun', '--sdk', sdk, '-f', 'clang'])
        self.archiver = "PATH=" + localpath + " " + toolchain.check_output(
            ['xcrun', '--sdk', sdk, '-f', 'libtool'])
        self.linker = deploytarget + " " + self.ccompiler
        self.lipo = "PATH=" + localpath + " " + toolchain.check_output(
            ['xcrun', '--sdk', sdk, '-f', 'lipo'])

        self.mflags += list(self.cflags) + [
            '-fobjc-arc', '-fno-objc-exceptions', '-x', 'objective-c'
        ]
        self.cflags += ['-x', 'c']
        self.cxxflags += ['-x', 'c++']

        self.cmcmd = self.cccmd.replace('$cflags', '$mflags')
        self.arcmd = self.rmcmd(
            '$out') + ' && $ar $ararchflags $arflags $in -o $out'
        self.lipocmd = '$lipo $in -create -output $out'

        if self.target.is_macos():
            self.frameworks = ['Cocoa', 'CoreFoundation']
        if self.target.is_ios():
            self.frameworks = ['CoreGraphics', 'UIKit', 'Foundation']