Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: infra/bots/recipe_modules/flavor/default_flavor.py

Issue 2198173002: Re-organize Skia recipes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix missing dependency Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 5
6 # pylint: disable=W0201
7
8
6 """Default flavor utils class, used for desktop builders.""" 9 """Default flavor utils class, used for desktop builders."""
7 10
8 11
9 import json 12 import json
10 13
11 14
12 WIN_TOOLCHAIN_DIR = 't' 15 WIN_TOOLCHAIN_DIR = 't'
13 16
14 17
15 class DeviceDirs(object): 18 class DeviceDirs(object):
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 62
60 The methods in this class define how certain high-level functions should 63 The methods in this class define how certain high-level functions should
61 work. Each build step flavor should correspond to a subclass of 64 work. Each build step flavor should correspond to a subclass of
62 DefaultFlavorUtils which may override any of these functions as appropriate 65 DefaultFlavorUtils which may override any of these functions as appropriate
63 for that flavor. 66 for that flavor.
64 67
65 For example, the AndroidFlavorUtils will override the functions for 68 For example, the AndroidFlavorUtils will override the functions for
66 copying files between the host and Android device, as well as the 69 copying files between the host and Android device, as well as the
67 'step' function, so that commands may be run through ADB. 70 'step' function, so that commands may be run through ADB.
68 """ 71 """
69 def __init__(self, skia_api, *args, **kwargs): 72 def __init__(self, m):
70 self._skia_api = skia_api 73 self.m = m
71 self._chrome_path = None 74 self._chrome_path = None
72 self._win_toolchain_dir = self._skia_api.slave_dir.join(WIN_TOOLCHAIN_DIR) 75 self._win_toolchain_dir = self.m.vars.slave_dir.join(WIN_TOOLCHAIN_DIR)
73 win_toolchain_asset_path = self._skia_api.infrabots_dir.join( 76 win_toolchain_asset_path = self.m.vars.infrabots_dir.join(
74 'assets', 'win_toolchain', 'VERSION') 77 'assets', 'win_toolchain', 'VERSION')
75 if not self._skia_api.m.path.exists(win_toolchain_asset_path): 78 if not self.m.path.exists(win_toolchain_asset_path):
76 self._win_toolchain_dir = self._skia_api.slave_dir 79 self._win_toolchain_dir = self.m.vars.slave_dir
77 80
78 81
79 def step(self, name, cmd, **kwargs): 82 def step(self, name, cmd, **kwargs):
80 """Wrapper for the Step API; runs a step as appropriate for this flavor.""" 83 """Wrapper for the Step API; runs a step as appropriate for this flavor."""
81 path_to_app = self._skia_api.skia_out.join( 84 path_to_app = self.m.vars.skia_out.join(
82 self._skia_api.configuration, cmd[0]) 85 self.m.vars.configuration, cmd[0])
83 if (self._skia_api.m.platform.is_linux and 86 if (self.m.platform.is_linux and
84 'x86_64' in self._skia_api.builder_name and 87 'x86_64' in self.m.vars.builder_name and
85 not 'TSAN' in self._skia_api.builder_name): 88 not 'TSAN' in self.m.vars.builder_name):
86 new_cmd = ['catchsegv', path_to_app] 89 new_cmd = ['catchsegv', path_to_app]
87 else: 90 else:
88 new_cmd = [path_to_app] 91 new_cmd = [path_to_app]
89 new_cmd.extend(cmd[1:]) 92 new_cmd.extend(cmd[1:])
90 return self._skia_api.run(self._skia_api.m.step, 93 return self.m.run(self.m.step,
91 name, cmd=new_cmd, **kwargs) 94 name, cmd=new_cmd, **kwargs)
92 95
93 @property 96 @property
94 def chrome_path(self): 97 def chrome_path(self):
95 """Path to a checkout of Chrome on this machine.""" 98 """Path to a checkout of Chrome on this machine."""
96 return self._win_toolchain_dir.join('src') 99 return self._win_toolchain_dir.join('src')
97 100
98 def bootstrap_win_toolchain(self): 101 def bootstrap_win_toolchain(self):
99 """Run bootstrapping script for the Windows toolchain.""" 102 """Run bootstrapping script for the Windows toolchain."""
100 bootstrap_script = self._skia_api.infrabots_dir.join( 103 bootstrap_script = self.m.vars.infrabots_dir.join(
101 'bootstrap_win_toolchain_json.py') 104 'bootstrap_win_toolchain_json.py')
102 win_toolchain_json = self._win_toolchain_dir.join( 105 win_toolchain_json = self._win_toolchain_dir.join(
103 'src', 'build', 'win_toolchain.json') 106 'src', 'build', 'win_toolchain.json')
104 self._skia_api.m.python( 107 self.m.python(
105 'bootstrap win toolchain', 108 'bootstrap win toolchain',
106 script=bootstrap_script, 109 script=bootstrap_script,
107 args=['--win_toolchain_json', win_toolchain_json, 110 args=['--win_toolchain_json', win_toolchain_json,
108 '--depot_tools_parent_dir', 111 '--depot_tools_parent_dir',
109 self._win_toolchain_dir]) 112 self._win_toolchain_dir])
110 113
111 def build_command_buffer(self): 114 def build_command_buffer(self):
112 """Build command_buffer.""" 115 """Build command_buffer."""
113 script = self._skia_api.skia_dir.join('tools', 'build_command_buffer.py') 116 script = self.m.vars.skia_dir.join('tools', 'build_command_buffer.py')
114 self._skia_api.run( 117 self.m.run(
115 self._skia_api.m.python, 'build command_buffer', 118 self.m.python, 'build command_buffer',
116 script=script, 119 script=script,
117 args=['--chrome-dir', self._skia_api.checkout_root, 120 args=['--chrome-dir', self.m.vars.checkout_root,
118 '--output-dir', self.out_dir, 121 '--output-dir', self.out_dir,
119 '--chrome-build-type', self._skia_api.configuration, 122 '--chrome-build-type', self.m.vars.configuration,
120 '--no-sync']) 123 '--no-sync'])
121 124
122 def compile(self, target): 125 def compile(self, target):
123 """Build the given target.""" 126 """Build the given target."""
124 # The CHROME_PATH environment variable is needed for builders that use 127 # The CHROME_PATH environment variable is needed for builders that use
125 # toolchains downloaded by Chrome. 128 # toolchains downloaded by Chrome.
126 env = {'CHROME_PATH': self.chrome_path} 129 env = {'CHROME_PATH': self.chrome_path}
127 if self._skia_api.m.platform.is_win: 130 if self.m.platform.is_win:
128 make_cmd = ['python', 'make.py'] 131 make_cmd = ['python', 'make.py']
129 self._skia_api._run_once(self.bootstrap_win_toolchain) 132 self.m.run.run_once(self.bootstrap_win_toolchain)
130 if 'Vulkan' in self._skia_api.builder_name: 133 if 'Vulkan' in self.m.vars.builder_name:
131 env['VK_SDK_PATH'] = self._skia_api.slave_dir.join('win_vulkan_sdk') 134 env['VK_SDK_PATH'] = self.m.vars.slave_dir.join('win_vulkan_sdk')
132 if not self._skia_api.m.path.exists(self._skia_api.infrabots_dir.join(
133 'assets', 'win_vulkan_sdk', 'VERSION')):
134 # TODO(kjlubick): Remove this once enough time has passed.
135 env['VK_SDK_PATH'] = self._skia_api.slave_dir.join('vulkan_1.0.17.0')
136 else: 135 else:
137 make_cmd = ['make'] 136 make_cmd = ['make']
138 cmd = make_cmd + [target] 137 cmd = make_cmd + [target]
139 try: 138 try:
140 self._skia_api.run(self._skia_api.m.step, 'build %s' % target, cmd=cmd, 139 self.m.run(self.m.step, 'build %s' % target, cmd=cmd,
141 env=env, cwd=self._skia_api.m.path['checkout']) 140 env=env, cwd=self.m.path['checkout'])
142 except self._skia_api.m.step.StepFailure: 141 except self.m.step.StepFailure:
143 if self._skia_api.m.platform.is_win: 142 if self.m.platform.is_win:
144 # The linker occasionally crashes on Windows. Try again. 143 # The linker occasionally crashes on Windows. Try again.
145 self._skia_api.run(self._skia_api.m.step, 'build %s' % target, cmd=cmd, 144 self.m.run(self.m.step, 'build %s' % target, cmd=cmd,
146 env=env, cwd=self._skia_api.m.path['checkout']) 145 env=env, cwd=self.m.path['checkout'])
147 else: 146 else:
148 raise 147 raise
149 if 'CommandBuffer' in self._skia_api.builder_name: 148 if 'CommandBuffer' in self.m.vars.builder_name:
150 self._skia_api._run_once(self.build_command_buffer) 149 self.m.run.run_once(self.build_command_buffer)
151 150
152 def copy_extra_build_products(self, swarming_out_dir): 151 def copy_extra_build_products(self, swarming_out_dir):
153 """Copy extra build products to specified directory. 152 """Copy extra build products to specified directory.
154 153
155 Copy flavor-specific build products to swarming_out_dir for use in test and 154 Copy flavor-specific build products to swarming_out_dir for use in test and
156 perf steps.""" 155 perf steps."""
157 if ("Win" in self._skia_api.builder_name and 156 if ("Win" in self.m.vars.builder_name and
158 "Vulkan" in self._skia_api.builder_name): 157 "Vulkan" in self.m.vars.builder_name):
159 # This copies vulkan-1.dll that has been bundled into win_vulkan_sdk 158 # This copies vulkan-1.dll that has been bundled into win_vulkan_sdk
160 # since version 2 See skia/api BUILD_PRODUCTS_ISOLATE_WHITELIST 159 # since version 2 See skia/api BUILD_PRODUCTS_ISOLATE_WHITELIST
161 self._skia_api.copy_build_products( 160 self.m.run.copy_build_products(
162 self._skia_api.m.path['slave_build'].join('win_vulkan_sdk'), 161 self.m.path['slave_build'].join('win_vulkan_sdk'),
163 swarming_out_dir) 162 swarming_out_dir)
164 163
165 @property 164 @property
166 def out_dir(self): 165 def out_dir(self):
167 """Flavor-specific out directory.""" 166 """Flavor-specific out directory."""
168 return self._skia_api.skia_out.join(self._skia_api.configuration) 167 return self.m.vars.skia_out.join(self.m.vars.configuration)
169 168
170 def device_path_join(self, *args): 169 def device_path_join(self, *args):
171 """Like os.path.join(), but for paths on a connected device.""" 170 """Like os.path.join(), but for paths on a connected device."""
172 return self._skia_api.m.path.join(*args) 171 return self.m.path.join(*args)
173 172
174 def device_path_exists(self, path): # pragma: no cover 173 def device_path_exists(self, path): # pragma: no cover
175 """Like os.path.exists(), but for paths on a connected device.""" 174 """Like os.path.exists(), but for paths on a connected device."""
176 return self._skia_api.m.path.exists(path, infra_step=True) 175 return self.m.path.exists(path, infra_step=True)
177 176
178 def copy_directory_contents_to_device(self, host_dir, device_dir): 177 def copy_directory_contents_to_device(self, host_dir, device_dir):
179 """Like shutil.copytree(), but for copying to a connected device.""" 178 """Like shutil.copytree(), but for copying to a connected device."""
180 # For "normal" builders who don't have an attached device, we expect 179 # For "normal" builders who don't have an attached device, we expect
181 # host_dir and device_dir to be the same. 180 # host_dir and device_dir to be the same.
182 if str(host_dir) != str(device_dir): 181 if str(host_dir) != str(device_dir):
183 raise ValueError('For builders who do not have attached devices, copying ' 182 raise ValueError('For builders who do not have attached devices, copying '
184 'from host to device is undefined and only allowed if ' 183 'from host to device is undefined and only allowed if '
185 'host_path and device_path are the same (%s vs %s).' % ( 184 'host_path and device_path are the same (%s vs %s).' % (
186 str(host_dir), str(device_dir))) # pragma: no cover 185 str(host_dir), str(device_dir))) # pragma: no cover
(...skipping 17 matching lines...) Expand all
204 'from host to device is undefined and only allowed if ' 203 'from host to device is undefined and only allowed if '
205 'host_path and device_path are the same (%s vs %s).' % ( 204 'host_path and device_path are the same (%s vs %s).' % (
206 str(host_path), str(device_path))) 205 str(host_path), str(device_path)))
207 206
208 def create_clean_device_dir(self, path): 207 def create_clean_device_dir(self, path):
209 """Like shutil.rmtree() + os.makedirs(), but on a connected device.""" 208 """Like shutil.rmtree() + os.makedirs(), but on a connected device."""
210 self.create_clean_host_dir(path) 209 self.create_clean_host_dir(path)
211 210
212 def create_clean_host_dir(self, path): 211 def create_clean_host_dir(self, path):
213 """Convenience function for creating a clean directory.""" 212 """Convenience function for creating a clean directory."""
214 self._skia_api.rmtree(path) 213 self.m.run.rmtree(path)
215 self._skia_api.m.file.makedirs( 214 self.m.file.makedirs(
216 self._skia_api.m.path.basename(path), path, infra_step=True) 215 self.m.path.basename(path), path, infra_step=True)
217 216
218 def install(self): 217 def install(self):
219 """Run device-specific installation steps.""" 218 """Run device-specific installation steps."""
220 pass 219 self.device_dirs = DeviceDirs(
220 dm_dir=self.m.vars.dm_dir,
221 perf_data_dir=self.m.vars.perf_data_dir,
222 resource_dir=self.m.vars.resource_dir,
223 images_dir=self.m.vars.images_dir,
224 skp_dir=self.m.vars.local_skp_dir,
225 tmp_dir=self.m.vars.tmp_dir)
221 226
222 def cleanup_steps(self): 227 def cleanup_steps(self):
223 """Run any device-specific cleanup steps.""" 228 """Run any device-specific cleanup steps."""
224 pass 229 pass
225 230
226 def get_device_dirs(self):
227 """ Set the directories which will be used by the build steps.
228
229 These refer to paths on the same device where the test executables will
230 run, for example, for Android bots these are paths on the Android device
231 itself. For desktop bots, these are just local paths.
232 """
233 return DeviceDirs(
234 dm_dir=self._skia_api.dm_dir,
235 perf_data_dir=self._skia_api.perf_data_dir,
236 resource_dir=self._skia_api.resource_dir,
237 images_dir=self._skia_api.images_dir,
238 skp_dir=self._skia_api.local_skp_dir,
239 tmp_dir=self._skia_api.tmp_dir)
240
241 def __repr__(self): 231 def __repr__(self):
242 return '<%s object>' % self.__class__.__name__ # pragma: no cover 232 return '<%s object>' % self.__class__.__name__ # pragma: no cover
OLDNEW
« no previous file with comments | « infra/bots/recipe_modules/flavor/coverage_flavor.py ('k') | infra/bots/recipe_modules/flavor/gn_flavor.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698