| Jingwen Chen | 7810e17 | 2022-07-29 02:25:34 +0000 | [diff] [blame] | 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 | // | 
| Colin Cross | d079e0b | 2022-08-16 10:27:33 -0700 | [diff] [blame] | 7 | //	http://www.apache.org/licenses/LICENSE-2.0 | 
| Jingwen Chen | 7810e17 | 2022-07-29 02:25:34 +0000 | [diff] [blame] | 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 |  | 
|  | 16 | import ( | 
|  | 17 | "android/soong/android" | 
| Cole Faust | 9e384e2 | 2023-02-08 17:43:09 -0800 | [diff] [blame] | 18 | "encoding/json" | 
| Jingwen Chen | 7810e17 | 2022-07-29 02:25:34 +0000 | [diff] [blame] | 19 | "strings" | 
|  | 20 | ) | 
|  | 21 |  | 
|  | 22 | // This file contains the bp2build integration for the apex package. | 
|  | 23 |  | 
|  | 24 | // Export constants as Starlark using bp2build to Bazel. | 
| Cole Faust | 9e384e2 | 2023-02-08 17:43:09 -0800 | [diff] [blame] | 25 | func BazelApexToolchainVars() (string, error) { | 
|  | 26 | marshalled, err := json.Marshal(apexAvailBaseline) | 
|  | 27 | if err != nil { | 
|  | 28 | return "", err | 
|  | 29 | } | 
| Jingwen Chen | 7810e17 | 2022-07-29 02:25:34 +0000 | [diff] [blame] | 30 | content := []string{ | 
|  | 31 | "# GENERATED BY SOONG. DO NOT EDIT.", | 
|  | 32 | "default_manifest_version = " + android.DefaultUpdatableModuleVersion, // constants.go is different in every branch. | 
| Cole Faust | 9e384e2 | 2023-02-08 17:43:09 -0800 | [diff] [blame] | 33 | "apex_available_baseline = json.decode('''" + string(marshalled) + "''')", | 
| Jingwen Chen | 7810e17 | 2022-07-29 02:25:34 +0000 | [diff] [blame] | 34 | } | 
| Cole Faust | 9e384e2 | 2023-02-08 17:43:09 -0800 | [diff] [blame] | 35 | return strings.Join(content, "\n"), nil | 
| Jingwen Chen | 7810e17 | 2022-07-29 02:25:34 +0000 | [diff] [blame] | 36 | } |