def get_recipe_env(self, arch): env = super(LXMLRecipe, self).get_recipe_env(arch) libxslt_recipe = Recipe.get_recipe("libxslt", self.ctx).get_build_dir(arch.arch) libxml2_recipe = Recipe.get_recipe("libxml2", self.ctx).get_build_dir(arch.arch) env["CC"] += " -I%s/include -I%s " % ( libxml2_recipe, libxslt_recipe, ) return env
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 get_recipe_env(self, arch): env = super(PyOpenSSLRecipe, self).get_recipe_env(arch) openssl_build_dir = Recipe.get_recipe('openssl', self.ctx).get_build_dir(arch.arch) env['CC'] = '%s -I%s' % (env['CC'], join(openssl_build_dir, 'include')) env['LDFLAGS'] = env['LDFLAGS'] + ' -L{}'.format( self.ctx.get_libs_dir(arch.arch) + '-L{}'.format(self.ctx.libs_dir)) + ' -L{}'.format( openssl_build_dir) return env
def get_recipe_env(self, arch=None): env = super(PyCryptoRecipe, self).get_recipe_env(arch) openssl_build_dir = Recipe.get_recipe('openssl', self.ctx).get_build_dir(arch.arch) env['CC'] = '%s -I%s' % (env['CC'], join(openssl_build_dir, 'include')) env['LDFLAGS'] = env['LDFLAGS'] + ' -L{}'.format( self.ctx.get_libs_dir(arch.arch) + '-L{}'.format(self.ctx.libs_dir)) + ' -L{}'.format( openssl_build_dir) env['EXTRA_CFLAGS'] = '--host linux-armv' env['ac_cv_func_malloc_0_nonnull'] = 'yes' return env
def get_recipe_env(self, arch): env = super(PyCryptoRecipe, self).get_recipe_env(arch) openssl_build_dir = Recipe.get_recipe("openssl", self.ctx).get_build_dir(arch.arch) env["CC"] = "%s -I%s" % (env["CC"], join(openssl_build_dir, "include")) env["LDFLAGS"] = ( env["LDFLAGS"] + " -L{}".format(self.ctx.get_libs_dir(arch.arch) + "-L{}".format(self.ctx.libs_dir)) + " -L{}".format(openssl_build_dir) ) env["EXTRA_CFLAGS"] = "--host linux-armv" env["ac_cv_func_malloc_0_nonnull"] = "yes" return env
def get_recipe_env(self, arch, with_flags_in_cc=True): env = super(FFPyPlayerRecipe, self).get_recipe_env(arch) build_dir = Recipe.get_recipe('ffmpeg', self.ctx).get_build_dir(arch.arch) env["FFMPEG_INCLUDE_DIR"] = join(build_dir, "include") env["FFMPEG_LIB_DIR"] = join(build_dir, "lib") env["SDL_INCLUDE_DIR"] = join(self.ctx.bootstrap.build_dir, 'jni', 'SDL', 'include') env["SDL_LIB_DIR"] = join(self.ctx.bootstrap.build_dir, 'libs', arch.arch) env["USE_SDL2_MIXER"] = '1' env["SDL2_MIXER_INCLUDE_DIR"] = join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_mixer') return env
def build_arch(self, arch): env = self.get_recipe_env(arch) harfbuzz_recipe = Recipe.get_recipe('harfbuzz', self.ctx) env['LDFLAGS'] = ' '.join( [env['LDFLAGS'], '-L{}'.format(join(harfbuzz_recipe.get_build_dir(arch.arch), 'src', '.libs'))]) with current_directory(self.get_build_dir(arch.arch)): configure = sh.Command('./configure') shprint(configure, '--host=arm-linux-androideabi', '--prefix={}'.format(realpath('.')), '--without-zlib', '--with-png=no', '--enable-shared', _env=env) shprint(sh.make, '-j5', _env=env) shprint(sh.cp, 'objs/.libs/libfreetype.so', self.ctx.libs_dir)
def build_cython_components(self, arch): info('Cythonizing anything necessary in {}'.format(self.name)) env = self.get_recipe_env(arch) with current_directory(self.get_build_dir(arch.arch)): hostpython = sh.Command(self.ctx.hostpython) info('Trying first build of {} to get cython files: this is ' 'expected to fail'.format(self.name)) try: shprint(hostpython, 'setup.py', 'build_ext', _env=env) except sh.ErrorReturnCode_1: print() info('{} first build failed (as expected)'.format(self.name)) info('Running cython where appropriate') shprint(sh.find, self.get_build_dir('armeabi'), '-iname', '*.pyx', '-exec', self.ctx.cython, '{}', ';', _env=env) info('ran cython') # shprint(hostpython, 'setup.py', 'build_ext', '-v', _env=env) print('stripping') build_lib = glob.glob('./build/lib*') shprint(sh.find, build_lib[0], '-name', '*.o', '-exec', env['STRIP'], '{}', ';', _env=env) print('stripped!?') # exit(1) # Here we do *not* use the normal hostpython binary in the # target python dir, because twisted tries to import # _io.so which would fail. hostpython_build = sh.Command(join( Recipe.get_recipe('hostpython2', self.ctx).get_build_dir('armeabi'), 'hostpython')) shprint(hostpython_build, 'setup.py', 'install', '-O2', '--root={}'.format(self.ctx.get_python_install_dir()), '--install-lib=/lib/python2.7/site-packages', _env=env)
def build_arch(self, arch): with current_directory(self.get_build_dir(arch.arch)): env = arch.get_env() flags = ['--disable-everything'] cflags = [] ldflags = [] if 'openssl' in self.ctx.recipe_build_order: flags += [ '--enable-openssl', '--enable-nonfree', '--enable-protocol=https,tls_openssl', ] build_dir = Recipe.get_recipe('openssl', self.ctx).get_build_dir(arch.arch) cflags += ['-I' + build_dir + '/include/'] ldflags += ['-L' + build_dir] if 'ffpyplayer_codecs' in self.ctx.recipe_build_order: # libx264 flags += ['--enable-libx264'] build_dir = Recipe.get_recipe('libx264', self.ctx).get_build_dir(arch.arch) cflags += ['-I' + build_dir + '/include/'] ldflags += ['-lx264', '-L' + build_dir + '/lib/'] # libshine flags += ['--enable-libshine'] build_dir = Recipe.get_recipe('libshine', self.ctx).get_build_dir(arch.arch) cflags += ['-I' + build_dir + '/include/'] ldflags += ['-lshine', '-L' + build_dir + '/lib/'] # Enable all codecs: flags += [ '--enable-parsers', '--enable-decoders', '--enable-encoders', '--enable-muxers', '--enable-demuxers', ] else: # Enable codecs only for .mp4: flags += [ '--enable-parser=aac,ac3,h261,h264,mpegaudio,mpeg4video,mpegvideo,vc1', '--enable-decoder=aac,h264,mpeg4,mpegvideo', '--enable-muxer=h264,mov,mp4,mpeg2video', '--enable-demuxer=aac,h264,m4v,mov,mpegvideo,vc1', ] # needed to prevent _ffmpeg.so: version node not found for symbol av_init_packet@LIBAVFORMAT_52 # /usr/bin/ld: failed to set dynamic section sizes: Bad value flags += [ '--disable-symver', ] # disable binaries / doc flags += [ '--disable-ffmpeg', '--disable-ffplay', '--disable-ffprobe', '--disable-ffserver', '--disable-doc', ] # other flags: flags += [ '--enable-filter=aresample,resample,crop,adelay,volume', '--enable-protocol=file,http', '--enable-small', '--enable-hwaccels', '--enable-gpl', '--enable-pic', '--disable-static', '--enable-shared', ] # android: flags += [ '--target-os=android', '--cross-prefix=arm-linux-androideabi-', '--arch=arm', '--sysroot=' + self.ctx.ndk_platform, '--enable-neon', '--prefix={}'.format(realpath('.')), ] cflags += [ '-mfpu=vfpv3-d16', '-mfloat-abi=softfp', '-fPIC', ] env['CFLAGS'] += ' ' + ' '.join(cflags) env['LDFLAGS'] += ' ' + ' '.join(ldflags) configure = sh.Command('./configure') shprint(configure, *flags, _env=env) shprint(sh.make, '-j4', _env=env) shprint(sh.make, 'install', _env=env) # copy libs: sh.cp('-a', sh.glob('./lib/lib*.so'), self.ctx.get_libs_dir(arch.arch))
def do_python_build(self, arch): if 'sqlite' in self.ctx.recipe_build_order: print('sqlite support not yet enabled in python recipe') exit(1) hostpython_recipe = Recipe.get_recipe('hostpython2', self.ctx) shprint(sh.cp, self.ctx.hostpython, self.get_build_dir(arch.arch)) shprint(sh.cp, self.ctx.hostpgen, self.get_build_dir(arch.arch)) hostpython = join(self.get_build_dir(arch.arch), 'hostpython') hostpgen = join(self.get_build_dir(arch.arch), 'hostpython') with current_directory(self.get_build_dir(arch.arch)): hostpython_recipe = Recipe.get_recipe('hostpython2', self.ctx) shprint(sh.cp, join(hostpython_recipe.get_recipe_dir(), 'Setup'), 'Modules') env = arch.get_env() # AND: Should probably move these to get_recipe_env for # neatness, but the whole recipe needs tidying along these # lines env['HOSTARCH'] = 'arm-eabi' env['BUILDARCH'] = shprint(sh.gcc, '-dumpmachine').stdout.split('\n')[0] env['CFLAGS'] = ' '.join([env['CFLAGS'], '-DNO_MALLINFO']) # TODO need to add a should_build that checks if optional # dependencies have changed (possibly in a generic way) if 'openssl' in self.ctx.recipe_build_order: openssl_build_dir = Recipe.get_recipe('openssl', self.ctx).get_build_dir(arch.arch) env['CFLAGS'] = ' '.join([env['CFLAGS'], '-I{}'.format(join(openssl_build_dir, 'include'))]) env['LDFLAGS'] = ' '.join([env['LDFLAGS'], '-L{}'.format(openssl_build_dir)]) configure = sh.Command('./configure') # AND: OFLAG isn't actually set, should it be? shprint(configure, '--host={}'.format(env['HOSTARCH']), '--build={}'.format(env['BUILDARCH']), # 'OPT={}'.format(env['OFLAG']), '--prefix={}'.format(realpath('./python-install')), '--enable-shared', '--disable-toolbox-glue', '--disable-framework', _env=env) # AND: tito left this comment in the original source. It's still true! # FIXME, the first time, we got a error at: # python$EXE ../../Tools/scripts/h2py.py -i '(u_long)' /usr/include/netinet/in.h # /home/tito/code/python-for-android/build/python/Python-2.7.2/python: 1: Syntax error: word unexpected (expecting ")") # because at this time, python is arm, not x86. even that, why /usr/include/netinet/in.h is used ? # check if we can avoid this part. make = sh.Command(env['MAKE'].split(' ')[0]) print('First install (expected to fail...') try: shprint(make, '-j5', 'install', 'HOSTPYTHON={}'.format(hostpython), 'HOSTPGEN={}'.format(hostpgen), 'CROSS_COMPILE_TARGET=yes', 'INSTSONAME=libpython2.7.so', _env=env) except sh.ErrorReturnCode_2: print('First python2 make failed. This is expected, trying again.') print('Second install (expected to work)') shprint(sh.touch, 'python.exe', 'python') shprint(make, '-j5', 'install', 'HOSTPYTHON={}'.format(hostpython), 'HOSTPGEN={}'.format(hostpgen), 'CROSS_COMPILE_TARGET=yes', 'INSTSONAME=libpython2.7.so', _env=env) if uname()[0] == 'Darwin': shprint(sh.cp, join(self.get_recipe_dir(), 'patches', '_scproxy.py'), join('python-install', 'Lib')) shprint(sh.cp, join(self.get_recipe_dir(), 'patches', '_scproxy.py'), join('python-install', 'lib', 'python2.7')) # reduce python for dir_name in ('test', join('json', 'tests'), 'lib-tk', join('sqlite3', 'test'), join('unittest, test'), join('lib2to3', 'tests'), join('bsddb', 'tests'), join('distutils', 'tests'), join('email', 'test'), 'curses'): shprint(sh.rm, '-rf', join('python-install', 'lib', 'python2.7', dir_name))
def build_armeabi(self): if 'sqlite' in self.ctx.recipe_build_order or 'openssl' in self.ctx.recipe_build_order: print('sqlite or openssl support not yet enabled in python recipe') exit(1) hostpython_recipe = Recipe.get_recipe('hostpython2', self.ctx) shprint(sh.cp, self.ctx.hostpython, self.get_build_dir('armeabi')) shprint(sh.cp, self.ctx.hostpgen, self.get_build_dir('armeabi')) hostpython = join(self.get_build_dir('armeabi'), 'hostpython') hostpgen = join(self.get_build_dir('armeabi'), 'hostpython') if exists(join(self.get_build_dir('armeabi'), 'libpython2.7.so')): print('libpython2.7.so already exists, skipping python build.') self.ctx.hostpython = join(self.ctx.build_dir, 'python-install', 'bin', 'python.host') return with current_directory(self.get_build_dir('armeabi')): hostpython_recipe = Recipe.get_recipe('hostpython2', self.ctx) shprint(sh.cp, join(hostpython_recipe.get_recipe_dir(), 'Setup'), 'Modules') env = ArchAndroid(self.ctx).get_env() configure = sh.Command('./configure') # AND: OFLAG isn't actually set, should it be? shprint( configure, '--host=arm-eabi', # 'OPT={}'.format(env['OFLAG']), '--prefix={}'.format(join(self.ctx.build_dir, 'python-install')), '--enable-shared', '--disable-toolbox-glue', '--disable-framefork', _env=env) # AND: tito left this comment in the original source. It's still true! # FIXME, the first time, we got a error at: # python$EXE ../../Tools/scripts/h2py.py -i '(u_long)' /usr/include/netinet/in.h # /home/tito/code/python-for-android/build/python/Python-2.7.2/python: 1: Syntax error: word unexpected (expecting ")") # because at this time, python is arm, not x86. even that, why /usr/include/netinet/in.h is used ? # check if we can avoid this part. make = sh.Command(env['MAKE'].split(' ')[0]) print('First install (expected to fail...') try: shprint(make, '-j5', 'install', 'HOSTPYTHON={}'.format(hostpython), 'HOSTPGEN={}'.format(hostpgen), 'CROSS_COMPILE_TARGET=yes', 'INSTSONAME=libpython2.7.so', _env=env) except sh.ErrorReturnCode_2: print( 'First python2 make failed. This is expected, trying again.' ) print('Second install (expected to work)') shprint(sh.touch, 'python.exe', 'python') shprint(make, '-j5', 'install', 'HOSTPYTHON={}'.format(hostpython), 'HOSTPGEN={}'.format(hostpgen), 'CROSS_COMPILE_TARGET=yes', 'INSTSONAME=libpython2.7.so', _env=env) if uname()[0] == 'Darwin': shprint(sh.cp, join(self.get_recipe_dir(), 'patches', '_scproxy.py'), join(self.get_build_dir(), 'Lib')) shprint( sh.cp, join(self.get_recipe_dir(), 'patches', '_scproxy.py'), join(self.ctx.build_dir, 'python-install', 'lib', 'python2.7')) print('Ready to copy .so for python arm') shprint(sh.cp, 'libpython2.7.so', self.ctx.libs_dir) print('Copying hostpython binary to targetpython folder') shprint( sh.cp, self.ctx.hostpython, join(self.ctx.build_dir, 'python-install', 'bin', 'python.host')) self.ctx.hostpython = join(self.ctx.build_dir, 'python-install', 'bin', 'python.host') # reduce python? for dir_name in ('test', join('json', 'tests'), 'lib-tk', join('sqlite3', 'test'), join('unittest, test'), join('lib2to3', 'tests'), join('bsddb', 'tests'), join('distutils', 'tests'), join('email', 'test'), 'curses'): shprint( sh.rm, '-rf', join(self.ctx.build_dir, 'python-install', 'lib', 'python2.7', dir_name))
def build_arch(self, arch): if 'sqlite' in self.ctx.recipe_build_order or 'openssl' in self.ctx.recipe_build_order: print('sqlite or openssl support not yet enabled in python recipe') exit(1) hostpython_recipe = Recipe.get_recipe('hostpython3', self.ctx) shprint(sh.cp, self.ctx.hostpython, self.get_build_dir(arch.arch)) shprint(sh.cp, self.ctx.hostpgen, self.get_build_dir(arch.arch)) hostpython = join(self.get_build_dir(arch.arch), 'hostpython') hostpgen = join(self.get_build_dir(arch.arch), 'hostpython') if exists(join(self.get_build_dir(arch.arch), 'libpython3.4m.so')): print('libpython3.4m.so already exists, skipping python build.') self.ctx.hostpython = join(self.ctx.build_dir, 'python-install', 'bin', 'python.host') return with current_directory(self.get_build_dir(arch.arch)): hostpython_recipe = Recipe.get_recipe('hostpython3', self.ctx) # shprint(sh.cp, join(hostpython_recipe.get_recipe_dir(), 'Setup'), 'Modules') env = ArchARM(self.ctx).get_env() env["LDFLAGS"] = env["LDFLAGS"] + ' -llog' # AND: Should probably move these to get_recipe_env for # neatness, but the whole recipe needs tidying along these # lines env['HOSTARCH'] = 'arm-eabi' env['BUILDARCH'] = shprint(sh.gcc, '-dumpmachine').stdout # env['CFLAGS'] = ' '.join([env['CFLAGS'], '-DNO_MALLINFO']) env['HOSTARCH'] = 'arm-linux-androideabi' env['BUILDARCH'] = 'x86_64-pc-linux-gnu' configure = sh.Command('./configure') # AND: OFLAG isn't actually set, should it be? # shprint(configure, # '--host={}'.format(env['HOSTARCH']), # '--build={}'.format(env['BUILDARCH']), # # 'OPT={}'.format(env['OFLAG']), # '--prefix={}'.format(join(self.ctx.build_dir, 'python-install')), # '--enable-shared', # '--disable-toolbox-glue', # '--disable-framefork', # _env=env) with open('config.site', 'w') as fileh: fileh.write(''' ac_cv_file__dev_ptmx=no ac_cv_file__dev_ptc=no ''') shprint(configure, 'CROSS_COMPILE_TARGET=yes', 'HOSTPYTHON={}'.format(hostpython), 'CONFIG_SITE=config.site', '--prefix={}'.format(join(self.ctx.build_dir, 'python-install')), '--host={}'.format(env['HOSTARCH']), '--build={}'.format(env['BUILDARCH']), '--disable-ipv6', '--enable-shared', '--without-ensurepip', _env=env) # The python2 build always fails the first time, but python3 seems to work. make = sh.Command(env['MAKE'].split(' ')[0]) # print('First install (expected to fail...') # try: # shprint(make, '-j5', 'install', 'HOSTPYTHON={}'.format(hostpython), # 'HOSTPGEN={}'.format(hostpgen), # 'CROSS_COMPILE_TARGET=yes', # 'INSTSONAME=libpython3.7.so', # _env=env) # except sh.ErrorReturnCode_2: # print('First python3 make failed. This is expected, trying again.') # print('Second install (expected to work)') shprint(sh.touch, 'python.exe', 'python') # shprint(make, '-j5', 'install', 'HOSTPYTHON={}'.format(hostpython), # 'HOSTPGEN={}'.format(hostpgen), # 'CROSS_COMPILE_TARGET=yes', # 'INSTSONAME=libpython3.7.so', # _env=env) shprint(make, '-j5', 'CROSS_COMPILE_TARGET=yes', 'HOSTPYTHON={}'.format(hostpython), 'HOSTPGEN={}'.format(hostpgen), _env=env) shprint(make, '-j5', 'install', 'CROSS_COMPILE_TARGET=yes', 'HOSTPYTHON={}'.format(hostpython), 'HOSTPGEN={}'.format(hostpgen), _env=env) # if uname()[0] == 'Darwin': # shprint(sh.cp, join(self.get_recipe_dir(), 'patches', '_scproxy.py'), # join(self.get_build_dir(), 'Lib')) # shprint(sh.cp, join(self.get_recipe_dir(), 'patches', '_scproxy.py'), # join(self.ctx.build_dir, 'python-install', 'lib', 'python3.7')) print('Ready to copy .so for python arm') shprint(sh.cp, 'libpython3.4m.so', self.ctx.libs_dir) shprint(sh.cp, 'libpython3.so', self.ctx.libs_dir) print('Copying hostpython binary to targetpython folder') shprint(sh.cp, self.ctx.hostpython, join(self.ctx.build_dir, 'python-install', 'bin', 'python.host')) self.ctx.hostpython = join(self.ctx.build_dir, 'python-install', 'bin', 'python.host') # reduce python? for dir_name in ('test', join('json', 'tests'), 'lib-tk', join('sqlite3', 'test'), join('unittest, test'), join('lib2to3', 'tests'), join('bsddb', 'tests'), join('distutils', 'tests'), join('email', 'test'), 'curses'): shprint(sh.rm, '-rf', join(self.ctx.build_dir, 'python-install', 'lib', 'python3.7', dir_name))
def build_arch(self, arch): with current_directory(self.get_build_dir(arch.arch)): env = arch.get_env() flags = ['--disable-everything'] cflags = [] ldflags = [] if 'openssl' in self.ctx.recipe_build_order: flags += [ '--enable-openssl', '--enable-nonfree', '--enable-protocol=https,tls_openssl', ] build_dir = Recipe.get_recipe( 'openssl', self.ctx).get_build_dir(arch.arch) cflags += ['-I' + build_dir + '/include/'] ldflags += ['-L' + build_dir] if 'ffpyplayer_codecs' in self.ctx.recipe_build_order: # libx264 flags += ['--enable-libx264'] build_dir = Recipe.get_recipe( 'libx264', self.ctx).get_build_dir(arch.arch) cflags += ['-I' + build_dir + '/include/'] ldflags += ['-lx264', '-L' + build_dir + '/lib/'] # libshine flags += ['--enable-libshine'] build_dir = Recipe.get_recipe( 'libshine', self.ctx).get_build_dir(arch.arch) cflags += ['-I' + build_dir + '/include/'] ldflags += ['-lshine', '-L' + build_dir + '/lib/'] # Enable all codecs: flags += [ '--enable-parsers', '--enable-decoders', '--enable-encoders', '--enable-muxers', '--enable-demuxers', ] else: # Enable codecs only for .mp4: flags += [ '--enable-parser=aac,ac3,h261,h264,mpegaudio,mpeg4video,mpegvideo,vc1', '--enable-decoder=aac,h264,mpeg4,mpegvideo', '--enable-muxer=h264,mov,mp4,mpeg2video', '--enable-demuxer=aac,h264,m4v,mov,mpegvideo,vc1', ] # needed to prevent _ffmpeg.so: version node not found for symbol av_init_packet@LIBAVFORMAT_52 # /usr/bin/ld: failed to set dynamic section sizes: Bad value flags += [ '--disable-symver', ] # disable binaries / doc flags += [ '--disable-ffmpeg', '--disable-ffplay', '--disable-ffprobe', '--disable-ffserver', '--disable-doc', ] # other flags: flags += [ '--enable-filter=aresample,resample,crop,adelay,volume', '--enable-protocol=file,http', '--enable-small', '--enable-hwaccels', '--enable-gpl', '--enable-pic', '--disable-static', '--enable-shared', ] # android: flags += [ '--target-os=android', '--cross-prefix=arm-linux-androideabi-', '--arch=arm', '--sysroot=' + self.ctx.ndk_platform, '--enable-neon', '--prefix={}'.format(realpath('.')), ] cflags += [ '-mfpu=vfpv3-d16', '-mfloat-abi=softfp', '-fPIC', ] env['CFLAGS'] += ' ' + ' '.join(cflags) env['LDFLAGS'] += ' ' + ' '.join(ldflags) configure = sh.Command('./configure') shprint(configure, *flags, _env=env) shprint(sh.make, '-j4', _env=env) shprint(sh.make, 'install', _env=env) # copy libs: sh.cp('-a', sh.glob('./lib/lib*.so'), self.ctx.get_libs_dir(arch.arch))
def build_armeabi(self): if "sqlite" in self.ctx.recipe_build_order or "openssl" in self.ctx.recipe_build_order: print("sqlite or openssl support not yet enabled in python recipe") exit(1) hostpython_recipe = Recipe.get_recipe("hostpython2", self.ctx) shprint(sh.cp, self.ctx.hostpython, self.get_build_dir("armeabi")) shprint(sh.cp, self.ctx.hostpgen, self.get_build_dir("armeabi")) hostpython = join(self.get_build_dir("armeabi"), "hostpython") hostpgen = join(self.get_build_dir("armeabi"), "hostpython") if exists(join(self.get_build_dir("armeabi"), "libpython2.7.so")): print("libpython2.7.so already exists, skipping python build.") self.ctx.hostpython = join(self.ctx.build_dir, "python-install", "bin", "python.host") return with current_directory(self.get_build_dir("armeabi")): hostpython_recipe = Recipe.get_recipe("hostpython2", self.ctx) shprint(sh.cp, join(hostpython_recipe.get_recipe_dir(), "Setup"), "Modules") env = ArchAndroid(self.ctx).get_env() configure = sh.Command("./configure") # AND: OFLAG isn't actually set, should it be? shprint( configure, "--host=arm-eabi", # 'OPT={}'.format(env['OFLAG']), "--prefix={}".format(join(self.ctx.build_dir, "python-install")), "--enable-shared", "--disable-toolbox-glue", "--disable-framefork", _env=env, ) # AND: tito left this comment in the original source. It's still true! # FIXME, the first time, we got a error at: # python$EXE ../../Tools/scripts/h2py.py -i '(u_long)' /usr/include/netinet/in.h # /home/tito/code/python-for-android/build/python/Python-2.7.2/python: 1: Syntax error: word unexpected (expecting ")") # because at this time, python is arm, not x86. even that, why /usr/include/netinet/in.h is used ? # check if we can avoid this part. make = sh.Command(env["MAKE"].split(" ")[0]) print("First install (expected to fail...") try: shprint( make, "-j5", "install", "HOSTPYTHON={}".format(hostpython), "HOSTPGEN={}".format(hostpgen), "CROSS_COMPILE_TARGET=yes", "INSTSONAME=libpython2.7.so", _env=env, ) except sh.ErrorReturnCode_2: print("First python2 make failed. This is expected, trying again.") print("Second install (expected to work)") shprint(sh.touch, "python.exe", "python") shprint( make, "-j5", "install", "HOSTPYTHON={}".format(hostpython), "HOSTPGEN={}".format(hostpgen), "CROSS_COMPILE_TARGET=yes", "INSTSONAME=libpython2.7.so", _env=env, ) if uname()[0] == "Darwin": shprint(sh.cp, join(self.get_recipe_dir(), "patches", "_scproxy.py"), join(self.get_build_dir(), "Lib")) shprint( sh.cp, join(self.get_recipe_dir(), "patches", "_scproxy.py"), join(self.ctx.build_dir, "python-install", "lib", "python2.7"), ) print("Ready to copy .so for python arm") shprint(sh.cp, "libpython2.7.so", self.ctx.libs_dir) print("Copying hostpython binary to targetpython folder") shprint(sh.cp, self.ctx.hostpython, join(self.ctx.build_dir, "python-install", "bin", "python.host")) self.ctx.hostpython = join(self.ctx.build_dir, "python-install", "bin", "python.host") # reduce python? for dir_name in ( "test", join("json", "tests"), "lib-tk", join("sqlite3", "test"), join("unittest, test"), join("lib2to3", "tests"), join("bsddb", "tests"), join("distutils", "tests"), join("email", "test"), "curses", ): shprint(sh.rm, "-rf", join(self.ctx.build_dir, "python-install", "lib", "python2.7", dir_name))
def do_python_build(self): if 'sqlite' in self.ctx.recipe_build_order: print('sqlite support not yet enabled in python recipe') exit(1) hostpython_recipe = Recipe.get_recipe('hostpython2', self.ctx) shprint(sh.cp, self.ctx.hostpython, self.get_build_dir('armeabi')) shprint(sh.cp, self.ctx.hostpgen, self.get_build_dir('armeabi')) hostpython = join(self.get_build_dir('armeabi'), 'hostpython') hostpgen = join(self.get_build_dir('armeabi'), 'hostpython') with current_directory(self.get_build_dir('armeabi')): hostpython_recipe = Recipe.get_recipe('hostpython2', self.ctx) shprint(sh.cp, join(hostpython_recipe.get_recipe_dir(), 'Setup'), 'Modules') env = ArchAndroid(self.ctx).get_env() # AND: Should probably move these to get_recipe_env for # neatness, but the whole recipe needs tidying along these # lines env['HOSTARCH'] = 'arm-eabi' env['BUILDARCH'] = shprint(sh.gcc, '-dumpmachine').stdout.split('\n')[0] env['CFLAGS'] = ' '.join([env['CFLAGS'], '-DNO_MALLINFO']) # TODO need to add a should_build that checks if optional # dependencies have changed (possibly in a generic way) if 'openssl' in self.ctx.recipe_build_order: openssl_build_dir = Recipe.get_recipe( 'openssl', self.ctx).get_build_dir('armeabi') env['CFLAGS'] = ' '.join([ env['CFLAGS'], '-I{}'.format(join(openssl_build_dir, 'include')) ]) env['LDFLAGS'] = ' '.join( [env['LDFLAGS'], '-L{}'.format(openssl_build_dir)]) configure = sh.Command('./configure') # AND: OFLAG isn't actually set, should it be? shprint( configure, '--host={}'.format(env['HOSTARCH']), '--build={}'.format(env['BUILDARCH']), # 'OPT={}'.format(env['OFLAG']), '--prefix={}'.format(realpath('./python-install')), '--enable-shared', '--disable-toolbox-glue', '--disable-framework', _env=env) # AND: tito left this comment in the original source. It's still true! # FIXME, the first time, we got a error at: # python$EXE ../../Tools/scripts/h2py.py -i '(u_long)' /usr/include/netinet/in.h # /home/tito/code/python-for-android/build/python/Python-2.7.2/python: 1: Syntax error: word unexpected (expecting ")") # because at this time, python is arm, not x86. even that, why /usr/include/netinet/in.h is used ? # check if we can avoid this part. make = sh.Command(env['MAKE'].split(' ')[0]) print('First install (expected to fail...') try: shprint(make, '-j5', 'install', 'HOSTPYTHON={}'.format(hostpython), 'HOSTPGEN={}'.format(hostpgen), 'CROSS_COMPILE_TARGET=yes', 'INSTSONAME=libpython2.7.so', _env=env) except sh.ErrorReturnCode_2: print( 'First python2 make failed. This is expected, trying again.' ) print('Second install (expected to work)') shprint(sh.touch, 'python.exe', 'python') shprint(make, '-j5', 'install', 'HOSTPYTHON={}'.format(hostpython), 'HOSTPGEN={}'.format(hostpgen), 'CROSS_COMPILE_TARGET=yes', 'INSTSONAME=libpython2.7.so', _env=env) if uname()[0] == 'Darwin': shprint(sh.cp, join(self.get_recipe_dir(), 'patches', '_scproxy.py'), join('python-install', 'Lib')) shprint(sh.cp, join(self.get_recipe_dir(), 'patches', '_scproxy.py'), join('python-install', 'lib', 'python2.7')) # reduce python for dir_name in ('test', join('json', 'tests'), 'lib-tk', join('sqlite3', 'test'), join('unittest, test'), join('lib2to3', 'tests'), join('bsddb', 'tests'), join('distutils', 'tests'), join('email', 'test'), 'curses'): shprint(sh.rm, '-rf', join('python-install', 'lib', 'python2.7', dir_name))