2016-07-29 21:48:20 +02:00
|
|
|
// Copyright 2016 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 cc
|
|
|
|
|
|
|
|
import (
|
2018-11-02 10:23:15 +01:00
|
|
|
"regexp"
|
Stubs variant is used when building for APEX
When a native module is built for an APEX and is depending on a native
library having stubs (i.e. stubs.versions property is set), the stubs
variant is used unless the dependent lib is directly included in the
same APEX with the depending module.
Example:
apex {
name: "myapex",
native_shared_libs: ["libX", "libY"],
}
cc_library {
name: "libX",
shared_libs: ["libY", "libZ"],
}
cc_library {
name: "libY",
stubs: { versions: ["1", "2"], },
}
cc_library {
name: "libZ",
stubs: { versions: ["1", "2"], },
}
In this case, libX is linking to the impl variant of libY (that provides
private APIs) while libY is linking to the version 2 stubs of libZ. This is
because libY is directly included in the same apex via
native_shared_libs property, but libZ isn't.
Bug: 112672359
Test: apex_test added
Change-Id: If9871b70dc74a06bd828dd4cd1aeebd2e68b837c
2018-11-18 10:02:45 +01:00
|
|
|
"sort"
|
|
|
|
"strconv"
|
2016-07-29 21:48:20 +02:00
|
|
|
"strings"
|
2018-11-02 10:23:15 +01:00
|
|
|
"sync"
|
2016-07-29 21:48:20 +02:00
|
|
|
|
|
|
|
"github.com/google/blueprint"
|
2016-10-01 02:10:16 +02:00
|
|
|
"github.com/google/blueprint/pathtools"
|
2016-07-29 21:48:20 +02:00
|
|
|
|
|
|
|
"android/soong/android"
|
2018-04-26 01:05:30 +02:00
|
|
|
"android/soong/cc/config"
|
Add support for versioned stubs.
A cc_library or cc_library_shared can be configured to have stubs
variants of the lib.
cc_library_shared {
name: "libfoo",
srcs: ["foo.cpp"],
stubs: {
symbol_file: "foo.map.txt",
versions: ["1", "2", "3"],
},
}
then, stubs variants of libfoo for version 1, 2, and 3 are created
from foo.map.txt. Each version has the symbols from the map file where
each symbol is annotated with the version that the symbol was introduced
via the 'introduced=<ver>' syntax. The versions don't need to be in sync
with the platform versions (e.g., P for 28). The versions are local to
the library.
For another library or executable to use the versioned stubs lib, use
the new 'name#ver' syntax to specify the version:
cc_binary {
name: "test",
....
shared_libs: ["libFoo#2"],
}
Internally, a new mutator 'version' is applied to all cc.Module objects.
By default, a variant named 'impl' is created for the non-stub version.
If the versions property is set, additional variations are created per a
version with the mutable property BuildStubs set as true, which lets the
compiler and the linker to build a stubs lib from the symbol file
instead from the source files.
This feature will be used to enforce stable interfaces among APEXs. When
a lib foo in an APEX is depending on a lib bar in another APEX, then bar
should have stable interface (in C lang) and foo should be depending on
one of the stubs libs of bar. Only libraries in the same APEX as foo can
link against non-stub version of it.
Bug: 112672359
Test: m (cc_test added)
Change-Id: I2488be0b9d7b7b8d7761234dc1c9c0e3add8601c
2018-10-15 15:25:07 +02:00
|
|
|
"android/soong/genrule"
|
2016-07-29 21:48:20 +02:00
|
|
|
)
|
|
|
|
|
2019-01-22 23:41:08 +01:00
|
|
|
type StaticSharedLibraryProperties struct {
|
|
|
|
Srcs []string `android:"arch_variant"`
|
|
|
|
Cflags []string `android:"arch_variant"`
|
|
|
|
|
|
|
|
Enabled *bool `android:"arch_variant"`
|
|
|
|
Whole_static_libs []string `android:"arch_variant"`
|
|
|
|
Static_libs []string `android:"arch_variant"`
|
|
|
|
Shared_libs []string `android:"arch_variant"`
|
|
|
|
System_shared_libs []string `android:"arch_variant"`
|
|
|
|
|
|
|
|
Export_shared_lib_headers []string `android:"arch_variant"`
|
|
|
|
Export_static_lib_headers []string `android:"arch_variant"`
|
|
|
|
}
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
type LibraryProperties struct {
|
2019-01-22 23:41:08 +01:00
|
|
|
Static StaticSharedLibraryProperties `android:"arch_variant"`
|
|
|
|
Shared StaticSharedLibraryProperties `android:"arch_variant"`
|
2016-07-29 21:48:20 +02:00
|
|
|
|
|
|
|
// local file name to pass to the linker as -unexported_symbols_list
|
|
|
|
Unexported_symbols_list *string `android:"arch_variant"`
|
|
|
|
// local file name to pass to the linker as -force_symbols_not_weak_list
|
|
|
|
Force_symbols_not_weak_list *string `android:"arch_variant"`
|
|
|
|
// local file name to pass to the linker as -force_symbols_weak_list
|
|
|
|
Force_symbols_weak_list *string `android:"arch_variant"`
|
|
|
|
|
|
|
|
// rename host libraries to prevent overlap with system installed libraries
|
|
|
|
Unique_host_soname *bool
|
|
|
|
|
2016-11-03 22:28:51 +01:00
|
|
|
Aidl struct {
|
|
|
|
// export headers generated from .aidl sources
|
2017-11-07 19:57:05 +01:00
|
|
|
Export_aidl_headers *bool
|
2016-11-03 22:28:51 +01:00
|
|
|
}
|
|
|
|
|
2016-10-21 01:11:43 +02:00
|
|
|
Proto struct {
|
|
|
|
// export headers generated from .proto sources
|
2017-11-07 19:57:05 +01:00
|
|
|
Export_proto_headers *bool
|
2016-10-21 01:11:43 +02:00
|
|
|
}
|
2017-10-13 09:29:00 +02:00
|
|
|
|
2017-11-07 19:57:05 +01:00
|
|
|
Static_ndk_lib *bool
|
Add support for versioned stubs.
A cc_library or cc_library_shared can be configured to have stubs
variants of the lib.
cc_library_shared {
name: "libfoo",
srcs: ["foo.cpp"],
stubs: {
symbol_file: "foo.map.txt",
versions: ["1", "2", "3"],
},
}
then, stubs variants of libfoo for version 1, 2, and 3 are created
from foo.map.txt. Each version has the symbols from the map file where
each symbol is annotated with the version that the symbol was introduced
via the 'introduced=<ver>' syntax. The versions don't need to be in sync
with the platform versions (e.g., P for 28). The versions are local to
the library.
For another library or executable to use the versioned stubs lib, use
the new 'name#ver' syntax to specify the version:
cc_binary {
name: "test",
....
shared_libs: ["libFoo#2"],
}
Internally, a new mutator 'version' is applied to all cc.Module objects.
By default, a variant named 'impl' is created for the non-stub version.
If the versions property is set, additional variations are created per a
version with the mutable property BuildStubs set as true, which lets the
compiler and the linker to build a stubs lib from the symbol file
instead from the source files.
This feature will be used to enforce stable interfaces among APEXs. When
a lib foo in an APEX is depending on a lib bar in another APEX, then bar
should have stable interface (in C lang) and foo should be depending on
one of the stubs libs of bar. Only libraries in the same APEX as foo can
link against non-stub version of it.
Bug: 112672359
Test: m (cc_test added)
Change-Id: I2488be0b9d7b7b8d7761234dc1c9c0e3add8601c
2018-10-15 15:25:07 +02:00
|
|
|
|
|
|
|
Stubs struct {
|
|
|
|
// Relative path to the symbol map. The symbol map provides the list of
|
|
|
|
// symbols that are exported for stubs variant of this library.
|
|
|
|
Symbol_file *string
|
|
|
|
|
|
|
|
// List versions to generate stubs libs for.
|
|
|
|
Versions []string
|
|
|
|
}
|
2018-11-07 13:43:34 +01:00
|
|
|
|
|
|
|
// set the name of the output
|
|
|
|
Stem *string `android:"arch_variant"`
|
|
|
|
|
|
|
|
// Names of modules to be overridden. Listed modules can only be other shared libraries
|
|
|
|
// (in Make or Soong).
|
|
|
|
// This does not completely prevent installation of the overridden libraries, but if both
|
|
|
|
// binaries would be installed by default (in PRODUCT_PACKAGES) the other library will be removed
|
|
|
|
// from PRODUCT_PACKAGES.
|
|
|
|
Overrides []string
|
2017-02-15 00:28:44 +01:00
|
|
|
}
|
2016-10-21 01:11:43 +02:00
|
|
|
|
2017-02-15 00:28:44 +01:00
|
|
|
type LibraryMutatedProperties struct {
|
2016-07-29 21:48:20 +02:00
|
|
|
VariantName string `blueprint:"mutated"`
|
2016-07-30 02:28:03 +02:00
|
|
|
|
|
|
|
// Build a static variant
|
|
|
|
BuildStatic bool `blueprint:"mutated"`
|
|
|
|
// Build a shared variant
|
|
|
|
BuildShared bool `blueprint:"mutated"`
|
|
|
|
// This variant is shared
|
|
|
|
VariantIsShared bool `blueprint:"mutated"`
|
|
|
|
// This variant is static
|
|
|
|
VariantIsStatic bool `blueprint:"mutated"`
|
Add support for versioned stubs.
A cc_library or cc_library_shared can be configured to have stubs
variants of the lib.
cc_library_shared {
name: "libfoo",
srcs: ["foo.cpp"],
stubs: {
symbol_file: "foo.map.txt",
versions: ["1", "2", "3"],
},
}
then, stubs variants of libfoo for version 1, 2, and 3 are created
from foo.map.txt. Each version has the symbols from the map file where
each symbol is annotated with the version that the symbol was introduced
via the 'introduced=<ver>' syntax. The versions don't need to be in sync
with the platform versions (e.g., P for 28). The versions are local to
the library.
For another library or executable to use the versioned stubs lib, use
the new 'name#ver' syntax to specify the version:
cc_binary {
name: "test",
....
shared_libs: ["libFoo#2"],
}
Internally, a new mutator 'version' is applied to all cc.Module objects.
By default, a variant named 'impl' is created for the non-stub version.
If the versions property is set, additional variations are created per a
version with the mutable property BuildStubs set as true, which lets the
compiler and the linker to build a stubs lib from the symbol file
instead from the source files.
This feature will be used to enforce stable interfaces among APEXs. When
a lib foo in an APEX is depending on a lib bar in another APEX, then bar
should have stable interface (in C lang) and foo should be depending on
one of the stubs libs of bar. Only libraries in the same APEX as foo can
link against non-stub version of it.
Bug: 112672359
Test: m (cc_test added)
Change-Id: I2488be0b9d7b7b8d7761234dc1c9c0e3add8601c
2018-10-15 15:25:07 +02:00
|
|
|
|
|
|
|
// This variant is a stubs lib
|
|
|
|
BuildStubs bool `blueprint:"mutated"`
|
|
|
|
// Version of the stubs lib
|
|
|
|
StubsVersion string `blueprint:"mutated"`
|
2016-07-30 02:28:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type FlagExporterProperties struct {
|
|
|
|
// list of directories relative to the Blueprints file that will
|
2016-11-03 23:53:42 +01:00
|
|
|
// be added to the include path (using -I) for this module and any module that links
|
2017-10-18 01:15:50 +02:00
|
|
|
// against this module. Directories listed in export_include_dirs do not need to be
|
|
|
|
// listed in local_include_dirs.
|
2016-07-30 02:28:03 +02:00
|
|
|
Export_include_dirs []string `android:"arch_variant"`
|
Split /system and /vendor modules, allow multi-installation
Nothing changes if BOARD_VNDK_VERSION isn't set.
When the VNDK is enabled (BOARD_VNDK_VERSION in Make), this will split
/system and /vendor modules into two different variant spaces that can't
link to each other. There are a few interfaces between the two variant
spaces:
The `llndk_library` stubs will be available in the /vendor variant, but
won't be installed, so at runtime the /system variant will be used.
Setting `vendor_available: true` will split a module into both variants.
The /system (or "core") variant will compile just like today. The
/vendor ("vendor") variant will compile against everything else in the
vendor space (so LL-NDK instead of libc/liblog/etc). There will be two
copies of these libraries installed onto the final device.
Since the available runtime interfaces for vendor modules may be
reduced, and your dependencies may not expose their private interfaces,
we allow the vendor variants to reduce their compilation set, and export
a different set of headers:
cc_library {
name: "libfoo",
srcs: ["common.cpp", "private_impl.cpp"],
export_include_dirs: ["include"],
target: {
vendor: {
export_include_dirs: ["include_vndk"],
exclude_srcs: ["private_impl.cpp"],
srcs: ["vendor_only.cpp"],
},
},
}
So the "core" variant would compile with both "common.cpp" and
"private_impl.cpp", and export "include".
The "vendor" variant would compile "common.cpp" and "vendor_only.cpp",
and export "include_vndk".
Bug: 36426473
Bug: 36079834
Test: out/soong/build.ninja, out/soong/Android- only changes due to _core addition and
.llndk -> .vendor
Test: attempt to compile with BOARD_VNDK_VERSION:=current
Change-Id: Idef28764043bf6c33dc0d2e7e2026c38867ff769
2017-04-06 21:43:22 +02:00
|
|
|
|
|
|
|
Target struct {
|
|
|
|
Vendor struct {
|
|
|
|
// list of exported include directories, like
|
|
|
|
// export_include_dirs, that will be applied to the
|
|
|
|
// vendor variant of this library. This will overwrite
|
|
|
|
// any other declarations.
|
2018-01-05 23:42:54 +01:00
|
|
|
Override_export_include_dirs []string
|
Split /system and /vendor modules, allow multi-installation
Nothing changes if BOARD_VNDK_VERSION isn't set.
When the VNDK is enabled (BOARD_VNDK_VERSION in Make), this will split
/system and /vendor modules into two different variant spaces that can't
link to each other. There are a few interfaces between the two variant
spaces:
The `llndk_library` stubs will be available in the /vendor variant, but
won't be installed, so at runtime the /system variant will be used.
Setting `vendor_available: true` will split a module into both variants.
The /system (or "core") variant will compile just like today. The
/vendor ("vendor") variant will compile against everything else in the
vendor space (so LL-NDK instead of libc/liblog/etc). There will be two
copies of these libraries installed onto the final device.
Since the available runtime interfaces for vendor modules may be
reduced, and your dependencies may not expose their private interfaces,
we allow the vendor variants to reduce their compilation set, and export
a different set of headers:
cc_library {
name: "libfoo",
srcs: ["common.cpp", "private_impl.cpp"],
export_include_dirs: ["include"],
target: {
vendor: {
export_include_dirs: ["include_vndk"],
exclude_srcs: ["private_impl.cpp"],
srcs: ["vendor_only.cpp"],
},
},
}
So the "core" variant would compile with both "common.cpp" and
"private_impl.cpp", and export "include".
The "vendor" variant would compile "common.cpp" and "vendor_only.cpp",
and export "include_vndk".
Bug: 36426473
Bug: 36079834
Test: out/soong/build.ninja, out/soong/Android- only changes due to _core addition and
.llndk -> .vendor
Test: attempt to compile with BOARD_VNDK_VERSION:=current
Change-Id: Idef28764043bf6c33dc0d2e7e2026c38867ff769
2017-04-06 21:43:22 +02:00
|
|
|
}
|
|
|
|
}
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
2017-11-03 01:00:50 +01:00
|
|
|
android.RegisterModuleType("cc_library_static", LibraryStaticFactory)
|
|
|
|
android.RegisterModuleType("cc_library_shared", LibrarySharedFactory)
|
|
|
|
android.RegisterModuleType("cc_library", LibraryFactory)
|
|
|
|
android.RegisterModuleType("cc_library_host_static", LibraryHostStaticFactory)
|
|
|
|
android.RegisterModuleType("cc_library_host_shared", LibraryHostSharedFactory)
|
|
|
|
android.RegisterModuleType("cc_library_headers", LibraryHeaderFactory)
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Module factory for combined static + shared libraries, device by default but with possible host
|
|
|
|
// support
|
2017-11-03 01:00:50 +01:00
|
|
|
func LibraryFactory() android.Module {
|
2016-12-09 23:46:15 +01:00
|
|
|
module, _ := NewLibrary(android.HostAndDeviceSupported)
|
2016-07-29 21:48:20 +02:00
|
|
|
return module.Init()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Module factory for static libraries
|
2017-11-03 01:00:50 +01:00
|
|
|
func LibraryStaticFactory() android.Module {
|
2016-12-09 23:46:15 +01:00
|
|
|
module, library := NewLibrary(android.HostAndDeviceSupported)
|
|
|
|
library.BuildOnlyStatic()
|
2016-07-29 21:48:20 +02:00
|
|
|
return module.Init()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Module factory for shared libraries
|
2017-11-03 01:00:50 +01:00
|
|
|
func LibrarySharedFactory() android.Module {
|
2016-12-09 23:46:15 +01:00
|
|
|
module, library := NewLibrary(android.HostAndDeviceSupported)
|
|
|
|
library.BuildOnlyShared()
|
2016-07-29 21:48:20 +02:00
|
|
|
return module.Init()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Module factory for host static libraries
|
2017-11-03 01:00:50 +01:00
|
|
|
func LibraryHostStaticFactory() android.Module {
|
2016-12-09 23:46:15 +01:00
|
|
|
module, library := NewLibrary(android.HostSupported)
|
|
|
|
library.BuildOnlyStatic()
|
2016-07-29 21:48:20 +02:00
|
|
|
return module.Init()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Module factory for host shared libraries
|
2017-11-03 01:00:50 +01:00
|
|
|
func LibraryHostSharedFactory() android.Module {
|
2016-12-09 23:46:15 +01:00
|
|
|
module, library := NewLibrary(android.HostSupported)
|
|
|
|
library.BuildOnlyShared()
|
2016-07-29 21:48:20 +02:00
|
|
|
return module.Init()
|
|
|
|
}
|
|
|
|
|
2016-12-13 21:50:57 +01:00
|
|
|
// Module factory for header-only libraries
|
2017-11-03 01:00:50 +01:00
|
|
|
func LibraryHeaderFactory() android.Module {
|
2016-12-13 21:50:57 +01:00
|
|
|
module, library := NewLibrary(android.HostAndDeviceSupported)
|
|
|
|
library.HeaderOnly()
|
|
|
|
return module.Init()
|
|
|
|
}
|
|
|
|
|
2016-07-29 21:48:20 +02:00
|
|
|
type flagExporter struct {
|
|
|
|
Properties FlagExporterProperties
|
|
|
|
|
2016-09-29 21:13:36 +02:00
|
|
|
flags []string
|
|
|
|
flagsDeps android.Paths
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
Split /system and /vendor modules, allow multi-installation
Nothing changes if BOARD_VNDK_VERSION isn't set.
When the VNDK is enabled (BOARD_VNDK_VERSION in Make), this will split
/system and /vendor modules into two different variant spaces that can't
link to each other. There are a few interfaces between the two variant
spaces:
The `llndk_library` stubs will be available in the /vendor variant, but
won't be installed, so at runtime the /system variant will be used.
Setting `vendor_available: true` will split a module into both variants.
The /system (or "core") variant will compile just like today. The
/vendor ("vendor") variant will compile against everything else in the
vendor space (so LL-NDK instead of libc/liblog/etc). There will be two
copies of these libraries installed onto the final device.
Since the available runtime interfaces for vendor modules may be
reduced, and your dependencies may not expose their private interfaces,
we allow the vendor variants to reduce their compilation set, and export
a different set of headers:
cc_library {
name: "libfoo",
srcs: ["common.cpp", "private_impl.cpp"],
export_include_dirs: ["include"],
target: {
vendor: {
export_include_dirs: ["include_vndk"],
exclude_srcs: ["private_impl.cpp"],
srcs: ["vendor_only.cpp"],
},
},
}
So the "core" variant would compile with both "common.cpp" and
"private_impl.cpp", and export "include".
The "vendor" variant would compile "common.cpp" and "vendor_only.cpp",
and export "include_vndk".
Bug: 36426473
Bug: 36079834
Test: out/soong/build.ninja, out/soong/Android- only changes due to _core addition and
.llndk -> .vendor
Test: attempt to compile with BOARD_VNDK_VERSION:=current
Change-Id: Idef28764043bf6c33dc0d2e7e2026c38867ff769
2017-04-06 21:43:22 +02:00
|
|
|
func (f *flagExporter) exportedIncludes(ctx ModuleContext) android.Paths {
|
2018-01-05 23:42:54 +01:00
|
|
|
if ctx.useVndk() && f.Properties.Target.Vendor.Override_export_include_dirs != nil {
|
|
|
|
return android.PathsForModuleSrc(ctx, f.Properties.Target.Vendor.Override_export_include_dirs)
|
Split /system and /vendor modules, allow multi-installation
Nothing changes if BOARD_VNDK_VERSION isn't set.
When the VNDK is enabled (BOARD_VNDK_VERSION in Make), this will split
/system and /vendor modules into two different variant spaces that can't
link to each other. There are a few interfaces between the two variant
spaces:
The `llndk_library` stubs will be available in the /vendor variant, but
won't be installed, so at runtime the /system variant will be used.
Setting `vendor_available: true` will split a module into both variants.
The /system (or "core") variant will compile just like today. The
/vendor ("vendor") variant will compile against everything else in the
vendor space (so LL-NDK instead of libc/liblog/etc). There will be two
copies of these libraries installed onto the final device.
Since the available runtime interfaces for vendor modules may be
reduced, and your dependencies may not expose their private interfaces,
we allow the vendor variants to reduce their compilation set, and export
a different set of headers:
cc_library {
name: "libfoo",
srcs: ["common.cpp", "private_impl.cpp"],
export_include_dirs: ["include"],
target: {
vendor: {
export_include_dirs: ["include_vndk"],
exclude_srcs: ["private_impl.cpp"],
srcs: ["vendor_only.cpp"],
},
},
}
So the "core" variant would compile with both "common.cpp" and
"private_impl.cpp", and export "include".
The "vendor" variant would compile "common.cpp" and "vendor_only.cpp",
and export "include_vndk".
Bug: 36426473
Bug: 36079834
Test: out/soong/build.ninja, out/soong/Android- only changes due to _core addition and
.llndk -> .vendor
Test: attempt to compile with BOARD_VNDK_VERSION:=current
Change-Id: Idef28764043bf6c33dc0d2e7e2026c38867ff769
2017-04-06 21:43:22 +02:00
|
|
|
} else {
|
|
|
|
return android.PathsForModuleSrc(ctx, f.Properties.Export_include_dirs)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-29 21:48:20 +02:00
|
|
|
func (f *flagExporter) exportIncludes(ctx ModuleContext, inc string) {
|
Split /system and /vendor modules, allow multi-installation
Nothing changes if BOARD_VNDK_VERSION isn't set.
When the VNDK is enabled (BOARD_VNDK_VERSION in Make), this will split
/system and /vendor modules into two different variant spaces that can't
link to each other. There are a few interfaces between the two variant
spaces:
The `llndk_library` stubs will be available in the /vendor variant, but
won't be installed, so at runtime the /system variant will be used.
Setting `vendor_available: true` will split a module into both variants.
The /system (or "core") variant will compile just like today. The
/vendor ("vendor") variant will compile against everything else in the
vendor space (so LL-NDK instead of libc/liblog/etc). There will be two
copies of these libraries installed onto the final device.
Since the available runtime interfaces for vendor modules may be
reduced, and your dependencies may not expose their private interfaces,
we allow the vendor variants to reduce their compilation set, and export
a different set of headers:
cc_library {
name: "libfoo",
srcs: ["common.cpp", "private_impl.cpp"],
export_include_dirs: ["include"],
target: {
vendor: {
export_include_dirs: ["include_vndk"],
exclude_srcs: ["private_impl.cpp"],
srcs: ["vendor_only.cpp"],
},
},
}
So the "core" variant would compile with both "common.cpp" and
"private_impl.cpp", and export "include".
The "vendor" variant would compile "common.cpp" and "vendor_only.cpp",
and export "include_vndk".
Bug: 36426473
Bug: 36079834
Test: out/soong/build.ninja, out/soong/Android- only changes due to _core addition and
.llndk -> .vendor
Test: attempt to compile with BOARD_VNDK_VERSION:=current
Change-Id: Idef28764043bf6c33dc0d2e7e2026c38867ff769
2017-04-06 21:43:22 +02:00
|
|
|
includeDirs := f.exportedIncludes(ctx)
|
2016-07-29 21:48:20 +02:00
|
|
|
for _, dir := range includeDirs.Strings() {
|
|
|
|
f.flags = append(f.flags, inc+dir)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *flagExporter) reexportFlags(flags []string) {
|
|
|
|
f.flags = append(f.flags, flags...)
|
|
|
|
}
|
|
|
|
|
2016-09-29 21:13:36 +02:00
|
|
|
func (f *flagExporter) reexportDeps(deps android.Paths) {
|
|
|
|
f.flagsDeps = append(f.flagsDeps, deps...)
|
|
|
|
}
|
|
|
|
|
2016-07-29 21:48:20 +02:00
|
|
|
func (f *flagExporter) exportedFlags() []string {
|
|
|
|
return f.flags
|
|
|
|
}
|
|
|
|
|
2016-09-29 21:13:36 +02:00
|
|
|
func (f *flagExporter) exportedFlagsDeps() android.Paths {
|
|
|
|
return f.flagsDeps
|
|
|
|
}
|
|
|
|
|
2016-07-29 21:48:20 +02:00
|
|
|
type exportedFlagsProducer interface {
|
|
|
|
exportedFlags() []string
|
2016-09-29 21:13:36 +02:00
|
|
|
exportedFlagsDeps() android.Paths
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var _ exportedFlagsProducer = (*flagExporter)(nil)
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
// libraryDecorator wraps baseCompiler, baseLinker and baseInstaller to provide library-specific
|
|
|
|
// functionality: static vs. shared linkage, reusing object files for shared libraries
|
|
|
|
type libraryDecorator struct {
|
2017-02-15 00:28:44 +01:00
|
|
|
Properties LibraryProperties
|
|
|
|
MutatedProperties LibraryMutatedProperties
|
2016-07-29 21:48:20 +02:00
|
|
|
|
|
|
|
// For reusing static library objects for shared library
|
2017-05-03 20:01:58 +02:00
|
|
|
reuseObjects Objects
|
|
|
|
reuseExportedFlags []string
|
2017-05-04 01:24:55 +02:00
|
|
|
reuseExportedDeps android.Paths
|
2017-05-03 20:01:58 +02:00
|
|
|
|
2016-10-01 02:10:16 +02:00
|
|
|
// table-of-contents file to optimize out relinking when possible
|
|
|
|
tocFile android.OptionalPath
|
2016-07-29 21:48:20 +02:00
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
flagExporter
|
|
|
|
stripper
|
|
|
|
|
|
|
|
// If we're used as a whole_static_lib, our missing dependencies need
|
|
|
|
// to be given
|
|
|
|
wholeStaticMissingDeps []string
|
|
|
|
|
|
|
|
// For whole_static_libs
|
2016-09-27 02:33:01 +02:00
|
|
|
objects Objects
|
2016-07-30 02:28:03 +02:00
|
|
|
|
|
|
|
// Uses the module's name if empty, but can be overridden. Does not include
|
|
|
|
// shlib suffix.
|
|
|
|
libName string
|
|
|
|
|
2017-02-08 22:45:53 +01:00
|
|
|
sabi *sabi
|
|
|
|
|
2017-02-10 01:16:31 +01:00
|
|
|
// Output archive of gcno coverage information files
|
|
|
|
coverageOutputFile android.OptionalPath
|
|
|
|
|
2017-02-08 22:45:53 +01:00
|
|
|
// linked Source Abi Dump
|
|
|
|
sAbiOutputFile android.OptionalPath
|
|
|
|
|
|
|
|
// Source Abi Diff
|
|
|
|
sAbiDiff android.OptionalPath
|
|
|
|
|
2017-11-29 02:34:01 +01:00
|
|
|
// Location of the static library in the sysroot. Empty if the library is
|
|
|
|
// not included in the NDK.
|
|
|
|
ndkSysrootPath android.Path
|
|
|
|
|
2018-09-05 01:28:17 +02:00
|
|
|
// Location of the linked, unstripped library for shared libraries
|
|
|
|
unstrippedOutputFile android.Path
|
|
|
|
|
2018-11-19 18:33:29 +01:00
|
|
|
// Location of the file that should be copied to dist dir when requested
|
|
|
|
distFile android.OptionalPath
|
|
|
|
|
Add support for versioned stubs.
A cc_library or cc_library_shared can be configured to have stubs
variants of the lib.
cc_library_shared {
name: "libfoo",
srcs: ["foo.cpp"],
stubs: {
symbol_file: "foo.map.txt",
versions: ["1", "2", "3"],
},
}
then, stubs variants of libfoo for version 1, 2, and 3 are created
from foo.map.txt. Each version has the symbols from the map file where
each symbol is annotated with the version that the symbol was introduced
via the 'introduced=<ver>' syntax. The versions don't need to be in sync
with the platform versions (e.g., P for 28). The versions are local to
the library.
For another library or executable to use the versioned stubs lib, use
the new 'name#ver' syntax to specify the version:
cc_binary {
name: "test",
....
shared_libs: ["libFoo#2"],
}
Internally, a new mutator 'version' is applied to all cc.Module objects.
By default, a variant named 'impl' is created for the non-stub version.
If the versions property is set, additional variations are created per a
version with the mutable property BuildStubs set as true, which lets the
compiler and the linker to build a stubs lib from the symbol file
instead from the source files.
This feature will be used to enforce stable interfaces among APEXs. When
a lib foo in an APEX is depending on a lib bar in another APEX, then bar
should have stable interface (in C lang) and foo should be depending on
one of the stubs libs of bar. Only libraries in the same APEX as foo can
link against non-stub version of it.
Bug: 112672359
Test: m (cc_test added)
Change-Id: I2488be0b9d7b7b8d7761234dc1c9c0e3add8601c
2018-10-15 15:25:07 +02:00
|
|
|
versionScriptPath android.ModuleGenPath
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
// Decorated interafaces
|
|
|
|
*baseCompiler
|
|
|
|
*baseLinker
|
|
|
|
*baseInstaller
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
func (library *libraryDecorator) linkerProps() []interface{} {
|
|
|
|
var props []interface{}
|
|
|
|
props = append(props, library.baseLinker.linkerProps()...)
|
|
|
|
return append(props,
|
|
|
|
&library.Properties,
|
2017-02-15 00:28:44 +01:00
|
|
|
&library.MutatedProperties,
|
2016-07-30 02:28:03 +02:00
|
|
|
&library.flagExporter.Properties,
|
2018-09-05 19:43:13 +02:00
|
|
|
&library.stripper.StripProperties)
|
2016-07-30 02:28:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (library *libraryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags {
|
|
|
|
flags = library.baseLinker.linkerFlags(ctx, flags)
|
2016-07-29 21:48:20 +02:00
|
|
|
|
|
|
|
// MinGW spits out warnings about -fPIC even for -fpie?!) being ignored because
|
|
|
|
// all code is position independent, and then those warnings get promoted to
|
|
|
|
// errors.
|
2017-04-04 21:59:48 +02:00
|
|
|
if !ctx.Windows() {
|
2016-07-29 21:48:20 +02:00
|
|
|
flags.CFlags = append(flags.CFlags, "-fPIC")
|
|
|
|
}
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
if library.static() {
|
2016-07-29 21:48:20 +02:00
|
|
|
flags.CFlags = append(flags.CFlags, library.Properties.Static.Cflags...)
|
2017-02-15 00:28:44 +01:00
|
|
|
} else if library.shared() {
|
2016-07-29 21:48:20 +02:00
|
|
|
flags.CFlags = append(flags.CFlags, library.Properties.Shared.Cflags...)
|
|
|
|
}
|
|
|
|
|
2017-02-15 00:28:44 +01:00
|
|
|
if library.shared() {
|
2016-07-30 02:28:03 +02:00
|
|
|
libName := library.getLibName(ctx)
|
|
|
|
var f []string
|
2016-06-14 02:19:03 +02:00
|
|
|
if ctx.toolchain().Bionic() {
|
2016-07-30 02:28:03 +02:00
|
|
|
f = append(f,
|
|
|
|
"-nostdlib",
|
|
|
|
"-Wl,--gc-sections",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
if ctx.Darwin() {
|
|
|
|
f = append(f,
|
|
|
|
"-dynamiclib",
|
|
|
|
"-single_module",
|
|
|
|
"-install_name @rpath/"+libName+flags.Toolchain.ShlibSuffix(),
|
|
|
|
)
|
2016-10-20 19:47:21 +02:00
|
|
|
if ctx.Arch().ArchType == android.X86 {
|
|
|
|
f = append(f,
|
|
|
|
"-read_only_relocs suppress",
|
|
|
|
)
|
|
|
|
}
|
2016-07-30 02:28:03 +02:00
|
|
|
} else {
|
|
|
|
f = append(f,
|
2018-10-08 05:54:34 +02:00
|
|
|
"-shared",
|
2016-07-30 02:28:03 +02:00
|
|
|
"-Wl,-soname,"+libName+flags.Toolchain.ShlibSuffix())
|
|
|
|
}
|
|
|
|
|
|
|
|
flags.LdFlags = append(f, flags.LdFlags...)
|
|
|
|
}
|
|
|
|
|
2016-07-29 21:48:20 +02:00
|
|
|
return flags
|
|
|
|
}
|
|
|
|
|
2017-11-16 23:33:08 +01:00
|
|
|
func (library *libraryDecorator) compilerFlags(ctx ModuleContext, flags Flags, deps PathDeps) Flags {
|
Split /system and /vendor modules, allow multi-installation
Nothing changes if BOARD_VNDK_VERSION isn't set.
When the VNDK is enabled (BOARD_VNDK_VERSION in Make), this will split
/system and /vendor modules into two different variant spaces that can't
link to each other. There are a few interfaces between the two variant
spaces:
The `llndk_library` stubs will be available in the /vendor variant, but
won't be installed, so at runtime the /system variant will be used.
Setting `vendor_available: true` will split a module into both variants.
The /system (or "core") variant will compile just like today. The
/vendor ("vendor") variant will compile against everything else in the
vendor space (so LL-NDK instead of libc/liblog/etc). There will be two
copies of these libraries installed onto the final device.
Since the available runtime interfaces for vendor modules may be
reduced, and your dependencies may not expose their private interfaces,
we allow the vendor variants to reduce their compilation set, and export
a different set of headers:
cc_library {
name: "libfoo",
srcs: ["common.cpp", "private_impl.cpp"],
export_include_dirs: ["include"],
target: {
vendor: {
export_include_dirs: ["include_vndk"],
exclude_srcs: ["private_impl.cpp"],
srcs: ["vendor_only.cpp"],
},
},
}
So the "core" variant would compile with both "common.cpp" and
"private_impl.cpp", and export "include".
The "vendor" variant would compile "common.cpp" and "vendor_only.cpp",
and export "include_vndk".
Bug: 36426473
Bug: 36079834
Test: out/soong/build.ninja, out/soong/Android- only changes due to _core addition and
.llndk -> .vendor
Test: attempt to compile with BOARD_VNDK_VERSION:=current
Change-Id: Idef28764043bf6c33dc0d2e7e2026c38867ff769
2017-04-06 21:43:22 +02:00
|
|
|
exportIncludeDirs := library.flagExporter.exportedIncludes(ctx)
|
2016-11-03 23:53:42 +01:00
|
|
|
if len(exportIncludeDirs) > 0 {
|
2017-04-26 23:55:27 +02:00
|
|
|
f := includeDirsToFlags(exportIncludeDirs)
|
|
|
|
flags.GlobalFlags = append(flags.GlobalFlags, f)
|
|
|
|
flags.YasmFlags = append(flags.YasmFlags, f)
|
2016-11-03 23:53:42 +01:00
|
|
|
}
|
|
|
|
|
Add support for versioned stubs.
A cc_library or cc_library_shared can be configured to have stubs
variants of the lib.
cc_library_shared {
name: "libfoo",
srcs: ["foo.cpp"],
stubs: {
symbol_file: "foo.map.txt",
versions: ["1", "2", "3"],
},
}
then, stubs variants of libfoo for version 1, 2, and 3 are created
from foo.map.txt. Each version has the symbols from the map file where
each symbol is annotated with the version that the symbol was introduced
via the 'introduced=<ver>' syntax. The versions don't need to be in sync
with the platform versions (e.g., P for 28). The versions are local to
the library.
For another library or executable to use the versioned stubs lib, use
the new 'name#ver' syntax to specify the version:
cc_binary {
name: "test",
....
shared_libs: ["libFoo#2"],
}
Internally, a new mutator 'version' is applied to all cc.Module objects.
By default, a variant named 'impl' is created for the non-stub version.
If the versions property is set, additional variations are created per a
version with the mutable property BuildStubs set as true, which lets the
compiler and the linker to build a stubs lib from the symbol file
instead from the source files.
This feature will be used to enforce stable interfaces among APEXs. When
a lib foo in an APEX is depending on a lib bar in another APEX, then bar
should have stable interface (in C lang) and foo should be depending on
one of the stubs libs of bar. Only libraries in the same APEX as foo can
link against non-stub version of it.
Bug: 112672359
Test: m (cc_test added)
Change-Id: I2488be0b9d7b7b8d7761234dc1c9c0e3add8601c
2018-10-15 15:25:07 +02:00
|
|
|
flags = library.baseCompiler.compilerFlags(ctx, flags, deps)
|
|
|
|
if library.buildStubs() {
|
2018-12-13 10:37:29 +01:00
|
|
|
// Remove -include <file> when compiling stubs. Otherwise, the force included
|
|
|
|
// headers might cause conflicting types error with the symbols in the
|
|
|
|
// generated stubs source code. e.g.
|
|
|
|
// double acos(double); // in header
|
|
|
|
// void acos() {} // in the generated source code
|
|
|
|
removeInclude := func(flags []string) []string {
|
|
|
|
ret := flags[:0]
|
|
|
|
for _, f := range flags {
|
|
|
|
if strings.HasPrefix(f, "-include ") {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
ret = append(ret, f)
|
|
|
|
}
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
flags.GlobalFlags = removeInclude(flags.GlobalFlags)
|
|
|
|
flags.CFlags = removeInclude(flags.CFlags)
|
|
|
|
|
Add support for versioned stubs.
A cc_library or cc_library_shared can be configured to have stubs
variants of the lib.
cc_library_shared {
name: "libfoo",
srcs: ["foo.cpp"],
stubs: {
symbol_file: "foo.map.txt",
versions: ["1", "2", "3"],
},
}
then, stubs variants of libfoo for version 1, 2, and 3 are created
from foo.map.txt. Each version has the symbols from the map file where
each symbol is annotated with the version that the symbol was introduced
via the 'introduced=<ver>' syntax. The versions don't need to be in sync
with the platform versions (e.g., P for 28). The versions are local to
the library.
For another library or executable to use the versioned stubs lib, use
the new 'name#ver' syntax to specify the version:
cc_binary {
name: "test",
....
shared_libs: ["libFoo#2"],
}
Internally, a new mutator 'version' is applied to all cc.Module objects.
By default, a variant named 'impl' is created for the non-stub version.
If the versions property is set, additional variations are created per a
version with the mutable property BuildStubs set as true, which lets the
compiler and the linker to build a stubs lib from the symbol file
instead from the source files.
This feature will be used to enforce stable interfaces among APEXs. When
a lib foo in an APEX is depending on a lib bar in another APEX, then bar
should have stable interface (in C lang) and foo should be depending on
one of the stubs libs of bar. Only libraries in the same APEX as foo can
link against non-stub version of it.
Bug: 112672359
Test: m (cc_test added)
Change-Id: I2488be0b9d7b7b8d7761234dc1c9c0e3add8601c
2018-10-15 15:25:07 +02:00
|
|
|
flags = addStubLibraryCompilerFlags(flags)
|
|
|
|
}
|
|
|
|
return flags
|
2016-11-03 23:53:42 +01:00
|
|
|
}
|
|
|
|
|
2017-04-20 15:53:59 +02:00
|
|
|
func extractExportIncludesFromFlags(flags []string) []string {
|
|
|
|
// This method is used in the generation of rules which produce
|
|
|
|
// abi-dumps for source files. Exported headers are needed to infer the
|
|
|
|
// abi exported by a library and filter out the rest of the abi dumped
|
|
|
|
// from a source. We extract the include flags exported by a library.
|
|
|
|
// This includes the flags exported which are re-exported from static
|
|
|
|
// library dependencies, exported header library dependencies and
|
2017-08-24 01:08:29 +02:00
|
|
|
// generated header dependencies. -isystem headers are not included
|
2017-04-20 15:53:59 +02:00
|
|
|
// since for bionic libraries, abi-filtering is taken care of by version
|
|
|
|
// scripts.
|
|
|
|
var exportedIncludes []string
|
|
|
|
for _, flag := range flags {
|
|
|
|
if strings.HasPrefix(flag, "-I") {
|
|
|
|
exportedIncludes = append(exportedIncludes, flag)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return exportedIncludes
|
|
|
|
}
|
|
|
|
|
2016-09-27 02:33:01 +02:00
|
|
|
func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects {
|
Add support for versioned stubs.
A cc_library or cc_library_shared can be configured to have stubs
variants of the lib.
cc_library_shared {
name: "libfoo",
srcs: ["foo.cpp"],
stubs: {
symbol_file: "foo.map.txt",
versions: ["1", "2", "3"],
},
}
then, stubs variants of libfoo for version 1, 2, and 3 are created
from foo.map.txt. Each version has the symbols from the map file where
each symbol is annotated with the version that the symbol was introduced
via the 'introduced=<ver>' syntax. The versions don't need to be in sync
with the platform versions (e.g., P for 28). The versions are local to
the library.
For another library or executable to use the versioned stubs lib, use
the new 'name#ver' syntax to specify the version:
cc_binary {
name: "test",
....
shared_libs: ["libFoo#2"],
}
Internally, a new mutator 'version' is applied to all cc.Module objects.
By default, a variant named 'impl' is created for the non-stub version.
If the versions property is set, additional variations are created per a
version with the mutable property BuildStubs set as true, which lets the
compiler and the linker to build a stubs lib from the symbol file
instead from the source files.
This feature will be used to enforce stable interfaces among APEXs. When
a lib foo in an APEX is depending on a lib bar in another APEX, then bar
should have stable interface (in C lang) and foo should be depending on
one of the stubs libs of bar. Only libraries in the same APEX as foo can
link against non-stub version of it.
Bug: 112672359
Test: m (cc_test added)
Change-Id: I2488be0b9d7b7b8d7761234dc1c9c0e3add8601c
2018-10-15 15:25:07 +02:00
|
|
|
if library.buildStubs() {
|
2018-12-07 08:25:39 +01:00
|
|
|
objs, versionScript := compileStubLibrary(ctx, flags, String(library.Properties.Stubs.Symbol_file), library.MutatedProperties.StubsVersion, "--apex")
|
Add support for versioned stubs.
A cc_library or cc_library_shared can be configured to have stubs
variants of the lib.
cc_library_shared {
name: "libfoo",
srcs: ["foo.cpp"],
stubs: {
symbol_file: "foo.map.txt",
versions: ["1", "2", "3"],
},
}
then, stubs variants of libfoo for version 1, 2, and 3 are created
from foo.map.txt. Each version has the symbols from the map file where
each symbol is annotated with the version that the symbol was introduced
via the 'introduced=<ver>' syntax. The versions don't need to be in sync
with the platform versions (e.g., P for 28). The versions are local to
the library.
For another library or executable to use the versioned stubs lib, use
the new 'name#ver' syntax to specify the version:
cc_binary {
name: "test",
....
shared_libs: ["libFoo#2"],
}
Internally, a new mutator 'version' is applied to all cc.Module objects.
By default, a variant named 'impl' is created for the non-stub version.
If the versions property is set, additional variations are created per a
version with the mutable property BuildStubs set as true, which lets the
compiler and the linker to build a stubs lib from the symbol file
instead from the source files.
This feature will be used to enforce stable interfaces among APEXs. When
a lib foo in an APEX is depending on a lib bar in another APEX, then bar
should have stable interface (in C lang) and foo should be depending on
one of the stubs libs of bar. Only libraries in the same APEX as foo can
link against non-stub version of it.
Bug: 112672359
Test: m (cc_test added)
Change-Id: I2488be0b9d7b7b8d7761234dc1c9c0e3add8601c
2018-10-15 15:25:07 +02:00
|
|
|
library.versionScriptPath = versionScript
|
|
|
|
return objs
|
|
|
|
}
|
|
|
|
|
2016-12-13 21:50:57 +01:00
|
|
|
if !library.buildShared() && !library.buildStatic() {
|
|
|
|
if len(library.baseCompiler.Properties.Srcs) > 0 {
|
|
|
|
ctx.PropertyErrorf("srcs", "cc_library_headers must not have any srcs")
|
|
|
|
}
|
|
|
|
if len(library.Properties.Static.Srcs) > 0 {
|
|
|
|
ctx.PropertyErrorf("static.srcs", "cc_library_headers must not have any srcs")
|
|
|
|
}
|
|
|
|
if len(library.Properties.Shared.Srcs) > 0 {
|
|
|
|
ctx.PropertyErrorf("shared.srcs", "cc_library_headers must not have any srcs")
|
|
|
|
}
|
|
|
|
return Objects{}
|
|
|
|
}
|
2018-07-10 09:01:19 +02:00
|
|
|
if ctx.shouldCreateVndkSourceAbiDump() || library.sabi.Properties.CreateSAbiDumps {
|
2017-09-06 22:10:03 +02:00
|
|
|
exportIncludeDirs := library.flagExporter.exportedIncludes(ctx)
|
2017-02-08 22:45:53 +01:00
|
|
|
var SourceAbiFlags []string
|
|
|
|
for _, dir := range exportIncludeDirs.Strings() {
|
2017-04-20 15:53:59 +02:00
|
|
|
SourceAbiFlags = append(SourceAbiFlags, "-I"+dir)
|
|
|
|
}
|
|
|
|
for _, reexportedInclude := range extractExportIncludesFromFlags(library.sabi.Properties.ReexportedIncludeFlags) {
|
|
|
|
SourceAbiFlags = append(SourceAbiFlags, reexportedInclude)
|
2017-02-08 22:45:53 +01:00
|
|
|
}
|
|
|
|
flags.SAbiFlags = SourceAbiFlags
|
|
|
|
total_length := len(library.baseCompiler.Properties.Srcs) + len(deps.GeneratedSources) + len(library.Properties.Shared.Srcs) +
|
|
|
|
len(library.Properties.Static.Srcs)
|
|
|
|
if total_length > 0 {
|
|
|
|
flags.SAbiDump = true
|
|
|
|
}
|
|
|
|
}
|
2016-09-27 02:33:01 +02:00
|
|
|
objs := library.baseCompiler.compile(ctx, flags, deps)
|
|
|
|
library.reuseObjects = objs
|
2016-10-26 19:03:47 +02:00
|
|
|
buildFlags := flagsToBuilderFlags(flags)
|
2016-07-29 21:48:20 +02:00
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
if library.static() {
|
2018-12-05 16:28:14 +01:00
|
|
|
srcs := ctx.ExpandSources(library.Properties.Static.Srcs, nil)
|
2016-09-27 02:33:01 +02:00
|
|
|
objs = objs.Append(compileObjs(ctx, buildFlags, android.DeviceStaticLibrary,
|
2018-01-23 19:49:04 +01:00
|
|
|
srcs, library.baseCompiler.pathDeps, library.baseCompiler.cFlagsDeps))
|
2017-02-15 00:28:44 +01:00
|
|
|
} else if library.shared() {
|
2018-12-05 16:28:14 +01:00
|
|
|
srcs := ctx.ExpandSources(library.Properties.Shared.Srcs, nil)
|
2016-09-27 02:33:01 +02:00
|
|
|
objs = objs.Append(compileObjs(ctx, buildFlags, android.DeviceSharedLibrary,
|
2018-01-23 19:49:04 +01:00
|
|
|
srcs, library.baseCompiler.pathDeps, library.baseCompiler.cFlagsDeps))
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
2016-09-27 02:33:01 +02:00
|
|
|
return objs
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type libraryInterface interface {
|
|
|
|
getWholeStaticMissingDeps() []string
|
|
|
|
static() bool
|
2016-09-27 02:33:01 +02:00
|
|
|
objs() Objects
|
2017-05-04 01:24:55 +02:00
|
|
|
reuseObjs() (Objects, []string, android.Paths)
|
2016-10-01 02:10:16 +02:00
|
|
|
toc() android.OptionalPath
|
2016-07-29 21:48:20 +02:00
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
// Returns true if the build options for the module have selected a static or shared build
|
|
|
|
buildStatic() bool
|
|
|
|
buildShared() bool
|
|
|
|
|
|
|
|
// Sets whether a specific variant is static or shared
|
2017-02-15 00:28:44 +01:00
|
|
|
setStatic()
|
|
|
|
setShared()
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
func (library *libraryDecorator) getLibName(ctx ModuleContext) string {
|
2016-07-29 21:48:20 +02:00
|
|
|
name := library.libName
|
|
|
|
if name == "" {
|
2018-11-07 13:43:34 +01:00
|
|
|
name = String(library.Properties.Stem)
|
|
|
|
if name == "" {
|
|
|
|
name = ctx.baseModuleName()
|
|
|
|
}
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
Support VNDK extensions
This commit adds `extends: "name"` property and provides basic support
to VNDK extensions. This is the simplest example:
```
cc_library {
name: "libvndk",
vendor_available: true,
vndk {
enabled: true,
},
}
cc_library {
name: "libvndk_ext",
vendor: true,
vndk: {
enabled: true,
extends: "libvndk",
},
}
```
A vndk extension library must extend an existing vndk library which has
`vendor_available: true`. These two libraries must have the same
`support_system_process` property.
VNDK-ext libraries are installed to `/vendor/lib[64]/vndk` and
VNDK-SP-ext libraries are installed to `/vendor/lib[64]/vndk-sp` by
default.
If there is a matching abi-dumps in `prebuilts/abi-dumps`,
`header-abi-diff` will be invoked to check for ABI breakages.
Bug: 38340960
Test: lunch aosp_walleye-userdebug && make -j8 # runs unit tests
Test: lunch aosp_arm-userdebug && make -j8 # build a target w/o VNDK
Test: Create a lsdump for a vndk lib, add an exported API to vndk lib,
and build fails as expected.
Test: Create a lsdump for a vndk lib, create an vndk extension lib with
extra API, and build succeeds as expected.
Test: Create libutils_ext, add an extra function to libutils_ext, and
call it from a HIDL service.
Change-Id: Iba90e08848ee99814405457f047321e6b52b2df0
2017-10-31 11:04:35 +01:00
|
|
|
if ctx.isVndkExt() {
|
|
|
|
name = ctx.getVndkExtendsModuleName()
|
|
|
|
}
|
|
|
|
|
2016-07-29 21:48:20 +02:00
|
|
|
if ctx.Host() && Bool(library.Properties.Unique_host_soname) {
|
|
|
|
if !strings.HasSuffix(name, "-host") {
|
|
|
|
name = name + "-host"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-15 00:28:44 +01:00
|
|
|
return name + library.MutatedProperties.VariantName
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
2018-11-02 10:23:15 +01:00
|
|
|
var versioningMacroNamesListMutex sync.Mutex
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
func (library *libraryDecorator) linkerInit(ctx BaseModuleContext) {
|
|
|
|
location := InstallInSystem
|
2018-07-26 23:00:24 +02:00
|
|
|
if library.baseLinker.sanitize.inSanitizerDir() {
|
2017-03-30 07:00:18 +02:00
|
|
|
location = InstallInSanitizerDir
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
2016-07-30 02:28:03 +02:00
|
|
|
library.baseInstaller.location = location
|
|
|
|
library.baseLinker.linkerInit(ctx)
|
Add support for versioned stubs.
A cc_library or cc_library_shared can be configured to have stubs
variants of the lib.
cc_library_shared {
name: "libfoo",
srcs: ["foo.cpp"],
stubs: {
symbol_file: "foo.map.txt",
versions: ["1", "2", "3"],
},
}
then, stubs variants of libfoo for version 1, 2, and 3 are created
from foo.map.txt. Each version has the symbols from the map file where
each symbol is annotated with the version that the symbol was introduced
via the 'introduced=<ver>' syntax. The versions don't need to be in sync
with the platform versions (e.g., P for 28). The versions are local to
the library.
For another library or executable to use the versioned stubs lib, use
the new 'name#ver' syntax to specify the version:
cc_binary {
name: "test",
....
shared_libs: ["libFoo#2"],
}
Internally, a new mutator 'version' is applied to all cc.Module objects.
By default, a variant named 'impl' is created for the non-stub version.
If the versions property is set, additional variations are created per a
version with the mutable property BuildStubs set as true, which lets the
compiler and the linker to build a stubs lib from the symbol file
instead from the source files.
This feature will be used to enforce stable interfaces among APEXs. When
a lib foo in an APEX is depending on a lib bar in another APEX, then bar
should have stable interface (in C lang) and foo should be depending on
one of the stubs libs of bar. Only libraries in the same APEX as foo can
link against non-stub version of it.
Bug: 112672359
Test: m (cc_test added)
Change-Id: I2488be0b9d7b7b8d7761234dc1c9c0e3add8601c
2018-10-15 15:25:07 +02:00
|
|
|
// Let baseLinker know whether this variant is for stubs or not, so that
|
|
|
|
// it can omit things that are not required for linking stubs.
|
|
|
|
library.baseLinker.dynamicProperties.BuildStubs = library.buildStubs()
|
2018-11-02 10:23:15 +01:00
|
|
|
|
|
|
|
if library.buildStubs() {
|
|
|
|
macroNames := versioningMacroNamesList(ctx.Config())
|
|
|
|
myName := versioningMacroName(ctx.ModuleName())
|
|
|
|
versioningMacroNamesListMutex.Lock()
|
|
|
|
defer versioningMacroNamesListMutex.Unlock()
|
|
|
|
if (*macroNames)[myName] == "" {
|
|
|
|
(*macroNames)[myName] = ctx.ModuleName()
|
|
|
|
} else if (*macroNames)[myName] != ctx.ModuleName() {
|
|
|
|
ctx.ModuleErrorf("Macro name %q for versioning conflicts with macro name from module %q ", myName, (*macroNames)[myName])
|
|
|
|
}
|
|
|
|
}
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
2018-12-05 16:28:14 +01:00
|
|
|
func (library *libraryDecorator) compilerDeps(ctx DepsContext, deps Deps) Deps {
|
|
|
|
deps = library.baseCompiler.compilerDeps(ctx, deps)
|
|
|
|
|
|
|
|
if library.static() {
|
|
|
|
android.ExtractSourcesDeps(ctx, library.Properties.Static.Srcs)
|
|
|
|
} else if library.shared() {
|
|
|
|
android.ExtractSourcesDeps(ctx, library.Properties.Shared.Srcs)
|
|
|
|
}
|
|
|
|
|
|
|
|
return deps
|
|
|
|
}
|
|
|
|
|
2016-12-14 02:06:13 +01:00
|
|
|
func (library *libraryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
|
2018-12-04 00:25:46 +01:00
|
|
|
if library.static() {
|
|
|
|
if library.Properties.Static.System_shared_libs != nil {
|
|
|
|
library.baseLinker.Properties.System_shared_libs = library.Properties.Static.System_shared_libs
|
|
|
|
}
|
|
|
|
} else if library.shared() {
|
|
|
|
if library.Properties.Shared.System_shared_libs != nil {
|
|
|
|
library.baseLinker.Properties.System_shared_libs = library.Properties.Shared.System_shared_libs
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-01 22:20:05 +02:00
|
|
|
deps = library.baseLinker.linkerDeps(ctx, deps)
|
2016-07-30 02:28:03 +02:00
|
|
|
|
2016-07-29 21:48:20 +02:00
|
|
|
if library.static() {
|
2016-07-30 02:28:03 +02:00
|
|
|
deps.WholeStaticLibs = append(deps.WholeStaticLibs,
|
|
|
|
library.Properties.Static.Whole_static_libs...)
|
2016-07-29 21:48:20 +02:00
|
|
|
deps.StaticLibs = append(deps.StaticLibs, library.Properties.Static.Static_libs...)
|
|
|
|
deps.SharedLibs = append(deps.SharedLibs, library.Properties.Static.Shared_libs...)
|
2019-01-22 23:41:08 +01:00
|
|
|
|
|
|
|
deps.ReexportSharedLibHeaders = append(deps.ReexportSharedLibHeaders, library.Properties.Static.Export_shared_lib_headers...)
|
|
|
|
deps.ReexportStaticLibHeaders = append(deps.ReexportStaticLibHeaders, library.Properties.Static.Export_static_lib_headers...)
|
2017-02-15 00:28:44 +01:00
|
|
|
} else if library.shared() {
|
2016-11-17 10:02:25 +01:00
|
|
|
if ctx.toolchain().Bionic() && !Bool(library.baseLinker.Properties.Nocrt) {
|
2017-09-28 02:01:44 +02:00
|
|
|
if !ctx.useSdk() {
|
2016-07-29 21:48:20 +02:00
|
|
|
deps.CrtBegin = "crtbegin_so"
|
|
|
|
deps.CrtEnd = "crtend_so"
|
|
|
|
} else {
|
2016-11-09 00:06:22 +01:00
|
|
|
// TODO(danalbert): Add generation of crt objects.
|
|
|
|
// For `sdk_version: "current"`, we don't actually have a
|
|
|
|
// freshly generated set of CRT objects. Use the last stable
|
|
|
|
// version.
|
|
|
|
version := ctx.sdkVersion()
|
|
|
|
if version == "current" {
|
2017-05-09 19:21:52 +02:00
|
|
|
version = getCurrentNdkPrebuiltVersion(ctx)
|
2016-11-09 00:06:22 +01:00
|
|
|
}
|
|
|
|
deps.CrtBegin = "ndk_crtbegin_so." + version
|
|
|
|
deps.CrtEnd = "ndk_crtend_so." + version
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
deps.WholeStaticLibs = append(deps.WholeStaticLibs, library.Properties.Shared.Whole_static_libs...)
|
|
|
|
deps.StaticLibs = append(deps.StaticLibs, library.Properties.Shared.Static_libs...)
|
|
|
|
deps.SharedLibs = append(deps.SharedLibs, library.Properties.Shared.Shared_libs...)
|
2019-01-22 23:41:08 +01:00
|
|
|
|
|
|
|
deps.ReexportSharedLibHeaders = append(deps.ReexportSharedLibHeaders, library.Properties.Shared.Export_shared_lib_headers...)
|
|
|
|
deps.ReexportStaticLibHeaders = append(deps.ReexportStaticLibHeaders, library.Properties.Shared.Export_static_lib_headers...)
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
2017-10-13 02:17:01 +02:00
|
|
|
if ctx.useVndk() {
|
|
|
|
deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, library.baseLinker.Properties.Target.Vendor.Exclude_static_libs)
|
|
|
|
deps.SharedLibs = removeListFromList(deps.SharedLibs, library.baseLinker.Properties.Target.Vendor.Exclude_shared_libs)
|
|
|
|
deps.StaticLibs = removeListFromList(deps.StaticLibs, library.baseLinker.Properties.Target.Vendor.Exclude_static_libs)
|
|
|
|
}
|
2018-01-31 16:54:12 +01:00
|
|
|
if ctx.inRecovery() {
|
|
|
|
deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, library.baseLinker.Properties.Target.Recovery.Exclude_static_libs)
|
|
|
|
deps.SharedLibs = removeListFromList(deps.SharedLibs, library.baseLinker.Properties.Target.Recovery.Exclude_shared_libs)
|
|
|
|
deps.StaticLibs = removeListFromList(deps.StaticLibs, library.baseLinker.Properties.Target.Recovery.Exclude_static_libs)
|
|
|
|
}
|
2018-02-06 23:40:13 +01:00
|
|
|
|
|
|
|
android.ExtractSourceDeps(ctx, library.Properties.Unexported_symbols_list)
|
|
|
|
android.ExtractSourceDeps(ctx, library.Properties.Force_symbols_not_weak_list)
|
|
|
|
android.ExtractSourceDeps(ctx, library.Properties.Force_symbols_weak_list)
|
|
|
|
|
2016-07-29 21:48:20 +02:00
|
|
|
return deps
|
|
|
|
}
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
func (library *libraryDecorator) linkStatic(ctx ModuleContext,
|
2016-09-27 02:33:01 +02:00
|
|
|
flags Flags, deps PathDeps, objs Objects) android.Path {
|
2016-07-29 21:48:20 +02:00
|
|
|
|
2016-09-27 02:33:01 +02:00
|
|
|
library.objects = deps.WholeStaticLibObjs.Copy()
|
|
|
|
library.objects = library.objects.Append(objs)
|
2016-07-29 21:48:20 +02:00
|
|
|
|
2018-02-15 23:12:26 +01:00
|
|
|
fileName := ctx.ModuleName() + library.MutatedProperties.VariantName + staticLibraryExtension
|
|
|
|
outputFile := android.PathForModuleOut(ctx, fileName)
|
2017-02-10 01:16:31 +01:00
|
|
|
builderFlags := flagsToBuilderFlags(flags)
|
2016-07-29 21:48:20 +02:00
|
|
|
|
2018-11-19 18:33:29 +01:00
|
|
|
if Bool(library.baseLinker.Properties.Use_version_lib) {
|
|
|
|
if ctx.Host() {
|
|
|
|
versionedOutputFile := outputFile
|
|
|
|
outputFile = android.PathForModuleOut(ctx, "unversioned", fileName)
|
|
|
|
library.injectVersionSymbol(ctx, outputFile, versionedOutputFile)
|
|
|
|
} else {
|
|
|
|
versionedOutputFile := android.PathForModuleOut(ctx, "versioned", fileName)
|
|
|
|
library.distFile = android.OptionalPathForPath(versionedOutputFile)
|
|
|
|
library.injectVersionSymbol(ctx, outputFile, versionedOutputFile)
|
|
|
|
}
|
2018-02-15 23:12:26 +01:00
|
|
|
}
|
|
|
|
|
2017-02-10 01:16:31 +01:00
|
|
|
TransformObjToStaticLib(ctx, library.objects.objFiles, builderFlags, outputFile, objs.tidyFiles)
|
|
|
|
|
|
|
|
library.coverageOutputFile = TransformCoverageFilesToLib(ctx, library.objects, builderFlags,
|
2017-02-15 00:28:44 +01:00
|
|
|
ctx.ModuleName()+library.MutatedProperties.VariantName)
|
2016-07-29 21:48:20 +02:00
|
|
|
|
|
|
|
library.wholeStaticMissingDeps = ctx.GetMissingDependencies()
|
|
|
|
|
|
|
|
ctx.CheckbuildFile(outputFile)
|
|
|
|
|
|
|
|
return outputFile
|
|
|
|
}
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
func (library *libraryDecorator) linkShared(ctx ModuleContext,
|
2016-09-27 02:33:01 +02:00
|
|
|
flags Flags, deps PathDeps, objs Objects) android.Path {
|
2016-07-29 21:48:20 +02:00
|
|
|
|
|
|
|
var linkerDeps android.Paths
|
2017-09-01 08:38:27 +02:00
|
|
|
linkerDeps = append(linkerDeps, flags.LdFlagsDeps...)
|
2016-07-29 21:48:20 +02:00
|
|
|
|
2018-02-06 23:40:13 +01:00
|
|
|
unexportedSymbols := ctx.ExpandOptionalSource(library.Properties.Unexported_symbols_list, "unexported_symbols_list")
|
|
|
|
forceNotWeakSymbols := ctx.ExpandOptionalSource(library.Properties.Force_symbols_not_weak_list, "force_symbols_not_weak_list")
|
|
|
|
forceWeakSymbols := ctx.ExpandOptionalSource(library.Properties.Force_symbols_weak_list, "force_symbols_weak_list")
|
2016-07-29 21:48:20 +02:00
|
|
|
if !ctx.Darwin() {
|
|
|
|
if unexportedSymbols.Valid() {
|
|
|
|
ctx.PropertyErrorf("unexported_symbols_list", "Only supported on Darwin")
|
|
|
|
}
|
|
|
|
if forceNotWeakSymbols.Valid() {
|
|
|
|
ctx.PropertyErrorf("force_symbols_not_weak_list", "Only supported on Darwin")
|
|
|
|
}
|
|
|
|
if forceWeakSymbols.Valid() {
|
|
|
|
ctx.PropertyErrorf("force_symbols_weak_list", "Only supported on Darwin")
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if unexportedSymbols.Valid() {
|
|
|
|
flags.LdFlags = append(flags.LdFlags, "-Wl,-unexported_symbols_list,"+unexportedSymbols.String())
|
|
|
|
linkerDeps = append(linkerDeps, unexportedSymbols.Path())
|
|
|
|
}
|
|
|
|
if forceNotWeakSymbols.Valid() {
|
|
|
|
flags.LdFlags = append(flags.LdFlags, "-Wl,-force_symbols_not_weak_list,"+forceNotWeakSymbols.String())
|
|
|
|
linkerDeps = append(linkerDeps, forceNotWeakSymbols.Path())
|
|
|
|
}
|
|
|
|
if forceWeakSymbols.Valid() {
|
|
|
|
flags.LdFlags = append(flags.LdFlags, "-Wl,-force_symbols_weak_list,"+forceWeakSymbols.String())
|
|
|
|
linkerDeps = append(linkerDeps, forceWeakSymbols.Path())
|
|
|
|
}
|
|
|
|
}
|
2019-01-12 05:39:10 +01:00
|
|
|
if library.buildStubs() {
|
|
|
|
linkerScriptFlags := "-Wl,--version-script," + library.versionScriptPath.String()
|
|
|
|
flags.LdFlags = append(flags.LdFlags, linkerScriptFlags)
|
|
|
|
linkerDeps = append(linkerDeps, library.versionScriptPath)
|
|
|
|
}
|
2016-07-29 21:48:20 +02:00
|
|
|
|
|
|
|
fileName := library.getLibName(ctx) + flags.Toolchain.ShlibSuffix()
|
|
|
|
outputFile := android.PathForModuleOut(ctx, fileName)
|
|
|
|
ret := outputFile
|
|
|
|
|
|
|
|
builderFlags := flagsToBuilderFlags(flags)
|
|
|
|
|
2018-09-11 01:50:05 +02:00
|
|
|
// Optimize out relinking against shared libraries whose interface hasn't changed by
|
|
|
|
// depending on a table of contents file instead of the library itself.
|
|
|
|
tocPath := outputFile.RelPathString()
|
|
|
|
tocPath = pathtools.ReplaceExtension(tocPath, flags.Toolchain.ShlibSuffix()[1:]+".toc")
|
|
|
|
tocFile := android.PathForOutput(ctx, tocPath)
|
|
|
|
library.tocFile = android.OptionalPathForPath(tocFile)
|
|
|
|
TransformSharedObjectToToc(ctx, outputFile, tocFile, builderFlags)
|
2016-09-15 00:04:48 +02:00
|
|
|
|
2016-07-29 21:48:20 +02:00
|
|
|
if library.stripper.needsStrip(ctx) {
|
2018-06-04 19:37:43 +02:00
|
|
|
// b/80093681, GNU strip/objcopy bug.
|
|
|
|
// Use llvm-{strip,objcopy} when clang lld is used.
|
2018-10-08 05:54:34 +02:00
|
|
|
builderFlags.stripUseLlvmStrip = library.baseLinker.useClangLld(ctx)
|
2016-07-29 21:48:20 +02:00
|
|
|
strippedOutputFile := outputFile
|
|
|
|
outputFile = android.PathForModuleOut(ctx, "unstripped", fileName)
|
|
|
|
library.stripper.strip(ctx, outputFile, strippedOutputFile, builderFlags)
|
|
|
|
}
|
|
|
|
|
2018-09-05 01:28:17 +02:00
|
|
|
library.unstrippedOutputFile = outputFile
|
|
|
|
|
2018-11-19 18:33:29 +01:00
|
|
|
if Bool(library.baseLinker.Properties.Use_version_lib) {
|
|
|
|
if ctx.Host() {
|
|
|
|
versionedOutputFile := outputFile
|
|
|
|
outputFile = android.PathForModuleOut(ctx, "unversioned", fileName)
|
|
|
|
library.injectVersionSymbol(ctx, outputFile, versionedOutputFile)
|
|
|
|
} else {
|
|
|
|
versionedOutputFile := android.PathForModuleOut(ctx, "versioned", fileName)
|
|
|
|
library.distFile = android.OptionalPathForPath(versionedOutputFile)
|
|
|
|
|
|
|
|
if library.stripper.needsStrip(ctx) {
|
|
|
|
out := android.PathForModuleOut(ctx, "versioned-stripped", fileName)
|
|
|
|
library.distFile = android.OptionalPathForPath(out)
|
|
|
|
library.stripper.strip(ctx, versionedOutputFile, out, builderFlags)
|
|
|
|
}
|
|
|
|
|
|
|
|
library.injectVersionSymbol(ctx, outputFile, versionedOutputFile)
|
|
|
|
}
|
2018-02-15 23:12:26 +01:00
|
|
|
}
|
|
|
|
|
2019-01-18 06:37:08 +01:00
|
|
|
sharedLibs := deps.EarlySharedLibs
|
|
|
|
sharedLibs = append(sharedLibs, deps.SharedLibs...)
|
2016-07-29 21:48:20 +02:00
|
|
|
sharedLibs = append(sharedLibs, deps.LateSharedLibs...)
|
|
|
|
|
2019-01-18 06:37:08 +01:00
|
|
|
linkerDeps = append(linkerDeps, deps.EarlySharedLibsDeps...)
|
2016-10-01 02:10:16 +02:00
|
|
|
linkerDeps = append(linkerDeps, deps.SharedLibsDeps...)
|
|
|
|
linkerDeps = append(linkerDeps, deps.LateSharedLibsDeps...)
|
2016-09-27 00:45:04 +02:00
|
|
|
linkerDeps = append(linkerDeps, objs.tidyFiles...)
|
2016-10-01 02:10:16 +02:00
|
|
|
|
2016-09-27 02:33:01 +02:00
|
|
|
TransformObjToDynamicBinary(ctx, objs.objFiles, sharedLibs,
|
2016-07-29 21:48:20 +02:00
|
|
|
deps.StaticLibs, deps.LateStaticLibs, deps.WholeStaticLibs,
|
|
|
|
linkerDeps, deps.CrtBegin, deps.CrtEnd, false, builderFlags, outputFile)
|
|
|
|
|
2017-02-10 01:16:31 +01:00
|
|
|
objs.coverageFiles = append(objs.coverageFiles, deps.StaticLibObjs.coverageFiles...)
|
|
|
|
objs.coverageFiles = append(objs.coverageFiles, deps.WholeStaticLibObjs.coverageFiles...)
|
2017-02-08 22:45:53 +01:00
|
|
|
|
|
|
|
objs.sAbiDumpFiles = append(objs.sAbiDumpFiles, deps.StaticLibObjs.sAbiDumpFiles...)
|
|
|
|
objs.sAbiDumpFiles = append(objs.sAbiDumpFiles, deps.WholeStaticLibObjs.sAbiDumpFiles...)
|
|
|
|
|
2017-02-10 01:16:31 +01:00
|
|
|
library.coverageOutputFile = TransformCoverageFilesToLib(ctx, objs, builderFlags, library.getLibName(ctx))
|
2017-06-26 21:52:58 +02:00
|
|
|
library.linkSAbiDumpFiles(ctx, objs, fileName, ret)
|
2017-02-10 01:16:31 +01:00
|
|
|
|
2016-07-29 21:48:20 +02:00
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
2018-07-11 12:10:41 +02:00
|
|
|
func getRefAbiDumpFile(ctx ModuleContext, vndkVersion, fileName string) android.Path {
|
2018-08-01 20:27:02 +02:00
|
|
|
isLlndk := inList(ctx.baseModuleName(), llndkLibraries) || inList(ctx.baseModuleName(), ndkMigratedLibs)
|
2018-07-11 12:10:41 +02:00
|
|
|
|
|
|
|
refAbiDumpTextFile := android.PathForVndkRefAbiDump(ctx, vndkVersion, fileName, isLlndk, false)
|
|
|
|
refAbiDumpGzipFile := android.PathForVndkRefAbiDump(ctx, vndkVersion, fileName, isLlndk, true)
|
|
|
|
|
|
|
|
if refAbiDumpTextFile.Valid() {
|
|
|
|
if refAbiDumpGzipFile.Valid() {
|
|
|
|
ctx.ModuleErrorf(
|
|
|
|
"Two reference ABI dump files are found: %q and %q. Please delete the stale one.",
|
|
|
|
refAbiDumpTextFile, refAbiDumpGzipFile)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return refAbiDumpTextFile.Path()
|
|
|
|
}
|
|
|
|
if refAbiDumpGzipFile.Valid() {
|
|
|
|
return UnzipRefDump(ctx, refAbiDumpGzipFile.Path(), fileName)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2017-06-26 21:52:58 +02:00
|
|
|
func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objects, fileName string, soFile android.Path) {
|
2018-07-10 09:01:19 +02:00
|
|
|
if len(objs.sAbiDumpFiles) > 0 && ctx.shouldCreateVndkSourceAbiDump() {
|
2018-03-21 04:53:48 +01:00
|
|
|
vndkVersion := ctx.DeviceConfig().PlatformVndkVersion()
|
|
|
|
if ver := ctx.DeviceConfig().VndkVersion(); ver != "" && ver != "current" {
|
Support VNDK extensions
This commit adds `extends: "name"` property and provides basic support
to VNDK extensions. This is the simplest example:
```
cc_library {
name: "libvndk",
vendor_available: true,
vndk {
enabled: true,
},
}
cc_library {
name: "libvndk_ext",
vendor: true,
vndk: {
enabled: true,
extends: "libvndk",
},
}
```
A vndk extension library must extend an existing vndk library which has
`vendor_available: true`. These two libraries must have the same
`support_system_process` property.
VNDK-ext libraries are installed to `/vendor/lib[64]/vndk` and
VNDK-SP-ext libraries are installed to `/vendor/lib[64]/vndk-sp` by
default.
If there is a matching abi-dumps in `prebuilts/abi-dumps`,
`header-abi-diff` will be invoked to check for ABI breakages.
Bug: 38340960
Test: lunch aosp_walleye-userdebug && make -j8 # runs unit tests
Test: lunch aosp_arm-userdebug && make -j8 # build a target w/o VNDK
Test: Create a lsdump for a vndk lib, add an exported API to vndk lib,
and build fails as expected.
Test: Create a lsdump for a vndk lib, create an vndk extension lib with
extra API, and build succeeds as expected.
Test: Create libutils_ext, add an extra function to libutils_ext, and
call it from a HIDL service.
Change-Id: Iba90e08848ee99814405457f047321e6b52b2df0
2017-10-31 11:04:35 +01:00
|
|
|
vndkVersion = ver
|
|
|
|
}
|
|
|
|
|
2017-09-06 22:10:03 +02:00
|
|
|
exportIncludeDirs := library.flagExporter.exportedIncludes(ctx)
|
2017-02-08 22:45:53 +01:00
|
|
|
var SourceAbiFlags []string
|
|
|
|
for _, dir := range exportIncludeDirs.Strings() {
|
2017-04-20 15:53:59 +02:00
|
|
|
SourceAbiFlags = append(SourceAbiFlags, "-I"+dir)
|
|
|
|
}
|
|
|
|
for _, reexportedInclude := range extractExportIncludesFromFlags(library.sabi.Properties.ReexportedIncludeFlags) {
|
|
|
|
SourceAbiFlags = append(SourceAbiFlags, reexportedInclude)
|
2017-02-08 22:45:53 +01:00
|
|
|
}
|
|
|
|
exportedHeaderFlags := strings.Join(SourceAbiFlags, " ")
|
2018-01-17 20:11:42 +01:00
|
|
|
library.sAbiOutputFile = TransformDumpToLinkedDump(ctx, objs.sAbiDumpFiles, soFile, fileName, exportedHeaderFlags)
|
2018-07-10 09:01:19 +02:00
|
|
|
|
2018-07-11 12:10:41 +02:00
|
|
|
refAbiDumpFile := getRefAbiDumpFile(ctx, vndkVersion, fileName)
|
|
|
|
if refAbiDumpFile != nil {
|
Support VNDK extensions
This commit adds `extends: "name"` property and provides basic support
to VNDK extensions. This is the simplest example:
```
cc_library {
name: "libvndk",
vendor_available: true,
vndk {
enabled: true,
},
}
cc_library {
name: "libvndk_ext",
vendor: true,
vndk: {
enabled: true,
extends: "libvndk",
},
}
```
A vndk extension library must extend an existing vndk library which has
`vendor_available: true`. These two libraries must have the same
`support_system_process` property.
VNDK-ext libraries are installed to `/vendor/lib[64]/vndk` and
VNDK-SP-ext libraries are installed to `/vendor/lib[64]/vndk-sp` by
default.
If there is a matching abi-dumps in `prebuilts/abi-dumps`,
`header-abi-diff` will be invoked to check for ABI breakages.
Bug: 38340960
Test: lunch aosp_walleye-userdebug && make -j8 # runs unit tests
Test: lunch aosp_arm-userdebug && make -j8 # build a target w/o VNDK
Test: Create a lsdump for a vndk lib, add an exported API to vndk lib,
and build fails as expected.
Test: Create a lsdump for a vndk lib, create an vndk extension lib with
extra API, and build succeeds as expected.
Test: Create libutils_ext, add an extra function to libutils_ext, and
call it from a HIDL service.
Change-Id: Iba90e08848ee99814405457f047321e6b52b2df0
2017-10-31 11:04:35 +01:00
|
|
|
library.sAbiDiff = SourceAbiDiff(ctx, library.sAbiOutputFile.Path(),
|
2018-07-11 12:10:41 +02:00
|
|
|
refAbiDumpFile, fileName, exportedHeaderFlags, ctx.isVndkExt())
|
2017-02-08 22:45:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
func (library *libraryDecorator) link(ctx ModuleContext,
|
2016-09-27 02:33:01 +02:00
|
|
|
flags Flags, deps PathDeps, objs Objects) android.Path {
|
2016-07-29 21:48:20 +02:00
|
|
|
|
2017-11-16 23:29:11 +01:00
|
|
|
objs = deps.Objs.Copy().Append(objs)
|
2016-07-29 21:48:20 +02:00
|
|
|
var out android.Path
|
2017-02-15 00:28:44 +01:00
|
|
|
if library.static() || library.header() {
|
2016-09-27 02:33:01 +02:00
|
|
|
out = library.linkStatic(ctx, flags, deps, objs)
|
2016-07-29 21:48:20 +02:00
|
|
|
} else {
|
2016-09-27 02:33:01 +02:00
|
|
|
out = library.linkShared(ctx, flags, deps, objs)
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
library.exportIncludes(ctx, "-I")
|
|
|
|
library.reexportFlags(deps.ReexportedFlags)
|
2016-09-29 21:13:36 +02:00
|
|
|
library.reexportDeps(deps.ReexportedFlagsDeps)
|
2016-07-29 21:48:20 +02:00
|
|
|
|
2017-11-07 19:57:05 +01:00
|
|
|
if Bool(library.Properties.Aidl.Export_aidl_headers) {
|
2016-11-03 22:28:51 +01:00
|
|
|
if library.baseCompiler.hasSrcExt(".aidl") {
|
2017-05-03 20:01:58 +02:00
|
|
|
flags := []string{
|
2016-11-03 22:28:51 +01:00
|
|
|
"-I" + android.PathForModuleGen(ctx, "aidl").String(),
|
2017-05-03 20:01:58 +02:00
|
|
|
}
|
|
|
|
library.reexportFlags(flags)
|
|
|
|
library.reuseExportedFlags = append(library.reuseExportedFlags, flags...)
|
2018-01-23 19:49:04 +01:00
|
|
|
library.reexportDeps(library.baseCompiler.pathDeps) // TODO: restrict to aidl deps
|
|
|
|
library.reuseExportedDeps = append(library.reuseExportedDeps, library.baseCompiler.pathDeps...)
|
2016-11-03 22:28:51 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-07 19:57:05 +01:00
|
|
|
if Bool(library.Properties.Proto.Export_proto_headers) {
|
2016-11-03 22:28:51 +01:00
|
|
|
if library.baseCompiler.hasSrcExt(".proto") {
|
2018-02-14 22:58:34 +01:00
|
|
|
includes := []string{}
|
|
|
|
if flags.ProtoRoot {
|
|
|
|
includes = append(includes, "-I"+android.ProtoSubDir(ctx).String())
|
2017-05-03 20:01:58 +02:00
|
|
|
}
|
2018-02-14 22:58:34 +01:00
|
|
|
includes = append(includes, "-I"+android.ProtoDir(ctx).String())
|
|
|
|
library.reexportFlags(includes)
|
|
|
|
library.reuseExportedFlags = append(library.reuseExportedFlags, includes...)
|
2018-01-23 19:49:04 +01:00
|
|
|
library.reexportDeps(library.baseCompiler.pathDeps) // TODO: restrict to proto deps
|
|
|
|
library.reuseExportedDeps = append(library.reuseExportedDeps, library.baseCompiler.pathDeps...)
|
2016-10-21 01:11:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-05 17:55:20 +02:00
|
|
|
if library.baseCompiler.hasSrcExt(".sysprop") {
|
|
|
|
flags := []string{
|
|
|
|
"-I" + android.PathForModuleGen(ctx, "sysprop", "include").String(),
|
|
|
|
}
|
|
|
|
library.reexportFlags(flags)
|
2018-12-19 06:39:29 +01:00
|
|
|
library.reexportDeps(library.baseCompiler.pathDeps)
|
2018-09-05 17:55:20 +02:00
|
|
|
library.reuseExportedFlags = append(library.reuseExportedFlags, flags...)
|
|
|
|
}
|
|
|
|
|
2018-11-02 10:23:15 +01:00
|
|
|
if library.buildStubs() {
|
|
|
|
library.reexportFlags([]string{"-D" + versioningMacroName(ctx.ModuleName()) + "=" + library.stubsVersion()})
|
|
|
|
}
|
|
|
|
|
2016-07-29 21:48:20 +02:00
|
|
|
return out
|
|
|
|
}
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
func (library *libraryDecorator) buildStatic() bool {
|
2018-04-11 01:14:46 +02:00
|
|
|
return library.MutatedProperties.BuildStatic && BoolDefault(library.Properties.Static.Enabled, true)
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
func (library *libraryDecorator) buildShared() bool {
|
2018-04-11 01:14:46 +02:00
|
|
|
return library.MutatedProperties.BuildShared && BoolDefault(library.Properties.Shared.Enabled, true)
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
func (library *libraryDecorator) getWholeStaticMissingDeps() []string {
|
2018-04-30 23:50:01 +02:00
|
|
|
return append([]string(nil), library.wholeStaticMissingDeps...)
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
2016-09-27 02:33:01 +02:00
|
|
|
func (library *libraryDecorator) objs() Objects {
|
|
|
|
return library.objects
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
2017-05-04 01:24:55 +02:00
|
|
|
func (library *libraryDecorator) reuseObjs() (Objects, []string, android.Paths) {
|
|
|
|
return library.reuseObjects, library.reuseExportedFlags, library.reuseExportedDeps
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
2016-10-01 02:10:16 +02:00
|
|
|
func (library *libraryDecorator) toc() android.OptionalPath {
|
|
|
|
return library.tocFile
|
|
|
|
}
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) {
|
2017-04-15 00:42:53 +02:00
|
|
|
if library.shared() {
|
2017-12-07 09:18:15 +01:00
|
|
|
if ctx.Device() && ctx.useVndk() {
|
|
|
|
if ctx.isVndkSp() {
|
|
|
|
library.baseInstaller.subDir = "vndk-sp"
|
|
|
|
} else if ctx.isVndk() {
|
|
|
|
library.baseInstaller.subDir = "vndk"
|
|
|
|
}
|
Support VNDK extensions
This commit adds `extends: "name"` property and provides basic support
to VNDK extensions. This is the simplest example:
```
cc_library {
name: "libvndk",
vendor_available: true,
vndk {
enabled: true,
},
}
cc_library {
name: "libvndk_ext",
vendor: true,
vndk: {
enabled: true,
extends: "libvndk",
},
}
```
A vndk extension library must extend an existing vndk library which has
`vendor_available: true`. These two libraries must have the same
`support_system_process` property.
VNDK-ext libraries are installed to `/vendor/lib[64]/vndk` and
VNDK-SP-ext libraries are installed to `/vendor/lib[64]/vndk-sp` by
default.
If there is a matching abi-dumps in `prebuilts/abi-dumps`,
`header-abi-diff` will be invoked to check for ABI breakages.
Bug: 38340960
Test: lunch aosp_walleye-userdebug && make -j8 # runs unit tests
Test: lunch aosp_arm-userdebug && make -j8 # build a target w/o VNDK
Test: Create a lsdump for a vndk lib, add an exported API to vndk lib,
and build fails as expected.
Test: Create a lsdump for a vndk lib, create an vndk extension lib with
extra API, and build succeeds as expected.
Test: Create libutils_ext, add an extra function to libutils_ext, and
call it from a HIDL service.
Change-Id: Iba90e08848ee99814405457f047321e6b52b2df0
2017-10-31 11:04:35 +01:00
|
|
|
|
|
|
|
// Append a version to vndk or vndk-sp directories on the system partition.
|
|
|
|
if ctx.isVndk() && !ctx.isVndkExt() {
|
|
|
|
vndkVersion := ctx.DeviceConfig().PlatformVndkVersion()
|
|
|
|
if vndkVersion != "current" && vndkVersion != "" {
|
|
|
|
library.baseInstaller.subDir += "-" + vndkVersion
|
|
|
|
}
|
2017-06-23 12:24:43 +02:00
|
|
|
}
|
|
|
|
}
|
2016-07-29 21:48:20 +02:00
|
|
|
library.baseInstaller.install(ctx, file)
|
|
|
|
}
|
2017-10-13 09:29:00 +02:00
|
|
|
|
2017-12-14 00:03:47 +01:00
|
|
|
if Bool(library.Properties.Static_ndk_lib) && library.static() &&
|
2018-01-31 16:54:12 +01:00
|
|
|
!ctx.useVndk() && !ctx.inRecovery() && ctx.Device() &&
|
Add support for versioned stubs.
A cc_library or cc_library_shared can be configured to have stubs
variants of the lib.
cc_library_shared {
name: "libfoo",
srcs: ["foo.cpp"],
stubs: {
symbol_file: "foo.map.txt",
versions: ["1", "2", "3"],
},
}
then, stubs variants of libfoo for version 1, 2, and 3 are created
from foo.map.txt. Each version has the symbols from the map file where
each symbol is annotated with the version that the symbol was introduced
via the 'introduced=<ver>' syntax. The versions don't need to be in sync
with the platform versions (e.g., P for 28). The versions are local to
the library.
For another library or executable to use the versioned stubs lib, use
the new 'name#ver' syntax to specify the version:
cc_binary {
name: "test",
....
shared_libs: ["libFoo#2"],
}
Internally, a new mutator 'version' is applied to all cc.Module objects.
By default, a variant named 'impl' is created for the non-stub version.
If the versions property is set, additional variations are created per a
version with the mutable property BuildStubs set as true, which lets the
compiler and the linker to build a stubs lib from the symbol file
instead from the source files.
This feature will be used to enforce stable interfaces among APEXs. When
a lib foo in an APEX is depending on a lib bar in another APEX, then bar
should have stable interface (in C lang) and foo should be depending on
one of the stubs libs of bar. Only libraries in the same APEX as foo can
link against non-stub version of it.
Bug: 112672359
Test: m (cc_test added)
Change-Id: I2488be0b9d7b7b8d7761234dc1c9c0e3add8601c
2018-10-15 15:25:07 +02:00
|
|
|
library.baseLinker.sanitize.isUnsanitizedVariant() &&
|
|
|
|
!library.buildStubs() {
|
2017-10-13 09:29:00 +02:00
|
|
|
installPath := getNdkSysrootBase(ctx).Join(
|
2018-04-26 01:05:30 +02:00
|
|
|
ctx, "usr/lib", config.NDKTriple(ctx.toolchain()), file.Base())
|
2017-10-13 09:29:00 +02:00
|
|
|
|
|
|
|
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
|
|
|
|
Rule: android.Cp,
|
|
|
|
Description: "install " + installPath.Base(),
|
|
|
|
Output: installPath,
|
|
|
|
Input: file,
|
|
|
|
})
|
|
|
|
|
2017-11-29 02:34:01 +01:00
|
|
|
library.ndkSysrootPath = installPath
|
2017-10-13 09:29:00 +02:00
|
|
|
}
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
func (library *libraryDecorator) static() bool {
|
2017-02-15 00:28:44 +01:00
|
|
|
return library.MutatedProperties.VariantIsStatic
|
|
|
|
}
|
|
|
|
|
|
|
|
func (library *libraryDecorator) shared() bool {
|
|
|
|
return library.MutatedProperties.VariantIsShared
|
|
|
|
}
|
|
|
|
|
|
|
|
func (library *libraryDecorator) header() bool {
|
|
|
|
return !library.static() && !library.shared()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (library *libraryDecorator) setStatic() {
|
|
|
|
library.MutatedProperties.VariantIsStatic = true
|
|
|
|
library.MutatedProperties.VariantIsShared = false
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
2017-02-15 00:28:44 +01:00
|
|
|
func (library *libraryDecorator) setShared() {
|
|
|
|
library.MutatedProperties.VariantIsStatic = false
|
|
|
|
library.MutatedProperties.VariantIsShared = true
|
2016-07-30 02:28:03 +02:00
|
|
|
}
|
2016-07-29 21:48:20 +02:00
|
|
|
|
2016-12-09 23:46:15 +01:00
|
|
|
func (library *libraryDecorator) BuildOnlyStatic() {
|
2017-02-15 00:28:44 +01:00
|
|
|
library.MutatedProperties.BuildShared = false
|
2016-12-09 23:46:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (library *libraryDecorator) BuildOnlyShared() {
|
2017-02-15 00:28:44 +01:00
|
|
|
library.MutatedProperties.BuildStatic = false
|
2016-12-09 23:46:15 +01:00
|
|
|
}
|
|
|
|
|
2016-12-13 21:50:57 +01:00
|
|
|
func (library *libraryDecorator) HeaderOnly() {
|
2017-02-15 00:28:44 +01:00
|
|
|
library.MutatedProperties.BuildShared = false
|
|
|
|
library.MutatedProperties.BuildStatic = false
|
2016-12-13 21:50:57 +01:00
|
|
|
}
|
|
|
|
|
Add support for versioned stubs.
A cc_library or cc_library_shared can be configured to have stubs
variants of the lib.
cc_library_shared {
name: "libfoo",
srcs: ["foo.cpp"],
stubs: {
symbol_file: "foo.map.txt",
versions: ["1", "2", "3"],
},
}
then, stubs variants of libfoo for version 1, 2, and 3 are created
from foo.map.txt. Each version has the symbols from the map file where
each symbol is annotated with the version that the symbol was introduced
via the 'introduced=<ver>' syntax. The versions don't need to be in sync
with the platform versions (e.g., P for 28). The versions are local to
the library.
For another library or executable to use the versioned stubs lib, use
the new 'name#ver' syntax to specify the version:
cc_binary {
name: "test",
....
shared_libs: ["libFoo#2"],
}
Internally, a new mutator 'version' is applied to all cc.Module objects.
By default, a variant named 'impl' is created for the non-stub version.
If the versions property is set, additional variations are created per a
version with the mutable property BuildStubs set as true, which lets the
compiler and the linker to build a stubs lib from the symbol file
instead from the source files.
This feature will be used to enforce stable interfaces among APEXs. When
a lib foo in an APEX is depending on a lib bar in another APEX, then bar
should have stable interface (in C lang) and foo should be depending on
one of the stubs libs of bar. Only libraries in the same APEX as foo can
link against non-stub version of it.
Bug: 112672359
Test: m (cc_test added)
Change-Id: I2488be0b9d7b7b8d7761234dc1c9c0e3add8601c
2018-10-15 15:25:07 +02:00
|
|
|
func (library *libraryDecorator) buildStubs() bool {
|
|
|
|
return library.MutatedProperties.BuildStubs
|
|
|
|
}
|
|
|
|
|
|
|
|
func (library *libraryDecorator) stubsVersion() string {
|
|
|
|
return library.MutatedProperties.StubsVersion
|
|
|
|
}
|
|
|
|
|
2018-11-02 10:23:15 +01:00
|
|
|
func versioningMacroNamesList(config android.Config) *map[string]string {
|
|
|
|
return config.Once("versioningMacroNamesList", func() interface{} {
|
|
|
|
m := make(map[string]string)
|
|
|
|
return &m
|
|
|
|
}).(*map[string]string)
|
|
|
|
}
|
|
|
|
|
|
|
|
// alphanumeric and _ characters are preserved.
|
|
|
|
// other characters are all converted to _
|
|
|
|
var charsNotForMacro = regexp.MustCompile("[^a-zA-Z0-9_]+")
|
|
|
|
|
|
|
|
func versioningMacroName(moduleName string) string {
|
|
|
|
macroName := charsNotForMacro.ReplaceAllString(moduleName, "_")
|
|
|
|
macroName = strings.ToUpper(moduleName)
|
|
|
|
return "__" + macroName + "_API__"
|
|
|
|
}
|
|
|
|
|
2016-12-09 23:46:15 +01:00
|
|
|
func NewLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorator) {
|
2016-07-30 02:28:03 +02:00
|
|
|
module := newModule(hod, android.MultilibBoth)
|
2016-07-29 21:48:20 +02:00
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
library := &libraryDecorator{
|
2017-02-15 00:28:44 +01:00
|
|
|
MutatedProperties: LibraryMutatedProperties{
|
2016-12-09 23:46:15 +01:00
|
|
|
BuildShared: true,
|
|
|
|
BuildStatic: true,
|
2016-07-29 21:48:20 +02:00
|
|
|
},
|
2016-07-30 02:28:03 +02:00
|
|
|
baseCompiler: NewBaseCompiler(),
|
2018-07-26 23:00:24 +02:00
|
|
|
baseLinker: NewBaseLinker(module.sanitize),
|
2016-07-30 02:28:03 +02:00
|
|
|
baseInstaller: NewBaseInstaller("lib", "lib64", InstallInSystem),
|
2017-02-08 22:45:53 +01:00
|
|
|
sabi: module.sabi,
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
module.compiler = library
|
|
|
|
module.linker = library
|
|
|
|
module.installer = library
|
|
|
|
|
|
|
|
return module, library
|
|
|
|
}
|
|
|
|
|
2017-05-03 20:01:58 +02:00
|
|
|
// connects a shared library to a static library in order to reuse its .o files to avoid
|
|
|
|
// compiling source files twice.
|
|
|
|
func reuseStaticLibrary(mctx android.BottomUpMutatorContext, static, shared *Module) {
|
|
|
|
if staticCompiler, ok := static.compiler.(*libraryDecorator); ok {
|
|
|
|
sharedCompiler := shared.compiler.(*libraryDecorator)
|
2018-12-04 00:25:46 +01:00
|
|
|
|
|
|
|
// Check libraries in addition to cflags, since libraries may be exporting different
|
|
|
|
// include directories.
|
2017-05-03 20:01:58 +02:00
|
|
|
if len(staticCompiler.Properties.Static.Cflags) == 0 &&
|
2018-12-04 00:25:46 +01:00
|
|
|
len(sharedCompiler.Properties.Shared.Cflags) == 0 &&
|
|
|
|
len(staticCompiler.Properties.Static.Whole_static_libs) == 0 &&
|
|
|
|
len(sharedCompiler.Properties.Shared.Whole_static_libs) == 0 &&
|
|
|
|
len(staticCompiler.Properties.Static.Static_libs) == 0 &&
|
|
|
|
len(sharedCompiler.Properties.Shared.Static_libs) == 0 &&
|
|
|
|
len(staticCompiler.Properties.Static.Shared_libs) == 0 &&
|
|
|
|
len(sharedCompiler.Properties.Shared.Shared_libs) == 0 &&
|
|
|
|
staticCompiler.Properties.Static.System_shared_libs == nil &&
|
|
|
|
sharedCompiler.Properties.Shared.System_shared_libs == nil {
|
2017-05-03 20:01:58 +02:00
|
|
|
|
|
|
|
mctx.AddInterVariantDependency(reuseObjTag, shared, static)
|
|
|
|
sharedCompiler.baseCompiler.Properties.OriginalSrcs =
|
|
|
|
sharedCompiler.baseCompiler.Properties.Srcs
|
|
|
|
sharedCompiler.baseCompiler.Properties.Srcs = nil
|
|
|
|
sharedCompiler.baseCompiler.Properties.Generated_sources = nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-03 07:25:58 +02:00
|
|
|
func LinkageMutator(mctx android.BottomUpMutatorContext) {
|
2016-07-30 02:28:03 +02:00
|
|
|
if m, ok := mctx.Module().(*Module); ok && m.linker != nil {
|
|
|
|
if library, ok := m.linker.(libraryInterface); ok {
|
|
|
|
var modules []blueprint.Module
|
|
|
|
if library.buildStatic() && library.buildShared() {
|
|
|
|
modules = mctx.CreateLocalVariations("static", "shared")
|
|
|
|
static := modules[0].(*Module)
|
|
|
|
shared := modules[1].(*Module)
|
|
|
|
|
2017-02-15 00:28:44 +01:00
|
|
|
static.linker.(libraryInterface).setStatic()
|
|
|
|
shared.linker.(libraryInterface).setShared()
|
2016-07-30 02:28:03 +02:00
|
|
|
|
2017-05-03 20:01:58 +02:00
|
|
|
reuseStaticLibrary(mctx, static, shared)
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
} else if library.buildStatic() {
|
|
|
|
modules = mctx.CreateLocalVariations("static")
|
2017-02-15 00:28:44 +01:00
|
|
|
modules[0].(*Module).linker.(libraryInterface).setStatic()
|
2016-07-30 02:28:03 +02:00
|
|
|
} else if library.buildShared() {
|
|
|
|
modules = mctx.CreateLocalVariations("shared")
|
2017-02-15 00:28:44 +01:00
|
|
|
modules[0].(*Module).linker.(libraryInterface).setShared()
|
2016-07-30 02:28:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
Add support for versioned stubs.
A cc_library or cc_library_shared can be configured to have stubs
variants of the lib.
cc_library_shared {
name: "libfoo",
srcs: ["foo.cpp"],
stubs: {
symbol_file: "foo.map.txt",
versions: ["1", "2", "3"],
},
}
then, stubs variants of libfoo for version 1, 2, and 3 are created
from foo.map.txt. Each version has the symbols from the map file where
each symbol is annotated with the version that the symbol was introduced
via the 'introduced=<ver>' syntax. The versions don't need to be in sync
with the platform versions (e.g., P for 28). The versions are local to
the library.
For another library or executable to use the versioned stubs lib, use
the new 'name#ver' syntax to specify the version:
cc_binary {
name: "test",
....
shared_libs: ["libFoo#2"],
}
Internally, a new mutator 'version' is applied to all cc.Module objects.
By default, a variant named 'impl' is created for the non-stub version.
If the versions property is set, additional variations are created per a
version with the mutable property BuildStubs set as true, which lets the
compiler and the linker to build a stubs lib from the symbol file
instead from the source files.
This feature will be used to enforce stable interfaces among APEXs. When
a lib foo in an APEX is depending on a lib bar in another APEX, then bar
should have stable interface (in C lang) and foo should be depending on
one of the stubs libs of bar. Only libraries in the same APEX as foo can
link against non-stub version of it.
Bug: 112672359
Test: m (cc_test added)
Change-Id: I2488be0b9d7b7b8d7761234dc1c9c0e3add8601c
2018-10-15 15:25:07 +02:00
|
|
|
|
Stubs variant is used when building for APEX
When a native module is built for an APEX and is depending on a native
library having stubs (i.e. stubs.versions property is set), the stubs
variant is used unless the dependent lib is directly included in the
same APEX with the depending module.
Example:
apex {
name: "myapex",
native_shared_libs: ["libX", "libY"],
}
cc_library {
name: "libX",
shared_libs: ["libY", "libZ"],
}
cc_library {
name: "libY",
stubs: { versions: ["1", "2"], },
}
cc_library {
name: "libZ",
stubs: { versions: ["1", "2"], },
}
In this case, libX is linking to the impl variant of libY (that provides
private APIs) while libY is linking to the version 2 stubs of libZ. This is
because libY is directly included in the same apex via
native_shared_libs property, but libZ isn't.
Bug: 112672359
Test: apex_test added
Change-Id: If9871b70dc74a06bd828dd4cd1aeebd2e68b837c
2018-11-18 10:02:45 +01:00
|
|
|
// maps a module name to the list of stubs versions available for the module
|
|
|
|
func stubsVersionsFor(config android.Config) map[string][]string {
|
|
|
|
return config.Once("stubVersions", func() interface{} {
|
|
|
|
return make(map[string][]string)
|
|
|
|
}).(map[string][]string)
|
|
|
|
}
|
|
|
|
|
|
|
|
var stubsVersionsLock sync.Mutex
|
|
|
|
|
|
|
|
func latestStubsVersionFor(config android.Config, name string) string {
|
|
|
|
versions, ok := stubsVersionsFor(config)[name]
|
|
|
|
if ok && len(versions) > 0 {
|
|
|
|
// the versions are alreay sorted in ascending order
|
|
|
|
return versions[len(versions)-1]
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
Add support for versioned stubs.
A cc_library or cc_library_shared can be configured to have stubs
variants of the lib.
cc_library_shared {
name: "libfoo",
srcs: ["foo.cpp"],
stubs: {
symbol_file: "foo.map.txt",
versions: ["1", "2", "3"],
},
}
then, stubs variants of libfoo for version 1, 2, and 3 are created
from foo.map.txt. Each version has the symbols from the map file where
each symbol is annotated with the version that the symbol was introduced
via the 'introduced=<ver>' syntax. The versions don't need to be in sync
with the platform versions (e.g., P for 28). The versions are local to
the library.
For another library or executable to use the versioned stubs lib, use
the new 'name#ver' syntax to specify the version:
cc_binary {
name: "test",
....
shared_libs: ["libFoo#2"],
}
Internally, a new mutator 'version' is applied to all cc.Module objects.
By default, a variant named 'impl' is created for the non-stub version.
If the versions property is set, additional variations are created per a
version with the mutable property BuildStubs set as true, which lets the
compiler and the linker to build a stubs lib from the symbol file
instead from the source files.
This feature will be used to enforce stable interfaces among APEXs. When
a lib foo in an APEX is depending on a lib bar in another APEX, then bar
should have stable interface (in C lang) and foo should be depending on
one of the stubs libs of bar. Only libraries in the same APEX as foo can
link against non-stub version of it.
Bug: 112672359
Test: m (cc_test added)
Change-Id: I2488be0b9d7b7b8d7761234dc1c9c0e3add8601c
2018-10-15 15:25:07 +02:00
|
|
|
// Version mutator splits a module into the mandatory non-stubs variant
|
Stubs variant is used when building for APEX
When a native module is built for an APEX and is depending on a native
library having stubs (i.e. stubs.versions property is set), the stubs
variant is used unless the dependent lib is directly included in the
same APEX with the depending module.
Example:
apex {
name: "myapex",
native_shared_libs: ["libX", "libY"],
}
cc_library {
name: "libX",
shared_libs: ["libY", "libZ"],
}
cc_library {
name: "libY",
stubs: { versions: ["1", "2"], },
}
cc_library {
name: "libZ",
stubs: { versions: ["1", "2"], },
}
In this case, libX is linking to the impl variant of libY (that provides
private APIs) while libY is linking to the version 2 stubs of libZ. This is
because libY is directly included in the same apex via
native_shared_libs property, but libZ isn't.
Bug: 112672359
Test: apex_test added
Change-Id: If9871b70dc74a06bd828dd4cd1aeebd2e68b837c
2018-11-18 10:02:45 +01:00
|
|
|
// (which is unnamed) and zero or more stubs variants.
|
|
|
|
func VersionMutator(mctx android.BottomUpMutatorContext) {
|
Add support for versioned stubs.
A cc_library or cc_library_shared can be configured to have stubs
variants of the lib.
cc_library_shared {
name: "libfoo",
srcs: ["foo.cpp"],
stubs: {
symbol_file: "foo.map.txt",
versions: ["1", "2", "3"],
},
}
then, stubs variants of libfoo for version 1, 2, and 3 are created
from foo.map.txt. Each version has the symbols from the map file where
each symbol is annotated with the version that the symbol was introduced
via the 'introduced=<ver>' syntax. The versions don't need to be in sync
with the platform versions (e.g., P for 28). The versions are local to
the library.
For another library or executable to use the versioned stubs lib, use
the new 'name#ver' syntax to specify the version:
cc_binary {
name: "test",
....
shared_libs: ["libFoo#2"],
}
Internally, a new mutator 'version' is applied to all cc.Module objects.
By default, a variant named 'impl' is created for the non-stub version.
If the versions property is set, additional variations are created per a
version with the mutable property BuildStubs set as true, which lets the
compiler and the linker to build a stubs lib from the symbol file
instead from the source files.
This feature will be used to enforce stable interfaces among APEXs. When
a lib foo in an APEX is depending on a lib bar in another APEX, then bar
should have stable interface (in C lang) and foo should be depending on
one of the stubs libs of bar. Only libraries in the same APEX as foo can
link against non-stub version of it.
Bug: 112672359
Test: m (cc_test added)
Change-Id: I2488be0b9d7b7b8d7761234dc1c9c0e3add8601c
2018-10-15 15:25:07 +02:00
|
|
|
if m, ok := mctx.Module().(*Module); ok && !m.inRecovery() && m.linker != nil {
|
Stubs variant is used when building for APEX
When a native module is built for an APEX and is depending on a native
library having stubs (i.e. stubs.versions property is set), the stubs
variant is used unless the dependent lib is directly included in the
same APEX with the depending module.
Example:
apex {
name: "myapex",
native_shared_libs: ["libX", "libY"],
}
cc_library {
name: "libX",
shared_libs: ["libY", "libZ"],
}
cc_library {
name: "libY",
stubs: { versions: ["1", "2"], },
}
cc_library {
name: "libZ",
stubs: { versions: ["1", "2"], },
}
In this case, libX is linking to the impl variant of libY (that provides
private APIs) while libY is linking to the version 2 stubs of libZ. This is
because libY is directly included in the same apex via
native_shared_libs property, but libZ isn't.
Bug: 112672359
Test: apex_test added
Change-Id: If9871b70dc74a06bd828dd4cd1aeebd2e68b837c
2018-11-18 10:02:45 +01:00
|
|
|
if library, ok := m.linker.(*libraryDecorator); ok && library.buildShared() &&
|
|
|
|
len(library.Properties.Stubs.Versions) > 0 {
|
|
|
|
versions := []string{}
|
Add support for versioned stubs.
A cc_library or cc_library_shared can be configured to have stubs
variants of the lib.
cc_library_shared {
name: "libfoo",
srcs: ["foo.cpp"],
stubs: {
symbol_file: "foo.map.txt",
versions: ["1", "2", "3"],
},
}
then, stubs variants of libfoo for version 1, 2, and 3 are created
from foo.map.txt. Each version has the symbols from the map file where
each symbol is annotated with the version that the symbol was introduced
via the 'introduced=<ver>' syntax. The versions don't need to be in sync
with the platform versions (e.g., P for 28). The versions are local to
the library.
For another library or executable to use the versioned stubs lib, use
the new 'name#ver' syntax to specify the version:
cc_binary {
name: "test",
....
shared_libs: ["libFoo#2"],
}
Internally, a new mutator 'version' is applied to all cc.Module objects.
By default, a variant named 'impl' is created for the non-stub version.
If the versions property is set, additional variations are created per a
version with the mutable property BuildStubs set as true, which lets the
compiler and the linker to build a stubs lib from the symbol file
instead from the source files.
This feature will be used to enforce stable interfaces among APEXs. When
a lib foo in an APEX is depending on a lib bar in another APEX, then bar
should have stable interface (in C lang) and foo should be depending on
one of the stubs libs of bar. Only libraries in the same APEX as foo can
link against non-stub version of it.
Bug: 112672359
Test: m (cc_test added)
Change-Id: I2488be0b9d7b7b8d7761234dc1c9c0e3add8601c
2018-10-15 15:25:07 +02:00
|
|
|
for _, v := range library.Properties.Stubs.Versions {
|
Stubs variant is used when building for APEX
When a native module is built for an APEX and is depending on a native
library having stubs (i.e. stubs.versions property is set), the stubs
variant is used unless the dependent lib is directly included in the
same APEX with the depending module.
Example:
apex {
name: "myapex",
native_shared_libs: ["libX", "libY"],
}
cc_library {
name: "libX",
shared_libs: ["libY", "libZ"],
}
cc_library {
name: "libY",
stubs: { versions: ["1", "2"], },
}
cc_library {
name: "libZ",
stubs: { versions: ["1", "2"], },
}
In this case, libX is linking to the impl variant of libY (that provides
private APIs) while libY is linking to the version 2 stubs of libZ. This is
because libY is directly included in the same apex via
native_shared_libs property, but libZ isn't.
Bug: 112672359
Test: apex_test added
Change-Id: If9871b70dc74a06bd828dd4cd1aeebd2e68b837c
2018-11-18 10:02:45 +01:00
|
|
|
if _, err := strconv.Atoi(v); err != nil {
|
|
|
|
mctx.PropertyErrorf("versions", "%q is not a number", v)
|
|
|
|
}
|
Add support for versioned stubs.
A cc_library or cc_library_shared can be configured to have stubs
variants of the lib.
cc_library_shared {
name: "libfoo",
srcs: ["foo.cpp"],
stubs: {
symbol_file: "foo.map.txt",
versions: ["1", "2", "3"],
},
}
then, stubs variants of libfoo for version 1, 2, and 3 are created
from foo.map.txt. Each version has the symbols from the map file where
each symbol is annotated with the version that the symbol was introduced
via the 'introduced=<ver>' syntax. The versions don't need to be in sync
with the platform versions (e.g., P for 28). The versions are local to
the library.
For another library or executable to use the versioned stubs lib, use
the new 'name#ver' syntax to specify the version:
cc_binary {
name: "test",
....
shared_libs: ["libFoo#2"],
}
Internally, a new mutator 'version' is applied to all cc.Module objects.
By default, a variant named 'impl' is created for the non-stub version.
If the versions property is set, additional variations are created per a
version with the mutable property BuildStubs set as true, which lets the
compiler and the linker to build a stubs lib from the symbol file
instead from the source files.
This feature will be used to enforce stable interfaces among APEXs. When
a lib foo in an APEX is depending on a lib bar in another APEX, then bar
should have stable interface (in C lang) and foo should be depending on
one of the stubs libs of bar. Only libraries in the same APEX as foo can
link against non-stub version of it.
Bug: 112672359
Test: m (cc_test added)
Change-Id: I2488be0b9d7b7b8d7761234dc1c9c0e3add8601c
2018-10-15 15:25:07 +02:00
|
|
|
versions = append(versions, v)
|
|
|
|
}
|
Stubs variant is used when building for APEX
When a native module is built for an APEX and is depending on a native
library having stubs (i.e. stubs.versions property is set), the stubs
variant is used unless the dependent lib is directly included in the
same APEX with the depending module.
Example:
apex {
name: "myapex",
native_shared_libs: ["libX", "libY"],
}
cc_library {
name: "libX",
shared_libs: ["libY", "libZ"],
}
cc_library {
name: "libY",
stubs: { versions: ["1", "2"], },
}
cc_library {
name: "libZ",
stubs: { versions: ["1", "2"], },
}
In this case, libX is linking to the impl variant of libY (that provides
private APIs) while libY is linking to the version 2 stubs of libZ. This is
because libY is directly included in the same apex via
native_shared_libs property, but libZ isn't.
Bug: 112672359
Test: apex_test added
Change-Id: If9871b70dc74a06bd828dd4cd1aeebd2e68b837c
2018-11-18 10:02:45 +01:00
|
|
|
sort.Slice(versions, func(i, j int) bool {
|
|
|
|
left, _ := strconv.Atoi(versions[i])
|
|
|
|
right, _ := strconv.Atoi(versions[j])
|
|
|
|
return left < right
|
|
|
|
})
|
|
|
|
|
|
|
|
// save the list of versions for later use
|
|
|
|
copiedVersions := make([]string, len(versions))
|
|
|
|
copy(copiedVersions, versions)
|
|
|
|
stubsVersionsLock.Lock()
|
|
|
|
defer stubsVersionsLock.Unlock()
|
|
|
|
stubsVersionsFor(mctx.Config())[mctx.ModuleName()] = copiedVersions
|
|
|
|
|
|
|
|
// "" is for the non-stubs variant
|
2019-01-03 13:35:58 +01:00
|
|
|
versions = append([]string{""}, versions...)
|
Stubs variant is used when building for APEX
When a native module is built for an APEX and is depending on a native
library having stubs (i.e. stubs.versions property is set), the stubs
variant is used unless the dependent lib is directly included in the
same APEX with the depending module.
Example:
apex {
name: "myapex",
native_shared_libs: ["libX", "libY"],
}
cc_library {
name: "libX",
shared_libs: ["libY", "libZ"],
}
cc_library {
name: "libY",
stubs: { versions: ["1", "2"], },
}
cc_library {
name: "libZ",
stubs: { versions: ["1", "2"], },
}
In this case, libX is linking to the impl variant of libY (that provides
private APIs) while libY is linking to the version 2 stubs of libZ. This is
because libY is directly included in the same apex via
native_shared_libs property, but libZ isn't.
Bug: 112672359
Test: apex_test added
Change-Id: If9871b70dc74a06bd828dd4cd1aeebd2e68b837c
2018-11-18 10:02:45 +01:00
|
|
|
|
Add support for versioned stubs.
A cc_library or cc_library_shared can be configured to have stubs
variants of the lib.
cc_library_shared {
name: "libfoo",
srcs: ["foo.cpp"],
stubs: {
symbol_file: "foo.map.txt",
versions: ["1", "2", "3"],
},
}
then, stubs variants of libfoo for version 1, 2, and 3 are created
from foo.map.txt. Each version has the symbols from the map file where
each symbol is annotated with the version that the symbol was introduced
via the 'introduced=<ver>' syntax. The versions don't need to be in sync
with the platform versions (e.g., P for 28). The versions are local to
the library.
For another library or executable to use the versioned stubs lib, use
the new 'name#ver' syntax to specify the version:
cc_binary {
name: "test",
....
shared_libs: ["libFoo#2"],
}
Internally, a new mutator 'version' is applied to all cc.Module objects.
By default, a variant named 'impl' is created for the non-stub version.
If the versions property is set, additional variations are created per a
version with the mutable property BuildStubs set as true, which lets the
compiler and the linker to build a stubs lib from the symbol file
instead from the source files.
This feature will be used to enforce stable interfaces among APEXs. When
a lib foo in an APEX is depending on a lib bar in another APEX, then bar
should have stable interface (in C lang) and foo should be depending on
one of the stubs libs of bar. Only libraries in the same APEX as foo can
link against non-stub version of it.
Bug: 112672359
Test: m (cc_test added)
Change-Id: I2488be0b9d7b7b8d7761234dc1c9c0e3add8601c
2018-10-15 15:25:07 +02:00
|
|
|
modules := mctx.CreateVariations(versions...)
|
|
|
|
for i, m := range modules {
|
|
|
|
l := m.(*Module).linker.(*libraryDecorator)
|
Stubs variant is used when building for APEX
When a native module is built for an APEX and is depending on a native
library having stubs (i.e. stubs.versions property is set), the stubs
variant is used unless the dependent lib is directly included in the
same APEX with the depending module.
Example:
apex {
name: "myapex",
native_shared_libs: ["libX", "libY"],
}
cc_library {
name: "libX",
shared_libs: ["libY", "libZ"],
}
cc_library {
name: "libY",
stubs: { versions: ["1", "2"], },
}
cc_library {
name: "libZ",
stubs: { versions: ["1", "2"], },
}
In this case, libX is linking to the impl variant of libY (that provides
private APIs) while libY is linking to the version 2 stubs of libZ. This is
because libY is directly included in the same apex via
native_shared_libs property, but libZ isn't.
Bug: 112672359
Test: apex_test added
Change-Id: If9871b70dc74a06bd828dd4cd1aeebd2e68b837c
2018-11-18 10:02:45 +01:00
|
|
|
if versions[i] != "" {
|
|
|
|
l.MutatedProperties.BuildStubs = true
|
|
|
|
l.MutatedProperties.StubsVersion = versions[i]
|
|
|
|
m.(*Module).Properties.HideFromMake = true
|
2018-12-10 18:47:16 +01:00
|
|
|
m.(*Module).sanitize = nil
|
|
|
|
m.(*Module).stl = nil
|
2018-12-12 02:26:20 +01:00
|
|
|
m.(*Module).Properties.PreventInstall = true
|
Add support for versioned stubs.
A cc_library or cc_library_shared can be configured to have stubs
variants of the lib.
cc_library_shared {
name: "libfoo",
srcs: ["foo.cpp"],
stubs: {
symbol_file: "foo.map.txt",
versions: ["1", "2", "3"],
},
}
then, stubs variants of libfoo for version 1, 2, and 3 are created
from foo.map.txt. Each version has the symbols from the map file where
each symbol is annotated with the version that the symbol was introduced
via the 'introduced=<ver>' syntax. The versions don't need to be in sync
with the platform versions (e.g., P for 28). The versions are local to
the library.
For another library or executable to use the versioned stubs lib, use
the new 'name#ver' syntax to specify the version:
cc_binary {
name: "test",
....
shared_libs: ["libFoo#2"],
}
Internally, a new mutator 'version' is applied to all cc.Module objects.
By default, a variant named 'impl' is created for the non-stub version.
If the versions property is set, additional variations are created per a
version with the mutable property BuildStubs set as true, which lets the
compiler and the linker to build a stubs lib from the symbol file
instead from the source files.
This feature will be used to enforce stable interfaces among APEXs. When
a lib foo in an APEX is depending on a lib bar in another APEX, then bar
should have stable interface (in C lang) and foo should be depending on
one of the stubs libs of bar. Only libraries in the same APEX as foo can
link against non-stub version of it.
Bug: 112672359
Test: m (cc_test added)
Change-Id: I2488be0b9d7b7b8d7761234dc1c9c0e3add8601c
2018-10-15 15:25:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
mctx.CreateVariations("")
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if genrule, ok := mctx.Module().(*genrule.Module); ok {
|
|
|
|
if props, ok := genrule.Extra.(*GenruleExtraProperties); ok && !props.InRecovery {
|
|
|
|
mctx.CreateVariations("")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|