Introduce cc_api_library
Introduce cc_api_library, which reflects imported API from other
inner-tree. This cc_api_library module type will later refer from
the other ninja module which generates stub library from the interface
description.
Tested environment :
* original libc definition has been removed temporarily, to ensure that
imported api stub library is being used from build
* Added new definition of libc as below
cc_api_library {
name: "libc",
arch: {
x86: {
src: "libs/x86/libc.so",
},
x86_64: {
src: "libs/x86_64/libc.so",
},
},
header_libs: [
"libc_headers",
],
export_header_lib_headers: ["libc_headers"],
min_sdk_version: "9",
vendor_available: true,
}
Bug: 236087698
Test: `ALLOW_MISSING_DEPENDENCIES=true m vendorimage` succeeded
Change-Id: I67070b0f3561aa2afd73b6c1c0fdf4255218baac
2022-07-26 02:48:22 +02:00
|
|
|
// Copyright 2022 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 multitree
|
|
|
|
|
|
|
|
import (
|
|
|
|
"android/soong/android"
|
2022-08-31 07:05:45 +02:00
|
|
|
"strings"
|
Introduce cc_api_library
Introduce cc_api_library, which reflects imported API from other
inner-tree. This cc_api_library module type will later refer from
the other ninja module which generates stub library from the interface
description.
Tested environment :
* original libc definition has been removed temporarily, to ensure that
imported api stub library is being used from build
* Added new definition of libc as below
cc_api_library {
name: "libc",
arch: {
x86: {
src: "libs/x86/libc.so",
},
x86_64: {
src: "libs/x86_64/libc.so",
},
},
header_libs: [
"libc_headers",
],
export_header_lib_headers: ["libc_headers"],
min_sdk_version: "9",
vendor_available: true,
}
Bug: 236087698
Test: `ALLOW_MISSING_DEPENDENCIES=true m vendorimage` succeeded
Change-Id: I67070b0f3561aa2afd73b6c1c0fdf4255218baac
2022-07-26 02:48:22 +02:00
|
|
|
|
|
|
|
"github.com/google/blueprint"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
apiImportNameSuffix = ".apiimport"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
RegisterApiImportsModule(android.InitRegistrationContext)
|
2022-08-31 07:05:45 +02:00
|
|
|
android.RegisterMakeVarsProvider(pctx, makeVarsProvider)
|
Introduce cc_api_library
Introduce cc_api_library, which reflects imported API from other
inner-tree. This cc_api_library module type will later refer from
the other ninja module which generates stub library from the interface
description.
Tested environment :
* original libc definition has been removed temporarily, to ensure that
imported api stub library is being used from build
* Added new definition of libc as below
cc_api_library {
name: "libc",
arch: {
x86: {
src: "libs/x86/libc.so",
},
x86_64: {
src: "libs/x86_64/libc.so",
},
},
header_libs: [
"libc_headers",
],
export_header_lib_headers: ["libc_headers"],
min_sdk_version: "9",
vendor_available: true,
}
Bug: 236087698
Test: `ALLOW_MISSING_DEPENDENCIES=true m vendorimage` succeeded
Change-Id: I67070b0f3561aa2afd73b6c1c0fdf4255218baac
2022-07-26 02:48:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func RegisterApiImportsModule(ctx android.RegistrationContext) {
|
|
|
|
ctx.RegisterModuleType("api_imports", apiImportsFactory)
|
|
|
|
}
|
|
|
|
|
|
|
|
type ApiImports struct {
|
|
|
|
android.ModuleBase
|
|
|
|
properties apiImportsProperties
|
|
|
|
}
|
|
|
|
|
|
|
|
type apiImportsProperties struct {
|
2023-02-06 14:08:13 +01:00
|
|
|
Shared_libs []string // List of C shared libraries from API surfaces
|
|
|
|
Header_libs []string // List of C header libraries from API surfaces
|
|
|
|
Apex_shared_libs []string // List of C shared libraries with APEX stubs
|
Introduce cc_api_library
Introduce cc_api_library, which reflects imported API from other
inner-tree. This cc_api_library module type will later refer from
the other ninja module which generates stub library from the interface
description.
Tested environment :
* original libc definition has been removed temporarily, to ensure that
imported api stub library is being used from build
* Added new definition of libc as below
cc_api_library {
name: "libc",
arch: {
x86: {
src: "libs/x86/libc.so",
},
x86_64: {
src: "libs/x86_64/libc.so",
},
},
header_libs: [
"libc_headers",
],
export_header_lib_headers: ["libc_headers"],
min_sdk_version: "9",
vendor_available: true,
}
Bug: 236087698
Test: `ALLOW_MISSING_DEPENDENCIES=true m vendorimage` succeeded
Change-Id: I67070b0f3561aa2afd73b6c1c0fdf4255218baac
2022-07-26 02:48:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// 'api_imports' is a module which describes modules available from API surfaces.
|
|
|
|
// This module is required to get the list of all imported API modules, because
|
|
|
|
// it is discouraged to loop and fetch all modules from its type information. The
|
|
|
|
// only module with name 'api_imports' will be used from the build.
|
|
|
|
func apiImportsFactory() android.Module {
|
|
|
|
module := &ApiImports{}
|
|
|
|
module.AddProperties(&module.properties)
|
|
|
|
android.InitAndroidModule(module)
|
|
|
|
return module
|
|
|
|
}
|
|
|
|
|
|
|
|
func (imports *ApiImports) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|
|
|
// ApiImport module does not generate any build actions
|
|
|
|
}
|
|
|
|
|
|
|
|
type ApiImportInfo struct {
|
2023-02-06 14:08:13 +01:00
|
|
|
SharedLibs, HeaderLibs, ApexSharedLibs map[string]string
|
Introduce cc_api_library
Introduce cc_api_library, which reflects imported API from other
inner-tree. This cc_api_library module type will later refer from
the other ninja module which generates stub library from the interface
description.
Tested environment :
* original libc definition has been removed temporarily, to ensure that
imported api stub library is being used from build
* Added new definition of libc as below
cc_api_library {
name: "libc",
arch: {
x86: {
src: "libs/x86/libc.so",
},
x86_64: {
src: "libs/x86_64/libc.so",
},
},
header_libs: [
"libc_headers",
],
export_header_lib_headers: ["libc_headers"],
min_sdk_version: "9",
vendor_available: true,
}
Bug: 236087698
Test: `ALLOW_MISSING_DEPENDENCIES=true m vendorimage` succeeded
Change-Id: I67070b0f3561aa2afd73b6c1c0fdf4255218baac
2022-07-26 02:48:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var ApiImportsProvider = blueprint.NewMutatorProvider(ApiImportInfo{}, "deps")
|
|
|
|
|
|
|
|
// Store module lists into ApiImportInfo and share it over mutator provider.
|
|
|
|
func (imports *ApiImports) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|
|
|
generateNameMapWithSuffix := func(names []string) map[string]string {
|
|
|
|
moduleNameMap := make(map[string]string)
|
|
|
|
for _, name := range names {
|
|
|
|
moduleNameMap[name] = name + apiImportNameSuffix
|
|
|
|
}
|
|
|
|
|
|
|
|
return moduleNameMap
|
|
|
|
}
|
|
|
|
|
|
|
|
sharedLibs := generateNameMapWithSuffix(imports.properties.Shared_libs)
|
|
|
|
headerLibs := generateNameMapWithSuffix(imports.properties.Header_libs)
|
2023-02-06 14:08:13 +01:00
|
|
|
apexSharedLibs := generateNameMapWithSuffix(imports.properties.Apex_shared_libs)
|
Introduce cc_api_library
Introduce cc_api_library, which reflects imported API from other
inner-tree. This cc_api_library module type will later refer from
the other ninja module which generates stub library from the interface
description.
Tested environment :
* original libc definition has been removed temporarily, to ensure that
imported api stub library is being used from build
* Added new definition of libc as below
cc_api_library {
name: "libc",
arch: {
x86: {
src: "libs/x86/libc.so",
},
x86_64: {
src: "libs/x86_64/libc.so",
},
},
header_libs: [
"libc_headers",
],
export_header_lib_headers: ["libc_headers"],
min_sdk_version: "9",
vendor_available: true,
}
Bug: 236087698
Test: `ALLOW_MISSING_DEPENDENCIES=true m vendorimage` succeeded
Change-Id: I67070b0f3561aa2afd73b6c1c0fdf4255218baac
2022-07-26 02:48:22 +02:00
|
|
|
|
|
|
|
ctx.SetProvider(ApiImportsProvider, ApiImportInfo{
|
2023-02-06 14:08:13 +01:00
|
|
|
SharedLibs: sharedLibs,
|
|
|
|
HeaderLibs: headerLibs,
|
|
|
|
ApexSharedLibs: apexSharedLibs,
|
Introduce cc_api_library
Introduce cc_api_library, which reflects imported API from other
inner-tree. This cc_api_library module type will later refer from
the other ninja module which generates stub library from the interface
description.
Tested environment :
* original libc definition has been removed temporarily, to ensure that
imported api stub library is being used from build
* Added new definition of libc as below
cc_api_library {
name: "libc",
arch: {
x86: {
src: "libs/x86/libc.so",
},
x86_64: {
src: "libs/x86_64/libc.so",
},
},
header_libs: [
"libc_headers",
],
export_header_lib_headers: ["libc_headers"],
min_sdk_version: "9",
vendor_available: true,
}
Bug: 236087698
Test: `ALLOW_MISSING_DEPENDENCIES=true m vendorimage` succeeded
Change-Id: I67070b0f3561aa2afd73b6c1c0fdf4255218baac
2022-07-26 02:48:22 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetApiImportSuffix() string {
|
|
|
|
return apiImportNameSuffix
|
|
|
|
}
|
2022-08-31 07:05:45 +02:00
|
|
|
|
|
|
|
func makeVarsProvider(ctx android.MakeVarsContext) {
|
|
|
|
ctx.VisitAllModules(func(m android.Module) {
|
|
|
|
if i, ok := m.(*ApiImports); ok {
|
|
|
|
ctx.Strict("API_IMPORTED_SHARED_LIBRARIES", strings.Join(i.properties.Shared_libs, " "))
|
|
|
|
ctx.Strict("API_IMPORTED_HEADER_LIBRARIES", strings.Join(i.properties.Header_libs, " "))
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|