source: tests/pybin/settings.py@ 524ed86

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 524ed86 was 28582b2, checked in by Thierry Delisle <tdelisle@…>, 7 years ago

Better handling of missing configurations

  • Property mode set to 100644
File size: 2.3 KB
Line 
1from __future__ import print_function
2
3import os
4import sys
5import tools
6
7try :
8 sys.path.append(os.getcwd())
9 import config
10
11 SRCDIR = os.path.abspath(config.SRCDIR)
12 BUILDDIR = os.path.abspath(config.BUILDDIR)
13except:
14 print('ERROR: missing config.py, re-run configure script.', file=sys.stderr)
15 sys.exit(1)
16
17class Architecture:
18 KnownArchitectures = {
19 'x64' : 'x64',
20 'x86-64' : 'x64',
21 'x86_64' : 'x64',
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:
33 self.cross_compile = True
34 try:
35 self.target = Architecture.makeCanonical( arch )
36 except KeyError:
37 print("Unkown architecture %s" % arch)
38 sys.exit(1)
39 else:
40 self.cross_compile = False
41 try:
42 arch = config.HOSTARCH
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
63
64class 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")
68
69def init( options ):
70 global arch
71 global dry_run
72 global generating
73 global make
74 global debug
75 global debugFlag
76
77 dry_run = options.dry_run
78 generating = options.regenerate_expected
79 make = 'make'
80 debug = Debug(options.debug)
81 arch = Architecture(options.arch)
82
83
84def updateMakeCmd(force, jobs):
85 global make
86
87 make = "make" if not force else ("make -j%i" % jobs)
88
89def 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)
Note: See TracBrowser for help on using the repository browser.