|
48 | 48 | from colorama import Style as Colo_Style, Fore as Colo_Fore
|
49 | 49 | from collections import defaultdict
|
50 | 50 |
|
| 51 | +from archs import ArchARM, ArchARMv7_a, Archx86, Archx86_64 |
51 | 52 |
|
52 | 53 | # monkey patch to show full output
|
53 | 54 | sh.ErrorReturnCode.truncate_cap = 999999
|
@@ -463,142 +464,6 @@ def sync(self):
|
463 | 464 | fd.write(unicode(json.dumps(self.data, ensure_ascii=False)))
|
464 | 465 |
|
465 | 466 |
|
466 |
| -class Arch(object): |
467 |
| - |
468 |
| - toolchain_prefix = None |
469 |
| - '''The prefix for the toolchain dir in the NDK.''' |
470 |
| - |
471 |
| - command_prefix = None |
472 |
| - '''The prefix for NDK commands such as gcc.''' |
473 |
| - |
474 |
| - def __init__(self, ctx): |
475 |
| - super(Arch, self).__init__() |
476 |
| - self.ctx = ctx |
477 |
| - |
478 |
| - def __str__(self): |
479 |
| - return self.arch |
480 |
| - |
481 |
| - @property |
482 |
| - def include_dirs(self): |
483 |
| - return [ |
484 |
| - "{}/{}".format( |
485 |
| - self.ctx.include_dir, |
486 |
| - d.format(arch=self)) |
487 |
| - for d in self.ctx.include_dirs] |
488 |
| - |
489 |
| - def get_env(self): |
490 |
| - include_dirs = [ |
491 |
| - "-I{}/{}".format( |
492 |
| - self.ctx.include_dir, |
493 |
| - d.format(arch=self)) |
494 |
| - for d in self.ctx.include_dirs] |
495 |
| - |
496 |
| - env = {} |
497 |
| - |
498 |
| - env["CFLAGS"] = " ".join([ |
499 |
| - "-DANDROID", "-mandroid", "-fomit-frame-pointer", |
500 |
| - "--sysroot", self.ctx.ndk_platform]) |
501 |
| - |
502 |
| - env["CXXFLAGS"] = env["CFLAGS"] |
503 |
| - |
504 |
| - env["LDFLAGS"] = " ".join(['-lm']) |
505 |
| - |
506 |
| - py_platform = sys.platform |
507 |
| - if py_platform in ['linux2', 'linux3']: |
508 |
| - py_platform = 'linux' |
509 |
| - |
510 |
| - toolchain_prefix = self.ctx.toolchain_prefix |
511 |
| - toolchain_version = self.ctx.toolchain_version |
512 |
| - |
513 |
| - env['TOOLCHAIN_PREFIX'] = toolchain_prefix |
514 |
| - env['TOOLCHAIN_VERSION'] = toolchain_version |
515 |
| - |
516 |
| - if toolchain_prefix == 'x86': |
517 |
| - toolchain_prefix = 'i686-linux-android' |
518 |
| - print('path is', environ['PATH']) |
519 |
| - cc = find_executable('{toolchain_prefix}-gcc'.format( |
520 |
| - toolchain_prefix=toolchain_prefix), path=environ['PATH']) |
521 |
| - if cc is None: |
522 |
| - warning('Couldn\'t find executable for CC. This indicates a ' |
523 |
| - 'problem locating the {} executable in the Android ' |
524 |
| - 'NDK, not that you don\'t have a normal compiler ' |
525 |
| - 'installed. Exiting.') |
526 |
| - exit(1) |
527 |
| - |
528 |
| - env['CC'] = '{toolchain_prefix}-gcc {cflags}'.format( |
529 |
| - toolchain_prefix=toolchain_prefix, |
530 |
| - cflags=env['CFLAGS']) |
531 |
| - env['CXX'] = '{toolchain_prefix}-g++ {cxxflags}'.format( |
532 |
| - toolchain_prefix=toolchain_prefix, |
533 |
| - cxxflags=env['CXXFLAGS']) |
534 |
| - |
535 |
| - env['AR'] = '{}-ar'.format(toolchain_prefix) |
536 |
| - env['RANLIB'] = '{}-ranlib'.format(toolchain_prefix) |
537 |
| - env['LD'] = '{}-ld'.format(toolchain_prefix) |
538 |
| - env['STRIP'] = '{}-strip --strip-unneeded'.format(toolchain_prefix) |
539 |
| - env['MAKE'] = 'make -j5' |
540 |
| - env['READELF'] = '{}-readelf'.format(toolchain_prefix) |
541 |
| - |
542 |
| - hostpython_recipe = Recipe.get_recipe('hostpython2', self.ctx) |
543 |
| - |
544 |
| - # AND: This hardcodes python version 2.7, needs fixing |
545 |
| - env['BUILDLIB_PATH'] = join( |
546 |
| - hostpython_recipe.get_build_dir(self.arch), |
547 |
| - 'build', 'lib.linux-{}-2.7'.format(uname()[-1])) |
548 |
| - |
549 |
| - env['PATH'] = environ['PATH'] |
550 |
| - |
551 |
| - env['ARCH'] = self.arch |
552 |
| - |
553 |
| - return env |
554 |
| - |
555 |
| - |
556 |
| -class ArchARM(Arch): |
557 |
| - arch = "armeabi" |
558 |
| - toolchain_prefix = 'arm-linux-androideabi' |
559 |
| - command_prefix = 'arm-linux-androideabi' |
560 |
| - platform_dir = 'arch-arm' |
561 |
| - |
562 |
| - |
563 |
| -class ArchARMv7_a(ArchARM): |
564 |
| - arch = 'armeabi-v7a' |
565 |
| - |
566 |
| - def get_env(self): |
567 |
| - env = super(ArchARMv7_a, self).get_env() |
568 |
| - env['CFLAGS'] = (env['CFLAGS'] + |
569 |
| - ' -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb') |
570 |
| - env['CXXFLAGS'] = env['CFLAGS'] |
571 |
| - return env |
572 |
| - |
573 |
| - |
574 |
| -class Archx86(Arch): |
575 |
| - arch = 'x86' |
576 |
| - toolchain_prefix = 'x86' |
577 |
| - command_prefix = 'i686-linux-android' |
578 |
| - platform_dir = 'arch-x86' |
579 |
| - |
580 |
| - def get_env(self): |
581 |
| - env = super(Archx86, self).get_env() |
582 |
| - env['CFLAGS'] = (env['CFLAGS'] + |
583 |
| - ' -march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32') |
584 |
| - env['CXXFLAGS'] = env['CFLAGS'] |
585 |
| - return env |
586 |
| - |
587 |
| - |
588 |
| -class Archx86_64(Arch): |
589 |
| - arch = 'x86_64' |
590 |
| - toolchain_prefix = 'x86' |
591 |
| - command_prefix = 'x86_64-linux-android' |
592 |
| - platform_dir = 'arch-x86' |
593 |
| - |
594 |
| - def get_env(self): |
595 |
| - env = super(Archx86_64, self).get_env() |
596 |
| - env['CFLAGS'] = (env['CFLAGS'] + |
597 |
| - ' -march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel') |
598 |
| - env['CXXFLAGS'] = env['CFLAGS'] |
599 |
| - return env |
600 |
| - |
601 |
| - |
602 | 467 | class Graph(object):
|
603 | 468 | # Taken from the old python-for-android/depsort
|
604 | 469 | # Modified to include alternative dependencies
|
|
0 commit comments