OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Build/test configurations, which are just dictionaries. This | 5 """Build/test configurations, which are just dictionaries. This |
6 "defines" the schema and provides some wrappers.""" | 6 "defines" the schema and provides some wrappers.""" |
7 | 7 |
8 | 8 |
9 import json | 9 import json |
10 import os.path | 10 import os.path |
11 import platform | 11 import platform |
12 import sys | 12 import sys |
13 | 13 |
14 | 14 |
15 class Config(object): | 15 class Config(object): |
16 """A Config is basically just a wrapper around a dictionary that species a | 16 """A Config is basically just a wrapper around a dictionary that species a |
17 build/test configuration. The dictionary is accessible through the values | 17 build/test configuration. The dictionary is accessible through the values |
18 member.""" | 18 member.""" |
19 | 19 |
20 # Valid values for target_os (None is also valid): | 20 # Valid values for target_os (None is also valid): |
21 OS_ANDROID = "android" | 21 OS_ANDROID = "android" |
22 OS_CHROMEOS = "chromeos" | 22 OS_CHROMEOS = "chromeos" |
23 OS_LINUX = "linux" | 23 OS_LINUX = "linux" |
24 OS_MAC = "mac" | 24 OS_MAC = "mac" |
25 OS_WINDOWS = "windows" | 25 OS_WINDOWS = "windows" |
26 | 26 |
27 # Valid values for target_arch (None is also valid): | 27 # Valid values for target_cpu (None is also valid): |
28 ARCH_X86 = "x86" | 28 ARCH_X86 = "x86" |
29 ARCH_X64 = "x64" | 29 ARCH_X64 = "x64" |
30 ARCH_ARM = "arm" | 30 ARCH_ARM = "arm" |
31 | 31 |
32 # Valid values for sanitizer (None is also valid): | 32 # Valid values for sanitizer (None is also valid): |
33 SANITIZER_ASAN = "asan" | 33 SANITIZER_ASAN = "asan" |
34 | 34 |
35 # Standard values for test types (test types are arbitrary strings; other | 35 # Standard values for test types (test types are arbitrary strings; other |
36 # values are allowed). | 36 # values are allowed). |
37 TEST_TYPE_DEFAULT = "default" | 37 TEST_TYPE_DEFAULT = "default" |
38 TEST_TYPE_UNIT = "unit" | 38 TEST_TYPE_UNIT = "unit" |
39 TEST_TYPE_PERF = "perf" | 39 TEST_TYPE_PERF = "perf" |
40 TEST_TYPE_INTEGRATION = "integration" | 40 TEST_TYPE_INTEGRATION = "integration" |
41 | 41 |
42 def __init__(self, target_os=None, target_arch=None, is_debug=True, | 42 def __init__(self, target_os=None, target_cpu=None, is_debug=True, |
43 is_clang=None, sanitizer=None, dcheck_always_on=False, | 43 is_clang=None, sanitizer=None, dcheck_always_on=False, |
44 **kwargs): | 44 **kwargs): |
45 """Constructs a Config with key-value pairs specified via keyword arguments. | 45 """Constructs a Config with key-value pairs specified via keyword arguments. |
46 If target_os is not specified, it will be set to the host OS.""" | 46 If target_os is not specified, it will be set to the host OS.""" |
47 | 47 |
48 assert target_os in (None, Config.OS_ANDROID, Config.OS_CHROMEOS, | 48 assert target_os in (None, Config.OS_ANDROID, Config.OS_CHROMEOS, |
49 Config.OS_LINUX, Config.OS_MAC, Config.OS_WINDOWS) | 49 Config.OS_LINUX, Config.OS_MAC, Config.OS_WINDOWS) |
50 assert target_arch in (None, Config.ARCH_X86, Config.ARCH_X64, | 50 assert target_cpu in (None, Config.ARCH_X86, Config.ARCH_X64, |
51 Config.ARCH_ARM) | 51 Config.ARCH_ARM) |
52 assert isinstance(is_debug, bool) | 52 assert isinstance(is_debug, bool) |
53 assert is_clang is None or isinstance(is_clang, bool) | 53 assert is_clang is None or isinstance(is_clang, bool) |
54 assert sanitizer in (None, Config.SANITIZER_ASAN) | 54 assert sanitizer in (None, Config.SANITIZER_ASAN) |
55 if "test_types" in kwargs: | 55 if "test_types" in kwargs: |
56 assert isinstance(kwargs["test_types"], list) | 56 assert isinstance(kwargs["test_types"], list) |
57 | 57 |
58 self.values = {} | 58 self.values = {} |
59 self.values["target_os"] = (self.GetHostOS() if target_os is None else | 59 self.values["target_os"] = (self.GetHostOS() if target_os is None else |
60 target_os) | 60 target_os) |
61 | 61 |
62 if target_arch is None: | 62 if target_cpu is None: |
63 if target_os == Config.OS_ANDROID: | 63 if target_os == Config.OS_ANDROID: |
64 target_arch = Config.ARCH_ARM | 64 target_cpu = Config.ARCH_ARM |
65 else: | 65 else: |
66 target_arch = self.GetHostCPUArch() | 66 target_cpu = self.GetHostCPUArch() |
67 self.values["target_arch"] = target_arch | 67 self.values["target_cpu"] = target_cpu |
68 | 68 |
69 self.values["is_debug"] = is_debug | 69 self.values["is_debug"] = is_debug |
70 self.values["is_clang"] = is_clang | 70 self.values["is_clang"] = is_clang |
71 self.values["sanitizer"] = sanitizer | 71 self.values["sanitizer"] = sanitizer |
72 self.values["dcheck_always_on"] = dcheck_always_on | 72 self.values["dcheck_always_on"] = dcheck_always_on |
73 | 73 |
74 self.values.update(kwargs) | 74 self.values.update(kwargs) |
75 | 75 |
76 @staticmethod | 76 @staticmethod |
77 def GetHostOS(): | 77 def GetHostOS(): |
(...skipping 19 matching lines...) Expand all Loading... |
97 raise Exception("Cannot identify CPU arch: %s" % machine) | 97 raise Exception("Cannot identify CPU arch: %s" % machine) |
98 | 98 |
99 # Getters for standard fields ------------------------------------------------ | 99 # Getters for standard fields ------------------------------------------------ |
100 | 100 |
101 @property | 101 @property |
102 def target_os(self): | 102 def target_os(self): |
103 """OS of the build/test target.""" | 103 """OS of the build/test target.""" |
104 return self.values["target_os"] | 104 return self.values["target_os"] |
105 | 105 |
106 @property | 106 @property |
107 def target_arch(self): | 107 def target_cpu(self): |
108 """CPU arch of the build/test target.""" | 108 """CPU arch of the build/test target.""" |
109 return self.values["target_arch"] | 109 return self.values["target_cpu"] |
110 | 110 |
111 @property | 111 @property |
112 def is_debug(self): | 112 def is_debug(self): |
113 """Is Debug build?""" | 113 """Is Debug build?""" |
114 return self.values["is_debug"] | 114 return self.values["is_debug"] |
115 | 115 |
116 @property | 116 @property |
117 def dcheck_always_on(self): | 117 def dcheck_always_on(self): |
118 """DCHECK and MOJO_DCHECK are fatal even in release builds""" | 118 """DCHECK and MOJO_DCHECK are fatal even in release builds""" |
119 return self.values["dcheck_always_on"] | 119 return self.values["dcheck_always_on"] |
120 | 120 |
121 @property | 121 @property |
122 def is_clang(self): | 122 def is_clang(self): |
123 """Should use clang?""" | 123 """Should use clang?""" |
124 return self.values["is_clang"] | 124 return self.values["is_clang"] |
125 | 125 |
126 @property | 126 @property |
127 def sanitizer(self): | 127 def sanitizer(self): |
128 """Sanitizer to use, if any.""" | 128 """Sanitizer to use, if any.""" |
129 return self.values["sanitizer"] | 129 return self.values["sanitizer"] |
130 | 130 |
131 @property | 131 @property |
132 def test_types(self): | 132 def test_types(self): |
133 """List of test types to run.""" | 133 """List of test types to run.""" |
134 return self.values.get("test_types", [Config.TEST_TYPE_DEFAULT]) | 134 return self.values.get("test_types", [Config.TEST_TYPE_DEFAULT]) |
OLD | NEW |