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 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_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 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 build_arch(self, arch): # 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(arch.arch)): 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", "BUILDPYTHON=hostpython", "hostpython", "PGEN=Parser/hostpgen", "Parser/hostpgen") shprint(sh.mv, join("Parser", "hostpgen"), "hostpgen") # if exists('python.exe'): # shprint(sh.mv, 'python.exe', 'hostpython') # elif exists('python'): # shprint(sh.mv, 'python', 'hostpython') if exists("hostpython"): pass # The above commands should automatically create # the hostpython binary, unlike with python2 else: warning("Unable to find the python executable after " "hostpython build! Exiting.") exit(1) self.ctx.hostpython = join(self.get_build_dir(arch.arch), "hostpython") self.ctx.hostpgen = join(self.get_build_dir(arch.arch), "hostpgen")
def install_python_package(self, arch): env = self.get_recipe_env(arch) info('Installing {} into site-packages'.format(self.name)) with current_directory(join(self.get_build_dir(arch.arch), 'python')): hostpython = sh.Command(self.hostpython_location) hpenv = env.copy() shprint(hostpython, 'setup.py', 'install', '-O2', '--root={}'.format(self.ctx.get_python_install_dir()), '--install-lib=.', _env=hpenv, *self.setup_extra_args) # Create __init__.py which is missing, see also: # - https://github.com/protocolbuffers/protobuf/issues/1296 # - https://stackoverflow.com/questions/13862562/ # google-protocol-buffers-not-found-when-trying-to-freeze-python-app open( join(self.ctx.get_site_packages_dir(), 'google', '__init__.py'), 'a', ).close()
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 install_python_package(self, arch): env = self.get_recipe_env(arch) info('Installing {} into site-packages'.format(self.name)) with current_directory(join(self.get_build_dir(arch.arch), 'python')): hostpython = sh.Command(self.hostpython_location) if self.ctx.python_recipe.from_crystax: hpenv = env.copy() shprint(hostpython, 'setup.py', 'install', '-O2', '--root={}'.format(self.ctx.get_python_install_dir()), '--install-lib=.', '--cpp_implementation', _env=hpenv, *self.setup_extra_args) else: hppath = join(dirname(self.hostpython_location), 'Lib', 'site-packages') hpenv = env.copy() if 'PYTHONPATH' in hpenv: hpenv['PYTHONPATH'] = ':'.join([hppath] + hpenv['PYTHONPATH'].split(':')) else: hpenv['PYTHONPATH'] = hppath shprint(hostpython, 'setup.py', 'install', '-O2', '--root={}'.format(self.ctx.get_python_install_dir()), '--install-lib=lib/python2.7/site-packages', '--cpp_implementation', _env=hpenv, *self.setup_extra_args)
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_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 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(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 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_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): 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 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)
def prebuild_armeabi(self): if exists(join(self.get_build_container_dir('armeabi'), '.patched')): info('awesomecnn already patched, skipping.') return shprint(sh.cp, join(self.get_recipe_dir(), 'patches', 'setup.py'), join(self.get_build_dir('armeabi'), 'setup.py')) #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 run_distribute(self): info_main("# Creating Android project ({})".format(self.name)) arch = self.ctx.archs[0] python_install_dir = self.ctx.get_python_install_dir() from_crystax = self.ctx.python_recipe.from_crystax if len(self.ctx.archs) > 1: raise ValueError("SDL2/gradle support only one arch") info("Copying SDL2/gradle build for {}".format(arch)) shprint(sh.rm, "-rf", self.dist_dir) shprint(sh.cp, "-r", self.build_dir, self.dist_dir) # either the build use environment variable (ANDROID_HOME) # or the local.properties if exists with current_directory(self.dist_dir): with open('local.properties', 'w') as fileh: fileh.write('sdk.dir={}'.format(self.ctx.sdk_dir)) with current_directory(self.dist_dir): info("Copying Python distribution") hostpython = sh.Command(self.ctx.hostpython) if self.ctx.python_recipe.name == 'python2': try: shprint(hostpython, '-OO', '-m', 'compileall', python_install_dir, _tail=10, _filterout="^Listing") except sh.ErrorReturnCode: pass if 'python2' in self.ctx.recipe_build_order and not exists('python-install'): shprint( sh.cp, '-a', python_install_dir, './python-install') self.distribute_libs(arch, [self.ctx.get_libs_dir(arch.arch)]) self.distribute_javaclasses(self.ctx.javaclass_dir, dest_dir=join("src", "main", "java")) python_bundle_dir = join('_python_bundle', '_python_bundle') if 'python2' in self.ctx.recipe_build_order: # Python 2 is a special case with its own packaging location python_bundle_dir = 'private' 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(SDL2GradleBootstrap, self).run_distribute()
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')) self.apply_patch(join('patches', 'fix-sdl-spam-log.patch')) shprint(sh.touch, join(self.get_build_container_dir('armeabi'), '.patched'))
def postbuild_arch(self, arch): super().postbuild_arch(arch) info("Copying java files") destdir = self.ctx.javaclass_dir path = join( self.get_build_dir(arch.arch), "bleak", "backends", "p4android", "java", "." ) shprint(sh.cp, "-a", path, destdir)
def build_compiled_components(self, arch): info('Building compiled components in {}'.format(self.name)) env = self.get_recipe_env(arch) hostpython = sh.Command(self.hostpython_location) with current_directory(self.get_build_dir(arch.arch)): if self.install_in_hostpython: shprint(hostpython, 'setup.py', 'clean', '--all', _env=env) shprint(hostpython, 'setup.py', self.build_cmd, '-v', '--android', _env=env, *self.setup_extra_args) build_dir = glob.glob('build/lib.*')[0] shprint(sh.find, build_dir, '-name', '"*.o"', '-exec', env['STRIP'], '{}', ';', _env=env)
def postbuild_arch(self, arch): # TODO: This code was copied from pyjnius, but judging by the # audiostream history, it looks like this step might have # happened automatically in the past. # Given the goal of migrating off of recipes, it would # be good to repair or build infrastructure for doing this # automatically, for when including a java class is # the best solution to a problem. super().postbuild_arch(arch) info('Copying audiostream java files to classes build dir') with current_directory(self.get_build_dir(arch.arch)): shprint(sh.cp, '-a', join('audiostream', 'platform', 'android'), self.ctx.javaclass_dir)
def prebuild_arch(self, arch): super(PygameJNIComponentsRecipe, self).postbuild_arch(arch) info('Unpacking pygame bootstrap JNI dir components') with current_directory(self.get_build_container_dir(arch)): if exists('sdl'): info('sdl dir exists, so it looks like the JNI components' + 'are already unpacked. Skipping.') return for dirn in glob.glob( join(self.get_build_dir(arch), 'pygame_bootstrap_jni', '*')): shprint(sh.mv, dirn, './') info('Unpacking was successful, deleting original container dir') shprint(sh.rm, '-rf', self.get_build_dir(arch)) info('Applying jpeg assembler patch') ndk_15_plus_patch = join(self.get_recipe_dir(), 'jpeg-ndk15-plus.patch') shprint(sh.patch, '-t', '-d', join(self.get_build_container_dir(arch), 'jpeg'), '-p1', '-i', ndk_15_plus_patch, _tail=10)
def install_python_package(self, arch): env = self.get_recipe_env(arch) info('Installing {} into site-packages'.format(self.name)) with current_directory(join(self.get_build_dir(arch.arch), 'python')): hostpython = sh.Command(self.hostpython_location) hpenv = env.copy() shprint(hostpython, 'setup.py', 'install', '-O2', '--root={}'.format(self.ctx.get_python_install_dir()), '--install-lib=.', '--cpp_implementation', _env=hpenv, *self.setup_extra_args)
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 run_distribute(self): info_main('# Creating Android project from build and {} bootstrap'.format( self.name)) # src_path = join(self.ctx.root_dir, 'bootstrap_templates', # self.name) src_path = join(self.bootstrap_dir, 'build') 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('Creating initial layout') for dirname in ('assets', 'bin', 'private', 'res', 'templates'): if not exists(dirname): shprint(sh.mkdir, dirname) info('Copying default files') shprint(sh.cp, '-a', join(self.build_dir, 'project.properties'), '.') shprint(sh.cp, '-a', join(src_path, 'build.py'), '.') shprint(sh.cp, '-a', join(src_path, 'buildlib'), '.') shprint(sh.cp, '-a', join(src_path, 'src'), '.') shprint(sh.cp, '-a', join(src_path, 'templates'), '.') shprint(sh.cp, '-a', join(src_path, 'res'), '.') shprint(sh.cp, '-a', join(src_path, 'blacklist.txt'), '.') shprint(sh.cp, '-a', join(src_path, 'whitelist.txt'), '.') with open('local.properties', 'w') as fileh: fileh.write('sdk.dir={}'.format(self.ctx.sdk_dir)) info('Copying python distribution') python_bundle_dir = join('_python_bundle', '_python_bundle') if 'python2legacy' in self.ctx.recipe_build_order: # a special case with its own packaging location python_bundle_dir = 'private' # And also must had an install directory, make sure of that self.ctx.python_recipe.create_python_install(self.dist_dir) self.distribute_libs( arch, [join(self.build_dir, 'libs', arch.arch), self.ctx.get_libs_dir(arch.arch)]) self.distribute_aars(arch) self.distribute_javaclasses(self.ctx.javaclass_dir) 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(PygameBootstrap, self).run_distribute()
def build_arch(self, arch): build_dir = self.get_build_dir(arch.arch) info("create links to icu libs") lib_dir = join(self.ctx.get_python_install_dir(), "lib") icu_libs = [f for f in os.listdir(lib_dir) if f.startswith("libicu")] for l in icu_libs: raw = l.rsplit(".", 1)[0] try: shprint(sh.ln, "-s", join(lib_dir, l), join(build_dir, raw)) except Exception: pass super(PyICURecipe, self).build_arch(arch)
def build_armeabi(self): if exists(join(self.ctx.libs_dir, 'libsdl.so')): info('libsdl.so already exists, skipping sdl build.') return env = ArchAndroid(self.ctx).get_env() with current_directory(self.get_jni_dir()): shprint(sh.ndk_build, 'V=1', _env=env) libs_dir = join(self.ctx.bootstrap.build_dir, 'libs', 'armeabi') import os contents = list(os.walk(libs_dir))[0][-1] for content in contents: shprint(sh.cp, '-a', join(self.ctx.bootstrap.build_dir, 'libs', 'armeabi', content), self.ctx.libs_dir)
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, _tail=10, _critical=True) 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 build_arch(self, arch): if exists(join(self.ctx.libs_dir, 'libsdl.so')): info('libsdl.so already exists, skipping sdl build.') return env = self.get_recipe_env(arch) with current_directory(self.get_jni_dir()): shprint(sh.ndk_build, 'V=1', _env=env, _tail=20, _critical=True) libs_dir = join(self.ctx.bootstrap.build_dir, 'libs', arch.arch) import os contents = list(os.walk(libs_dir))[0][-1] for content in contents: shprint(sh.cp, '-a', join(self.ctx.bootstrap.build_dir, 'libs', arch.arch, content), self.ctx.libs_dir)
def build_armeabi(self): if exists(join(self.ctx.libs_dir, "libsdl.so")): info("libsdl.so already exists, skipping sdl build.") return env = ArchAndroid(self.ctx).get_env() with current_directory(self.get_jni_dir()): shprint(sh.ndk_build, "V=1", _env=env, _tail=20, _critical=True) libs_dir = join(self.ctx.bootstrap.build_dir, "libs", "armeabi") import os contents = list(os.walk(libs_dir))[0][-1] for content in contents: shprint(sh.cp, "-a", join(self.ctx.bootstrap.build_dir, "libs", "armeabi", content), self.ctx.libs_dir)
def build_arch(self, arch): if not exists(join(self.get_build_dir(arch.arch), 'libpython2.7.so')): self.do_python_build(arch) if not exists(self.ctx.get_python_install_dir()): shprint(sh.cp, '-a', join(self.get_build_dir(arch.arch), 'python-install'), self.ctx.get_python_install_dir()) # This should be safe to run every time info('Copying hostpython binary to targetpython folder') shprint(sh.cp, self.ctx.hostpython, join(self.ctx.get_python_install_dir(), 'bin', 'python.host')) self.ctx.hostpython = join(self.ctx.get_python_install_dir(), 'bin', 'python.host') if not exists(join(self.ctx.get_libs_dir(arch.arch), 'libpython2.7.so')): shprint(sh.cp, join(self.get_build_dir(arch.arch), 'libpython2.7.so'), self.ctx.get_libs_dir(arch.arch))
def build_arch(self, arch): if not exists(join(self.get_build_dir(arch.arch), "libpython2.7.so")): self.do_python_build(arch) if not exists(self.ctx.get_python_install_dir()): shprint( sh.cp, "-a", join(self.get_build_dir(arch.arch), "python-install"), self.ctx.get_python_install_dir() ) # This should be safe to run every time info("Copying hostpython binary to targetpython folder") shprint(sh.cp, self.ctx.hostpython, join(self.ctx.get_python_install_dir(), "bin", "python.host")) self.ctx.hostpython = join(self.ctx.get_python_install_dir(), "bin", "python.host") if not exists(join(self.ctx.get_libs_dir(arch.arch), "libpython2.7.so")): shprint(sh.cp, join(self.get_build_dir(arch.arch), "libpython2.7.so"), self.ctx.get_libs_dir(arch.arch))
def build_arch(self, arch): if exists(join(self.ctx.libs_dir, 'libsdl.so')): info('libsdl.so already exists, skipping sdl build.') return env = arch.get_env() with current_directory(self.get_jni_dir()): shprint(sh.ndk_build, 'V=1', _env=env, _tail=20, _critical=True) libs_dir = join(self.ctx.bootstrap.build_dir, 'libs', arch.arch) import os contents = list(os.walk(libs_dir))[0][-1] for content in contents: shprint(sh.cp, '-a', join(self.ctx.bootstrap.build_dir, 'libs', arch.arch, content), self.ctx.libs_dir)
def run_distribute(self): info_main("# Creating Android project ({})".format(self.name)) arch = self.ctx.archs[0] python_install_dir = self.ctx.get_python_install_dir() from_crystax = self.ctx.python_recipe.from_crystax if len(self.ctx.archs) > 1: raise ValueError("SDL2/gradle support only one arch") info("Copying SDL2/gradle build for {}".format(arch)) shprint(sh.rm, "-rf", self.dist_dir) shprint(sh.cp, "-r", self.build_dir, self.dist_dir) # either the build use environment variable (ANDROID_HOME) # or the local.properties if exists with current_directory(self.dist_dir): with open('local.properties', 'w') as fileh: fileh.write('sdk.dir={}'.format(self.ctx.sdk_dir)) with current_directory(self.dist_dir): info("Copying Python distribution") python_bundle_dir = join('_python_bundle', '_python_bundle') if 'python2legacy' in self.ctx.recipe_build_order: # a special case with its own packaging location python_bundle_dir = 'private' # And also must had an install directory, make sure of that self.ctx.python_recipe.create_python_install(self.dist_dir) self.distribute_libs(arch, [self.ctx.get_libs_dir(arch.arch)]) self.distribute_javaclasses(self.ctx.javaclass_dir, dest_dir=join("src", "main", "java")) 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(SDL2GradleBootstrap, self).run_distribute()
def build_arch(self, arch): super(VlcRecipe, self).build_arch(arch) build_dir = self.get_build_dir(arch.arch) port_dir = join(build_dir, 'vlc-port-android') aar = self.aars[arch] if not exists(aar): with current_directory(port_dir): env = dict(environ) env.update({ 'ANDROID_ABI': arch.arch, 'ANDROID_NDK': self.ctx.ndk_dir, 'ANDROID_SDK': self.ctx.sdk_dir, }) info("compiling vlc from sources") debug("environment: {}".format(env)) if not exists(join('bin', 'VLC-debug.apk')): shprint(sh.Command('./compile.sh'), _env=env, _tail=50, _critical=True) shprint(sh.Command('./compile-libvlc.sh'), _env=env, _tail=50, _critical=True) shprint(sh.cp, '-a', aar, self.ctx.aars_dir)
def assemble_distribution(self): info_main("# Creating Android project ({})".format(self.name)) arch = self.ctx.archs[0] if len(self.ctx.archs) > 1: raise ValueError("SDL2/gradle support only one arch") info("Copying SDL2/gradle build for {}".format(arch)) shprint(sh.rm, "-rf", self.dist_dir) shprint(sh.cp, "-r", self.build_dir, self.dist_dir) # either the build use environment variable (ANDROID_HOME) # or the local.properties if exists with current_directory(self.dist_dir): with open('local.properties', 'w') as fileh: fileh.write('sdk.dir={}'.format(self.ctx.sdk_dir)) with current_directory(self.dist_dir): info("Copying Python distribution") python_bundle_dir = join('_python_bundle', '_python_bundle') self.distribute_libs(arch, [self.ctx.get_libs_dir(arch.arch)]) self.distribute_javaclasses(self.ctx.javaclass_dir, dest_dir=join("src", "main", "java")) 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') if not self.ctx.with_debug_symbols: self.strip_libraries(arch) self.fry_eggs(site_packages_dir) super().assemble_distribution()
def build_arch(self, arch): # 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(arch.arch)): 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', 'BUILDPYTHON=hostpython', 'hostpython', 'PGEN=Parser/hostpgen', 'Parser/hostpgen') shprint(sh.mv, join('Parser', 'hostpgen'), 'hostpgen') # if exists('python.exe'): # shprint(sh.mv, 'python.exe', 'hostpython') # elif exists('python'): # shprint(sh.mv, 'python', 'hostpython') if exists('hostpython'): pass # The above commands should automatically create # the hostpython binary, unlike with python2 else: warning('Unable to find the python executable after ' 'hostpython build! Exiting.') exit(1) self.ctx.hostpython = join(self.get_build_dir(arch.arch), 'hostpython') self.ctx.hostpgen = join(self.get_build_dir(arch.arch), 'hostpgen')
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', 'BUILDPYTHON=hostpython', 'hostpython', 'PGEN=Parser/hostpgen', 'Parser/hostpgen') shprint(sh.mv, join('Parser', 'hostpgen'), 'hostpgen') # if exists('python.exe'): # shprint(sh.mv, 'python.exe', 'hostpython') # elif exists('python'): # shprint(sh.mv, 'python', 'hostpython') if exists('hostpython'): pass # The above commands should automatically create # the hostpython binary, unlike with python2 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 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): # AND: I'm going to ignore any extra pythonrecipe or cythonrecipe behaviour for now 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(arch.arch)): info("hostpython is " + self.ctx.hostpython) hostpython = sh.Command(self.ctx.hostpython) shprint(hostpython, "setup.py", "install", "-O2", _env=env, _tail=10, _critical=True) 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 prebuild_arch(self, arch): super(PygameJNIComponentsRecipe, self).postbuild_arch(arch) info('Unpacking pygame bootstrap JNI dir components') with current_directory(self.get_build_container_dir(arch)): if exists('sdl'): info('sdl dir exists, so it looks like the JNI components' + 'are already unpacked. Skipping.') return for dirn in glob.glob(join(self.get_build_dir(arch), 'pygame_bootstrap_jni', '*')): shprint(sh.mv, dirn, './') info('Unpacking was successful, deleting original container dir') shprint(sh.rm, '-rf', self.get_build_dir(arch))