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