// Copyright 2020 Google Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package bazel import ( "fmt" "path/filepath" "regexp" "sort" "strings" "github.com/google/blueprint" ) // BazelTargetModuleProperties contain properties and metadata used for // Blueprint to BUILD file conversion. type BazelTargetModuleProperties struct { // The Bazel rule class for this target. Rule_class string `blueprint:"mutated"` // The target label for the bzl file containing the definition of the rule class. Bzl_load_location string `blueprint:"mutated"` } var productVariableSubstitutionPattern = regexp.MustCompile("%(d|s)") // Label is used to represent a Bazel compatible Label. Also stores the original // bp text to support string replacement. type Label struct { // The string representation of a Bazel target label. This can be a relative // or fully qualified label. These labels are used for generating BUILD // files with bp2build. Label string // The original Soong/Blueprint module name that the label was derived from. // This is used for replacing references to the original name with the new // label, for example in genrule cmds. // // While there is a reversible 1:1 mapping from the module name to Bazel // label with bp2build that could make computing the original module name // from the label automatic, it is not the case for handcrafted targets, // where modules can have a custom label mapping through the { bazel_module: // { label: