def prebuild_arch(self, arch): super(CdecimalRecipe, self).prebuild_arch(arch) if not is_darwin(): if '64' in arch.arch: machine = 'ansi64' else: machine = 'ansi32' self.setup_extra_args = ['--with-machine=' + machine]
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.decode('utf-8').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) setuplocal = join('Modules', 'Setup.local') shprint(sh.cp, join(self.get_recipe_dir(), 'Setup.local-ssl'), setuplocal) shprint(sh.sed, '-i', 's#^SSL=.*#SSL={}#'.format(openssl_build_dir), setuplocal) 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 is_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 do_python_build(self, arch): 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() env['HOSTARCH'] = 'arm-eabi' env['BUILDARCH'] = shprint( sh.gcc, '-dumpmachine').stdout.decode('utf-8').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: 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 # NDK has langinfo.h but doesn't define nl_langinfo() env['ac_cv_header_langinfo_h'] = 'no' configure = sh.Command('./configure') 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) # 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 is_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 do_python_build(self, arch): 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('hostpython2legacy', self.ctx) shprint(sh.cp, join(hostpython_recipe.get_recipe_dir(), 'Setup'), 'Modules') env = arch.get_env() env['HOSTARCH'] = 'arm-eabi' env['BUILDARCH'] = shprint(sh.gcc, '-dumpmachine').stdout.decode('utf-8').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: recipe = Recipe.get_recipe('openssl', self.ctx) openssl_build = recipe.get_build_dir(arch.arch) env['OPENSSL_BUILD'] = openssl_build env['OPENSSL_VERSION'] = recipe.version if 'sqlite3' in self.ctx.recipe_build_order: # Include sqlite3 in python2legacy 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 # NDK has langinfo.h but doesn't define nl_langinfo() env['ac_cv_header_langinfo_h'] = 'no' configure = sh.Command('./configure') 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) # 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 # noqa # /home/tito/code/python-for-android/build/python/Python-2.7.2/python: 1: Syntax error: word unexpected (expecting ")") # noqa # 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, '-j' + str(cpu_count()), '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, '-j' + str(cpu_count()), 'install', 'HOSTPYTHON={}'.format(hostpython), 'HOSTPGEN={}'.format(hostpgen), 'CROSS_COMPILE_TARGET=yes', 'INSTSONAME=libpython2.7.so', _env=env) if is_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 do_python_build(self, arch): shprint(sh.cp, self.ctx.hostpython, self.get_build_dir(arch.arch)) shprint(sh.cp, self.ctx.hostpgen, join(self.get_build_dir(arch.arch), 'Parser')) 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-linux-androideabi' env['BUILDARCH'] = shprint( sh.gcc, '-dumpmachine').stdout.decode('utf-8').split('\n')[0] env['CFLAGS'] = ' '.join([env['CFLAGS'], '-DNO_MALLINFO']) env['LDFLAGS'] += ' -Wl,--allow-multiple-definition' # 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: r = Recipe.get_recipe('openssl', self.ctx) openssl_build_dir = r.get_build_dir(arch.arch) setuplocal = join('Modules', 'Setup.local') shprint(sh.cp, join(self.get_recipe_dir(), 'Setup.local-ssl'), setuplocal) #shprint(sh.cat, 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'] = r.version env['CFLAGS'] += ' -I%s' % join(openssl_build_dir, 'include') env['LDFLAGS'] += ' -L%s' % openssl_build_dir if 'sqlite3' in self.ctx.recipe_build_order: # Include sqlite3 in python2 build r = Recipe.get_recipe('sqlite3', self.ctx) i = ' -I' + r.get_build_dir(arch.arch) l = ' -L' + r.get_lib_dir(arch) + ' -lsqlite3' # Insert or append to env f = 'CPPFLAGS' env[f] = env[f] + i if f in env else i f = 'LDFLAGS' env[f] = env[f] + l if f in env else l with open('config.site', 'w') as fileh: fileh.write(''' ac_cv_file__dev_ptmx=no ac_cv_file__dev_ptc=no ac_cv_have_long_long_format=yes ''') configure = sh.Command('./configure') # AND: OFLAG isn't actually set, should it be? shprint(configure, 'CROSS_COMPILE_TARGET=yes', 'CONFIG_SITE=config.site', '--host={}'.format(env['HOSTARCH']), '--build={}'.format(env['BUILDARCH']), '--prefix={}'.format(realpath('./python-install')), '--enable-shared', '--enable-ipv6', '--disable-toolbox-glue', '--disable-framework', '--with-system-ffi', _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. # Hardcoded, remove -I/usr/include/x86_64-linux-gnu from CCSHARED and CFLAGS # to prevent overriding android arm sysroot includes 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('Make compile...') shprint(make, '-j5', 'HOSTPYTHON={}'.format(hostpython), 'HOSTPGEN={}'.format(hostpgen), 'CROSS_COMPILE_TARGET=yes', 'INSTSONAME=libpython2.7.so', _env=env) print('Second install (expected to work)') shprint(sh.touch, 'python.exe', 'python') # -k added to keep going (need to figure out the reason for make: *** [libinstall] Error 1) shprint(make, '-j5', 'install', 'HOSTPYTHON={}'.format(hostpython), 'HOSTPGEN={}'.format(hostpgen), 'CROSS_COMPILE_TARGET=yes', 'INSTSONAME=libpython2.7.so', _env=env) if is_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 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.decode("utf-8").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 is_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 prebuild_arch(self, arch): super(CdecimalRecipe, self).prebuild_arch(arch) if not is_darwin(): self.setup_extra_args = ['--with-machine=ansi32']