source: tests/pybin/settings.py@ 0e0f128c

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr no_list persistent-indexer pthread-emulation qualifiedEnum
Last change on this file since 0e0f128c was 575a6e5, checked in by Thierry Delisle <tdelisle@…>, 7 years ago

Cross compilation appears to be working

  • Property mode set to 100644
File size: 2.9 KB
RevLine 
[f85bc15]1from __future__ import print_function
2
3import os
[f3b9efc]4import sys
[28582b2]5import tools
[bacc36c]6
[f85bc15]7try :
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]13except:
14 print('ERROR: missing config.py, re-run configure script.', file=sys.stderr)
15 sys.exit(1)
16
[bacc36c]17class 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
[575a6e5]31 CrossCompileFlags = {
32 'x64' : 'ARCH_FLAGS=-m64',
33 'x86' : 'ARCH_FLAGS=-m32',
34 }
35
[f3b9efc]36 def __init__(self, arch):
[575a6e5]37 try:
38 canonical_host = Architecture.makeCanonical( config.HOSTARCH )
39 except KeyError:
40 print("Unkown host architecture %s" % config.HOSTARCH, file=sys.stderr)
41 sys.exit(1)
42
[f3b9efc]43 if arch:
44 try:
[575a6e5]45 arch = Architecture.makeCanonical( arch )
[f3b9efc]46 except KeyError:
[575a6e5]47 print("Unkown architecture %s" % arch, file=sys.stderr)
[f3b9efc]48 sys.exit(1)
[575a6e5]49
50 if arch and arch != canonical_host:
51 self.target = arch
52 self.cross_compile = True
53 try :
54 self.flags = Architecture.CrossCompileFlags[arch]
[f3b9efc]55 except KeyError:
[575a6e5]56 print("Cross compilation not available for architecture %s" % arch, file=sys.stderr)
[f3b9efc]57 sys.exit(1)
58
[575a6e5]59 else:
60 self.target = canonical_host
61 self.cross_compile = False
62 self.flags = ""
63
[f3b9efc]64 self.string = self.target
65
66 def update(self):
67 if not self.cross_compile:
68 self.target = machine_default()
69 self.string = self.target
70 print("updated to %s" % self.target)
71
72 def match(self, arch):
73 return True if not arch else self.target == arch
74
75 @classmethod
76 def makeCanonical(_, arch):
77 return Architecture.KnownArchitectures[arch]
78
[bacc36c]79
[f3b9efc]80class Debug:
81 def __init__(self, value):
82 self.string = "debug" if value else "no debug"
[575a6e5]83 self.flags = """DEBUG_FLAGS="%s" """ % ("-debug -O0" if value else "-nodebug -O2")
[bacc36c]84
[a5121bf]85class Install:
86 def __init__(self, value):
87 self.string = "installed" if value else "in-tree"
88 self.flags = """INSTALL_FLAGS="%s" """ % ("" if value else "-in-tree")
89
[bacc36c]90def init( options ):
91 global arch
92 global dry_run
93 global generating
94 global make
[209383b]95 global debug
[a5121bf]96 global install
[bacc36c]97
98 dry_run = options.dry_run
99 generating = options.regenerate_expected
[f3b9efc]100 make = 'make'
101 debug = Debug(options.debug)
[a5121bf]102 install = Install(options.install)
[f3b9efc]103 arch = Architecture(options.arch)
[bacc36c]104
[f85bc15]105
[bacc36c]106def updateMakeCmd(force, jobs):
107 global make
108
[28582b2]109 make = "make" if not force else ("make -j%i" % jobs)
110
111def validate():
112 make_ret, _ = tools.make( ".validate", error_file = ".validate.err", redirects = "2> /dev/null 1> /dev/null", )
113 if make_ret != 0:
114 with open (".validate.err", "r") as myfile:
115 error=myfile.read()
[575a6e5]116 print("ERROR: Invalid configuration %s:%s" % (arch.string, debug.string), file=sys.stderr)
[28582b2]117 print(" verify returned : \n%s" % error, file=sys.stderr)
118 tools.rm("%s/.validate.err" % BUILDDIR)
119 sys.exit(1)
120
121 tools.rm("%s/.validate.err" % BUILDDIR)
Note: See TracBrowser for help on using the repository browser.