[f85bc15] | 1 | from __future__ import print_function |
---|
| 2 | |
---|
| 3 | import os |
---|
[f3b9efc] | 4 | import sys |
---|
[bacc36c] | 5 | |
---|
[f85bc15] | 6 | try : |
---|
| 7 | sys.path.append(os.getcwd()) |
---|
[552f5cb] | 8 | import config |
---|
[f85bc15] | 9 | |
---|
[552f5cb] | 10 | SRCDIR = os.path.abspath(config.SRCDIR) |
---|
| 11 | BUILDDIR = os.path.abspath(config.BUILDDIR) |
---|
[f85bc15] | 12 | except: |
---|
| 13 | print('ERROR: missing config.py, re-run configure script.', file=sys.stderr) |
---|
| 14 | sys.exit(1) |
---|
| 15 | |
---|
[bacc36c] | 16 | class Architecture: |
---|
[f3b9efc] | 17 | KnownArchitectures = { |
---|
| 18 | 'x64' : 'x64', |
---|
| 19 | 'x86-64' : 'x64', |
---|
[552f5cb] | 20 | 'x86_64' : 'x64', |
---|
[f3b9efc] | 21 | 'x86' : 'x86', |
---|
| 22 | 'i386' : 'x86', |
---|
| 23 | 'i486' : 'x86', |
---|
| 24 | 'i686' : 'x86', |
---|
| 25 | 'Intel 80386' : 'x86', |
---|
| 26 | 'arm' : 'arm', |
---|
| 27 | 'ARM' : 'arm', |
---|
| 28 | } |
---|
| 29 | |
---|
| 30 | def __init__(self, arch): |
---|
| 31 | if arch: |
---|
[bacc36c] | 32 | self.cross_compile = True |
---|
[f3b9efc] | 33 | try: |
---|
| 34 | self.target = Architecture.makeCanonical( arch ) |
---|
| 35 | except KeyError: |
---|
| 36 | print("Unkown architecture %s" % arch) |
---|
| 37 | sys.exit(1) |
---|
[bacc36c] | 38 | else: |
---|
| 39 | self.cross_compile = False |
---|
[f3b9efc] | 40 | try: |
---|
[552f5cb] | 41 | arch = config.HOSTARCH |
---|
[f3b9efc] | 42 | self.target = Architecture.makeCanonical( arch ) |
---|
| 43 | except KeyError: |
---|
| 44 | print("Running on unkown architecture %s" % arch) |
---|
| 45 | sys.exit(1) |
---|
| 46 | |
---|
| 47 | self.string = self.target |
---|
| 48 | |
---|
| 49 | def update(self): |
---|
| 50 | if not self.cross_compile: |
---|
| 51 | self.target = machine_default() |
---|
| 52 | self.string = self.target |
---|
| 53 | print("updated to %s" % self.target) |
---|
| 54 | |
---|
| 55 | def match(self, arch): |
---|
| 56 | return True if not arch else self.target == arch |
---|
| 57 | |
---|
| 58 | @classmethod |
---|
| 59 | def makeCanonical(_, arch): |
---|
| 60 | return Architecture.KnownArchitectures[arch] |
---|
| 61 | |
---|
[bacc36c] | 62 | |
---|
[f3b9efc] | 63 | class Debug: |
---|
| 64 | def __init__(self, value): |
---|
| 65 | self.string = "debug" if value else "no debug" |
---|
| 66 | self.flags = """DEBUG_FLAGS="%s" """ % ("-debug" if value else "-nodebug") |
---|
[bacc36c] | 67 | |
---|
| 68 | def init( options ): |
---|
| 69 | global arch |
---|
| 70 | global dry_run |
---|
| 71 | global generating |
---|
| 72 | global make |
---|
[209383b] | 73 | global debug |
---|
| 74 | global debugFlag |
---|
[bacc36c] | 75 | |
---|
| 76 | dry_run = options.dry_run |
---|
| 77 | generating = options.regenerate_expected |
---|
[f3b9efc] | 78 | make = 'make' |
---|
| 79 | debug = Debug(options.debug) |
---|
| 80 | arch = Architecture(options.arch) |
---|
[bacc36c] | 81 | |
---|
[f85bc15] | 82 | |
---|
[bacc36c] | 83 | def updateMakeCmd(force, jobs): |
---|
| 84 | global make |
---|
| 85 | |
---|
[552f5cb] | 86 | make = "make" if not force else ("make -j%i" % jobs) |
---|