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