def build_arch(self, arch): super(LibxsltRecipe, self).build_arch(arch) env = self.get_recipe_env(arch) with current_directory(self.get_build_dir(arch.arch)): # If the build is done with /bin/sh things blow up, # try really hard to use bash env['CC'] += " -I%s" % self.get_build_dir(arch.arch) libxml = dirname(dirname(self.get_build_container_dir( arch.arch))) + "/libxml2/%s/libxml2" % arch.arch shprint(sh.Command('./configure'), '--build=i686-pc-linux-gnu', '--host=arm-linux-eabi', '--without-plugins', '--without-debug', '--without-python', '--without-crypto', '--with-libxml-src=%s' % libxml, _env=env) shprint(sh.make, "V=1", _env=env) shutil.copyfile( 'libxslt/.libs/libxslt.a', join(self.ctx.get_libs_dir(arch.arch), 'libxslt.a')) shutil.copyfile( 'libexslt/.libs/libexslt.a', join(self.ctx.get_libs_dir(arch.arch), 'libexslt.a'))
def build_arch(self, arch): super(LibtorrentRecipe, self).build_arch(arch) env = self.get_recipe_env(arch) with current_directory(join(self.get_build_dir(arch.arch), 'bindings/python')): # Compile libtorrent with boost libraries and python bindings b2 = sh.Command(join(env['BOOST_ROOT'], 'b2')) shprint(b2, '-q', '-j5', 'toolset=gcc-' + env['ARCH'], 'target-os=android', 'threading=multi', 'link=shared', 'boost-link=shared', 'boost=source', 'encryption=openssl' if 'openssl' in recipe.ctx.recipe_build_order else '', '--prefix=' + env['CROSSHOME'], 'release', _env=env) # Common build directories build_subdirs = 'gcc-arm/release/boost-link-shared/boost-source' if 'openssl' in recipe.ctx.recipe_build_order: build_subdirs += '/encryption-openssl' build_subdirs += '/libtorrent-python-pic-on/target-os-android/threading-multi/visibility-hidden' # Copy the shared libraries into the libs folder shutil.copyfile(join(env['BOOST_BUILD_PATH'], 'bin.v2/libs/python/build', build_subdirs, 'libboost_python.so'), join(self.ctx.get_libs_dir(arch.arch), 'libboost_python.so')) shutil.copyfile(join(env['BOOST_BUILD_PATH'], 'bin.v2/libs/system/build', build_subdirs, 'libboost_system.so'), join(self.ctx.get_libs_dir(arch.arch), 'libboost_system.so')) if 'openssl' in recipe.ctx.recipe_build_order: shutil.copyfile(join(env['BOOST_BUILD_PATH'], 'bin.v2/libs/date_time/build', build_subdirs, 'libboost_date_time.so'), join(self.ctx.get_libs_dir(arch.arch), 'libboost_date_time.so')) shutil.copyfile(join(self.get_build_dir(arch.arch), 'bin', build_subdirs, 'libtorrent_rasterbar.so'), join(self.ctx.get_libs_dir(arch.arch), 'libtorrent_rasterbar.so')) shutil.copyfile(join(self.get_build_dir(arch.arch), 'bindings/python/bin', build_subdirs, 'libtorrent.so'), join(self.ctx.get_site_packages_dir(arch.arch), 'libtorrent.so'))
def prebuild_arch(self, arch): super(Python3Recipe, self).prebuild_arch(arch) if self.version == '3.6' or self.version == '3.7': Python3Recipe.patches = [ 'patch_python3.6.patch', 'remove_android_api_check.patch', 'selectors.patch' ] build_dir = self.get_build_dir(arch.arch) # copy bundled libffi to _ctypes sh.cp("-r", join(self.get_recipe_dir(), 'libffi'), join(build_dir, 'Modules', '_ctypes')) print #####Copied bundle####' shprint(sh.ln, '-sf', realpath(join(build_dir, 'Lib/site-packages/README.txt')), join(build_dir, 'Lib/site-packages/README')) python_build_files = ['android.mk', 'config.c', 'interpreter.c'] ndk_build_tools_python_dir = join(self.ctx.ndk_dir, 'build', 'tools', 'build-target-python') for python_build_file in python_build_files: shprint( sh.cp, join(self.get_recipe_dir(), python_build_file + '.3.7'), join(ndk_build_tools_python_dir, python_build_file + '.3.7')) ndk_sources_python_dir = join(self.ctx.ndk_dir, 'sources', 'python') if not os.path.exists(join(ndk_sources_python_dir, '3.7')): os.mkdir(join(ndk_sources_python_dir, '3.7')) sh.sed('s#3.5#3.7#', join(ndk_sources_python_dir, '3.5/Android.mk'), _out=join(ndk_sources_python_dir, '3.7/Android.mk'))
def build_arch(self, arch): env = self.get_recipe_env(arch) with current_directory(self.get_build_dir(arch.arch)): # sh fails with code 255 trying to execute ./Configure # so instead we manually run perl passing in Configure perl = sh.Command('perl') buildarch = self.select_build_arch(arch) # XXX if we don't have no-asm, using clang and ndk-15c, i got: # crypto/aes/bsaes-armv7.S:1372:14: error: immediate operand must be in the range [0,4095] # add r8, r6, #.LREVM0SR-.LM0 @ borrow r8 # ^ # crypto/aes/bsaes-armv7.S:1434:14: error: immediate operand must be in the range [0,4095] # sub r6, r8, #.LREVM0SR-.LSR @ pass constants config_args = ['shared', 'no-dso', 'no-asm'] if self.use_legacy: config_args.append('no-krb5') config_args.append(buildarch) if not self.use_legacy: config_args.append('-D__ANDROID_API__={}'.format(self.ctx.ndk_api)) shprint(perl, 'Configure', *config_args, _env=env) self.apply_patch( 'disable-sover{}.patch'.format( '-legacy' if self.use_legacy else ''), arch.arch) if self.use_legacy: self.apply_patch('rename-shared-lib.patch', arch.arch) shprint(sh.make, 'build_libs', _env=env) self.install_libs(arch, 'libssl' + self.version + '.so', 'libcrypto' + self.version + '.so')
def build_armeabi(self): # AND: I'm going to ignore any extra pythonrecipe or cythonrecipe behaviour for now arch = ArchAndroid(self.ctx) env = self.get_recipe_env(arch) env['CFLAGS'] = env['CFLAGS'] + ' -I{jni_path}/png -I{jni_path}/jpeg'.format( jni_path=join(self.ctx.bootstrap.build_dir, 'jni')) env['CFLAGS'] = env['CFLAGS'] + ' -I{jni_path}/sdl/include -I{jni_path}/sdl_mixer'.format( jni_path=join(self.ctx.bootstrap.build_dir, 'jni')) env['CFLAGS'] = env['CFLAGS'] + ' -I{jni_path}/sdl_ttf -I{jni_path}/sdl_image'.format( jni_path=join(self.ctx.bootstrap.build_dir, 'jni')) debug('pygame cflags', env['CFLAGS']) env['LDFLAGS'] = env['LDFLAGS'] + ' -L{libs_path} -L{src_path}/obj/local/{arch} -lm -lz'.format( libs_path=self.ctx.libs_dir, src_path=self.ctx.bootstrap.build_dir, arch=env['ARCH']) env['LDSHARED'] = join(self.ctx.root_dir, 'tools', 'liblink') with current_directory(self.get_build_dir('armeabi')): info('hostpython is ' + self.ctx.hostpython) hostpython = sh.Command(self.ctx.hostpython) shprint(hostpython, 'setup.py', 'install', '-O2', _env=env) info('strip is ' + env['STRIP']) build_lib = glob.glob('./build/lib*') assert len(build_lib) == 1 print('stripping pygame') shprint(sh.find, build_lib[0], '-name', '*.o', '-exec', env['STRIP'], '{}', ';') python_install_path = join(self.ctx.build_dir, 'python-install') # AND: Should do some deleting here! print('Should remove pygame tests etc. here, but skipping for now')
def run_distribute(self): info_main('# Creating Android project from build and {} bootstrap'.format( self.name)) shprint(sh.rm, '-rf', self.dist_dir) shprint(sh.cp, '-r', self.build_dir, self.dist_dir) with current_directory(self.dist_dir): with open('local.properties', 'w') as fileh: fileh.write('sdk.dir={}'.format(self.ctx.sdk_dir)) arch = self.ctx.archs[0] if len(self.ctx.archs) > 1: raise ValueError('built for more than one arch, but bootstrap cannot handle that yet') info('Bootstrap running with arch {}'.format(arch)) with current_directory(self.dist_dir): info('Copying python distribution') self.distribute_libs(arch, [self.ctx.get_libs_dir(arch.arch)]) self.distribute_aars(arch) self.distribute_javaclasses(self.ctx.javaclass_dir) python_bundle_dir = join('_python_bundle', '_python_bundle') ensure_dir(python_bundle_dir) site_packages_dir = self.ctx.python_recipe.create_python_bundle( join(self.dist_dir, python_bundle_dir), arch) if 'sqlite3' not in self.ctx.recipe_build_order: with open('blacklist.txt', 'a') as fileh: fileh.write('\nsqlite3/*\nlib-dynload/_sqlite3.so\n') self.strip_libraries(arch) self.fry_eggs(site_packages_dir) super(WebViewBootstrap, self).run_distribute()
def build_armeabi(self): # AND: Should use an i386 recipe system warning('Running hostpython build. Arch is armeabi! ' 'This is naughty, need to fix the Arch system!') # AND: Fix armeabi again with current_directory(self.get_build_dir('armeabi')): if exists('hostpython'): info('hostpython already exists, skipping build') self.ctx.hostpython = join(self.get_build_dir('armeabi'), 'hostpython') self.ctx.hostpgen = join(self.get_build_dir('armeabi'), 'hostpgen') return configure = sh.Command('./configure') shprint(configure) shprint(sh.make, '-j5') shprint(sh.mv, join('Parser', 'pgen'), 'hostpgen') if exists('python.exe'): shprint(sh.mv, 'python.exe', 'hostpython') elif exists('python'): shprint(sh.mv, 'python', 'hostpython') else: warning('Unable to find the python executable after ' 'hostpython build! Exiting.') exit(1) self.ctx.hostpython = join(self.get_build_dir('armeabi'), 'hostpython') self.ctx.hostpgen = join(self.get_build_dir('armeabi'), 'hostpgen')
def set_libs_flags(self, env, arch): '''Takes care to properly link libraries with python depending on our requirements and the attribute :attr:`opt_depends`. ''' if 'libffi' in self.ctx.recipe_build_order: info('Activating flags for libffi') recipe = Recipe.get_recipe('libffi', self.ctx) include = ' -I' + ' -I'.join(recipe.get_include_dirs(arch)) ldflag = ' -L' + join(recipe.get_build_dir(arch.arch), recipe.get_host(arch), '.libs') + ' -lffi' env['CPPFLAGS'] = env.get('CPPFLAGS', '') + include env['LDFLAGS'] = env.get('LDFLAGS', '') + ldflag if 'openssl' in self.ctx.recipe_build_order: recipe = Recipe.get_recipe('openssl', self.ctx) openssl_build_dir = recipe.get_build_dir(arch.arch) setuplocal = join('Modules', 'Setup.local') shprint(sh.cp, join(self.get_recipe_dir(), 'Setup.local-ssl'), setuplocal) shprint(sh.sed, '-i.backup', 's#^SSL=.*#SSL={}#'.format(openssl_build_dir), setuplocal) env['OPENSSL_VERSION'] = recipe.version if 'sqlite3' in self.ctx.recipe_build_order: # Include sqlite3 in python2 build recipe = Recipe.get_recipe('sqlite3', self.ctx) include = ' -I' + recipe.get_build_dir(arch.arch) lib = ' -L' + recipe.get_lib_dir(arch) + ' -lsqlite3' # Insert or append to env flag = 'CPPFLAGS' env[flag] = env[flag] + include if flag in env else include flag = 'LDFLAGS' env[flag] = env[flag] + lib if flag in env else lib return env
def build_armeabi(self): # AND: Should use an i386 recipe system warning('Running hostpython build. Arch is armeabi! ' 'This is naughty, need to fix the Arch system!') # AND: Fix armeabi again with current_directory(self.get_build_dir('armeabi')): if exists('hostpython'): info('hostpython already exists, skipping build') self.ctx.hostpython = join(self.get_build_dir('armeabi'), 'hostpython') self.ctx.hostpgen = join(self.get_build_dir('armeabi'), 'hostpgen') return configure = sh.Command('./configure') shprint(configure) shprint(sh.make, '-j5') shprint(sh.mv, join('Parser', 'pgen'), 'hostpgen') if exists('python.exe'): shprint(sh.mv, 'python.exe', 'hostpython') elif exists('python'): shprint(sh.mv, 'python', 'hostpython') else: warning('Unable to find the python executable after ' 'hostpython build! Exiting.') exit(1) self.ctx.hostpython = join(self.get_build_dir('armeabi'), 'hostpython') self.ctx.hostpgen = join(self.get_build_dir('armeabi'), 'hostpgen')
def prebuild_arch(self, arch): super(Python2LegacyRecipe, self).prebuild_arch(arch) patch_mark = join(self.get_build_dir(arch.arch), '.openssl-patched') if 'openssl' in self.ctx.recipe_build_order and not exists(patch_mark): self.apply_patch(join('patches', 'enable-openssl.patch'), arch.arch) shprint(sh.touch, patch_mark)
def run_distribute(self): info_main('# Creating Android project from build and {} bootstrap'.format( self.name)) info('This currently just copies the build stuff straight from the build dir.') shprint(sh.rm, '-rf', self.dist_dir) shprint(sh.cp, '-r', self.build_dir, self.dist_dir) with current_directory(self.dist_dir): with open('local.properties', 'w') as fileh: fileh.write('sdk.dir={}'.format(self.ctx.sdk_dir)) arch = self.ctx.archs[0] if len(self.ctx.archs) > 1: raise ValueError('built for more than one arch, but bootstrap cannot handle that yet') info('Bootstrap running with arch {}'.format(arch)) with current_directory(self.dist_dir): info('Copying python distribution') self.distribute_libs(arch, [self.ctx.get_libs_dir(arch.arch)]) self.distribute_aars(arch) self.distribute_javaclasses(self.ctx.javaclass_dir) python_bundle_dir = join('_python_bundle', '_python_bundle') ensure_dir(python_bundle_dir) site_packages_dir = self.ctx.python_recipe.create_python_bundle( join(self.dist_dir, python_bundle_dir), arch) if 'sqlite3' not in self.ctx.recipe_build_order: with open('blacklist.txt', 'a') as fileh: fileh.write('\nsqlite3/*\nlib-dynload/_sqlite3.so\n') self.strip_libraries(arch) self.fry_eggs(site_packages_dir) super(ServiceOnlyBootstrap, self).run_distribute()
def prebuild_armeabi(self): build_dir = self.get_build_container_dir('armeabi') if exists(join(build_dir, '.patched')): info('Python2 already patched, skipping.') return self.apply_patch( join('patches', 'Python-{}-xcompile.patch'.format(self.version))) self.apply_patch( join('patches', 'Python-{}-ctypes-disable-wchar.patch'.format(self.version))) self.apply_patch(join('patches', 'disable-modules.patch')) self.apply_patch(join('patches', 'fix-locale.patch')) self.apply_patch(join('patches', 'fix-gethostbyaddr.patch')) self.apply_patch(join('patches', 'fix-setup-flags.patch')) self.apply_patch(join('patches', 'fix-filesystemdefaultencoding.patch')) self.apply_patch(join('patches', 'fix-termios.patch')) self.apply_patch(join('patches', 'custom-loader.patch')) self.apply_patch(join('patches', 'verbose-compilation.patch')) self.apply_patch(join('patches', 'fix-remove-corefoundation.patch')) self.apply_patch(join('patches', 'fix-dynamic-lookup.patch')) self.apply_patch(join('patches', 'fix-dlfcn.patch')) self.apply_patch(join('patches', 'parsetuple.patch')) # self.apply_patch(join('patches', 'ctypes-find-library.patch')) self.apply_patch(join('patches', 'ctypes-find-library-updated.patch')) if uname()[0] == 'Linux': self.apply_patch(join('patches', 'fix-configure-darwin.patch')) self.apply_patch(join('patches', 'fix-distutils-darwin.patch')) if self.ctx.android_api > 19: self.apply_patch(join('patches', 'fix-ftime-removal.patch')) shprint(sh.touch, join(build_dir, '.patched'))
def build_arch(self, arch): super(Libxml2Recipe, self).build_arch(arch) env = self.get_recipe_env(arch) with current_directory(self.get_build_dir(arch.arch)): env["CC"] += " -I%s" % self.get_build_dir(arch.arch) shprint( sh.Command("./configure"), "--host=arm-linux-eabi", "--without-modules", "--without-legacy", "--without-history", "--without-debug", "--without-docbook", "--without-python", "--without-threads", "--without-iconv", _env=env, ) # Ensure we only build libxml2.la as if we do everything # we'll need the glob dependency which is a big headache shprint(sh.make, "libxml2.la", _env=env) shutil.copyfile( ".libs/libxml2.a", join(self.ctx.get_libs_dir(arch.arch), "libxml2.a") )
def build_arch(self, arch): # build_compiled_components(self, arch) info("Building compiled components for my_lib") env = self.get_recipe_env(arch) info(json.dumps(env, indent=2)) target = self.get_target(arch) platform = self.ctx.android_api build_dir = self.get_build_dir(arch.arch) lib_dir = join(build_dir, "target", target, "debug") with current_directory(build_dir): cargo = sh.Command("cargo") shprint( cargo, "ndk", "--platform", str(platform), "--target", target, "build", # "--release", _env=env, ) shutil.copyfile( join(lib_dir, "libmy_lib.so"), join(self.ctx.get_site_packages_dir(arch.arch), "my_lib.so"), )
def prebuild_arch(self, arch): build_dir = self.get_build_container_dir(arch.arch) if exists(join(build_dir, '.patched')): info('Python2 already patched, skipping.') return self.apply_patch(join('patches', 'Python-{}-xcompile.patch'.format(self.version)), arch.arch) self.apply_patch(join('patches', 'Python-{}-ctypes-disable-wchar.patch'.format(self.version)), arch.arch) self.apply_patch(join('patches', 'disable-modules.patch'), arch.arch) self.apply_patch(join('patches', 'fix-locale.patch'), arch.arch) self.apply_patch(join('patches', 'fix-gethostbyaddr.patch'), arch.arch) self.apply_patch(join('patches', 'fix-setup-flags.patch'), arch.arch) self.apply_patch(join('patches', 'fix-filesystemdefaultencoding.patch'), arch.arch) self.apply_patch(join('patches', 'fix-termios.patch'), arch.arch) self.apply_patch(join('patches', 'custom-loader.patch'), arch.arch) self.apply_patch(join('patches', 'verbose-compilation.patch'), arch.arch) self.apply_patch(join('patches', 'fix-remove-corefoundation.patch'), arch.arch) self.apply_patch(join('patches', 'fix-dynamic-lookup.patch'), arch.arch) self.apply_patch(join('patches', 'fix-dlfcn.patch'), arch.arch) self.apply_patch(join('patches', 'parsetuple.patch'), arch.arch) # self.apply_patch(join('patches', 'ctypes-find-library.patch'), arch.arch) self.apply_patch(join('patches', 'ctypes-find-library-updated.patch'), arch.arch) if uname()[0] == 'Linux': self.apply_patch(join('patches', 'fix-configure-darwin.patch'), arch.arch) self.apply_patch(join('patches', 'fix-distutils-darwin.patch'), arch.arch) if self.ctx.android_api > 19: self.apply_patch(join('patches', 'fix-ftime-removal.patch'), arch.arch) shprint(sh.touch, join(build_dir, '.patched'))
def build_arch(self, arch): env = self.get_recipe_env(arch) with current_directory(self.get_build_dir(arch.arch)): # sh fails with code 255 trying to execute ./Configure # so instead we manually run perl passing in Configure perl = sh.Command('perl') buildarch = self.select_build_arch(arch) config_args = ['shared', 'no-dso', 'no-asm'] config_args.append(buildarch) shprint(perl, 'Configure', *config_args, _env=env) self.apply_patch('disable-sover.patch', arch.arch) makefile = join(self.get_build_dir(arch.arch), 'Makefile') sh.sed('-i', 's/CROSS_COMPILE=arm-linux-androideabi-/CROSS_COMPILE=/g', makefile) sh.sed('-i', 's/CROSS_COMPILE=aarch64-linux-android-/CROSS_COMPILE=/g', makefile) shprint(sh.make, 'build_libs', _env=env) self.install_libs(arch, 'libssl.a', 'libssl' + self.version + '.so', 'libcrypto.a', 'libcrypto' + self.version + '.so')
def prebuild_arch(self, arch): build_dir = self.get_build_container_dir(arch.arch) if exists(join(build_dir, '.patched')): print('Python3 already patched, skipping.') return # # self.apply_patch(join('patches_inclement', # # 'python-{version}-define_macro.patch'.format(version=self.version))) # # self.apply_patch(join('patches_inclement', # # 'python-{version}-android-locale.patch'.format(version=self.version))) # # self.apply_patch(join('patches_inclement', # # 'python-{version}-android-misc.patch'.format(version=self.version))) # self.apply_patch(join('patches_inclement', # 'python-{version}-locale_and_android_misc.patch'.format(version=self.version))) self.apply_patch(join('patches', 'python-{version}-android-libmpdec.patch'.format(version=self.version)), arch.arch) self.apply_patch(join('patches', 'python-{version}-android-locale.patch'.format(version=self.version)), arch.arch) self.apply_patch(join('patches', 'python-{version}-android-misc.patch'.format(version=self.version)), arch.arch) # self.apply_patch(join('patches', 'python-{version}-android-missing-getdents64-definition.patch'.format(version=self.version)), arch.arch) self.apply_patch(join('patches', 'python-{version}-cross-compile.patch'.format(version=self.version)), arch.arch) self.apply_patch(join('patches', 'python-{version}-python-misc.patch'.format(version=self.version)), arch.arch) self.apply_patch(join('patches', 'python-{version}-libpymodules_loader.patch'.format(version=self.version)), arch.arch) self.apply_patch('log_failures.patch', arch.arch) shprint(sh.touch, join(build_dir, '.patched'))
def build_arch(self, arch): super(LibxsltRecipe, self).build_arch(arch) env = self.get_recipe_env(arch) with current_directory(self.get_build_dir(arch.arch)): # If the build is done with /bin/sh things blow up, # try really hard to use bash env["CC"] += " -I%s" % self.get_build_dir(arch.arch) libxml = Recipe.get_recipe( 'libxml2', self.ctx).get_build_dir(arch.arch) shprint( sh.Command("./configure"), "--build=i686-pc-linux-gnu", "--host=arm-linux-eabi", "--without-plugins", "--without-debug", "--without-python", "--without-crypto", "--with-libxml-src=%s" % libxml, _env=env, ) shprint(sh.make, "V=1", _env=env) shutil.copyfile( "libxslt/.libs/libxslt.a", join(self.ctx.get_libs_dir(arch.arch), "libxslt.a"), ) shutil.copyfile( "libexslt/.libs/libexslt.a", join(self.ctx.get_libs_dir(arch.arch), "libexslt.a"), )
def prebuild_arch(self, arch): super(VlcRecipe, self).prebuild_arch(arch) build_dir = self.get_build_dir(arch.arch) port_dir = join(build_dir, 'vlc-port-android') if self.ENV_LIBVLC_AAR in environ: self.aars[arch] = aar = environ.get(self.ENV_LIBVLC_AAR) if not exists(aar): warning("Error: libvlc-<ver>.aar bundle " \ "not found in {}".format(aar)) info("check {} environment!".format(self.ENV_LIBVLC_AAR)) exit(1) else: aar_path = join(port_dir, 'libvlc', 'build', 'outputs', 'aar') self.aars[arch] = aar = join(aar_path, 'libvlc-{}.aar'.format(self.version)) warning("HINT: set path to precompiled libvlc-<ver>.aar bundle " \ "in {} environment!".format(self.ENV_LIBVLC_AAR)) info("libvlc-<ver>.aar should build " \ "from sources at {}".format(port_dir)) if not exists(join(port_dir, 'compile.sh')): info("clone vlc port for android sources from {}".format( self.port_git)) shprint(sh.git, 'clone', self.port_git, port_dir, _tail=20, _critical=True) vlc_dir = join(port_dir, 'vlc') if not exists(join(vlc_dir, 'Makefile.am')): info("clone vlc sources from {}".format(self.vlc_git)) shprint(sh.git, 'clone', self.vlc_git, vlc_dir, _tail=20, _critical=True)
def prebuild_arch(self, arch): super(Python3Recipe, self).prebuild_arch(arch) if self.version == '3.6': Python3Recipe.patches = ['patch_python3.6.patch'] build_dir = self.get_build_dir(arch.arch) shprint(sh.ln, '-sf', realpath(join(build_dir, 'Lib/site-packages/README.txt')), join(build_dir, 'Lib/site-packages/README')) python_build_files = ['android.mk', 'config.c', 'interpreter.c'] ndk_build_tools_python_dir = join(self.ctx.ndk_dir, 'build', 'tools', 'build-target-python') for python_build_file in python_build_files: shprint( sh.cp, join(ndk_build_tools_python_dir, python_build_file + '.3.5'), join(ndk_build_tools_python_dir, python_build_file + '.3.6')) ndk_sources_python_dir = join(self.ctx.ndk_dir, 'sources', 'python') if not os.path.exists(join(ndk_sources_python_dir, '3.6')): os.mkdir(join(ndk_sources_python_dir, '3.6')) sh.sed('s#3.5#3.6#', join(ndk_sources_python_dir, '3.5/Android.mk'), _out=join(ndk_sources_python_dir, '3.6/Android.mk'))
def prebuild_armeabi(self): build_dir = self.get_build_container_dir('armeabi') if exists(join(build_dir, '.patched')): print('Python3 already patched, skipping.') return self.apply_patch( join( 'patches', 'python-{version}-android-libmpdec.patch'.format( version=self.version))) self.apply_patch( join( 'patches', 'python-{version}-android-locale.patch'.format( version=self.version))) self.apply_patch( join( 'patches', 'python-{version}-android-misc.patch'.format( version=self.version))) # self.apply_patch(join('patches', 'python-{version}-android-missing-getdents64-definition.patch'.format(version=self.version))) self.apply_patch( join( 'patches', 'python-{version}-cross-compile.patch'.format( version=self.version))) self.apply_patch( join( 'patches', 'python-{version}-python-misc.patch'.format( version=self.version))) shprint(sh.touch, join(build_dir, '.patched'))
def build_arch(self, arch): env = self.get_recipe_env(arch) with current_directory(self.get_build_dir(arch.arch)): # sh fails with code 255 trying to execute ./Configure # so instead we manually run perl passing in Configure perl = sh.Command('perl') buildarch = self.select_build_arch(arch) # XXX if we don't have no-asm, using clang and ndk-15c, i got: # crypto/aes/bsaes-armv7.S:1372:14: error: immediate operand must be in the range [0,4095] # add r8, r6, #.LREVM0SR-.LM0 @ borrow r8 # ^ # crypto/aes/bsaes-armv7.S:1434:14: error: immediate operand must be in the range [0,4095] # sub r6, r8, #.LREVM0SR-.LSR @ pass constants config_args = ['shared', 'no-dso', 'no-asm'] if self.use_legacy: config_args.append('no-krb5') config_args.append(buildarch) if not self.use_legacy: config_args.append('-D__ANDROID_API__={}'.format( self.ctx.ndk_api)) shprint(perl, 'Configure', *config_args, _env=env) self.apply_patch( 'disable-sover{}.patch'.format( '-legacy' if self.use_legacy else ''), arch.arch) if self.use_legacy: self.apply_patch('rename-shared-lib.patch', arch.arch) shprint(sh.make, 'build_libs', _env=env) self.install_libs(arch, 'libssl' + self.version + '.so', 'libcrypto' + self.version + '.so')
def set_libs_flags(self, env, arch): '''Takes care to properly link libraries with python depending on our requirements and the attribute :attr:`opt_depends`. ''' if 'libffi' in self.ctx.recipe_build_order: info('Activating flags for libffi') recipe = Recipe.get_recipe('libffi', self.ctx) include = ' -I' + ' -I'.join(recipe.get_include_dirs(arch)) ldflag = ' -L' + join(recipe.get_build_dir(arch.arch), recipe.get_host(arch), '.libs') + ' -lffi' env['CPPFLAGS'] = env.get('CPPFLAGS', '') + include env['LDFLAGS'] = env.get('LDFLAGS', '') + ldflag if 'openssl' in self.ctx.recipe_build_order: recipe = Recipe.get_recipe('openssl', self.ctx) openssl_build_dir = recipe.get_build_dir(arch.arch) setuplocal = join('Modules', 'Setup.local') shprint(sh.cp, join(self.get_recipe_dir(), 'Setup.local-ssl'), setuplocal) shprint(sh.sed, '-i.backup', 's#^SSL=.*#SSL={}#'.format(openssl_build_dir), setuplocal) env['OPENSSL_VERSION'] = recipe.version if 'sqlite3' in self.ctx.recipe_build_order: # Include sqlite3 in python2 build recipe = Recipe.get_recipe('sqlite3', self.ctx) include = ' -I' + recipe.get_build_dir(arch.arch) lib = ' -L' + recipe.get_lib_dir(arch) + ' -lsqlite3' # Insert or append to env flag = 'CPPFLAGS' env[flag] = env[flag] + include if flag in env else include flag = 'LDFLAGS' env[flag] = env[flag] + lib if flag in env else lib return env
def build_arch(self, arch): with current_directory(self.get_build_dir()): if exists('hostpython'): info('hostpython already exists, skipping build') self.ctx.hostpython = join(self.get_build_dir(), 'hostpython') self.ctx.hostpgen = join(self.get_build_dir(), 'hostpgen') return configure = sh.Command('./configure') shprint(configure) shprint(sh.make, '-j5') shprint(sh.mv, join('Parser', 'pgen'), 'hostpgen') if exists('python.exe'): shprint(sh.mv, 'python.exe', 'hostpython') elif exists('python'): shprint(sh.mv, 'python', 'hostpython') else: warning('Unable to find the python executable after ' 'hostpython build! Exiting.') exit(1) self.ctx.hostpython = join(self.get_build_dir(), 'hostpython') self.ctx.hostpgen = join(self.get_build_dir(), 'hostpgen')
def build_arch(self, arch): recipe_build_dir = self.get_build_dir(arch.arch) # Create a subdirectory to actually perform the build build_dir = join(recipe_build_dir, BUILD_SUBDIR) ensure_dir(build_dir) if not exists(join(build_dir, 'python')): with current_directory(recipe_build_dir): # Configure the build with current_directory(build_dir): if not exists('config.status'): shprint(sh.Command(join(recipe_build_dir, 'configure'))) # Create the Setup file. This copying from Setup.dist # seems to be the normal and expected procedure. shprint(sh.cp, join('Modules', 'Setup.dist'), join(build_dir, 'Modules', 'Setup')) result = shprint(sh.make, '-C', build_dir) else: info('Skipping hostpython3 build as it has already been completed') self.ctx.hostpython = join(build_dir, 'python')
def get_recipe_env(self, arch=None, with_flags_in_cc=True): env = super(PILRecipe, self).get_recipe_env(arch, with_flags_in_cc) env['PYTHON_INCLUDE_ROOT'] = self.ctx.python_recipe.include_root(arch.arch) env['PYTHON_LINK_ROOT'] = self.ctx.python_recipe.link_root(arch.arch) ndk_lib_dir = join(self.ctx.ndk_platform, 'usr', 'lib') ndk_include_dir = join(self.ctx.ndk_dir, 'sysroot', 'usr', 'include') png = self.get_recipe('png', self.ctx) png_lib_dir = png.get_lib_dir(arch) png_jni_dir = png.get_jni_dir(arch) jpeg = self.get_recipe('jpeg', self.ctx) jpeg_inc_dir = jpeg_lib_dir = jpeg.get_build_dir(arch.arch) if 'freetype' in self.ctx.recipe_build_order: freetype = self.get_recipe('freetype', self.ctx) free_lib_dir = join(freetype.get_build_dir(arch.arch), 'objs', '.libs') free_inc_dir = join(freetype.get_build_dir(arch.arch), 'include') # hack freetype to be found by pil freetype_link = join(free_inc_dir, 'freetype') if not exists(freetype_link): shprint(sh.ln, '-s', join(free_inc_dir), freetype_link) harfbuzz = self.get_recipe('harfbuzz', self.ctx) harf_lib_dir = join(harfbuzz.get_build_dir(arch.arch), 'src', '.libs') harf_inc_dir = harfbuzz.get_build_dir(arch.arch) env['FREETYPE_ROOT'] = '{}|{}'.format(free_lib_dir, free_inc_dir) env['JPEG_ROOT'] = '{}|{}'.format(jpeg_lib_dir, jpeg_inc_dir) env['ZLIB_ROOT'] = '{}|{}'.format(ndk_lib_dir, ndk_include_dir) cflags = ' -std=c99' cflags += ' -I{}'.format(png_jni_dir) if 'freetype' in self.ctx.recipe_build_order: cflags += ' -I{} -I{}'.format(harf_inc_dir, join(harf_inc_dir, 'src')) cflags += ' -I{}'.format(free_inc_dir) cflags += ' -I{}'.format(jpeg_inc_dir) cflags += ' -I{}'.format(ndk_include_dir) py_v = self.ctx.python_recipe.major_minor_version_string if py_v[0] == '3': py_v += 'm' env['LIBS'] = ' -lpython{version} -lpng'.format(version=py_v) if 'freetype' in self.ctx.recipe_build_order: env['LIBS'] += ' -lfreetype -lharfbuzz' env['LIBS'] += ' -ljpeg -lturbojpeg' env['LDFLAGS'] += ' -L{} -L{}'.format(env['PYTHON_LINK_ROOT'], png_lib_dir) if 'freetype' in self.ctx.recipe_build_order: env['LDFLAGS'] += ' -L{} -L{}'.format(harf_lib_dir, free_lib_dir) env['LDFLAGS'] += ' -L{} -L{}'.format(jpeg_lib_dir, ndk_lib_dir) if cflags not in env['CFLAGS']: env['CFLAGS'] += cflags return env
def get_recipe_env(self, arch=None, with_flags_in_cc=True): env = super(PILRecipe, self).get_recipe_env(arch, with_flags_in_cc) env['PYTHON_INCLUDE_ROOT'] = self.ctx.python_recipe.include_root(arch.arch) env['PYTHON_LINK_ROOT'] = self.ctx.python_recipe.link_root(arch.arch) ndk_lib_dir = join(self.ctx.ndk_platform, 'usr', 'lib') ndk_include_dir = join(self.ctx.ndk_dir, 'sysroot', 'usr', 'include') png = self.get_recipe('png', self.ctx) png_lib_dir = png.get_lib_dir(arch) png_jni_dir = png.get_jni_dir(arch) jpeg = self.get_recipe('jpeg', self.ctx) jpeg_inc_dir = jpeg_lib_dir = jpeg.get_build_dir(arch.arch) if 'freetype' in self.ctx.recipe_build_order: freetype = self.get_recipe('freetype', self.ctx) free_lib_dir = join(freetype.get_build_dir(arch.arch), 'objs', '.libs') free_inc_dir = join(freetype.get_build_dir(arch.arch), 'include') # hack freetype to be found by pil freetype_link = join(free_inc_dir, 'freetype') if not exists(freetype_link): shprint(sh.ln, '-s', join(free_inc_dir), freetype_link) harfbuzz = self.get_recipe('harfbuzz', self.ctx) harf_lib_dir = join(harfbuzz.get_build_dir(arch.arch), 'src', '.libs') harf_inc_dir = harfbuzz.get_build_dir(arch.arch) env['FREETYPE_ROOT'] = '{}|{}'.format(free_lib_dir, free_inc_dir) env['JPEG_ROOT'] = '{}|{}'.format(jpeg_lib_dir, jpeg_inc_dir) env['ZLIB_ROOT'] = '{}|{}'.format(ndk_lib_dir, ndk_include_dir) cflags = ' -std=c99' cflags += ' -I{}'.format(png_jni_dir) if 'freetype' in self.ctx.recipe_build_order: cflags += ' -I{} -I{}'.format(harf_inc_dir, join(harf_inc_dir, 'src')) cflags += ' -I{}'.format(free_inc_dir) cflags += ' -I{}'.format(jpeg_inc_dir) cflags += ' -I{}'.format(ndk_include_dir) py_v = self.ctx.python_recipe.major_minor_version_string if py_v[0] == '3': py_v += 'm' env['LIBS'] = ' -lpython{version} -lpng'.format(version=py_v) if 'freetype' in self.ctx.recipe_build_order: env['LIBS'] += ' -lfreetype -lharfbuzz' env['LIBS'] += ' -ljpeg -lturbojpeg' env['LDFLAGS'] += ' -L{} -L{}'.format(env['PYTHON_LINK_ROOT'], png_lib_dir) if 'freetype' in self.ctx.recipe_build_order: env['LDFLAGS'] += ' -L{} -L{}'.format(harf_lib_dir, free_lib_dir) env['LDFLAGS'] += ' -L{} -L{}'.format(jpeg_lib_dir, ndk_lib_dir) if cflags not in env['CFLAGS']: env['CFLAGS'] += cflags return env
def prebuild_arch(self, arch): super(PyjniusRecipe, self).prebuild_arch(arch) build_dir = self.get_build_dir(arch.arch) if exists(join(build_dir, '.patched')): print('pyjniussdl2 already pathed, skipping') return self.apply_patch('sdl2_jnienv_getter.patch') shprint(sh.touch, join(build_dir, '.patched'))
def build_arch(self, arch): env = self.get_recipe_env(arch) if 'JNI_DIR' in environ: env['NDK_PROJECT_DIR'] = environ['JNI_DIR'] with current_directory(self.get_jni_dir()): shprint(sh.ndk_build, "V=1", _env=env)
def prebuild_arch(self, arch): super(LibSDL2Image, self).prebuild_arch(arch) build_dir = self.get_build_dir(arch.arch) if exists(join(build_dir, '.patched')): info('SDL2_image already patched, skipping') return self.apply_patch('disable_webp.patch') shprint(sh.touch, join(build_dir, '.patched'))
def prepare_build_dir(self, arch): shprint(sh.rm, "-rf", self.get_build_dir(arch)) shprint( sh.ln, "-s", join(self.get_recipe_dir(), self.src_filename), self.get_build_dir(arch), )
def prebuild_arch(self, arch): with current_directory(self.get_build_dir(arch.arch)): # Cross compiling for 32 bits in 64 bit ubuntu before precise is # failing. See # https://bugs.launchpad.net/ubuntu/+source/python2.7/+bug/873007 shprint(sh.sed, '-i', "s|BUILD_CEXTENSIONS = True|BUILD_CEXTENSIONS = False|", 'setup.py')
def build_arch(self, arch): super(FFMpegRecipe, self).build_arch(arch) env = self.get_recipe_env(arch) build_dir = self.get_build_dir(arch.arch) with current_directory(build_dir): bash = sh.Command('bash') shprint(bash, 'init_update_libs.sh') shprint(bash, 'android_build.sh', _env=env)
def prebuild_arch(self, arch): libdir = self.ctx.get_libs_dir(arch.arch) with current_directory(self.get_build_dir(arch.arch)): # pg_config_helper will return the system installed libpq, but we # need the one we just cross-compiled shprint(sh.sed, '-i', "s|pg_config_helper.query(.libdir.)|'{}'|".format(libdir), 'setup.py')
def prebuild_arch(self, arch): super(LibSDL2Image, self).prebuild_arch(arch) build_dir = self.get_build_dir(arch.arch) if exists(join(build_dir, ".patched")): info("SDL2_image already patched, skipping") return self.apply_patch("disable_webp.patch") shprint(sh.touch, join(build_dir, ".patched"))
def prebuild_arch(self, arch): super(PyOpenSSLRecipe, self).prebuild_arch(arch) build_dir = self.get_build_dir(arch.arch) if exists(join(build_dir, '.patched')): print('pyOpenSSL already patched, skipping') return self.apply_patch('fix-dlfcn.patch') shprint(sh.touch, join(build_dir, '.patched'))
def prebuild_arch(self, arch): super(PyCryptoRecipe, self).prebuild_arch(arch) build_dir = self.get_build_dir(arch.arch) if exists(join(build_dir, '.patched')): print('pycrypto already patched, skipping') return self.apply_patch('add_length.patch') shprint(sh.touch, join(build_dir, '.patched'))
def prebuild_arch(self, arch): super(LibSDL2Recipe, self).prebuild_arch(arch) build_dir = self.get_build_dir(arch.arch) if exists(join(build_dir, '.patched')): info('SDL2 already patched, skipping') return self.apply_patch('add_nativeSetEnv.patch') shprint(sh.touch, join(build_dir, '.patched'))
def build_arch(self, arch): super(FFMpegRecipe, self).build_arch(arch) env = self.get_recipe_env(arch) build_dir = self.get_build_dir(arch.arch) with current_directory(build_dir): bash = sh.Command('bash') shprint(bash, 'init_update_libs.sh') shprint(bash, 'android_build.sh', _env=env)
def prebuild_arch(self, arch): super(PyOpenSSLRecipe, self).prebuild_arch(arch) build_dir = self.get_build_dir(arch.arch) if exists(join(build_dir, '.patched')): print('pyOpenSSL already patched, skipping') return self.apply_patch('fix-dlfcn.patch', arch.arch) shprint(sh.touch, join(build_dir, '.patched'))
def build_arch(self, arch): super(LibsodiumRecipe, self).build_arch(arch) env = self.get_recipe_env(arch) with current_directory(self.get_build_dir(arch.arch)): bash = sh.Command('bash') shprint(bash, 'configure', '--disable-soname-versions', '--host=arm-linux-androideabi', '--enable-shared', _env=env) shprint(sh.make, _env=env) shutil.copyfile('src/libsodium/.libs/libsodium.so', join(self.ctx.get_libs_dir(arch.arch), 'libsodium.so'))
def prebuild_arch(self, arch): super(KivySDL2Recipe, self).prebuild_arch(arch) build_dir = self.get_build_dir(arch.arch) if exists(join(build_dir, '.patched')): print('kivysdl2 already patched, skipping') return self.apply_patch('android_sdl2_compat.patch') shprint(sh.touch, join(build_dir, '.patched'))
def prebuild_arch(self, arch): super(PyjniusRecipe, self).prebuild_arch(arch) build_dir = self.get_build_dir(arch.arch) if exists(join(build_dir, '.patched')): print('pyjniussdl2 already pathed, skipping') return self.apply_patch('sdl2_jnienv_getter.patch') shprint(sh.touch, join(build_dir, '.patched'))
def prebuild_arch(self, arch): super(KivySDL2Recipe, self).prebuild_arch(arch) build_dir = self.get_build_dir(arch.arch) if exists(join(build_dir, '.patched')): print('kivysdl2 already patched, skipping') return self.apply_patch('android_sdl2_compat.patch') shprint(sh.touch, join(build_dir, '.patched'))
def build_arch(self, arch): env = self.get_recipe_env(arch) with current_directory(self.get_build_dir(arch.arch)): # sh fails with code 255 trying to execute ./Configure # so instead we manually run perl passing in Configure perl = sh.Command("perl") shprint(perl, "Configure", "no-dso", "no-krb5", "linux-armv4", _env=env) shprint(sh.make, "build_libs", _env=env)
def build_arch(self, arch): env = self.get_recipe_env(arch) with current_directory(self.get_build_dir(arch.arch)): # sh fails with code 255 trying to execute ./Configure # so instead we manually run perl passing in Configure perl = sh.Command('perl') shprint(perl, 'Configure', 'no-dso', 'no-krb5', 'linux-armv4', _env=env) shprint(sh.make, 'build_libs', _env=env)
def prebuild_arch(self, arch): libdir = self.ctx.get_libs_dir(arch.arch) with current_directory(self.get_build_dir(arch.arch)): # pg_config_helper will return the system installed libpq, but we # need the one we just cross-compiled shprint(sh.sed, '-i', "s|pg_config_helper.query(.libdir.)|'{}'|".format(libdir), 'setup.py')
def prebuild_arch(self, arch): if exists(join(self.get_build_container_dir(arch.arch), ".patched")): info("Pygame already patched, skipping.") return shprint(sh.cp, join(self.get_recipe_dir(), "Setup"), join(self.get_build_dir(arch.arch), "Setup")) self.apply_patch(join("patches", "fix-surface-access.patch"), arch.arch) self.apply_patch(join("patches", "fix-array-surface.patch"), arch.arch) self.apply_patch(join("patches", "fix-sdl-spam-log.patch"), arch.arch) shprint(sh.touch, join(self.get_build_container_dir(arch.arch), ".patched"))
def prebuild_armeabi(self): if exists(join(self.get_build_container_dir('armeabi'), '.patched')): info('Pygame already patched, skipping.') return shprint(sh.cp, join(self.get_recipe_dir(), 'Setup'), join(self.get_build_dir('armeabi'), 'Setup')) self.apply_patch(join('patches', 'fix-surface-access.patch')) self.apply_patch(join('patches', 'fix-array-surface.patch')) shprint(sh.touch, join(self.get_build_container_dir('armeabi'), '.patched'))
def prebuild_arch(self, arch): super(LibSDL2Mixer, self).prebuild_arch(arch) build_dir = self.get_build_dir(arch.arch) if exists(join(build_dir, '.patched')): info('SDL2_mixer already patched, skipping') return self.apply_patch('disable_modplug_mikmod_smpeg.patch') shprint(sh.touch, join(build_dir, '.patched'))
def prebuild_arch(self, arch): super(NumpyRecipe, self).prebuild_arch(arch) build_dir = self.get_build_dir(arch.arch) if exists(join(build_dir, '.patched')): print('numpy already patched, skipping') return self.apply_patch('patches/fix-numpy.patch') shprint(sh.touch, join(build_dir, '.patched'))
def build_compiled_components(self, arch): info('Configuring compiled components in {}'.format(self.name)) env = self.get_recipe_env(arch) with current_directory(self.get_build_dir(arch.arch)): configure = sh.Command('./configure') shprint(configure, '--host=arm-eabi', '--prefix={}'.format(self.ctx.get_python_install_dir()), '--enable-shared', _env=env) super(PyCryptoRecipe, self).build_compiled_components(arch)