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 
17 #include "linkerconfig/apexconfig.h"
18 #include "linkerconfig/environment.h"
19 #include "linkerconfig/sectionbuilder.h"
20 
21 using android::linkerconfig::modules::ApexInfo;
22 using android::linkerconfig::modules::DirToSection;
23 using android::linkerconfig::modules::Section;
24 
25 namespace android {
26 namespace linkerconfig {
27 namespace contents {
28 android::linkerconfig::modules::Configuration CreateApexConfiguration(
29     Context& ctx, const ApexInfo& apex_info) {
30   std::vector<Section> sections;
31 
32   ctx.SetCurrentLinkerConfigType(
33       android::linkerconfig::contents::LinkerConfigType::ApexBinary);
34 
35   std::vector<DirToSection> dirToSection = {
36       {apex_info.path + "/bin", apex_info.name}};
37 
38   if (apex_info.name == "com.android.art") {
39     sections.push_back(BuildApexArtSection(ctx, apex_info));
40   } else {
41     sections.push_back(BuildApexDefaultSection(ctx, apex_info));
42   }
43   return android::linkerconfig::modules::Configuration(std::move(sections),
44                                                        dirToSection);
45 }
46 }  // namespace contents
47 }  // namespace linkerconfig
48 }  // namespace android
49