bp2build.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright (C) 2022 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. package apex
  15. import (
  16. "android/soong/android"
  17. "encoding/json"
  18. "strings"
  19. )
  20. // This file contains the bp2build integration for the apex package.
  21. // Export constants as Starlark using bp2build to Bazel.
  22. func BazelApexToolchainVars() (string, error) {
  23. marshalled, err := json.Marshal(apexAvailBaseline)
  24. if err != nil {
  25. return "", err
  26. }
  27. content := []string{
  28. "# GENERATED BY SOONG. DO NOT EDIT.",
  29. "default_manifest_version = " + android.DefaultUpdatableModuleVersion, // constants.go is different in every branch.
  30. "apex_available_baseline = json.decode('''" + string(marshalled) + "''')",
  31. }
  32. return strings.Join(content, "\n"), nil
  33. }