source: tests/pybin/settings.py @ 202ad72

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprno_listpersistent-indexerpthread-emulationqualifiedEnum
Last change on this file since 202ad72 was 47c1928, checked in by Thierry Delisle <tdelisle@…>, 6 years ago

Host now properly affects compiler

  • Property mode set to 100644
File size: 2.9 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        CrossCompileFlags = {
32                'x64' : 'ARCH_FLAGS=-m64',
33                'x86' : 'ARCH_FLAGS=-m32',
34        }
35
36        def __init__(self, arch):
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
43                if arch:
44                        try:
45                                arch = Architecture.makeCanonical( arch )
46                        except KeyError:
47                                print("Unkown architecture %s" % arch, file=sys.stderr)
48                                sys.exit(1)
49
50                if arch and arch != canonical_host:
51                        self.target = arch
52                        self.cross_compile = True
53                else:
54                        self.target = canonical_host
55                        self.cross_compile = False
56
57
58                try :
59                        self.flags = Architecture.CrossCompileFlags[self.target]
60                except KeyError:
61                        print("Cross compilation not available for architecture %s" % self.target, file=sys.stderr)
62                        sys.exit(1)
63
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
79
80class Debug:
81        def __init__(self, value):
82                self.string = "debug" if value else "no debug"
83                self.flags  = """DEBUG_FLAGS="%s" """ % ("-debug -O0" if value else "-nodebug -O2")
84
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
90def init( options ):
91        global arch
92        global dry_run
93        global generating
94        global make
95        global debug
96        global install
97
98        dry_run    = options.dry_run
99        generating = options.regenerate_expected
100        make       = 'make'
101        debug        = Debug(options.debug)
102        install    = Install(options.install)
103        arch       = Architecture(options.arch)
104
105
106def updateMakeCmd(force, jobs):
107        global make
108
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()
116                print("ERROR: Invalid configuration %s:%s" % (arch.string, debug.string), file=sys.stderr)
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.