Tiancong Wang | af05017 | 2019-07-10 11:52:03 -0700 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
| 2 | # Copyright 2019 The Chromium OS Authors. All rights reserved. |
| 3 | # Use of this source code is governed by a BSD-style license that can be |
| 4 | # found in the LICENSE file. |
| 5 | |
| 6 | """Toolchain-related operations.""" |
| 7 | |
| 8 | from __future__ import print_function |
| 9 | |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 10 | import collections |
Mike Frysinger | ef94e4c | 2020-02-10 23:59:54 -0500 | [diff] [blame] | 11 | import sys |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 12 | |
LaMont Jones | 5d2edcb | 2019-12-23 11:32:03 -0700 | [diff] [blame] | 13 | from chromite.api import controller |
Alex Klein | 076841b | 2019-08-29 15:19:39 -0600 | [diff] [blame] | 14 | from chromite.api import faux |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 15 | from chromite.api import validate |
LaMont Jones | 5d2edcb | 2019-12-23 11:32:03 -0700 | [diff] [blame] | 16 | from chromite.api.controller import controller_util |
Tiancong Wang | 24a3df7 | 2019-08-20 15:48:51 -0700 | [diff] [blame] | 17 | from chromite.api.gen.chromite.api import toolchain_pb2 |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 18 | from chromite.api.gen.chromiumos.builder_config_pb2 import BuilderConfig |
LaMont Jones | 5d2edcb | 2019-12-23 11:32:03 -0700 | [diff] [blame] | 19 | from chromite.lib import cros_logging as logging |
| 20 | from chromite.lib import toolchain_util |
Tiancong Wang | af05017 | 2019-07-10 11:52:03 -0700 | [diff] [blame] | 21 | |
Mike Frysinger | ef94e4c | 2020-02-10 23:59:54 -0500 | [diff] [blame] | 22 | |
| 23 | assert sys.version_info >= (3, 6), 'This module requires Python 3.6+' |
| 24 | |
| 25 | |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 26 | _Handlers = collections.namedtuple('_Handlers', ['name', 'prepare', 'bundle']) |
| 27 | _TOOLCHAIN_ARTIFACT_HANDLERS = { |
LaMont Jones | cd1503d | 2020-03-04 09:09:59 -0700 | [diff] [blame] | 28 | BuilderConfig.Artifacts.UNVERIFIED_CHROME_LLVM_ORDERFILE: |
LaMont Jones | d394458 | 2020-03-04 10:37:05 -0700 | [diff] [blame] | 29 | _Handlers('UnverifiedChromeLlvmOrderfile', |
LaMont Jones | 5d2edcb | 2019-12-23 11:32:03 -0700 | [diff] [blame] | 30 | toolchain_util.PrepareForBuild, |
| 31 | toolchain_util.BundleArtifacts), |
LaMont Jones | cd1503d | 2020-03-04 09:09:59 -0700 | [diff] [blame] | 32 | BuilderConfig.Artifacts.VERIFIED_CHROME_LLVM_ORDERFILE: |
LaMont Jones | d394458 | 2020-03-04 10:37:05 -0700 | [diff] [blame] | 33 | _Handlers('VerifiedChromeLlvmOrderfile', |
LaMont Jones | 5d2edcb | 2019-12-23 11:32:03 -0700 | [diff] [blame] | 34 | toolchain_util.PrepareForBuild, |
| 35 | toolchain_util.BundleArtifacts), |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 36 | BuilderConfig.Artifacts.CHROME_CLANG_WARNINGS_FILE: |
LaMont Jones | 5d2edcb | 2019-12-23 11:32:03 -0700 | [diff] [blame] | 37 | _Handlers('ChromeClangWarningsFile', |
LaMont Jones | 90bab63 | 2020-01-27 15:58:26 -0700 | [diff] [blame] | 38 | toolchain_util.PrepareForBuild, |
| 39 | toolchain_util.BundleArtifacts), |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 40 | BuilderConfig.Artifacts.UNVERIFIED_LLVM_PGO_FILE: |
LaMont Jones | 5d2edcb | 2019-12-23 11:32:03 -0700 | [diff] [blame] | 41 | _Handlers('UnverifiedLlvmPgoFile', |
LaMont Jones | 90bab63 | 2020-01-27 15:58:26 -0700 | [diff] [blame] | 42 | toolchain_util.PrepareForBuild, |
| 43 | toolchain_util.BundleArtifacts), |
LaMont Jones | 45ca6c4 | 2020-02-05 09:39:09 -0700 | [diff] [blame] | 44 | BuilderConfig.Artifacts.UNVERIFIED_CHROME_BENCHMARK_AFDO_FILE: |
| 45 | _Handlers('UnverifiedChromeBenchmarkAfdoFile', |
LaMont Jones | 90bab63 | 2020-01-27 15:58:26 -0700 | [diff] [blame] | 46 | toolchain_util.PrepareForBuild, |
| 47 | toolchain_util.BundleArtifacts), |
LaMont Jones | 53bddd0 | 2020-03-12 15:02:54 -0600 | [diff] [blame^] | 48 | BuilderConfig.Artifacts.UNVERIFIED_CHROME_BENCHMARK_PERF_FILE: |
| 49 | _Handlers('UnverifiedChromeBenchmarkPerfFile', |
| 50 | toolchain_util.PrepareForBuild, |
| 51 | toolchain_util.BundleArtifacts), |
LaMont Jones | 45ca6c4 | 2020-02-05 09:39:09 -0700 | [diff] [blame] | 52 | BuilderConfig.Artifacts.VERIFIED_CHROME_BENCHMARK_AFDO_FILE: |
| 53 | _Handlers('VerifiedChromeBenchmarkAfdoFile', |
LaMont Jones | 90bab63 | 2020-01-27 15:58:26 -0700 | [diff] [blame] | 54 | toolchain_util.PrepareForBuild, |
| 55 | toolchain_util.BundleArtifacts), |
LaMont Jones | 45ca6c4 | 2020-02-05 09:39:09 -0700 | [diff] [blame] | 56 | BuilderConfig.Artifacts.UNVERIFIED_KERNEL_CWP_AFDO_FILE: |
| 57 | _Handlers('UnverifiedKernelCwpAfdoFile', |
| 58 | toolchain_util.PrepareForBuild, |
| 59 | toolchain_util.BundleArtifacts), |
| 60 | BuilderConfig.Artifacts.VERIFIED_KERNEL_CWP_AFDO_FILE: |
| 61 | _Handlers('VerifiedKernelCwpAfdoFile', |
| 62 | toolchain_util.PrepareForBuild, |
| 63 | toolchain_util.BundleArtifacts), |
| 64 | BuilderConfig.Artifacts.UNVERIFIED_CHROME_CWP_AFDO_FILE: |
| 65 | _Handlers('UnverifiedChromeCwpAfdoFile', |
| 66 | toolchain_util.PrepareForBuild, |
| 67 | toolchain_util.BundleArtifacts), |
| 68 | BuilderConfig.Artifacts.VERIFIED_CHROME_CWP_AFDO_FILE: |
| 69 | _Handlers('VerifiedChromeCwpAfdoFile', |
| 70 | toolchain_util.PrepareForBuild, |
| 71 | toolchain_util.BundleArtifacts), |
| 72 | BuilderConfig.Artifacts.VERIFIED_RELEASE_AFDO_FILE: |
| 73 | _Handlers('VerifiedReleaseAfdoFile', |
LaMont Jones | 90bab63 | 2020-01-27 15:58:26 -0700 | [diff] [blame] | 74 | toolchain_util.PrepareForBuild, |
| 75 | toolchain_util.BundleArtifacts), |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | |
| 79 | # TODO(crbug/1031213): When @faux is expanded to have more than success/failure, |
| 80 | # this should be changed. |
| 81 | @faux.all_empty |
LaMont Jones | 5d2edcb | 2019-12-23 11:32:03 -0700 | [diff] [blame] | 82 | @validate.require('artifact_types') |
| 83 | # Note: chroot and sysroot are unspecified the first time that the build_target |
| 84 | # recipe calls PrepareForBuild. The second time, they are specified. No |
| 85 | # validation check because "all" values are valid. |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 86 | @validate.validation_complete |
| 87 | def PrepareForBuild(input_proto, output_proto, _config): |
| 88 | """Prepare to build toolchain artifacts. |
| 89 | |
| 90 | The handlers (from _TOOLCHAIN_ARTIFACT_HANDLERS above) are called with: |
| 91 | artifact_name (str): name of the artifact type. |
LaMont Jones | 5d2edcb | 2019-12-23 11:32:03 -0700 | [diff] [blame] | 92 | chroot (chroot_lib.Chroot): chroot. Will be None if the chroot has not |
| 93 | yet been created. |
| 94 | sysroot_path (str): sysroot path inside the chroot (e.g., /build/atlas). |
| 95 | Will be an empty string if the sysroot has not yet been created. |
| 96 | build_target_name (str): name of the build target (e.g., atlas). Will be |
| 97 | an empty string if the sysroot has not yet been created. |
| 98 | input_artifacts ({(str) name:[str gs_locations]}): locations for possible |
| 99 | input artifacts. The handler is expected to know which keys it should |
| 100 | be using, and ignore any keys that it does not understand. |
LaMont Jones | 45ca6c4 | 2020-02-05 09:39:09 -0700 | [diff] [blame] | 101 | additional_args ({(str) name: (str) value}) Dictionary of additional |
| 102 | arguments. |
LaMont Jones | a215f1e | 2019-12-06 10:18:58 -0700 | [diff] [blame] | 103 | |
| 104 | They locate and modify any ebuilds and/or source required for the artifact |
| 105 | being created, then return a value from toolchain_util.PrepareForBuildReturn. |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 106 | |
LaMont Jones | 5d2edcb | 2019-12-23 11:32:03 -0700 | [diff] [blame] | 107 | This function sets output_proto.build_relevance to the result. |
| 108 | |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 109 | Args: |
| 110 | input_proto (PrepareForToolchainBuildRequest): The input proto |
| 111 | output_proto (PrepareForToolchainBuildResponse): The output proto |
| 112 | _config (api_config.ApiConfig): The API call config. |
| 113 | """ |
LaMont Jones | 5d2edcb | 2019-12-23 11:32:03 -0700 | [diff] [blame] | 114 | if input_proto.chroot.path: |
| 115 | chroot = controller_util.ParseChroot(input_proto.chroot) |
| 116 | else: |
| 117 | chroot = None |
LaMont Jones | 4579e8c | 2019-12-06 14:20:37 -0700 | [diff] [blame] | 118 | |
LaMont Jones | 5d2edcb | 2019-12-23 11:32:03 -0700 | [diff] [blame] | 119 | input_artifacts = collections.defaultdict(list) |
| 120 | for art in input_proto.input_artifacts: |
| 121 | item = _TOOLCHAIN_ARTIFACT_HANDLERS.get(art.input_artifact_type) |
| 122 | if item: |
| 123 | input_artifacts[item.name].extend( |
| 124 | ['gs://%s' % str(x) for x in art.input_artifact_gs_locations]) |
| 125 | |
LaMont Jones | 45ca6c4 | 2020-02-05 09:39:09 -0700 | [diff] [blame] | 126 | # Pass along any additional args. |
| 127 | additional_args = {} |
| 128 | which = input_proto.additional_args.WhichOneof('prepare_for_build_args') |
| 129 | if which: |
| 130 | # All of the additional arguments we understand are strings, so we can |
| 131 | # copy whichever argument we got without processing it. |
| 132 | additional_args[which] = getattr(input_proto.additional_args, which) |
| 133 | |
LaMont Jones | 5d2edcb | 2019-12-23 11:32:03 -0700 | [diff] [blame] | 134 | results = set() |
| 135 | sysroot_path = input_proto.sysroot.path |
| 136 | build_target = input_proto.sysroot.build_target.name |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 137 | for artifact_type in input_proto.artifact_types: |
LaMont Jones | 5d2edcb | 2019-12-23 11:32:03 -0700 | [diff] [blame] | 138 | # Unknown artifact_types are an error. |
| 139 | handler = _TOOLCHAIN_ARTIFACT_HANDLERS[artifact_type] |
| 140 | if handler.prepare: |
LaMont Jones | a215f1e | 2019-12-06 10:18:58 -0700 | [diff] [blame] | 141 | results.add(handler.prepare( |
LaMont Jones | 45ca6c4 | 2020-02-05 09:39:09 -0700 | [diff] [blame] | 142 | handler.name, chroot, sysroot_path, build_target, input_artifacts, |
| 143 | additional_args)) |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 144 | |
| 145 | # Translate the returns from the handlers we called. |
| 146 | # If any NEEDED => NEEDED |
| 147 | # elif any UNKNOWN => UNKNOWN |
| 148 | # elif any POINTLESS => POINTLESS |
| 149 | # else UNKNOWN. |
| 150 | proto_resp = toolchain_pb2.PrepareForToolchainBuildResponse |
| 151 | if toolchain_util.PrepareForBuildReturn.NEEDED in results: |
| 152 | output_proto.build_relevance = proto_resp.NEEDED |
| 153 | elif toolchain_util.PrepareForBuildReturn.UNKNOWN in results: |
| 154 | output_proto.build_relevance = proto_resp.UNKNOWN |
| 155 | elif toolchain_util.PrepareForBuildReturn.POINTLESS in results: |
| 156 | output_proto.build_relevance = proto_resp.POINTLESS |
| 157 | else: |
| 158 | output_proto.build_relevance = proto_resp.UNKNOWN |
LaMont Jones | 5d2edcb | 2019-12-23 11:32:03 -0700 | [diff] [blame] | 159 | return controller.RETURN_CODE_SUCCESS |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 160 | |
| 161 | |
| 162 | # TODO(crbug/1031213): When @faux is expanded to have more than success/failure, |
| 163 | # this should be changed. |
| 164 | @faux.all_empty |
LaMont Jones | 4579e8c | 2019-12-06 14:20:37 -0700 | [diff] [blame] | 165 | @validate.require('chroot.path', 'sysroot.path', 'sysroot.build_target.name', |
| 166 | 'output_dir', 'artifact_types') |
| 167 | @validate.exists('output_dir') |
LaMont Jones | 5d2edcb | 2019-12-23 11:32:03 -0700 | [diff] [blame] | 168 | @validate.validation_complete |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 169 | def BundleArtifacts(input_proto, output_proto, _config): |
| 170 | """Bundle toolchain artifacts. |
| 171 | |
| 172 | The handlers (from _TOOLCHAIN_ARTIFACT_HANDLERS above) are called with: |
LaMont Jones | a215f1e | 2019-12-06 10:18:58 -0700 | [diff] [blame] | 173 | artifact_name (str): name of the artifact type |
LaMont Jones | 5d2edcb | 2019-12-23 11:32:03 -0700 | [diff] [blame] | 174 | chroot (chroot_lib.Chroot): chroot |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 175 | sysroot_path (str): sysroot path inside the chroot (e.g., /build/atlas) |
LaMont Jones | 5d2edcb | 2019-12-23 11:32:03 -0700 | [diff] [blame] | 176 | chrome_root (str): path to chrome root. (e.g., /b/s/w/ir/k/chrome) |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 177 | build_target_name (str): name of the build target (e.g., atlas) |
| 178 | output_dir (str): absolute path where artifacts are being bundled. |
| 179 | (e.g., /b/s/w/ir/k/recipe_cleanup/artifactssptfMU) |
| 180 | |
| 181 | Note: the actual upload to GS is done by CI, not here. |
| 182 | |
| 183 | Args: |
| 184 | input_proto (BundleToolchainRequest): The input proto |
| 185 | output_proto (BundleToolchainResponse): The output proto |
| 186 | _config (api_config.ApiConfig): The API call config. |
| 187 | """ |
LaMont Jones | 5d2edcb | 2019-12-23 11:32:03 -0700 | [diff] [blame] | 188 | chroot = controller_util.ParseChroot(input_proto.chroot) |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 189 | |
LaMont Jones | 45ca6c4 | 2020-02-05 09:39:09 -0700 | [diff] [blame] | 190 | # Pass along any additional args. |
| 191 | additional_args = {} |
| 192 | which = input_proto.additional_args.WhichOneof('prepare_for_build_args') |
| 193 | if which: |
| 194 | # All of the additional arguments we understand are strings, so we can |
| 195 | # copy whichever argument we got without processing it. |
| 196 | additional_args[which] = getattr(input_proto.additional_args, which) |
| 197 | |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 198 | for artifact_type in input_proto.artifact_types: |
LaMont Jones | 5d2edcb | 2019-12-23 11:32:03 -0700 | [diff] [blame] | 199 | if artifact_type not in _TOOLCHAIN_ARTIFACT_HANDLERS: |
| 200 | logging.error('%s not understood', artifact_type) |
| 201 | return controller.RETURN_CODE_UNRECOVERABLE |
| 202 | handler = _TOOLCHAIN_ARTIFACT_HANDLERS[artifact_type] |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 203 | if handler and handler.bundle: |
| 204 | artifacts = handler.bundle( |
LaMont Jones | 5d2edcb | 2019-12-23 11:32:03 -0700 | [diff] [blame] | 205 | handler.name, chroot, input_proto.sysroot.path, |
LaMont Jones | 45ca6c4 | 2020-02-05 09:39:09 -0700 | [diff] [blame] | 206 | input_proto.sysroot.build_target.name, input_proto.output_dir, |
| 207 | additional_args) |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 208 | if artifacts: |
LaMont Jones | 5d2edcb | 2019-12-23 11:32:03 -0700 | [diff] [blame] | 209 | art_info = output_proto.artifacts_info.add() |
| 210 | art_info.artifact_type = artifact_type |
| 211 | for artifact in artifacts: |
| 212 | art_info.artifacts.add().path = artifact |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 213 | |
| 214 | |
| 215 | # TODO(crbug/1019868): Remove legacy code when cbuildbot builders are gone. |
| 216 | _NAMES_FOR_AFDO_ARTIFACTS = { |
Tiancong Wang | f9c736c | 2019-08-26 13:54:38 -0700 | [diff] [blame] | 217 | toolchain_pb2.ORDERFILE: 'orderfile', |
| 218 | toolchain_pb2.KERNEL_AFDO: 'kernel_afdo', |
| 219 | toolchain_pb2.CHROME_AFDO: 'chrome_afdo' |
| 220 | } |
| 221 | |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 222 | # TODO(crbug/1019868): Remove legacy code when cbuildbot builders are gone. |
Tiancong Wang | f9c736c | 2019-08-26 13:54:38 -0700 | [diff] [blame] | 223 | # Using a function instead of a dict because we need to mock these |
| 224 | # functions in unittest, and mock doesn't play well with a dict definition. |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 225 | def _GetMethodForUpdatingAFDOArtifacts(artifact_type): |
Tiancong Wang | f9c736c | 2019-08-26 13:54:38 -0700 | [diff] [blame] | 226 | return { |
| 227 | toolchain_pb2.ORDERFILE: toolchain_util.OrderfileUpdateChromeEbuild, |
| 228 | toolchain_pb2.KERNEL_AFDO: toolchain_util.AFDOUpdateKernelEbuild, |
| 229 | toolchain_pb2.CHROME_AFDO: toolchain_util.AFDOUpdateChromeEbuild |
| 230 | }[artifact_type] |
Tiancong Wang | 24a3df7 | 2019-08-20 15:48:51 -0700 | [diff] [blame] | 231 | |
Tiancong Wang | af05017 | 2019-07-10 11:52:03 -0700 | [diff] [blame] | 232 | |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 233 | # TODO(crbug/1019868): Remove legacy code when cbuildbot builders are gone. |
Michael Mortensen | 54bd70a | 2019-11-21 14:45:38 -0700 | [diff] [blame] | 234 | def _UpdateEbuildWithAFDOArtifactsResponse(_input_proto, output_proto, _config): |
| 235 | """Add successful status to the faux response.""" |
| 236 | output_proto.status = True |
| 237 | |
| 238 | |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 239 | # TODO(crbug/1019868): Remove legacy code when cbuildbot builders are gone. |
Michael Mortensen | 54bd70a | 2019-11-21 14:45:38 -0700 | [diff] [blame] | 240 | @faux.success(_UpdateEbuildWithAFDOArtifactsResponse) |
| 241 | @faux.empty_error |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 242 | @validate.require('build_target.name') |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 243 | @validate.is_in('artifact_type', _NAMES_FOR_AFDO_ARTIFACTS) |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 244 | @validate.validation_complete |
Tiancong Wang | 24a3df7 | 2019-08-20 15:48:51 -0700 | [diff] [blame] | 245 | def UpdateEbuildWithAFDOArtifacts(input_proto, output_proto, _config): |
| 246 | """Update Chrome or kernel ebuild with most recent unvetted artifacts. |
Tiancong Wang | af05017 | 2019-07-10 11:52:03 -0700 | [diff] [blame] | 247 | |
| 248 | Args: |
Tiancong Wang | 24a3df7 | 2019-08-20 15:48:51 -0700 | [diff] [blame] | 249 | input_proto (VerifyAFDOArtifactsRequest): The input proto |
| 250 | output_proto (VerifyAFDOArtifactsResponse): The output proto |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 251 | _config (api_config.ApiConfig): The API call config. |
Tiancong Wang | af05017 | 2019-07-10 11:52:03 -0700 | [diff] [blame] | 252 | """ |
Tiancong Wang | af05017 | 2019-07-10 11:52:03 -0700 | [diff] [blame] | 253 | board = input_proto.build_target.name |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 254 | update_method = _GetMethodForUpdatingAFDOArtifacts(input_proto.artifact_type) |
Tiancong Wang | f9c736c | 2019-08-26 13:54:38 -0700 | [diff] [blame] | 255 | output_proto.status = update_method(board) |
Tiancong Wang | af05017 | 2019-07-10 11:52:03 -0700 | [diff] [blame] | 256 | |
| 257 | |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 258 | # TODO(crbug/1019868): Remove legacy code when cbuildbot builders are gone. |
Michael Mortensen | 54bd70a | 2019-11-21 14:45:38 -0700 | [diff] [blame] | 259 | def _UploadVettedAFDOArtifactsResponse(_input_proto, output_proto, _config): |
| 260 | """Add successful status to the faux response.""" |
| 261 | output_proto.status = True |
| 262 | |
| 263 | |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 264 | # TODO(crbug/1019868): Remove legacy code when cbuildbot builders are gone. |
Michael Mortensen | 54bd70a | 2019-11-21 14:45:38 -0700 | [diff] [blame] | 265 | @faux.success(_UploadVettedAFDOArtifactsResponse) |
| 266 | @faux.empty_error |
Tiancong Wang | 24a3df7 | 2019-08-20 15:48:51 -0700 | [diff] [blame] | 267 | @validate.require('build_target.name') |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 268 | @validate.is_in('artifact_type', _NAMES_FOR_AFDO_ARTIFACTS) |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 269 | @validate.validation_complete |
Tiancong Wang | 24a3df7 | 2019-08-20 15:48:51 -0700 | [diff] [blame] | 270 | def UploadVettedAFDOArtifacts(input_proto, output_proto, _config): |
Tiancong Wang | af05017 | 2019-07-10 11:52:03 -0700 | [diff] [blame] | 271 | """Upload a vetted orderfile to GS bucket. |
| 272 | |
| 273 | Args: |
Tiancong Wang | 24a3df7 | 2019-08-20 15:48:51 -0700 | [diff] [blame] | 274 | input_proto (VerifyAFDOArtifactsRequest): The input proto |
| 275 | output_proto (VerifyAFDOArtifactsResponse): The output proto |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 276 | _config (api_config.ApiConfig): The API call config. |
Tiancong Wang | af05017 | 2019-07-10 11:52:03 -0700 | [diff] [blame] | 277 | """ |
Tiancong Wang | 24a3df7 | 2019-08-20 15:48:51 -0700 | [diff] [blame] | 278 | board = input_proto.build_target.name |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 279 | artifact_type = _NAMES_FOR_AFDO_ARTIFACTS[input_proto.artifact_type] |
Tiancong Wang | 24a3df7 | 2019-08-20 15:48:51 -0700 | [diff] [blame] | 280 | output_proto.status = toolchain_util.UploadAndPublishVettedAFDOArtifacts( |
| 281 | artifact_type, board) |