1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #pragma once
17 
18 #include <algorithm>
19 #include <map>
20 #include <string>
21 #include <vector>
22 
23 namespace android {
24 namespace linkerconfig {
25 namespace modules {
26 struct ApexInfo {
27   std::string name;
28   std::string namespace_name;
29   std::string path;
30   std::vector<std::string> provide_libs;
31   std::vector<std::string> require_libs;
32   std::vector<std::string> jni_libs;
33   bool has_bin;
34   bool has_lib;
35 
36   ApexInfo() = default;  // for std::map::operator[]
ApexInfoApexInfo37   ApexInfo(std::string name, std::string path,
38            std::vector<std::string> provide_libs,
39            std::vector<std::string> require_libs,
40            std::vector<std::string> jni_libs, bool has_bin, bool has_lib)
41       : name(std::move(name)),
42         path(std::move(path)),
43         provide_libs(std::move(provide_libs)),
44         require_libs(std::move(require_libs)),
45         jni_libs(std::move(jni_libs)),
46         has_bin(has_bin),
47         has_lib(has_lib) {
48     this->namespace_name = this->name;
49     std::replace(
50         this->namespace_name.begin(), this->namespace_name.end(), '.', '_');
51   }
52 };
53 
54 std::map<std::string, ApexInfo> ScanActiveApexes(const std::string& root);
55 }  // namespace modules
56 }  // namespace linkerconfig
57 }  // namespace android