• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2023 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15load(
16    ":fdo_profile_transitions.bzl",
17    "CLI_CODECOV_KEY",
18    "CLI_FDO_KEY",
19    "FDO_PROFILE_ATTR_KEY",
20    "apply_fdo_profile",
21)
22load(":lto_transitions.bzl", "CLI_FEATURES_KEY", "apply_drop_lto")
23
24# Both LTO and FDO require an incoming transition on cc_library_shared
25def _lto_and_fdo_profile_incoming_transition_impl(settings, attr):
26    new_fdo_settings = apply_fdo_profile(
27        settings[CLI_CODECOV_KEY],
28        getattr(attr, FDO_PROFILE_ATTR_KEY),
29    )
30
31    new_lto_settings = apply_drop_lto(settings[CLI_FEATURES_KEY])
32
33    if new_fdo_settings == None:
34        new_fdo_settings = {}
35    if new_lto_settings == None:
36        new_lto_settings = {}
37    return new_fdo_settings | new_lto_settings
38
39lto_and_fdo_profile_incoming_transition = transition(
40    implementation = _lto_and_fdo_profile_incoming_transition_impl,
41    inputs = [
42        CLI_CODECOV_KEY,
43        CLI_FEATURES_KEY,
44    ],
45    outputs = [
46        CLI_FDO_KEY,
47        CLI_FEATURES_KEY,
48    ],
49)
50