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