2017-11-17 19:55:38 +01:00
|
|
|
// Copyright 2017 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.
|
|
|
|
|
2015-04-28 22:30:13 +02:00
|
|
|
package cc
|
|
|
|
|
|
|
|
import (
|
2017-09-28 02:05:30 +02:00
|
|
|
"fmt"
|
Squash vendor sources before linkageMutator runs
linkageMutator removes srcs property of the shared variant of a lib in
order to reuse *.o files compiled for the static variant also to the
shared variant.
However, this causes problem when vendor-specific srcs are specified in
target: {vendor: {srcs: ["..."]}}. For example, let's assume
cc_library {
name: "libfoo",
srcs: ["foo.c"],
target: {
vendor: {
srcs: ["bar.c"],
},
},
}
Then,
static_vendor: inputs = foo.o, bar.o
shared_vendor: inputs = foo.o (from static_vendor), bar.o (from
static_vendor), bar.o
So, bar.o is included twice and this causes multiple symbol definition
error.
In order to handle the problem, vendor mutator is applied before the
linkage mutator and the vendor-specific srcs are squashed in the vendor
mutator.
Bug: 67731122
Test: build
Test: cc_test.go
Change-Id: I2a5390295dddfc41260e9b6f02746908cdf47228
2017-10-12 16:05:00 +02:00
|
|
|
"os"
|
2019-05-09 06:29:15 +02:00
|
|
|
"path/filepath"
|
2015-04-28 22:30:13 +02:00
|
|
|
"reflect"
|
2021-02-19 14:57:10 +01:00
|
|
|
"regexp"
|
2022-07-22 19:22:02 +02:00
|
|
|
"runtime"
|
2017-09-28 02:05:30 +02:00
|
|
|
"strings"
|
2015-04-28 22:30:13 +02:00
|
|
|
"testing"
|
2019-09-24 23:55:04 +02:00
|
|
|
|
2023-04-28 17:21:25 +02:00
|
|
|
"android/soong/aidl_library"
|
2019-09-24 23:55:04 +02:00
|
|
|
"android/soong/android"
|
2024-01-03 06:24:34 +01:00
|
|
|
|
|
|
|
"github.com/google/blueprint"
|
2015-04-28 22:30:13 +02:00
|
|
|
)
|
|
|
|
|
2023-01-18 18:15:31 +01:00
|
|
|
func init() {
|
|
|
|
registerTestMutators(android.InitRegistrationContext)
|
|
|
|
}
|
|
|
|
|
Squash vendor sources before linkageMutator runs
linkageMutator removes srcs property of the shared variant of a lib in
order to reuse *.o files compiled for the static variant also to the
shared variant.
However, this causes problem when vendor-specific srcs are specified in
target: {vendor: {srcs: ["..."]}}. For example, let's assume
cc_library {
name: "libfoo",
srcs: ["foo.c"],
target: {
vendor: {
srcs: ["bar.c"],
},
},
}
Then,
static_vendor: inputs = foo.o, bar.o
shared_vendor: inputs = foo.o (from static_vendor), bar.o (from
static_vendor), bar.o
So, bar.o is included twice and this causes multiple symbol definition
error.
In order to handle the problem, vendor mutator is applied before the
linkage mutator and the vendor-specific srcs are squashed in the vendor
mutator.
Bug: 67731122
Test: build
Test: cc_test.go
Change-Id: I2a5390295dddfc41260e9b6f02746908cdf47228
2017-10-12 16:05:00 +02:00
|
|
|
func TestMain(m *testing.M) {
|
2021-03-23 00:21:32 +01:00
|
|
|
os.Exit(m.Run())
|
Squash vendor sources before linkageMutator runs
linkageMutator removes srcs property of the shared variant of a lib in
order to reuse *.o files compiled for the static variant also to the
shared variant.
However, this causes problem when vendor-specific srcs are specified in
target: {vendor: {srcs: ["..."]}}. For example, let's assume
cc_library {
name: "libfoo",
srcs: ["foo.c"],
target: {
vendor: {
srcs: ["bar.c"],
},
},
}
Then,
static_vendor: inputs = foo.o, bar.o
shared_vendor: inputs = foo.o (from static_vendor), bar.o (from
static_vendor), bar.o
So, bar.o is included twice and this causes multiple symbol definition
error.
In order to handle the problem, vendor mutator is applied before the
linkage mutator and the vendor-specific srcs are squashed in the vendor
mutator.
Bug: 67731122
Test: build
Test: cc_test.go
Change-Id: I2a5390295dddfc41260e9b6f02746908cdf47228
2017-10-12 16:05:00 +02:00
|
|
|
}
|
|
|
|
|
2021-03-23 00:20:25 +01:00
|
|
|
var prepareForCcTest = android.GroupFixturePreparers(
|
2021-02-24 19:51:54 +01:00
|
|
|
PrepareForTestWithCcIncludeVndk,
|
|
|
|
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
2023-11-29 09:58:16 +01:00
|
|
|
variables.VendorApiLevel = StringPtr("202404")
|
2021-02-24 19:51:54 +01:00
|
|
|
variables.DeviceVndkVersion = StringPtr("current")
|
2021-04-01 14:35:20 +02:00
|
|
|
variables.Platform_vndk_version = StringPtr("29")
|
2021-02-24 19:51:54 +01:00
|
|
|
}),
|
|
|
|
)
|
|
|
|
|
2024-01-03 06:24:34 +01:00
|
|
|
// TODO(b/316829758) Update prepareForCcTest with this configuration and remove prepareForCcTestWithoutVndk
|
|
|
|
var prepareForCcTestWithoutVndk = android.GroupFixturePreparers(
|
|
|
|
PrepareForIntegrationTestWithCc,
|
|
|
|
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
|
|
|
variables.VendorApiLevel = StringPtr("202404")
|
|
|
|
}),
|
|
|
|
)
|
|
|
|
|
2023-01-18 18:15:31 +01:00
|
|
|
var apexVariationName = "apex28"
|
|
|
|
var apexVersion = "28"
|
|
|
|
|
|
|
|
func registerTestMutators(ctx android.RegistrationContext) {
|
|
|
|
ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
|
|
|
|
ctx.BottomUp("apex", testApexMutator).Parallel()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func testApexMutator(mctx android.BottomUpMutatorContext) {
|
|
|
|
modules := mctx.CreateVariations(apexVariationName)
|
|
|
|
apexInfo := android.ApexInfo{
|
|
|
|
ApexVariationName: apexVariationName,
|
|
|
|
MinSdkVersion: android.ApiLevelForTest(apexVersion),
|
|
|
|
}
|
|
|
|
mctx.SetVariationProvider(modules[0], android.ApexInfoProvider, apexInfo)
|
|
|
|
}
|
|
|
|
|
2021-03-23 01:02:06 +01:00
|
|
|
// testCcWithConfig runs tests using the prepareForCcTest
|
2021-02-24 19:51:54 +01:00
|
|
|
//
|
|
|
|
// See testCc for an explanation as to how to stop using this deprecated method.
|
|
|
|
//
|
|
|
|
// deprecated
|
2019-12-14 05:41:13 +01:00
|
|
|
func testCcWithConfig(t *testing.T, config android.Config) *android.TestContext {
|
2019-09-24 23:55:04 +02:00
|
|
|
t.Helper()
|
2021-03-23 01:02:06 +01:00
|
|
|
result := prepareForCcTest.RunTestWithConfig(t, config)
|
2021-02-24 19:51:54 +01:00
|
|
|
return result.TestContext
|
2017-09-28 02:05:30 +02:00
|
|
|
}
|
|
|
|
|
2021-03-23 01:02:06 +01:00
|
|
|
// testCc runs tests using the prepareForCcTest
|
2021-02-24 19:51:54 +01:00
|
|
|
//
|
2021-03-23 01:02:06 +01:00
|
|
|
// Do not add any new usages of this, instead use the prepareForCcTest directly as it makes it much
|
2021-02-24 19:51:54 +01:00
|
|
|
// easier to customize the test behavior.
|
|
|
|
//
|
|
|
|
// If it is necessary to customize the behavior of an existing test that uses this then please first
|
2021-03-23 01:02:06 +01:00
|
|
|
// convert the test to using prepareForCcTest first and then in a following change add the
|
2021-02-24 19:51:54 +01:00
|
|
|
// appropriate fixture preparers. Keeping the conversion change separate makes it easy to verify
|
|
|
|
// that it did not change the test behavior unexpectedly.
|
|
|
|
//
|
|
|
|
// deprecated
|
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
|
|
|
func testCc(t *testing.T, bp string) *android.TestContext {
|
2018-03-29 08:08:15 +02:00
|
|
|
t.Helper()
|
2021-03-23 01:02:06 +01:00
|
|
|
result := prepareForCcTest.RunTestWithBp(t, bp)
|
2021-02-24 19:51:54 +01:00
|
|
|
return result.TestContext
|
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
|
|
|
}
|
|
|
|
|
2021-03-23 01:02:06 +01:00
|
|
|
// testCcErrorWithConfig runs tests using the prepareForCcTest
|
2021-02-24 19:51:54 +01:00
|
|
|
//
|
|
|
|
// See testCc for an explanation as to how to stop using this deprecated method.
|
|
|
|
//
|
|
|
|
// deprecated
|
2019-11-18 11:52:14 +01:00
|
|
|
func testCcErrorWithConfig(t *testing.T, pattern string, config android.Config) {
|
2018-03-29 08:08:15 +02:00
|
|
|
t.Helper()
|
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
|
|
|
|
2021-03-23 01:02:06 +01:00
|
|
|
prepareForCcTest.
|
2021-02-24 19:51:54 +01:00
|
|
|
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(pattern)).
|
|
|
|
RunTestWithConfig(t, config)
|
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
|
|
|
}
|
|
|
|
|
2021-03-23 01:02:06 +01:00
|
|
|
// testCcError runs tests using the prepareForCcTest
|
2021-02-24 19:51:54 +01:00
|
|
|
//
|
|
|
|
// See testCc for an explanation as to how to stop using this deprecated method.
|
|
|
|
//
|
|
|
|
// deprecated
|
2019-11-18 11:52:14 +01:00
|
|
|
func testCcError(t *testing.T, pattern string, bp string) {
|
2020-10-19 11:51:07 +02:00
|
|
|
t.Helper()
|
2021-03-23 00:21:32 +01:00
|
|
|
config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
|
2019-11-18 11:52:14 +01:00
|
|
|
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
|
2021-04-01 14:35:20 +02:00
|
|
|
config.TestProductVariables.Platform_vndk_version = StringPtr("29")
|
2019-11-18 11:52:14 +01:00
|
|
|
testCcErrorWithConfig(t, pattern, config)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-03-23 01:02:06 +01:00
|
|
|
// testCcErrorProductVndk runs tests using the prepareForCcTest
|
2021-02-24 19:51:54 +01:00
|
|
|
//
|
|
|
|
// See testCc for an explanation as to how to stop using this deprecated method.
|
|
|
|
//
|
|
|
|
// deprecated
|
2019-11-18 11:52:14 +01:00
|
|
|
func testCcErrorProductVndk(t *testing.T, pattern string, bp string) {
|
2020-10-20 11:54:21 +02:00
|
|
|
t.Helper()
|
2021-03-23 00:21:32 +01:00
|
|
|
config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
|
2019-11-18 11:52:14 +01:00
|
|
|
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
|
2021-04-01 14:35:20 +02:00
|
|
|
config.TestProductVariables.Platform_vndk_version = StringPtr("29")
|
2019-11-18 11:52:14 +01:00
|
|
|
testCcErrorWithConfig(t, pattern, config)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
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
|
|
|
const (
|
2019-11-21 01:39:12 +01:00
|
|
|
coreVariant = "android_arm64_armv8-a_shared"
|
2021-04-01 14:35:20 +02:00
|
|
|
vendorVariant = "android_vendor.29_arm64_armv8-a_shared"
|
|
|
|
productVariant = "android_product.29_arm64_armv8-a_shared"
|
2019-11-21 02:12:35 +01:00
|
|
|
recoveryVariant = "android_recovery_arm64_armv8-a_shared"
|
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
|
|
|
)
|
|
|
|
|
2021-03-21 23:01:55 +01:00
|
|
|
// Test that the PrepareForTestWithCcDefaultModules provides all the files that it uses by
|
|
|
|
// running it in a fixture that requires all source files to exist.
|
|
|
|
func TestPrepareForTestWithCcDefaultModules(t *testing.T) {
|
|
|
|
android.GroupFixturePreparers(
|
|
|
|
PrepareForTestWithCcDefaultModules,
|
|
|
|
android.PrepareForTestDisallowNonExistentPaths,
|
|
|
|
).RunTest(t)
|
|
|
|
}
|
|
|
|
|
2017-09-28 02:05:30 +02:00
|
|
|
func TestVendorSrc(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2017-09-28 02:05:30 +02:00
|
|
|
ctx := testCc(t, `
|
|
|
|
cc_library {
|
|
|
|
name: "libTest",
|
|
|
|
srcs: ["foo.c"],
|
2019-06-02 09:53:50 +02:00
|
|
|
no_libcrt: true,
|
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
|
|
|
nocrt: true,
|
|
|
|
system_shared_libs: [],
|
2017-09-28 02:05:30 +02:00
|
|
|
vendor_available: true,
|
|
|
|
target: {
|
|
|
|
vendor: {
|
|
|
|
srcs: ["bar.c"],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
Squash vendor sources before linkageMutator runs
linkageMutator removes srcs property of the shared variant of a lib in
order to reuse *.o files compiled for the static variant also to the
shared variant.
However, this causes problem when vendor-specific srcs are specified in
target: {vendor: {srcs: ["..."]}}. For example, let's assume
cc_library {
name: "libfoo",
srcs: ["foo.c"],
target: {
vendor: {
srcs: ["bar.c"],
},
},
}
Then,
static_vendor: inputs = foo.o, bar.o
shared_vendor: inputs = foo.o (from static_vendor), bar.o (from
static_vendor), bar.o
So, bar.o is included twice and this causes multiple symbol definition
error.
In order to handle the problem, vendor mutator is applied before the
linkage mutator and the vendor-specific srcs are squashed in the vendor
mutator.
Bug: 67731122
Test: build
Test: cc_test.go
Change-Id: I2a5390295dddfc41260e9b6f02746908cdf47228
2017-10-12 16:05:00 +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
|
|
|
ld := ctx.ModuleForTests("libTest", vendorVariant).Rule("ld")
|
Squash vendor sources before linkageMutator runs
linkageMutator removes srcs property of the shared variant of a lib in
order to reuse *.o files compiled for the static variant also to the
shared variant.
However, this causes problem when vendor-specific srcs are specified in
target: {vendor: {srcs: ["..."]}}. For example, let's assume
cc_library {
name: "libfoo",
srcs: ["foo.c"],
target: {
vendor: {
srcs: ["bar.c"],
},
},
}
Then,
static_vendor: inputs = foo.o, bar.o
shared_vendor: inputs = foo.o (from static_vendor), bar.o (from
static_vendor), bar.o
So, bar.o is included twice and this causes multiple symbol definition
error.
In order to handle the problem, vendor mutator is applied before the
linkage mutator and the vendor-specific srcs are squashed in the vendor
mutator.
Bug: 67731122
Test: build
Test: cc_test.go
Change-Id: I2a5390295dddfc41260e9b6f02746908cdf47228
2017-10-12 16:05:00 +02:00
|
|
|
var objs []string
|
|
|
|
for _, o := range ld.Inputs {
|
|
|
|
objs = append(objs, o.Base())
|
|
|
|
}
|
2018-01-03 22:40:46 +01:00
|
|
|
if len(objs) != 2 || objs[0] != "foo.o" || objs[1] != "bar.o" {
|
Squash vendor sources before linkageMutator runs
linkageMutator removes srcs property of the shared variant of a lib in
order to reuse *.o files compiled for the static variant also to the
shared variant.
However, this causes problem when vendor-specific srcs are specified in
target: {vendor: {srcs: ["..."]}}. For example, let's assume
cc_library {
name: "libfoo",
srcs: ["foo.c"],
target: {
vendor: {
srcs: ["bar.c"],
},
},
}
Then,
static_vendor: inputs = foo.o, bar.o
shared_vendor: inputs = foo.o (from static_vendor), bar.o (from
static_vendor), bar.o
So, bar.o is included twice and this causes multiple symbol definition
error.
In order to handle the problem, vendor mutator is applied before the
linkage mutator and the vendor-specific srcs are squashed in the vendor
mutator.
Bug: 67731122
Test: build
Test: cc_test.go
Change-Id: I2a5390295dddfc41260e9b6f02746908cdf47228
2017-10-12 16:05:00 +02:00
|
|
|
t.Errorf("inputs of libTest must be []string{\"foo.o\", \"bar.o\"}, but was %#v.", objs)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-12 06:19:28 +02:00
|
|
|
func checkInstallPartition(t *testing.T, ctx *android.TestContext, name, variant, expected string) {
|
|
|
|
mod := ctx.ModuleForTests(name, variant).Module().(*Module)
|
|
|
|
partitionDefined := false
|
|
|
|
checkPartition := func(specific bool, partition string) {
|
|
|
|
if specific {
|
|
|
|
if expected != partition && !partitionDefined {
|
|
|
|
// The variant is installed to the 'partition'
|
|
|
|
t.Errorf("%s variant of %q must not be installed to %s partition", variant, name, partition)
|
|
|
|
}
|
|
|
|
partitionDefined = true
|
|
|
|
} else {
|
|
|
|
// The variant is not installed to the 'partition'
|
|
|
|
if expected == partition {
|
|
|
|
t.Errorf("%s variant of %q must be installed to %s partition", variant, name, partition)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
socSpecific := func(m *Module) bool {
|
2023-11-30 01:00:16 +01:00
|
|
|
return m.SocSpecific() || m.InstallInVendor()
|
2021-04-12 06:19:28 +02:00
|
|
|
}
|
|
|
|
deviceSpecific := func(m *Module) bool {
|
2023-11-30 01:00:16 +01:00
|
|
|
return m.DeviceSpecific() || m.InstallInOdm()
|
2021-04-12 06:19:28 +02:00
|
|
|
}
|
|
|
|
productSpecific := func(m *Module) bool {
|
2023-11-30 01:00:16 +01:00
|
|
|
return m.ProductSpecific() || m.InstallInProduct()
|
2021-04-12 06:19:28 +02:00
|
|
|
}
|
|
|
|
systemExtSpecific := func(m *Module) bool {
|
|
|
|
return m.SystemExtSpecific()
|
|
|
|
}
|
|
|
|
checkPartition(socSpecific(mod), "vendor")
|
|
|
|
checkPartition(deviceSpecific(mod), "odm")
|
|
|
|
checkPartition(productSpecific(mod), "product")
|
|
|
|
checkPartition(systemExtSpecific(mod), "system_ext")
|
|
|
|
if !partitionDefined && expected != "system" {
|
|
|
|
t.Errorf("%s variant of %q is expected to be installed to %s partition,"+
|
|
|
|
" but installed to system partition", variant, name, expected)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestInstallPartition(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2021-04-12 06:19:28 +02:00
|
|
|
t.Helper()
|
|
|
|
ctx := prepareForCcTest.RunTestWithBp(t, `
|
|
|
|
cc_library {
|
|
|
|
name: "libsystem",
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libsystem_ext",
|
|
|
|
system_ext_specific: true,
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libproduct",
|
|
|
|
product_specific: true,
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libvendor",
|
|
|
|
vendor: true,
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libodm",
|
|
|
|
device_specific: true,
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "liball_available",
|
|
|
|
vendor_available: true,
|
|
|
|
product_available: true,
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libsystem_ext_all_available",
|
|
|
|
system_ext_specific: true,
|
|
|
|
vendor_available: true,
|
|
|
|
product_available: true,
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "liball_available_odm",
|
|
|
|
odm_available: true,
|
|
|
|
product_available: true,
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libproduct_vendoravailable",
|
|
|
|
product_specific: true,
|
|
|
|
vendor_available: true,
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libproduct_odmavailable",
|
|
|
|
product_specific: true,
|
|
|
|
odm_available: true,
|
|
|
|
}
|
|
|
|
`).TestContext
|
|
|
|
|
|
|
|
checkInstallPartition(t, ctx, "libsystem", coreVariant, "system")
|
|
|
|
checkInstallPartition(t, ctx, "libsystem_ext", coreVariant, "system_ext")
|
|
|
|
checkInstallPartition(t, ctx, "libproduct", productVariant, "product")
|
|
|
|
checkInstallPartition(t, ctx, "libvendor", vendorVariant, "vendor")
|
|
|
|
checkInstallPartition(t, ctx, "libodm", vendorVariant, "odm")
|
|
|
|
|
|
|
|
checkInstallPartition(t, ctx, "liball_available", coreVariant, "system")
|
|
|
|
checkInstallPartition(t, ctx, "liball_available", productVariant, "product")
|
|
|
|
checkInstallPartition(t, ctx, "liball_available", vendorVariant, "vendor")
|
|
|
|
|
|
|
|
checkInstallPartition(t, ctx, "libsystem_ext_all_available", coreVariant, "system_ext")
|
|
|
|
checkInstallPartition(t, ctx, "libsystem_ext_all_available", productVariant, "product")
|
|
|
|
checkInstallPartition(t, ctx, "libsystem_ext_all_available", vendorVariant, "vendor")
|
|
|
|
|
|
|
|
checkInstallPartition(t, ctx, "liball_available_odm", coreVariant, "system")
|
|
|
|
checkInstallPartition(t, ctx, "liball_available_odm", productVariant, "product")
|
|
|
|
checkInstallPartition(t, ctx, "liball_available_odm", vendorVariant, "odm")
|
|
|
|
|
|
|
|
checkInstallPartition(t, ctx, "libproduct_vendoravailable", productVariant, "product")
|
|
|
|
checkInstallPartition(t, ctx, "libproduct_vendoravailable", vendorVariant, "vendor")
|
|
|
|
|
|
|
|
checkInstallPartition(t, ctx, "libproduct_odmavailable", productVariant, "product")
|
|
|
|
checkInstallPartition(t, ctx, "libproduct_odmavailable", vendorVariant, "odm")
|
|
|
|
}
|
|
|
|
|
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
|
|
|
func checkVndkModule(t *testing.T, ctx *android.TestContext, name, subDir string,
|
2020-02-28 07:07:59 +01:00
|
|
|
isVndkSp bool, extends string, variant string) {
|
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
|
|
|
|
2018-03-29 08:08:15 +02:00
|
|
|
t.Helper()
|
|
|
|
|
2020-02-28 07:07:59 +01:00
|
|
|
mod := ctx.ModuleForTests(name, variant).Module().(*Module)
|
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
|
|
|
|
|
|
|
// Check library properties.
|
|
|
|
lib, ok := mod.compiler.(*libraryDecorator)
|
|
|
|
if !ok {
|
|
|
|
t.Errorf("%q must have libraryDecorator", name)
|
|
|
|
} else if lib.baseInstaller.subDir != subDir {
|
|
|
|
t.Errorf("%q must use %q as subdir but it is using %q", name, subDir,
|
|
|
|
lib.baseInstaller.subDir)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check VNDK properties.
|
|
|
|
if mod.vndkdep == nil {
|
|
|
|
t.Fatalf("%q must have `vndkdep`", name)
|
|
|
|
}
|
2019-10-18 23:49:46 +02:00
|
|
|
if !mod.IsVndk() {
|
|
|
|
t.Errorf("%q IsVndk() must equal to true", name)
|
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
|
|
|
}
|
2021-04-01 15:49:36 +02:00
|
|
|
if mod.IsVndkSp() != isVndkSp {
|
|
|
|
t.Errorf("%q IsVndkSp() must equal to %t", name, isVndkSp)
|
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
|
|
|
}
|
|
|
|
|
|
|
|
// Check VNDK extension properties.
|
|
|
|
isVndkExt := extends != ""
|
2020-12-02 15:00:51 +01:00
|
|
|
if mod.IsVndkExt() != isVndkExt {
|
|
|
|
t.Errorf("%q IsVndkExt() must equal to %t", name, isVndkExt)
|
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 actualExtends := mod.getVndkExtendsModuleName(); actualExtends != extends {
|
|
|
|
t.Errorf("%q must extend from %q but get %q", name, extends, actualExtends)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-03 00:56:39 +01:00
|
|
|
func checkWriteFileOutput(t *testing.T, ctx *android.TestContext, params android.TestingBuildParams, expected []string) {
|
2019-11-06 08:46:15 +01:00
|
|
|
t.Helper()
|
2023-11-03 00:56:39 +01:00
|
|
|
content := android.ContentFromFileRuleForTests(t, ctx, params)
|
2020-11-13 20:48:42 +01:00
|
|
|
actual := strings.FieldsFunc(content, func(r rune) bool { return r == '\n' })
|
2019-11-06 08:46:15 +01:00
|
|
|
assertArrayString(t, actual, expected)
|
|
|
|
}
|
|
|
|
|
2019-10-22 12:32:18 +02:00
|
|
|
func checkVndkOutput(t *testing.T, ctx *android.TestContext, output string, expected []string) {
|
|
|
|
t.Helper()
|
|
|
|
vndkSnapshot := ctx.SingletonForTests("vndk-snapshot")
|
2023-11-03 00:56:39 +01:00
|
|
|
checkWriteFileOutput(t, ctx, vndkSnapshot.Output(output), expected)
|
2019-11-06 08:46:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func checkVndkLibrariesOutput(t *testing.T, ctx *android.TestContext, module string, expected []string) {
|
|
|
|
t.Helper()
|
2021-11-12 07:47:54 +01:00
|
|
|
got := ctx.ModuleForTests(module, "android_common").Module().(*vndkLibrariesTxt).fileNames
|
2021-01-06 23:51:30 +01:00
|
|
|
assertArrayString(t, got, expected)
|
2019-10-22 12:32:18 +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
|
|
|
func TestVndk(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2019-12-14 05:41:13 +01:00
|
|
|
bp := `
|
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
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_private",
|
Define vndk.private property for VNDK-private libraries
To define VNDK-private libraries, we used `vendor_available: false`.
Because of it, `vendor_available == nil` had different meaning from
`vendor_available: false` for the VNDK libraries.
To clarify this, we change the logic for defining VNDK-private
libraries which was:
cc_library {
name: "vndk_private",
vendor_available: false,
product_available: false,
vndk: {
enabled: true,
},
}
It must be replaced with
cc_library {
name: "vndk_private",
vendor_available: true,
product_available: true,
vndk: {
enabled: true,
private: true,
},
}
Bug: 175768895
Test: m nothing
Change-Id: I81769f57c2231e54b682a28e4b82631ab9f3d390
2020-12-23 10:23:14 +01:00
|
|
|
vendor_available: true,
|
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
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
Define vndk.private property for VNDK-private libraries
To define VNDK-private libraries, we used `vendor_available: false`.
Because of it, `vendor_available == nil` had different meaning from
`vendor_available: false` for the VNDK libraries.
To clarify this, we change the logic for defining VNDK-private
libraries which was:
cc_library {
name: "vndk_private",
vendor_available: false,
product_available: false,
vndk: {
enabled: true,
},
}
It must be replaced with
cc_library {
name: "vndk_private",
vendor_available: true,
product_available: true,
vndk: {
enabled: true,
private: true,
},
}
Bug: 175768895
Test: m nothing
Change-Id: I81769f57c2231e54b682a28e4b82631ab9f3d390
2020-12-23 10:23:14 +01:00
|
|
|
private: true,
|
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
|
|
|
},
|
|
|
|
nocrt: true,
|
2019-10-30 10:43:49 +01:00
|
|
|
stem: "libvndk-private",
|
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
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
2020-10-29 10:24:11 +01:00
|
|
|
name: "libvndk_product",
|
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
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2020-10-29 10:24:11 +01:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
target: {
|
|
|
|
vendor: {
|
|
|
|
cflags: ["-DTEST"],
|
|
|
|
},
|
|
|
|
product: {
|
|
|
|
cflags: ["-DTEST"],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_sp",
|
|
|
|
vendor_available: true,
|
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
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
support_system_process: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
2019-10-30 10:43:49 +01:00
|
|
|
suffix: "-x",
|
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
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_sp_private",
|
Define vndk.private property for VNDK-private libraries
To define VNDK-private libraries, we used `vendor_available: false`.
Because of it, `vendor_available == nil` had different meaning from
`vendor_available: false` for the VNDK libraries.
To clarify this, we change the logic for defining VNDK-private
libraries which was:
cc_library {
name: "vndk_private",
vendor_available: false,
product_available: false,
vndk: {
enabled: true,
},
}
It must be replaced with
cc_library {
name: "vndk_private",
vendor_available: true,
product_available: true,
vndk: {
enabled: true,
private: true,
},
}
Bug: 175768895
Test: m nothing
Change-Id: I81769f57c2231e54b682a28e4b82631ab9f3d390
2020-12-23 10:23:14 +01:00
|
|
|
vendor_available: true,
|
2020-10-29 10:24:11 +01:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
support_system_process: true,
|
Define vndk.private property for VNDK-private libraries
To define VNDK-private libraries, we used `vendor_available: false`.
Because of it, `vendor_available == nil` had different meaning from
`vendor_available: false` for the VNDK libraries.
To clarify this, we change the logic for defining VNDK-private
libraries which was:
cc_library {
name: "vndk_private",
vendor_available: false,
product_available: false,
vndk: {
enabled: true,
},
}
It must be replaced with
cc_library {
name: "vndk_private",
vendor_available: true,
product_available: true,
vndk: {
enabled: true,
private: true,
},
}
Bug: 175768895
Test: m nothing
Change-Id: I81769f57c2231e54b682a28e4b82631ab9f3d390
2020-12-23 10:23:14 +01:00
|
|
|
private: true,
|
2020-10-29 10:24:11 +01:00
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
target: {
|
|
|
|
vendor: {
|
|
|
|
suffix: "-x",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_sp_product_private",
|
Define vndk.private property for VNDK-private libraries
To define VNDK-private libraries, we used `vendor_available: false`.
Because of it, `vendor_available == nil` had different meaning from
`vendor_available: false` for the VNDK libraries.
To clarify this, we change the logic for defining VNDK-private
libraries which was:
cc_library {
name: "vndk_private",
vendor_available: false,
product_available: false,
vndk: {
enabled: true,
},
}
It must be replaced with
cc_library {
name: "vndk_private",
vendor_available: true,
product_available: true,
vndk: {
enabled: true,
private: true,
},
}
Bug: 175768895
Test: m nothing
Change-Id: I81769f57c2231e54b682a28e4b82631ab9f3d390
2020-12-23 10:23:14 +01:00
|
|
|
vendor_available: true,
|
|
|
|
product_available: true,
|
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
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
support_system_process: true,
|
Define vndk.private property for VNDK-private libraries
To define VNDK-private libraries, we used `vendor_available: false`.
Because of it, `vendor_available == nil` had different meaning from
`vendor_available: false` for the VNDK libraries.
To clarify this, we change the logic for defining VNDK-private
libraries which was:
cc_library {
name: "vndk_private",
vendor_available: false,
product_available: false,
vndk: {
enabled: true,
},
}
It must be replaced with
cc_library {
name: "vndk_private",
vendor_available: true,
product_available: true,
vndk: {
enabled: true,
private: true,
},
}
Bug: 175768895
Test: m nothing
Change-Id: I81769f57c2231e54b682a28e4b82631ab9f3d390
2020-12-23 10:23:14 +01:00
|
|
|
private: true,
|
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
|
|
|
},
|
|
|
|
nocrt: true,
|
2019-10-30 10:43:49 +01:00
|
|
|
target: {
|
|
|
|
vendor: {
|
|
|
|
suffix: "-x",
|
|
|
|
},
|
2020-10-29 10:24:11 +01:00
|
|
|
product: {
|
|
|
|
suffix: "-x",
|
|
|
|
},
|
2019-10-30 10:43:49 +01: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
|
|
|
}
|
2020-10-29 10:24:11 +01:00
|
|
|
|
2021-04-16 12:58:18 +02:00
|
|
|
cc_library {
|
|
|
|
name: "libllndk",
|
2021-04-27 02:19:41 +02:00
|
|
|
llndk: {
|
|
|
|
symbol_file: "libllndk.map.txt",
|
|
|
|
export_llndk_headers: ["libllndk_headers"],
|
|
|
|
}
|
2021-04-16 12:58:18 +02:00
|
|
|
}
|
|
|
|
|
2021-05-24 11:17:33 +02:00
|
|
|
cc_library {
|
|
|
|
name: "libclang_rt.hwasan-llndk",
|
|
|
|
llndk: {
|
|
|
|
symbol_file: "libclang_rt.hwasan.map.txt",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-27 01:53:58 +02:00
|
|
|
cc_library_headers {
|
2021-04-16 12:58:18 +02:00
|
|
|
name: "libllndk_headers",
|
2021-04-27 01:53:58 +02:00
|
|
|
llndk: {
|
|
|
|
llndk_headers: true,
|
|
|
|
},
|
2021-04-16 12:58:18 +02:00
|
|
|
export_include_dirs: ["include"],
|
|
|
|
}
|
|
|
|
|
2020-12-28 22:50:21 +01:00
|
|
|
llndk_libraries_txt {
|
2019-11-06 08:46:15 +01:00
|
|
|
name: "llndk.libraries.txt",
|
|
|
|
}
|
2020-12-28 22:50:21 +01:00
|
|
|
vndkcore_libraries_txt {
|
2019-11-06 08:46:15 +01:00
|
|
|
name: "vndkcore.libraries.txt",
|
|
|
|
}
|
2020-12-28 22:50:21 +01:00
|
|
|
vndksp_libraries_txt {
|
2019-11-06 08:46:15 +01:00
|
|
|
name: "vndksp.libraries.txt",
|
|
|
|
}
|
2020-12-28 22:50:21 +01:00
|
|
|
vndkprivate_libraries_txt {
|
2019-11-06 08:46:15 +01:00
|
|
|
name: "vndkprivate.libraries.txt",
|
|
|
|
}
|
2020-12-28 22:50:21 +01:00
|
|
|
vndkproduct_libraries_txt {
|
2020-12-07 04:44:03 +01:00
|
|
|
name: "vndkproduct.libraries.txt",
|
|
|
|
}
|
2020-12-28 22:50:21 +01:00
|
|
|
vndkcorevariant_libraries_txt {
|
2019-11-06 08:46:15 +01:00
|
|
|
name: "vndkcorevariant.libraries.txt",
|
2020-12-28 22:50:21 +01:00
|
|
|
insert_vndk_version: false,
|
2019-11-06 08:46:15 +01:00
|
|
|
}
|
2019-12-14 05:41:13 +01:00
|
|
|
`
|
|
|
|
|
2021-03-23 00:21:32 +01:00
|
|
|
config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
|
2019-12-14 05:41:13 +01:00
|
|
|
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
|
2021-04-01 14:35:20 +02:00
|
|
|
config.TestProductVariables.Platform_vndk_version = StringPtr("29")
|
2019-12-14 05:41:13 +01:00
|
|
|
|
|
|
|
ctx := testCcWithConfig(t, config)
|
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
|
|
|
|
2020-10-20 11:54:21 +02:00
|
|
|
// subdir == "" because VNDK libs are not supposed to be installed separately.
|
|
|
|
// They are installed as part of VNDK APEX instead.
|
|
|
|
checkVndkModule(t, ctx, "libvndk", "", false, "", vendorVariant)
|
|
|
|
checkVndkModule(t, ctx, "libvndk_private", "", false, "", vendorVariant)
|
2020-10-29 10:24:11 +01:00
|
|
|
checkVndkModule(t, ctx, "libvndk_product", "", false, "", vendorVariant)
|
2020-10-20 11:54:21 +02:00
|
|
|
checkVndkModule(t, ctx, "libvndk_sp", "", true, "", vendorVariant)
|
|
|
|
checkVndkModule(t, ctx, "libvndk_sp_private", "", true, "", vendorVariant)
|
2020-10-29 10:24:11 +01:00
|
|
|
checkVndkModule(t, ctx, "libvndk_sp_product_private", "", true, "", vendorVariant)
|
2019-05-09 06:29:15 +02:00
|
|
|
|
2020-10-29 10:24:11 +01:00
|
|
|
checkVndkModule(t, ctx, "libvndk_product", "", false, "", productVariant)
|
|
|
|
checkVndkModule(t, ctx, "libvndk_sp_product_private", "", true, "", productVariant)
|
2020-10-29 08:49:43 +01:00
|
|
|
|
2019-05-09 06:29:15 +02:00
|
|
|
// Check VNDK snapshot output.
|
|
|
|
snapshotDir := "vndk-snapshot"
|
2021-03-23 00:21:32 +01:00
|
|
|
snapshotVariantPath := filepath.Join("out/soong", snapshotDir, "arm64")
|
2019-05-09 06:29:15 +02:00
|
|
|
|
|
|
|
vndkLibPath := filepath.Join(snapshotVariantPath, fmt.Sprintf("arch-%s-%s",
|
|
|
|
"arm64", "armv8-a"))
|
|
|
|
vndkLib2ndPath := filepath.Join(snapshotVariantPath, fmt.Sprintf("arch-%s-%s",
|
|
|
|
"arm", "armv7-a-neon"))
|
|
|
|
|
|
|
|
vndkCoreLibPath := filepath.Join(vndkLibPath, "shared", "vndk-core")
|
|
|
|
vndkSpLibPath := filepath.Join(vndkLibPath, "shared", "vndk-sp")
|
2021-04-16 12:58:18 +02:00
|
|
|
llndkLibPath := filepath.Join(vndkLibPath, "shared", "llndk-stub")
|
|
|
|
|
2019-05-09 06:29:15 +02:00
|
|
|
vndkCoreLib2ndPath := filepath.Join(vndkLib2ndPath, "shared", "vndk-core")
|
|
|
|
vndkSpLib2ndPath := filepath.Join(vndkLib2ndPath, "shared", "vndk-sp")
|
2021-04-16 12:58:18 +02:00
|
|
|
llndkLib2ndPath := filepath.Join(vndkLib2ndPath, "shared", "llndk-stub")
|
2019-05-09 06:29:15 +02:00
|
|
|
|
2021-04-01 14:35:20 +02:00
|
|
|
variant := "android_vendor.29_arm64_armv8-a_shared"
|
|
|
|
variant2nd := "android_vendor.29_arm_armv7-a-neon_shared"
|
2019-05-09 06:29:15 +02:00
|
|
|
|
2020-06-01 14:53:49 +02:00
|
|
|
snapshotSingleton := ctx.SingletonForTests("vndk-snapshot")
|
|
|
|
|
2021-05-20 19:01:32 +02:00
|
|
|
CheckSnapshot(t, ctx, snapshotSingleton, "libvndk", "libvndk.so", vndkCoreLibPath, variant)
|
|
|
|
CheckSnapshot(t, ctx, snapshotSingleton, "libvndk", "libvndk.so", vndkCoreLib2ndPath, variant2nd)
|
|
|
|
CheckSnapshot(t, ctx, snapshotSingleton, "libvndk_product", "libvndk_product.so", vndkCoreLibPath, variant)
|
|
|
|
CheckSnapshot(t, ctx, snapshotSingleton, "libvndk_product", "libvndk_product.so", vndkCoreLib2ndPath, variant2nd)
|
|
|
|
CheckSnapshot(t, ctx, snapshotSingleton, "libvndk_sp", "libvndk_sp-x.so", vndkSpLibPath, variant)
|
|
|
|
CheckSnapshot(t, ctx, snapshotSingleton, "libvndk_sp", "libvndk_sp-x.so", vndkSpLib2ndPath, variant2nd)
|
|
|
|
CheckSnapshot(t, ctx, snapshotSingleton, "libllndk", "libllndk.so", llndkLibPath, variant)
|
|
|
|
CheckSnapshot(t, ctx, snapshotSingleton, "libllndk", "libllndk.so", llndkLib2ndPath, variant2nd)
|
2019-11-06 08:53:07 +01:00
|
|
|
|
|
|
|
snapshotConfigsPath := filepath.Join(snapshotVariantPath, "configs")
|
2021-11-12 07:47:54 +01:00
|
|
|
CheckSnapshot(t, ctx, snapshotSingleton, "llndk.libraries.txt", "llndk.libraries.txt", snapshotConfigsPath, "android_common")
|
|
|
|
CheckSnapshot(t, ctx, snapshotSingleton, "vndkcore.libraries.txt", "vndkcore.libraries.txt", snapshotConfigsPath, "android_common")
|
|
|
|
CheckSnapshot(t, ctx, snapshotSingleton, "vndksp.libraries.txt", "vndksp.libraries.txt", snapshotConfigsPath, "android_common")
|
|
|
|
CheckSnapshot(t, ctx, snapshotSingleton, "vndkprivate.libraries.txt", "vndkprivate.libraries.txt", snapshotConfigsPath, "android_common")
|
|
|
|
CheckSnapshot(t, ctx, snapshotSingleton, "vndkproduct.libraries.txt", "vndkproduct.libraries.txt", snapshotConfigsPath, "android_common")
|
2019-10-22 12:32:18 +02:00
|
|
|
|
|
|
|
checkVndkOutput(t, ctx, "vndk/vndk.libraries.txt", []string{
|
|
|
|
"LLNDK: libc.so",
|
|
|
|
"LLNDK: libdl.so",
|
|
|
|
"LLNDK: libft2.so",
|
2021-04-16 12:58:18 +02:00
|
|
|
"LLNDK: libllndk.so",
|
2019-10-22 12:32:18 +02:00
|
|
|
"LLNDK: libm.so",
|
|
|
|
"VNDK-SP: libc++.so",
|
2019-10-30 10:43:49 +01:00
|
|
|
"VNDK-SP: libvndk_sp-x.so",
|
|
|
|
"VNDK-SP: libvndk_sp_private-x.so",
|
2020-10-29 10:24:11 +01:00
|
|
|
"VNDK-SP: libvndk_sp_product_private-x.so",
|
2019-10-30 10:43:49 +01:00
|
|
|
"VNDK-core: libvndk-private.so",
|
2019-10-22 12:32:18 +02:00
|
|
|
"VNDK-core: libvndk.so",
|
2020-10-29 10:24:11 +01:00
|
|
|
"VNDK-core: libvndk_product.so",
|
2019-10-22 12:32:18 +02:00
|
|
|
"VNDK-private: libft2.so",
|
2019-10-30 10:43:49 +01:00
|
|
|
"VNDK-private: libvndk-private.so",
|
|
|
|
"VNDK-private: libvndk_sp_private-x.so",
|
2020-10-29 10:24:11 +01:00
|
|
|
"VNDK-private: libvndk_sp_product_private-x.so",
|
2020-12-07 04:44:03 +01:00
|
|
|
"VNDK-product: libc++.so",
|
|
|
|
"VNDK-product: libvndk_product.so",
|
|
|
|
"VNDK-product: libvndk_sp_product_private-x.so",
|
2019-10-30 10:43:49 +01:00
|
|
|
})
|
2021-05-24 11:17:33 +02:00
|
|
|
checkVndkLibrariesOutput(t, ctx, "llndk.libraries.txt", []string{"libc.so", "libclang_rt.hwasan-llndk.so", "libdl.so", "libft2.so", "libllndk.so", "libm.so"})
|
2020-10-29 10:24:11 +01:00
|
|
|
checkVndkLibrariesOutput(t, ctx, "vndkcore.libraries.txt", []string{"libvndk-private.so", "libvndk.so", "libvndk_product.so"})
|
|
|
|
checkVndkLibrariesOutput(t, ctx, "vndksp.libraries.txt", []string{"libc++.so", "libvndk_sp-x.so", "libvndk_sp_private-x.so", "libvndk_sp_product_private-x.so"})
|
|
|
|
checkVndkLibrariesOutput(t, ctx, "vndkprivate.libraries.txt", []string{"libft2.so", "libvndk-private.so", "libvndk_sp_private-x.so", "libvndk_sp_product_private-x.so"})
|
2020-12-07 04:44:03 +01:00
|
|
|
checkVndkLibrariesOutput(t, ctx, "vndkproduct.libraries.txt", []string{"libc++.so", "libvndk_product.so", "libvndk_sp_product_private-x.so"})
|
2019-11-06 08:46:15 +01:00
|
|
|
checkVndkLibrariesOutput(t, ctx, "vndkcorevariant.libraries.txt", nil)
|
|
|
|
}
|
|
|
|
|
2020-06-09 10:15:37 +02:00
|
|
|
func TestVndkWithHostSupported(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2020-06-09 10:15:37 +02:00
|
|
|
ctx := testCc(t, `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_host_supported",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2020-06-09 10:15:37 +02:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
host_supported: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_host_supported_but_disabled_on_device",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2020-06-09 10:15:37 +02:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
host_supported: true,
|
|
|
|
enabled: false,
|
|
|
|
target: {
|
|
|
|
host: {
|
|
|
|
enabled: true,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-28 22:50:21 +01:00
|
|
|
vndkcore_libraries_txt {
|
2020-06-09 10:15:37 +02:00
|
|
|
name: "vndkcore.libraries.txt",
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
checkVndkLibrariesOutput(t, ctx, "vndkcore.libraries.txt", []string{"libvndk_host_supported.so"})
|
|
|
|
}
|
|
|
|
|
2019-11-06 08:46:15 +01:00
|
|
|
func TestVndkLibrariesTxtAndroidMk(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2019-12-14 05:41:13 +01:00
|
|
|
bp := `
|
2020-12-28 22:50:21 +01:00
|
|
|
llndk_libraries_txt {
|
2019-11-06 08:46:15 +01:00
|
|
|
name: "llndk.libraries.txt",
|
2020-12-28 22:50:21 +01:00
|
|
|
insert_vndk_version: true,
|
2019-12-14 05:41:13 +01:00
|
|
|
}`
|
2021-03-23 00:21:32 +01:00
|
|
|
config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
|
2019-12-14 05:41:13 +01:00
|
|
|
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
|
2021-04-01 14:35:20 +02:00
|
|
|
config.TestProductVariables.Platform_vndk_version = StringPtr("29")
|
2023-08-11 03:14:43 +02:00
|
|
|
config.TestProductVariables.KeepVndk = BoolPtr(true)
|
2019-12-14 05:41:13 +01:00
|
|
|
ctx := testCcWithConfig(t, config)
|
2019-11-06 08:46:15 +01:00
|
|
|
|
2021-11-12 07:47:54 +01:00
|
|
|
module := ctx.ModuleForTests("llndk.libraries.txt", "android_common")
|
2020-07-03 22:18:24 +02:00
|
|
|
entries := android.AndroidMkEntriesForTest(t, ctx, module.Module())[0]
|
2021-04-01 14:35:20 +02:00
|
|
|
assertArrayString(t, entries.EntryMap["LOCAL_MODULE_STEM"], []string{"llndk.libraries.29.txt"})
|
2019-10-22 12:32:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestVndkUsingCoreVariant(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2019-12-14 05:41:13 +01:00
|
|
|
bp := `
|
2019-10-22 12:32:18 +02:00
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2019-10-22 12:32:18 +02:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_sp",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2019-10-22 12:32:18 +02:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
support_system_process: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk2",
|
Define vndk.private property for VNDK-private libraries
To define VNDK-private libraries, we used `vendor_available: false`.
Because of it, `vendor_available == nil` had different meaning from
`vendor_available: false` for the VNDK libraries.
To clarify this, we change the logic for defining VNDK-private
libraries which was:
cc_library {
name: "vndk_private",
vendor_available: false,
product_available: false,
vndk: {
enabled: true,
},
}
It must be replaced with
cc_library {
name: "vndk_private",
vendor_available: true,
product_available: true,
vndk: {
enabled: true,
private: true,
},
}
Bug: 175768895
Test: m nothing
Change-Id: I81769f57c2231e54b682a28e4b82631ab9f3d390
2020-12-23 10:23:14 +01:00
|
|
|
vendor_available: true,
|
|
|
|
product_available: true,
|
2019-10-22 12:32:18 +02:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
Define vndk.private property for VNDK-private libraries
To define VNDK-private libraries, we used `vendor_available: false`.
Because of it, `vendor_available == nil` had different meaning from
`vendor_available: false` for the VNDK libraries.
To clarify this, we change the logic for defining VNDK-private
libraries which was:
cc_library {
name: "vndk_private",
vendor_available: false,
product_available: false,
vndk: {
enabled: true,
},
}
It must be replaced with
cc_library {
name: "vndk_private",
vendor_available: true,
product_available: true,
vndk: {
enabled: true,
private: true,
},
}
Bug: 175768895
Test: m nothing
Change-Id: I81769f57c2231e54b682a28e4b82631ab9f3d390
2020-12-23 10:23:14 +01:00
|
|
|
private: true,
|
2019-10-22 12:32:18 +02:00
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
2019-11-06 08:46:15 +01:00
|
|
|
|
2020-12-28 22:50:21 +01:00
|
|
|
vndkcorevariant_libraries_txt {
|
2019-11-06 08:46:15 +01:00
|
|
|
name: "vndkcorevariant.libraries.txt",
|
2020-12-28 22:50:21 +01:00
|
|
|
insert_vndk_version: false,
|
2019-11-06 08:46:15 +01:00
|
|
|
}
|
2019-12-14 05:41:13 +01:00
|
|
|
`
|
|
|
|
|
2021-03-23 00:21:32 +01:00
|
|
|
config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
|
2019-12-14 05:41:13 +01:00
|
|
|
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
|
2021-04-01 14:35:20 +02:00
|
|
|
config.TestProductVariables.Platform_vndk_version = StringPtr("29")
|
2019-12-14 05:41:13 +01:00
|
|
|
config.TestProductVariables.VndkUseCoreVariant = BoolPtr(true)
|
2023-10-06 07:12:43 +02:00
|
|
|
config.TestProductVariables.KeepVndk = BoolPtr(true)
|
2019-12-14 05:41:13 +01:00
|
|
|
|
|
|
|
setVndkMustUseVendorVariantListForTest(config, []string{"libvndk"})
|
|
|
|
|
|
|
|
ctx := testCcWithConfig(t, config)
|
2019-10-22 12:32:18 +02:00
|
|
|
|
2019-11-06 08:46:15 +01:00
|
|
|
checkVndkLibrariesOutput(t, ctx, "vndkcorevariant.libraries.txt", []string{"libc++.so", "libvndk2.so", "libvndk_sp.so"})
|
2019-10-30 10:43:49 +01:00
|
|
|
}
|
|
|
|
|
2020-06-05 23:26:16 +02:00
|
|
|
func TestDataLibs(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2020-06-05 23:26:16 +02:00
|
|
|
bp := `
|
|
|
|
cc_test_library {
|
|
|
|
name: "test_lib",
|
|
|
|
srcs: ["test_lib.cpp"],
|
|
|
|
gtest: false,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_test {
|
|
|
|
name: "main_test",
|
|
|
|
data_libs: ["test_lib"],
|
|
|
|
gtest: false,
|
|
|
|
}
|
2020-07-09 23:12:52 +02:00
|
|
|
`
|
2020-06-05 23:26:16 +02:00
|
|
|
|
2021-03-23 00:21:32 +01:00
|
|
|
config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
|
2020-06-05 23:26:16 +02:00
|
|
|
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
|
2021-04-01 14:35:20 +02:00
|
|
|
config.TestProductVariables.Platform_vndk_version = StringPtr("29")
|
2020-06-05 23:26:16 +02:00
|
|
|
config.TestProductVariables.VndkUseCoreVariant = BoolPtr(true)
|
|
|
|
|
|
|
|
ctx := testCcWithConfig(t, config)
|
|
|
|
module := ctx.ModuleForTests("main_test", "android_arm_armv7-a-neon").Module()
|
|
|
|
testBinary := module.(*Module).linker.(*testBinary)
|
|
|
|
outputFiles, err := module.(android.OutputFileProducer).OutputFiles("")
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("Expected cc_test to produce output files, error: %s", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if len(outputFiles) != 1 {
|
|
|
|
t.Errorf("expected exactly one output file. output files: [%s]", outputFiles)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if len(testBinary.dataPaths()) != 1 {
|
2023-11-16 21:56:02 +01:00
|
|
|
t.Errorf("expected exactly one test data file. test data files: [%v]", testBinary.dataPaths())
|
2020-06-05 23:26:16 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
outputPath := outputFiles[0].String()
|
2020-07-09 23:12:52 +02:00
|
|
|
testBinaryPath := testBinary.dataPaths()[0].SrcPath.String()
|
2020-06-05 23:26:16 +02:00
|
|
|
|
|
|
|
if !strings.HasSuffix(outputPath, "/main_test") {
|
|
|
|
t.Errorf("expected test output file to be 'main_test', but was '%s'", outputPath)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if !strings.HasSuffix(testBinaryPath, "/test_lib.so") {
|
|
|
|
t.Errorf("expected test data file to be 'test_lib.so', but was '%s'", testBinaryPath)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-09 23:12:52 +02:00
|
|
|
func TestDataLibsRelativeInstallPath(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2020-07-09 23:12:52 +02:00
|
|
|
bp := `
|
|
|
|
cc_test_library {
|
|
|
|
name: "test_lib",
|
|
|
|
srcs: ["test_lib.cpp"],
|
|
|
|
relative_install_path: "foo/bar/baz",
|
|
|
|
gtest: false,
|
|
|
|
}
|
|
|
|
|
2021-11-04 19:09:38 +01:00
|
|
|
cc_binary {
|
|
|
|
name: "test_bin",
|
|
|
|
relative_install_path: "foo/bar/baz",
|
|
|
|
compile_multilib: "both",
|
|
|
|
}
|
|
|
|
|
2020-07-09 23:12:52 +02:00
|
|
|
cc_test {
|
|
|
|
name: "main_test",
|
|
|
|
data_libs: ["test_lib"],
|
2021-11-04 19:09:38 +01:00
|
|
|
data_bins: ["test_bin"],
|
2020-07-09 23:12:52 +02:00
|
|
|
gtest: false,
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
2021-03-23 00:21:32 +01:00
|
|
|
config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
|
2020-07-09 23:12:52 +02:00
|
|
|
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
|
2021-04-01 14:35:20 +02:00
|
|
|
config.TestProductVariables.Platform_vndk_version = StringPtr("29")
|
2020-07-09 23:12:52 +02:00
|
|
|
config.TestProductVariables.VndkUseCoreVariant = BoolPtr(true)
|
|
|
|
|
|
|
|
ctx := testCcWithConfig(t, config)
|
|
|
|
module := ctx.ModuleForTests("main_test", "android_arm_armv7-a-neon").Module()
|
|
|
|
testBinary := module.(*Module).linker.(*testBinary)
|
|
|
|
outputFiles, err := module.(android.OutputFileProducer).OutputFiles("")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("Expected cc_test to produce output files, error: %s", err)
|
|
|
|
}
|
|
|
|
if len(outputFiles) != 1 {
|
2021-11-04 19:09:38 +01:00
|
|
|
t.Fatalf("expected exactly one output file. output files: [%s]", outputFiles)
|
2020-07-09 23:12:52 +02:00
|
|
|
}
|
2021-11-04 19:09:38 +01:00
|
|
|
if len(testBinary.dataPaths()) != 2 {
|
2023-11-16 21:56:02 +01:00
|
|
|
t.Fatalf("expected exactly one test data file. test data files: [%v]", testBinary.dataPaths())
|
2020-07-09 23:12:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
outputPath := outputFiles[0].String()
|
|
|
|
|
|
|
|
if !strings.HasSuffix(outputPath, "/main_test") {
|
|
|
|
t.Errorf("expected test output file to be 'main_test', but was '%s'", outputPath)
|
|
|
|
}
|
2020-07-03 22:18:24 +02:00
|
|
|
entries := android.AndroidMkEntriesForTest(t, ctx, module)[0]
|
2020-07-09 23:12:52 +02:00
|
|
|
if !strings.HasSuffix(entries.EntryMap["LOCAL_TEST_DATA"][0], ":test_lib.so:foo/bar/baz") {
|
|
|
|
t.Errorf("expected LOCAL_TEST_DATA to end with `:test_lib.so:foo/bar/baz`,"+
|
2020-06-17 22:10:42 +02:00
|
|
|
" but was '%s'", entries.EntryMap["LOCAL_TEST_DATA"][0])
|
2020-07-09 23:12:52 +02:00
|
|
|
}
|
2021-11-04 19:09:38 +01:00
|
|
|
if !strings.HasSuffix(entries.EntryMap["LOCAL_TEST_DATA"][1], ":test_bin:foo/bar/baz") {
|
|
|
|
t.Errorf("expected LOCAL_TEST_DATA to end with `:test_bin:foo/bar/baz`,"+
|
|
|
|
" but was '%s'", entries.EntryMap["LOCAL_TEST_DATA"][1])
|
|
|
|
}
|
2020-07-09 23:12:52 +02:00
|
|
|
}
|
|
|
|
|
2022-03-24 22:06:14 +01:00
|
|
|
func TestTestBinaryTestSuites(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2022-03-24 22:06:14 +01:00
|
|
|
bp := `
|
|
|
|
cc_test {
|
|
|
|
name: "main_test",
|
|
|
|
srcs: ["main_test.cpp"],
|
|
|
|
test_suites: [
|
|
|
|
"suite_1",
|
|
|
|
"suite_2",
|
|
|
|
],
|
|
|
|
gtest: false,
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
ctx := prepareForCcTest.RunTestWithBp(t, bp).TestContext
|
|
|
|
module := ctx.ModuleForTests("main_test", "android_arm_armv7-a-neon").Module()
|
|
|
|
|
|
|
|
entries := android.AndroidMkEntriesForTest(t, ctx, module)[0]
|
|
|
|
compatEntries := entries.EntryMap["LOCAL_COMPATIBILITY_SUITE"]
|
|
|
|
if len(compatEntries) != 2 {
|
|
|
|
t.Errorf("expected two elements in LOCAL_COMPATIBILITY_SUITE. got %d", len(compatEntries))
|
|
|
|
}
|
|
|
|
if compatEntries[0] != "suite_1" {
|
|
|
|
t.Errorf("expected LOCAL_COMPATIBILITY_SUITE to be`suite_1`,"+
|
|
|
|
" but was '%s'", compatEntries[0])
|
|
|
|
}
|
|
|
|
if compatEntries[1] != "suite_2" {
|
|
|
|
t.Errorf("expected LOCAL_COMPATIBILITY_SUITE to be`suite_2`,"+
|
|
|
|
" but was '%s'", compatEntries[1])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestTestLibraryTestSuites(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2022-03-24 22:06:14 +01:00
|
|
|
bp := `
|
|
|
|
cc_test_library {
|
|
|
|
name: "main_test_lib",
|
|
|
|
srcs: ["main_test_lib.cpp"],
|
|
|
|
test_suites: [
|
|
|
|
"suite_1",
|
|
|
|
"suite_2",
|
|
|
|
],
|
|
|
|
gtest: false,
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
ctx := prepareForCcTest.RunTestWithBp(t, bp).TestContext
|
|
|
|
module := ctx.ModuleForTests("main_test_lib", "android_arm_armv7-a-neon_shared").Module()
|
|
|
|
|
|
|
|
entries := android.AndroidMkEntriesForTest(t, ctx, module)[0]
|
|
|
|
compatEntries := entries.EntryMap["LOCAL_COMPATIBILITY_SUITE"]
|
|
|
|
if len(compatEntries) != 2 {
|
|
|
|
t.Errorf("expected two elements in LOCAL_COMPATIBILITY_SUITE. got %d", len(compatEntries))
|
|
|
|
}
|
|
|
|
if compatEntries[0] != "suite_1" {
|
|
|
|
t.Errorf("expected LOCAL_COMPATIBILITY_SUITE to be`suite_1`,"+
|
|
|
|
" but was '%s'", compatEntries[0])
|
|
|
|
}
|
|
|
|
if compatEntries[1] != "suite_2" {
|
|
|
|
t.Errorf("expected LOCAL_COMPATIBILITY_SUITE to be`suite_2`,"+
|
|
|
|
" but was '%s'", compatEntries[1])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-29 08:49:43 +01:00
|
|
|
func TestVndkModuleError(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2020-10-29 08:49:43 +01:00
|
|
|
// Check the error message for vendor_available and product_available properties.
|
2021-01-07 09:45:31 +01:00
|
|
|
testCcErrorProductVndk(t, "vndk: vendor_available must be set to true when `vndk: {enabled: true}`", `
|
2020-10-29 10:24:11 +01:00
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
2021-01-07 09:45:31 +01:00
|
|
|
testCcErrorProductVndk(t, "vndk: vendor_available must be set to true when `vndk: {enabled: true}`", `
|
2020-10-29 10:24:11 +01:00
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
product_available: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
testCcErrorProductVndk(t, "product properties must have the same values with the vendor properties for VNDK modules", `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndkprop",
|
|
|
|
vendor_available: true,
|
|
|
|
product_available: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
target: {
|
|
|
|
vendor: {
|
|
|
|
cflags: ["-DTEST",],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
`)
|
2020-10-29 08:49:43 +01:00
|
|
|
}
|
|
|
|
|
2018-03-29 08:08:15 +02:00
|
|
|
func TestVndkDepError(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2018-03-29 08:08:15 +02:00
|
|
|
// Check whether an error is emitted when a VNDK lib depends on a system lib.
|
|
|
|
testCcError(t, "dependency \".*\" of \".*\" missing variant", `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2018-03-29 08:08:15 +02:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
shared_libs: ["libfwk"], // Cause error
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libfwk",
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
// Check whether an error is emitted when a VNDK lib depends on a vendor lib.
|
|
|
|
testCcError(t, "dependency \".*\" of \".*\" missing variant", `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2018-03-29 08:08:15 +02:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
shared_libs: ["libvendor"], // Cause error
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvendor",
|
|
|
|
vendor: true,
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
// Check whether an error is emitted when a VNDK-SP lib depends on a system lib.
|
|
|
|
testCcError(t, "dependency \".*\" of \".*\" missing variant", `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_sp",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2018-03-29 08:08:15 +02:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
support_system_process: true,
|
|
|
|
},
|
|
|
|
shared_libs: ["libfwk"], // Cause error
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libfwk",
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
// Check whether an error is emitted when a VNDK-SP lib depends on a vendor lib.
|
|
|
|
testCcError(t, "dependency \".*\" of \".*\" missing variant", `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_sp",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2018-03-29 08:08:15 +02:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
support_system_process: true,
|
|
|
|
},
|
|
|
|
shared_libs: ["libvendor"], // Cause error
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvendor",
|
|
|
|
vendor: true,
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
// Check whether an error is emitted when a VNDK-SP lib depends on a VNDK lib.
|
|
|
|
testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_sp",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2018-03-29 08:08:15 +02:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
support_system_process: true,
|
|
|
|
},
|
|
|
|
shared_libs: ["libvndk"], // Cause error
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2018-03-29 08:08:15 +02:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
2019-01-18 07:20:43 +01:00
|
|
|
|
|
|
|
// Check whether an error is emitted when a VNDK lib depends on a non-VNDK lib.
|
|
|
|
testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2019-01-18 07:20:43 +01:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
shared_libs: ["libnonvndk"],
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libnonvndk",
|
|
|
|
vendor_available: true,
|
2023-09-27 09:22:10 +02:00
|
|
|
product_available: true,
|
2019-01-18 07:20:43 +01:00
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
// Check whether an error is emitted when a VNDK-private lib depends on a non-VNDK lib.
|
|
|
|
testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndkprivate",
|
Define vndk.private property for VNDK-private libraries
To define VNDK-private libraries, we used `vendor_available: false`.
Because of it, `vendor_available == nil` had different meaning from
`vendor_available: false` for the VNDK libraries.
To clarify this, we change the logic for defining VNDK-private
libraries which was:
cc_library {
name: "vndk_private",
vendor_available: false,
product_available: false,
vndk: {
enabled: true,
},
}
It must be replaced with
cc_library {
name: "vndk_private",
vendor_available: true,
product_available: true,
vndk: {
enabled: true,
private: true,
},
}
Bug: 175768895
Test: m nothing
Change-Id: I81769f57c2231e54b682a28e4b82631ab9f3d390
2020-12-23 10:23:14 +01:00
|
|
|
vendor_available: true,
|
|
|
|
product_available: true,
|
2019-01-18 07:20:43 +01:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
Define vndk.private property for VNDK-private libraries
To define VNDK-private libraries, we used `vendor_available: false`.
Because of it, `vendor_available == nil` had different meaning from
`vendor_available: false` for the VNDK libraries.
To clarify this, we change the logic for defining VNDK-private
libraries which was:
cc_library {
name: "vndk_private",
vendor_available: false,
product_available: false,
vndk: {
enabled: true,
},
}
It must be replaced with
cc_library {
name: "vndk_private",
vendor_available: true,
product_available: true,
vndk: {
enabled: true,
private: true,
},
}
Bug: 175768895
Test: m nothing
Change-Id: I81769f57c2231e54b682a28e4b82631ab9f3d390
2020-12-23 10:23:14 +01:00
|
|
|
private: true,
|
2019-01-18 07:20:43 +01:00
|
|
|
},
|
|
|
|
shared_libs: ["libnonvndk"],
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libnonvndk",
|
|
|
|
vendor_available: true,
|
2023-09-27 09:22:10 +02:00
|
|
|
product_available: true,
|
2019-01-18 07:20:43 +01:00
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
// Check whether an error is emitted when a VNDK-sp lib depends on a non-VNDK lib.
|
|
|
|
testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndksp",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2019-01-18 07:20:43 +01:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
support_system_process: true,
|
|
|
|
},
|
|
|
|
shared_libs: ["libnonvndk"],
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libnonvndk",
|
|
|
|
vendor_available: true,
|
2023-09-27 09:22:10 +02:00
|
|
|
product_available: true,
|
2019-01-18 07:20:43 +01:00
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
// Check whether an error is emitted when a VNDK-sp-private lib depends on a non-VNDK lib.
|
|
|
|
testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndkspprivate",
|
Define vndk.private property for VNDK-private libraries
To define VNDK-private libraries, we used `vendor_available: false`.
Because of it, `vendor_available == nil` had different meaning from
`vendor_available: false` for the VNDK libraries.
To clarify this, we change the logic for defining VNDK-private
libraries which was:
cc_library {
name: "vndk_private",
vendor_available: false,
product_available: false,
vndk: {
enabled: true,
},
}
It must be replaced with
cc_library {
name: "vndk_private",
vendor_available: true,
product_available: true,
vndk: {
enabled: true,
private: true,
},
}
Bug: 175768895
Test: m nothing
Change-Id: I81769f57c2231e54b682a28e4b82631ab9f3d390
2020-12-23 10:23:14 +01:00
|
|
|
vendor_available: true,
|
|
|
|
product_available: true,
|
2019-01-18 07:20:43 +01:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
support_system_process: true,
|
Define vndk.private property for VNDK-private libraries
To define VNDK-private libraries, we used `vendor_available: false`.
Because of it, `vendor_available == nil` had different meaning from
`vendor_available: false` for the VNDK libraries.
To clarify this, we change the logic for defining VNDK-private
libraries which was:
cc_library {
name: "vndk_private",
vendor_available: false,
product_available: false,
vndk: {
enabled: true,
},
}
It must be replaced with
cc_library {
name: "vndk_private",
vendor_available: true,
product_available: true,
vndk: {
enabled: true,
private: true,
},
}
Bug: 175768895
Test: m nothing
Change-Id: I81769f57c2231e54b682a28e4b82631ab9f3d390
2020-12-23 10:23:14 +01:00
|
|
|
private: true,
|
2019-01-18 07:20:43 +01:00
|
|
|
},
|
|
|
|
shared_libs: ["libnonvndk"],
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libnonvndk",
|
|
|
|
vendor_available: true,
|
2023-09-27 09:22:10 +02:00
|
|
|
product_available: true,
|
2019-01-18 07:20:43 +01:00
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDoubleLoadbleDep(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2019-01-18 07:20:43 +01:00
|
|
|
// okay to link : LLNDK -> double_loadable VNDK
|
|
|
|
testCc(t, `
|
|
|
|
cc_library {
|
|
|
|
name: "libllndk",
|
|
|
|
shared_libs: ["libdoubleloadable"],
|
2021-04-27 02:19:41 +02:00
|
|
|
llndk: {
|
|
|
|
symbol_file: "libllndk.map.txt",
|
|
|
|
}
|
2019-01-18 07:20:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libdoubleloadable",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2019-01-18 07:20:43 +01:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
double_loadable: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
// okay to link : LLNDK -> VNDK-SP
|
|
|
|
testCc(t, `
|
|
|
|
cc_library {
|
|
|
|
name: "libllndk",
|
|
|
|
shared_libs: ["libvndksp"],
|
2021-04-27 02:19:41 +02:00
|
|
|
llndk: {
|
|
|
|
symbol_file: "libllndk.map.txt",
|
|
|
|
}
|
2019-01-18 07:20:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndksp",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2019-01-18 07:20:43 +01:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
support_system_process: true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
// okay to link : double_loadable -> double_loadable
|
|
|
|
testCc(t, `
|
|
|
|
cc_library {
|
|
|
|
name: "libdoubleloadable1",
|
|
|
|
shared_libs: ["libdoubleloadable2"],
|
|
|
|
vendor_available: true,
|
|
|
|
double_loadable: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libdoubleloadable2",
|
|
|
|
vendor_available: true,
|
|
|
|
double_loadable: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
// okay to link : double_loadable VNDK -> double_loadable VNDK private
|
|
|
|
testCc(t, `
|
|
|
|
cc_library {
|
|
|
|
name: "libdoubleloadable",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2019-01-18 07:20:43 +01:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
double_loadable: true,
|
|
|
|
shared_libs: ["libnondoubleloadable"],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libnondoubleloadable",
|
Define vndk.private property for VNDK-private libraries
To define VNDK-private libraries, we used `vendor_available: false`.
Because of it, `vendor_available == nil` had different meaning from
`vendor_available: false` for the VNDK libraries.
To clarify this, we change the logic for defining VNDK-private
libraries which was:
cc_library {
name: "vndk_private",
vendor_available: false,
product_available: false,
vndk: {
enabled: true,
},
}
It must be replaced with
cc_library {
name: "vndk_private",
vendor_available: true,
product_available: true,
vndk: {
enabled: true,
private: true,
},
}
Bug: 175768895
Test: m nothing
Change-Id: I81769f57c2231e54b682a28e4b82631ab9f3d390
2020-12-23 10:23:14 +01:00
|
|
|
vendor_available: true,
|
|
|
|
product_available: true,
|
2019-01-18 07:20:43 +01:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
Define vndk.private property for VNDK-private libraries
To define VNDK-private libraries, we used `vendor_available: false`.
Because of it, `vendor_available == nil` had different meaning from
`vendor_available: false` for the VNDK libraries.
To clarify this, we change the logic for defining VNDK-private
libraries which was:
cc_library {
name: "vndk_private",
vendor_available: false,
product_available: false,
vndk: {
enabled: true,
},
}
It must be replaced with
cc_library {
name: "vndk_private",
vendor_available: true,
product_available: true,
vndk: {
enabled: true,
private: true,
},
}
Bug: 175768895
Test: m nothing
Change-Id: I81769f57c2231e54b682a28e4b82631ab9f3d390
2020-12-23 10:23:14 +01:00
|
|
|
private: true,
|
2019-01-18 07:20:43 +01:00
|
|
|
},
|
|
|
|
double_loadable: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
// okay to link : LLNDK -> core-only -> vendor_available & double_loadable
|
|
|
|
testCc(t, `
|
|
|
|
cc_library {
|
|
|
|
name: "libllndk",
|
|
|
|
shared_libs: ["libcoreonly"],
|
2021-04-27 02:19:41 +02:00
|
|
|
llndk: {
|
|
|
|
symbol_file: "libllndk.map.txt",
|
|
|
|
}
|
2019-01-18 07:20:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libcoreonly",
|
|
|
|
shared_libs: ["libvendoravailable"],
|
|
|
|
}
|
|
|
|
|
|
|
|
// indirect dependency of LLNDK
|
|
|
|
cc_library {
|
|
|
|
name: "libvendoravailable",
|
|
|
|
vendor_available: true,
|
|
|
|
double_loadable: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDoubleLoadableDepError(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2019-01-18 07:20:43 +01:00
|
|
|
// Check whether an error is emitted when a LLNDK depends on a non-double_loadable VNDK lib.
|
|
|
|
testCcError(t, "module \".*\" variant \".*\": link.* \".*\" which is not LL-NDK, VNDK-SP, .*double_loadable", `
|
|
|
|
cc_library {
|
|
|
|
name: "libllndk",
|
|
|
|
shared_libs: ["libnondoubleloadable"],
|
2021-04-27 02:19:41 +02:00
|
|
|
llndk: {
|
|
|
|
symbol_file: "libllndk.map.txt",
|
|
|
|
}
|
2019-01-18 07:20:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libnondoubleloadable",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2019-01-18 07:20:43 +01:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
// Check whether an error is emitted when a LLNDK depends on a non-double_loadable vendor_available lib.
|
|
|
|
testCcError(t, "module \".*\" variant \".*\": link.* \".*\" which is not LL-NDK, VNDK-SP, .*double_loadable", `
|
|
|
|
cc_library {
|
|
|
|
name: "libllndk",
|
2019-06-02 09:53:50 +02:00
|
|
|
no_libcrt: true,
|
2019-01-18 07:20:43 +01:00
|
|
|
shared_libs: ["libnondoubleloadable"],
|
2021-04-27 02:19:41 +02:00
|
|
|
llndk: {
|
|
|
|
symbol_file: "libllndk.map.txt",
|
|
|
|
}
|
2019-01-18 07:20:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libnondoubleloadable",
|
|
|
|
vendor_available: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
2021-01-14 06:26:06 +01:00
|
|
|
// Check whether an error is emitted when a LLNDK depends on a non-double_loadable indirectly.
|
2019-01-18 07:20:43 +01:00
|
|
|
testCcError(t, "module \".*\" variant \".*\": link.* \".*\" which is not LL-NDK, VNDK-SP, .*double_loadable", `
|
|
|
|
cc_library {
|
2021-01-14 06:26:06 +01:00
|
|
|
name: "libllndk",
|
|
|
|
shared_libs: ["libcoreonly"],
|
2021-04-27 02:19:41 +02:00
|
|
|
llndk: {
|
|
|
|
symbol_file: "libllndk.map.txt",
|
|
|
|
}
|
2019-01-18 07:20:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
2021-01-14 06:26:06 +01:00
|
|
|
name: "libcoreonly",
|
|
|
|
shared_libs: ["libvendoravailable"],
|
2019-01-18 07:20:43 +01:00
|
|
|
}
|
|
|
|
|
2021-01-14 06:26:06 +01:00
|
|
|
// indirect dependency of LLNDK
|
2019-01-18 07:20:43 +01:00
|
|
|
cc_library {
|
2021-01-14 06:26:06 +01:00
|
|
|
name: "libvendoravailable",
|
2019-01-18 07:20:43 +01:00
|
|
|
vendor_available: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
2021-01-14 06:26:06 +01:00
|
|
|
// The error is not from 'client' but from 'libllndk'
|
|
|
|
testCcError(t, "module \"libllndk\".* links a library \"libnondoubleloadable\".*double_loadable", `
|
2019-01-18 07:20:43 +01:00
|
|
|
cc_library {
|
2021-01-14 06:26:06 +01:00
|
|
|
name: "client",
|
2019-01-18 07:20:43 +01:00
|
|
|
vendor_available: true,
|
|
|
|
double_loadable: true,
|
2021-01-14 06:26:06 +01:00
|
|
|
shared_libs: ["libllndk"],
|
2019-01-18 07:20:43 +01:00
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libllndk",
|
2021-01-14 06:26:06 +01:00
|
|
|
shared_libs: ["libnondoubleloadable"],
|
2021-04-27 02:19:41 +02:00
|
|
|
llndk: {
|
|
|
|
symbol_file: "libllndk.map.txt",
|
|
|
|
}
|
2019-01-18 07:20:43 +01:00
|
|
|
}
|
|
|
|
cc_library {
|
2021-01-14 06:26:06 +01:00
|
|
|
name: "libnondoubleloadable",
|
2019-01-18 07:20:43 +01:00
|
|
|
vendor_available: true,
|
|
|
|
}
|
|
|
|
`)
|
2018-03-29 08:08:15 +02:00
|
|
|
}
|
|
|
|
|
2020-10-19 11:51:07 +02:00
|
|
|
func TestCheckVndkMembershipBeforeDoubleLoadable(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2020-10-19 11:51:07 +02:00
|
|
|
testCcError(t, "module \"libvndksp\" variant .*: .*: VNDK-SP must only depend on VNDK-SP", `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndksp",
|
|
|
|
shared_libs: ["libanothervndksp"],
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2020-10-19 11:51:07 +02:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
support_system_process: true,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libllndk",
|
|
|
|
shared_libs: ["libanothervndksp"],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libanothervndksp",
|
|
|
|
vendor_available: true,
|
2023-09-27 09:22:10 +02:00
|
|
|
product_available: true,
|
2020-10-19 11:51:07 +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
|
|
|
func TestVndkExt(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
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
|
|
|
// This test checks the VNDK-Ext properties.
|
2020-02-28 07:07:59 +01:00
|
|
|
bp := `
|
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
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
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
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
2019-10-22 12:53:47 +02:00
|
|
|
cc_library {
|
|
|
|
name: "libvndk2",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2019-10-22 12:53:47 +02:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
target: {
|
|
|
|
vendor: {
|
|
|
|
suffix: "-suffix",
|
|
|
|
},
|
2020-10-29 08:49:43 +01:00
|
|
|
product: {
|
|
|
|
suffix: "-suffix",
|
|
|
|
},
|
2019-10-22 12:53:47 +02:00
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
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
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_ext",
|
|
|
|
vendor: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
extends: "libvndk",
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
2019-10-22 12:53:47 +02:00
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk2_ext",
|
|
|
|
vendor: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
extends: "libvndk2",
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
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
|
|
|
|
2020-02-28 07:07:59 +01:00
|
|
|
cc_library {
|
|
|
|
name: "libvndk_ext_product",
|
|
|
|
product_specific: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
extends: "libvndk",
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
2019-10-22 12:53:47 +02:00
|
|
|
|
2020-02-28 07:07:59 +01:00
|
|
|
cc_library {
|
|
|
|
name: "libvndk2_ext_product",
|
|
|
|
product_specific: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
extends: "libvndk2",
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`
|
2021-03-23 00:21:32 +01:00
|
|
|
config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
|
2020-02-28 07:07:59 +01:00
|
|
|
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
|
2021-04-01 14:35:20 +02:00
|
|
|
config.TestProductVariables.Platform_vndk_version = StringPtr("29")
|
2020-02-28 07:07:59 +01:00
|
|
|
|
|
|
|
ctx := testCcWithConfig(t, config)
|
|
|
|
|
|
|
|
checkVndkModule(t, ctx, "libvndk_ext", "vndk", false, "libvndk", vendorVariant)
|
|
|
|
checkVndkModule(t, ctx, "libvndk_ext_product", "vndk", false, "libvndk", productVariant)
|
|
|
|
|
|
|
|
mod_vendor := ctx.ModuleForTests("libvndk2_ext", vendorVariant).Module().(*Module)
|
|
|
|
assertString(t, mod_vendor.outputFile.Path().Base(), "libvndk2-suffix.so")
|
|
|
|
|
|
|
|
mod_product := ctx.ModuleForTests("libvndk2_ext_product", productVariant).Module().(*Module)
|
|
|
|
assertString(t, mod_product.outputFile.Path().Base(), "libvndk2-suffix.so")
|
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
|
|
|
}
|
|
|
|
|
|
|
|
func TestVndkExtError(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
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
|
|
|
// This test ensures an error is emitted in ill-formed vndk-ext definition.
|
2020-02-28 07:07:59 +01:00
|
|
|
testCcError(t, "must set `vendor: true` or `product_specific: true` to set `extends: \".*\"`", `
|
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
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
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
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_ext",
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
extends: "libvndk",
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
testCcError(t, "must set `extends: \"\\.\\.\\.\"` to vndk extension", `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
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
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_ext",
|
|
|
|
vendor: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
2020-02-28 07:07:59 +01:00
|
|
|
|
|
|
|
testCcErrorProductVndk(t, "must set `extends: \"\\.\\.\\.\"` to vndk extension", `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2020-02-28 07:07:59 +01:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_ext_product",
|
|
|
|
product_specific: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
testCcErrorProductVndk(t, "must not set at the same time as `vndk: {extends: \"\\.\\.\\.\"}`", `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2020-02-28 07:07:59 +01:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_ext_product",
|
|
|
|
product_specific: true,
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2020-02-28 07:07:59 +01:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
extends: "libvndk",
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
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
|
|
|
}
|
|
|
|
|
|
|
|
func TestVndkExtInconsistentSupportSystemProcessError(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
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
|
|
|
// This test ensures an error is emitted for inconsistent support_system_process.
|
|
|
|
testCcError(t, "module \".*\" with mismatched support_system_process", `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
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
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_sp_ext",
|
|
|
|
vendor: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
extends: "libvndk",
|
|
|
|
support_system_process: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
testCcError(t, "module \".*\" with mismatched support_system_process", `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_sp",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
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
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
support_system_process: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_ext",
|
|
|
|
vendor: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
extends: "libvndk_sp",
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestVndkExtVendorAvailableFalseError(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2018-03-29 08:08:15 +02:00
|
|
|
// This test ensures an error is emitted when a VNDK-Ext library extends a VNDK library
|
Define vndk.private property for VNDK-private libraries
To define VNDK-private libraries, we used `vendor_available: false`.
Because of it, `vendor_available == nil` had different meaning from
`vendor_available: false` for the VNDK libraries.
To clarify this, we change the logic for defining VNDK-private
libraries which was:
cc_library {
name: "vndk_private",
vendor_available: false,
product_available: false,
vndk: {
enabled: true,
},
}
It must be replaced with
cc_library {
name: "vndk_private",
vendor_available: true,
product_available: true,
vndk: {
enabled: true,
private: true,
},
}
Bug: 175768895
Test: m nothing
Change-Id: I81769f57c2231e54b682a28e4b82631ab9f3d390
2020-12-23 10:23:14 +01:00
|
|
|
// with `private: true`.
|
|
|
|
testCcError(t, "`extends` refers module \".*\" which has `private: true`", `
|
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
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
Define vndk.private property for VNDK-private libraries
To define VNDK-private libraries, we used `vendor_available: false`.
Because of it, `vendor_available == nil` had different meaning from
`vendor_available: false` for the VNDK libraries.
To clarify this, we change the logic for defining VNDK-private
libraries which was:
cc_library {
name: "vndk_private",
vendor_available: false,
product_available: false,
vndk: {
enabled: true,
},
}
It must be replaced with
cc_library {
name: "vndk_private",
vendor_available: true,
product_available: true,
vndk: {
enabled: true,
private: true,
},
}
Bug: 175768895
Test: m nothing
Change-Id: I81769f57c2231e54b682a28e4b82631ab9f3d390
2020-12-23 10:23:14 +01:00
|
|
|
vendor_available: true,
|
|
|
|
product_available: true,
|
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
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
Define vndk.private property for VNDK-private libraries
To define VNDK-private libraries, we used `vendor_available: false`.
Because of it, `vendor_available == nil` had different meaning from
`vendor_available: false` for the VNDK libraries.
To clarify this, we change the logic for defining VNDK-private
libraries which was:
cc_library {
name: "vndk_private",
vendor_available: false,
product_available: false,
vndk: {
enabled: true,
},
}
It must be replaced with
cc_library {
name: "vndk_private",
vendor_available: true,
product_available: true,
vndk: {
enabled: true,
private: true,
},
}
Bug: 175768895
Test: m nothing
Change-Id: I81769f57c2231e54b682a28e4b82631ab9f3d390
2020-12-23 10:23:14 +01:00
|
|
|
private: true,
|
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
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_ext",
|
|
|
|
vendor: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
extends: "libvndk",
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
2020-02-28 07:07:59 +01:00
|
|
|
|
Define vndk.private property for VNDK-private libraries
To define VNDK-private libraries, we used `vendor_available: false`.
Because of it, `vendor_available == nil` had different meaning from
`vendor_available: false` for the VNDK libraries.
To clarify this, we change the logic for defining VNDK-private
libraries which was:
cc_library {
name: "vndk_private",
vendor_available: false,
product_available: false,
vndk: {
enabled: true,
},
}
It must be replaced with
cc_library {
name: "vndk_private",
vendor_available: true,
product_available: true,
vndk: {
enabled: true,
private: true,
},
}
Bug: 175768895
Test: m nothing
Change-Id: I81769f57c2231e54b682a28e4b82631ab9f3d390
2020-12-23 10:23:14 +01:00
|
|
|
testCcErrorProductVndk(t, "`extends` refers module \".*\" which has `private: true`", `
|
2020-02-28 07:07:59 +01:00
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
Define vndk.private property for VNDK-private libraries
To define VNDK-private libraries, we used `vendor_available: false`.
Because of it, `vendor_available == nil` had different meaning from
`vendor_available: false` for the VNDK libraries.
To clarify this, we change the logic for defining VNDK-private
libraries which was:
cc_library {
name: "vndk_private",
vendor_available: false,
product_available: false,
vndk: {
enabled: true,
},
}
It must be replaced with
cc_library {
name: "vndk_private",
vendor_available: true,
product_available: true,
vndk: {
enabled: true,
private: true,
},
}
Bug: 175768895
Test: m nothing
Change-Id: I81769f57c2231e54b682a28e4b82631ab9f3d390
2020-12-23 10:23:14 +01:00
|
|
|
vendor_available: true,
|
|
|
|
product_available: true,
|
2020-02-28 07:07:59 +01:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
Define vndk.private property for VNDK-private libraries
To define VNDK-private libraries, we used `vendor_available: false`.
Because of it, `vendor_available == nil` had different meaning from
`vendor_available: false` for the VNDK libraries.
To clarify this, we change the logic for defining VNDK-private
libraries which was:
cc_library {
name: "vndk_private",
vendor_available: false,
product_available: false,
vndk: {
enabled: true,
},
}
It must be replaced with
cc_library {
name: "vndk_private",
vendor_available: true,
product_available: true,
vndk: {
enabled: true,
private: true,
},
}
Bug: 175768895
Test: m nothing
Change-Id: I81769f57c2231e54b682a28e4b82631ab9f3d390
2020-12-23 10:23:14 +01:00
|
|
|
private: true,
|
2020-02-28 07:07:59 +01:00
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_ext_product",
|
|
|
|
product_specific: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
extends: "libvndk",
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
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
|
|
|
}
|
|
|
|
|
2018-03-29 08:08:15 +02:00
|
|
|
func TestVendorModuleUseVndkExt(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2018-03-29 08:08:15 +02:00
|
|
|
// This test ensures a vendor module can depend on a VNDK-Ext library.
|
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
|
|
|
testCc(t, `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
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
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_ext",
|
|
|
|
vendor: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
extends: "libvndk",
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_sp",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
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
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
support_system_process: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_sp_ext",
|
|
|
|
vendor: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
extends: "libvndk_sp",
|
|
|
|
support_system_process: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvendor",
|
|
|
|
vendor: true,
|
|
|
|
shared_libs: ["libvndk_ext", "libvndk_sp_ext"],
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
}
|
|
|
|
|
2018-03-29 08:08:15 +02:00
|
|
|
func TestVndkExtUseVendorLib(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2018-03-29 08:08:15 +02:00
|
|
|
// This test ensures a VNDK-Ext library can depend on a vendor library.
|
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
|
|
|
testCc(t, `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
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
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_ext",
|
|
|
|
vendor: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
extends: "libvndk",
|
|
|
|
},
|
|
|
|
shared_libs: ["libvendor"],
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvendor",
|
|
|
|
vendor: true,
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
2018-03-29 08:08:15 +02:00
|
|
|
|
|
|
|
// This test ensures a VNDK-SP-Ext library can depend on a vendor library.
|
|
|
|
testCc(t, `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_sp",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2018-03-29 08:08:15 +02:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
support_system_process: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_sp_ext",
|
|
|
|
vendor: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
extends: "libvndk_sp",
|
|
|
|
support_system_process: true,
|
|
|
|
},
|
|
|
|
shared_libs: ["libvendor"], // Cause an error
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvendor",
|
|
|
|
vendor: true,
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
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
|
|
|
}
|
|
|
|
|
2020-02-28 07:07:59 +01:00
|
|
|
func TestProductVndkExtDependency(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2020-02-28 07:07:59 +01:00
|
|
|
bp := `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2020-02-28 07:07:59 +01:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_ext_product",
|
|
|
|
product_specific: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
extends: "libvndk",
|
|
|
|
},
|
|
|
|
shared_libs: ["libproduct_for_vndklibs"],
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_sp",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2020-02-28 07:07:59 +01:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
support_system_process: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_sp_ext_product",
|
|
|
|
product_specific: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
extends: "libvndk_sp",
|
|
|
|
support_system_process: true,
|
|
|
|
},
|
|
|
|
shared_libs: ["libproduct_for_vndklibs"],
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libproduct",
|
|
|
|
product_specific: true,
|
|
|
|
shared_libs: ["libvndk_ext_product", "libvndk_sp_ext_product"],
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libproduct_for_vndklibs",
|
|
|
|
product_specific: true,
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`
|
2021-03-23 00:21:32 +01:00
|
|
|
config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
|
2020-02-28 07:07:59 +01:00
|
|
|
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
|
2021-04-01 14:35:20 +02:00
|
|
|
config.TestProductVariables.Platform_vndk_version = StringPtr("29")
|
2020-02-28 07:07:59 +01:00
|
|
|
|
|
|
|
testCcWithConfig(t, config)
|
|
|
|
}
|
|
|
|
|
2018-03-29 08:08:15 +02:00
|
|
|
func TestVndkSpExtUseVndkError(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2018-03-29 08:08:15 +02:00
|
|
|
// This test ensures an error is emitted if a VNDK-SP-Ext library depends on a 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
|
|
|
// library.
|
|
|
|
testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", `
|
2018-03-29 08:08:15 +02:00
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2018-03-29 08:08:15 +02:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
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
|
|
|
cc_library {
|
|
|
|
name: "libvndk_sp",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
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
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
support_system_process: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_sp_ext",
|
|
|
|
vendor: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
extends: "libvndk_sp",
|
|
|
|
support_system_process: true,
|
|
|
|
},
|
2018-03-29 08:08:15 +02:00
|
|
|
shared_libs: ["libvndk"], // Cause an error
|
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
|
|
|
nocrt: true,
|
|
|
|
}
|
2018-03-29 08:08:15 +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
|
|
|
|
2018-03-29 08:08:15 +02:00
|
|
|
// This test ensures an error is emitted if a VNDK-SP-Ext library depends on a VNDK-Ext
|
|
|
|
// library.
|
|
|
|
testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", `
|
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
|
|
|
cc_library {
|
2018-03-29 08:08:15 +02:00
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2018-03-29 08:08:15 +02:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_ext",
|
|
|
|
vendor: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
extends: "libvndk",
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_sp",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2018-03-29 08:08:15 +02:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
support_system_process: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_sp_ext",
|
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
|
|
|
vendor: true,
|
2018-03-29 08:08:15 +02:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
extends: "libvndk_sp",
|
|
|
|
support_system_process: true,
|
|
|
|
},
|
|
|
|
shared_libs: ["libvndk_ext"], // Cause an error
|
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
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
}
|
|
|
|
|
2018-03-29 08:08:15 +02:00
|
|
|
func TestVndkUseVndkExtError(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2018-03-29 08:08:15 +02:00
|
|
|
// This test ensures an error is emitted if a VNDK/VNDK-SP library depends on a
|
|
|
|
// VNDK-Ext/VNDK-SP-Ext library.
|
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
|
|
|
testCcError(t, "dependency \".*\" of \".*\" missing variant", `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
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
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_ext",
|
|
|
|
vendor: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
extends: "libvndk",
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk2",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
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
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
shared_libs: ["libvndk_ext"],
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
2018-11-06 17:12:13 +01:00
|
|
|
testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", `
|
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
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
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
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_ext",
|
|
|
|
vendor: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
extends: "libvndk",
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk2",
|
|
|
|
vendor_available: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
target: {
|
|
|
|
vendor: {
|
|
|
|
shared_libs: ["libvndk_ext"],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
testCcError(t, "dependency \".*\" of \".*\" missing variant", `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_sp",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
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
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
support_system_process: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_sp_ext",
|
|
|
|
vendor: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
extends: "libvndk_sp",
|
|
|
|
support_system_process: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_sp_2",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
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
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
support_system_process: true,
|
|
|
|
},
|
|
|
|
shared_libs: ["libvndk_sp_ext"],
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
2018-11-06 17:12:13 +01:00
|
|
|
testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", `
|
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
|
|
|
cc_library {
|
|
|
|
name: "libvndk_sp",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
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
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_sp_ext",
|
|
|
|
vendor: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
extends: "libvndk_sp",
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_sp2",
|
|
|
|
vendor_available: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
target: {
|
|
|
|
vendor: {
|
|
|
|
shared_libs: ["libvndk_sp_ext"],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
}
|
|
|
|
|
2019-11-18 11:52:14 +01:00
|
|
|
func TestEnforceProductVndkVersion(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2019-11-18 11:52:14 +01:00
|
|
|
bp := `
|
|
|
|
cc_library {
|
|
|
|
name: "libllndk",
|
2021-04-27 02:19:41 +02:00
|
|
|
llndk: {
|
|
|
|
symbol_file: "libllndk.map.txt",
|
|
|
|
}
|
2019-11-18 11:52:14 +01:00
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2019-11-18 11:52:14 +01:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_sp",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2019-11-18 11:52:14 +01:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
support_system_process: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libva",
|
|
|
|
vendor_available: true,
|
|
|
|
nocrt: true,
|
|
|
|
}
|
2020-10-29 08:49:43 +01:00
|
|
|
cc_library {
|
|
|
|
name: "libpa",
|
|
|
|
product_available: true,
|
|
|
|
nocrt: true,
|
|
|
|
}
|
2020-10-29 10:24:11 +01:00
|
|
|
cc_library {
|
|
|
|
name: "libboth_available",
|
|
|
|
vendor_available: true,
|
|
|
|
product_available: true,
|
|
|
|
nocrt: true,
|
2021-03-08 11:25:55 +01:00
|
|
|
srcs: ["foo.c"],
|
2020-10-29 10:24:11 +01:00
|
|
|
target: {
|
|
|
|
vendor: {
|
|
|
|
suffix: "-vendor",
|
|
|
|
},
|
|
|
|
product: {
|
|
|
|
suffix: "-product",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
2019-11-18 11:52:14 +01:00
|
|
|
cc_library {
|
|
|
|
name: "libproduct_va",
|
|
|
|
product_specific: true,
|
|
|
|
vendor_available: true,
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libprod",
|
|
|
|
product_specific: true,
|
|
|
|
shared_libs: [
|
|
|
|
"libllndk",
|
|
|
|
"libvndk",
|
|
|
|
"libvndk_sp",
|
2020-10-29 08:49:43 +01:00
|
|
|
"libpa",
|
2020-10-29 10:24:11 +01:00
|
|
|
"libboth_available",
|
2019-11-18 11:52:14 +01:00
|
|
|
"libproduct_va",
|
|
|
|
],
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libvendor",
|
|
|
|
vendor: true,
|
|
|
|
shared_libs: [
|
|
|
|
"libllndk",
|
|
|
|
"libvndk",
|
|
|
|
"libvndk_sp",
|
|
|
|
"libva",
|
2020-10-29 10:24:11 +01:00
|
|
|
"libboth_available",
|
2019-11-18 11:52:14 +01:00
|
|
|
"libproduct_va",
|
|
|
|
],
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
2021-03-23 01:02:06 +01:00
|
|
|
ctx := prepareForCcTest.RunTestWithBp(t, bp).TestContext
|
2019-11-18 11:52:14 +01:00
|
|
|
|
2020-10-20 11:54:21 +02:00
|
|
|
checkVndkModule(t, ctx, "libvndk", "", false, "", productVariant)
|
|
|
|
checkVndkModule(t, ctx, "libvndk_sp", "", true, "", productVariant)
|
2020-10-29 10:24:11 +01:00
|
|
|
|
|
|
|
mod_vendor := ctx.ModuleForTests("libboth_available", vendorVariant).Module().(*Module)
|
|
|
|
assertString(t, mod_vendor.outputFile.Path().Base(), "libboth_available-vendor.so")
|
|
|
|
|
|
|
|
mod_product := ctx.ModuleForTests("libboth_available", productVariant).Module().(*Module)
|
|
|
|
assertString(t, mod_product.outputFile.Path().Base(), "libboth_available-product.so")
|
2021-03-08 11:25:55 +01:00
|
|
|
|
|
|
|
ensureStringContains := func(t *testing.T, str string, substr string) {
|
|
|
|
t.Helper()
|
|
|
|
if !strings.Contains(str, substr) {
|
|
|
|
t.Errorf("%q is not found in %v", substr, str)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ensureStringNotContains := func(t *testing.T, str string, substr string) {
|
|
|
|
t.Helper()
|
|
|
|
if strings.Contains(str, substr) {
|
|
|
|
t.Errorf("%q is found in %v", substr, str)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// _static variant is used since _shared reuses *.o from the static variant
|
|
|
|
vendor_static := ctx.ModuleForTests("libboth_available", strings.Replace(vendorVariant, "_shared", "_static", 1))
|
|
|
|
product_static := ctx.ModuleForTests("libboth_available", strings.Replace(productVariant, "_shared", "_static", 1))
|
|
|
|
|
|
|
|
vendor_cflags := vendor_static.Rule("cc").Args["cFlags"]
|
|
|
|
ensureStringContains(t, vendor_cflags, "-D__ANDROID_VNDK__")
|
|
|
|
ensureStringContains(t, vendor_cflags, "-D__ANDROID_VENDOR__")
|
|
|
|
ensureStringNotContains(t, vendor_cflags, "-D__ANDROID_PRODUCT__")
|
2023-11-29 09:58:16 +01:00
|
|
|
ensureStringContains(t, vendor_cflags, "-D__ANDROID_VENDOR_API__=202404")
|
2021-03-08 11:25:55 +01:00
|
|
|
|
|
|
|
product_cflags := product_static.Rule("cc").Args["cFlags"]
|
|
|
|
ensureStringContains(t, product_cflags, "-D__ANDROID_VNDK__")
|
|
|
|
ensureStringContains(t, product_cflags, "-D__ANDROID_PRODUCT__")
|
|
|
|
ensureStringNotContains(t, product_cflags, "-D__ANDROID_VENDOR__")
|
2023-11-29 09:58:16 +01:00
|
|
|
ensureStringNotContains(t, product_cflags, "-D__ANDROID_VENDOR_API__=202404")
|
2019-11-18 11:52:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestEnforceProductVndkVersionErrors(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2021-04-01 14:35:20 +02:00
|
|
|
testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:product.29", `
|
2019-11-18 11:52:14 +01:00
|
|
|
cc_library {
|
|
|
|
name: "libprod",
|
|
|
|
product_specific: true,
|
|
|
|
shared_libs: [
|
|
|
|
"libvendor",
|
|
|
|
],
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libvendor",
|
|
|
|
vendor: true,
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
2021-04-01 14:35:20 +02:00
|
|
|
testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:product.29", `
|
2019-11-18 11:52:14 +01:00
|
|
|
cc_library {
|
|
|
|
name: "libprod",
|
|
|
|
product_specific: true,
|
|
|
|
shared_libs: [
|
|
|
|
"libsystem",
|
|
|
|
],
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libsystem",
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
2021-04-01 14:35:20 +02:00
|
|
|
testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:product.29", `
|
2020-10-29 10:24:11 +01:00
|
|
|
cc_library {
|
|
|
|
name: "libprod",
|
|
|
|
product_specific: true,
|
|
|
|
shared_libs: [
|
|
|
|
"libva",
|
|
|
|
],
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libva",
|
|
|
|
vendor_available: true,
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
Define vndk.private property for VNDK-private libraries
To define VNDK-private libraries, we used `vendor_available: false`.
Because of it, `vendor_available == nil` had different meaning from
`vendor_available: false` for the VNDK libraries.
To clarify this, we change the logic for defining VNDK-private
libraries which was:
cc_library {
name: "vndk_private",
vendor_available: false,
product_available: false,
vndk: {
enabled: true,
},
}
It must be replaced with
cc_library {
name: "vndk_private",
vendor_available: true,
product_available: true,
vndk: {
enabled: true,
private: true,
},
}
Bug: 175768895
Test: m nothing
Change-Id: I81769f57c2231e54b682a28e4b82631ab9f3d390
2020-12-23 10:23:14 +01:00
|
|
|
testCcErrorProductVndk(t, "non-VNDK module should not link to \".*\" which has `private: true`", `
|
2019-11-18 11:52:14 +01:00
|
|
|
cc_library {
|
|
|
|
name: "libprod",
|
|
|
|
product_specific: true,
|
|
|
|
shared_libs: [
|
|
|
|
"libvndk_private",
|
|
|
|
],
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_private",
|
Define vndk.private property for VNDK-private libraries
To define VNDK-private libraries, we used `vendor_available: false`.
Because of it, `vendor_available == nil` had different meaning from
`vendor_available: false` for the VNDK libraries.
To clarify this, we change the logic for defining VNDK-private
libraries which was:
cc_library {
name: "vndk_private",
vendor_available: false,
product_available: false,
vndk: {
enabled: true,
},
}
It must be replaced with
cc_library {
name: "vndk_private",
vendor_available: true,
product_available: true,
vndk: {
enabled: true,
private: true,
},
}
Bug: 175768895
Test: m nothing
Change-Id: I81769f57c2231e54b682a28e4b82631ab9f3d390
2020-12-23 10:23:14 +01:00
|
|
|
vendor_available: true,
|
|
|
|
product_available: true,
|
2019-11-18 11:52:14 +01:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
Define vndk.private property for VNDK-private libraries
To define VNDK-private libraries, we used `vendor_available: false`.
Because of it, `vendor_available == nil` had different meaning from
`vendor_available: false` for the VNDK libraries.
To clarify this, we change the logic for defining VNDK-private
libraries which was:
cc_library {
name: "vndk_private",
vendor_available: false,
product_available: false,
vndk: {
enabled: true,
},
}
It must be replaced with
cc_library {
name: "vndk_private",
vendor_available: true,
product_available: true,
vndk: {
enabled: true,
private: true,
},
}
Bug: 175768895
Test: m nothing
Change-Id: I81769f57c2231e54b682a28e4b82631ab9f3d390
2020-12-23 10:23:14 +01:00
|
|
|
private: true,
|
2019-11-18 11:52:14 +01:00
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
2021-04-01 14:35:20 +02:00
|
|
|
testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:product.29", `
|
2019-11-18 11:52:14 +01:00
|
|
|
cc_library {
|
|
|
|
name: "libprod",
|
|
|
|
product_specific: true,
|
|
|
|
shared_libs: [
|
|
|
|
"libsystem_ext",
|
|
|
|
],
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libsystem_ext",
|
|
|
|
system_ext_specific: true,
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:", `
|
|
|
|
cc_library {
|
|
|
|
name: "libsystem",
|
|
|
|
shared_libs: [
|
|
|
|
"libproduct_va",
|
|
|
|
],
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libproduct_va",
|
|
|
|
product_specific: true,
|
|
|
|
vendor_available: true,
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
}
|
|
|
|
|
2019-05-15 21:01:54 +02:00
|
|
|
func TestMakeLinkType(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2019-12-14 05:41:13 +01:00
|
|
|
bp := `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2019-12-14 05:41:13 +01:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libvndksp",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2019-12-14 05:41:13 +01:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
support_system_process: true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libvndkprivate",
|
Define vndk.private property for VNDK-private libraries
To define VNDK-private libraries, we used `vendor_available: false`.
Because of it, `vendor_available == nil` had different meaning from
`vendor_available: false` for the VNDK libraries.
To clarify this, we change the logic for defining VNDK-private
libraries which was:
cc_library {
name: "vndk_private",
vendor_available: false,
product_available: false,
vndk: {
enabled: true,
},
}
It must be replaced with
cc_library {
name: "vndk_private",
vendor_available: true,
product_available: true,
vndk: {
enabled: true,
private: true,
},
}
Bug: 175768895
Test: m nothing
Change-Id: I81769f57c2231e54b682a28e4b82631ab9f3d390
2020-12-23 10:23:14 +01:00
|
|
|
vendor_available: true,
|
|
|
|
product_available: true,
|
2019-12-14 05:41:13 +01:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
Define vndk.private property for VNDK-private libraries
To define VNDK-private libraries, we used `vendor_available: false`.
Because of it, `vendor_available == nil` had different meaning from
`vendor_available: false` for the VNDK libraries.
To clarify this, we change the logic for defining VNDK-private
libraries which was:
cc_library {
name: "vndk_private",
vendor_available: false,
product_available: false,
vndk: {
enabled: true,
},
}
It must be replaced with
cc_library {
name: "vndk_private",
vendor_available: true,
product_available: true,
vndk: {
enabled: true,
private: true,
},
}
Bug: 175768895
Test: m nothing
Change-Id: I81769f57c2231e54b682a28e4b82631ab9f3d390
2020-12-23 10:23:14 +01:00
|
|
|
private: true,
|
2019-12-14 05:41:13 +01:00
|
|
|
},
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libvendor",
|
|
|
|
vendor: true,
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libvndkext",
|
|
|
|
vendor: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
extends: "libvndk",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
vndk_prebuilt_shared {
|
|
|
|
name: "prevndk",
|
|
|
|
version: "27",
|
|
|
|
target_arch: "arm",
|
|
|
|
binder32bit: true,
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2019-12-14 05:41:13 +01:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
arch: {
|
|
|
|
arm: {
|
|
|
|
srcs: ["liba.so"],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libllndk",
|
2021-04-27 02:19:41 +02:00
|
|
|
llndk: {
|
|
|
|
symbol_file: "libllndk.map.txt",
|
|
|
|
}
|
2019-12-14 05:41:13 +01:00
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libllndkprivate",
|
2021-04-27 02:19:41 +02:00
|
|
|
llndk: {
|
|
|
|
symbol_file: "libllndkprivate.map.txt",
|
|
|
|
private: true,
|
|
|
|
}
|
2021-01-06 23:51:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
llndk_libraries_txt {
|
|
|
|
name: "llndk.libraries.txt",
|
|
|
|
}
|
|
|
|
vndkcore_libraries_txt {
|
|
|
|
name: "vndkcore.libraries.txt",
|
|
|
|
}
|
|
|
|
vndksp_libraries_txt {
|
|
|
|
name: "vndksp.libraries.txt",
|
|
|
|
}
|
|
|
|
vndkprivate_libraries_txt {
|
|
|
|
name: "vndkprivate.libraries.txt",
|
|
|
|
}
|
|
|
|
vndkcorevariant_libraries_txt {
|
|
|
|
name: "vndkcorevariant.libraries.txt",
|
|
|
|
insert_vndk_version: false,
|
|
|
|
}
|
|
|
|
`
|
2019-12-14 05:41:13 +01:00
|
|
|
|
2021-03-23 00:21:32 +01:00
|
|
|
config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
|
2019-05-15 21:01:54 +02:00
|
|
|
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
|
2021-04-01 14:35:20 +02:00
|
|
|
config.TestProductVariables.Platform_vndk_version = StringPtr("29")
|
2019-05-15 21:01:54 +02:00
|
|
|
// native:vndk
|
2019-12-14 05:41:13 +01:00
|
|
|
ctx := testCcWithConfig(t, config)
|
2019-05-15 21:01:54 +02:00
|
|
|
|
2021-01-06 23:51:30 +01:00
|
|
|
checkVndkLibrariesOutput(t, ctx, "vndkcore.libraries.txt",
|
|
|
|
[]string{"libvndk.so", "libvndkprivate.so"})
|
|
|
|
checkVndkLibrariesOutput(t, ctx, "vndksp.libraries.txt",
|
|
|
|
[]string{"libc++.so", "libvndksp.so"})
|
|
|
|
checkVndkLibrariesOutput(t, ctx, "llndk.libraries.txt",
|
|
|
|
[]string{"libc.so", "libdl.so", "libft2.so", "libllndk.so", "libllndkprivate.so", "libm.so"})
|
|
|
|
checkVndkLibrariesOutput(t, ctx, "vndkprivate.libraries.txt",
|
|
|
|
[]string{"libft2.so", "libllndkprivate.so", "libvndkprivate.so"})
|
2019-05-15 21:01:54 +02:00
|
|
|
|
2019-11-21 02:12:35 +01:00
|
|
|
vendorVariant27 := "android_vendor.27_arm64_armv8-a_shared"
|
2019-08-26 09:52:35 +02:00
|
|
|
|
2019-05-15 21:01:54 +02:00
|
|
|
tests := []struct {
|
|
|
|
variant string
|
|
|
|
name string
|
|
|
|
expected string
|
|
|
|
}{
|
|
|
|
{vendorVariant, "libvndk", "native:vndk"},
|
|
|
|
{vendorVariant, "libvndksp", "native:vndk"},
|
|
|
|
{vendorVariant, "libvndkprivate", "native:vndk_private"},
|
|
|
|
{vendorVariant, "libvendor", "native:vendor"},
|
|
|
|
{vendorVariant, "libvndkext", "native:vendor"},
|
2020-12-17 01:46:01 +01:00
|
|
|
{vendorVariant, "libllndk", "native:vndk"},
|
2019-08-26 09:52:35 +02:00
|
|
|
{vendorVariant27, "prevndk.vndk.27.arm.binder32", "native:vndk"},
|
2019-05-15 21:01:54 +02:00
|
|
|
{coreVariant, "libvndk", "native:platform"},
|
|
|
|
{coreVariant, "libvndkprivate", "native:platform"},
|
|
|
|
{coreVariant, "libllndk", "native:platform"},
|
|
|
|
}
|
|
|
|
for _, test := range tests {
|
|
|
|
t.Run(test.name, func(t *testing.T) {
|
|
|
|
module := ctx.ModuleForTests(test.name, test.variant).Module().(*Module)
|
|
|
|
assertString(t, module.makeLinkType, test.expected)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-28 02:05:30 +02:00
|
|
|
var staticLinkDepOrderTestCases = []struct {
|
|
|
|
// This is a string representation of a map[moduleName][]moduleDependency .
|
|
|
|
// It models the dependencies declared in an Android.bp file.
|
2017-11-28 00:48:57 +01:00
|
|
|
inStatic string
|
|
|
|
|
|
|
|
// This is a string representation of a map[moduleName][]moduleDependency .
|
|
|
|
// It models the dependencies declared in an Android.bp file.
|
|
|
|
inShared string
|
2017-09-28 02:05:30 +02:00
|
|
|
|
|
|
|
// allOrdered is a string representation of a map[moduleName][]moduleDependency .
|
|
|
|
// The keys of allOrdered specify which modules we would like to check.
|
|
|
|
// The values of allOrdered specify the expected result (of the transitive closure of all
|
|
|
|
// dependencies) for each module to test
|
|
|
|
allOrdered string
|
|
|
|
|
|
|
|
// outOrdered is a string representation of a map[moduleName][]moduleDependency .
|
|
|
|
// The keys of outOrdered specify which modules we would like to check.
|
|
|
|
// The values of outOrdered specify the expected result (of the ordered linker command line)
|
|
|
|
// for each module to test.
|
|
|
|
outOrdered string
|
|
|
|
}{
|
|
|
|
// Simple tests
|
|
|
|
{
|
2017-11-28 00:48:57 +01:00
|
|
|
inStatic: "",
|
2017-09-28 02:05:30 +02:00
|
|
|
outOrdered: "",
|
|
|
|
},
|
|
|
|
{
|
2017-11-28 00:48:57 +01:00
|
|
|
inStatic: "a:",
|
2017-09-28 02:05:30 +02:00
|
|
|
outOrdered: "a:",
|
|
|
|
},
|
|
|
|
{
|
2017-11-28 00:48:57 +01:00
|
|
|
inStatic: "a:b; b:",
|
2017-09-28 02:05:30 +02:00
|
|
|
outOrdered: "a:b; b:",
|
|
|
|
},
|
|
|
|
// Tests of reordering
|
|
|
|
{
|
|
|
|
// diamond example
|
2017-11-28 00:48:57 +01:00
|
|
|
inStatic: "a:d,b,c; b:d; c:d; d:",
|
2017-09-28 02:05:30 +02:00
|
|
|
outOrdered: "a:b,c,d; b:d; c:d; d:",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// somewhat real example
|
2017-11-28 00:48:57 +01:00
|
|
|
inStatic: "bsdiff_unittest:b,c,d,e,f,g,h,i; e:b",
|
2017-09-28 02:05:30 +02:00
|
|
|
outOrdered: "bsdiff_unittest:c,d,e,b,f,g,h,i; e:b",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// multiple reorderings
|
2017-11-28 00:48:57 +01:00
|
|
|
inStatic: "a:b,c,d,e; d:b; e:c",
|
2017-09-28 02:05:30 +02:00
|
|
|
outOrdered: "a:d,b,e,c; d:b; e:c",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// should reorder without adding new transitive dependencies
|
2017-11-28 00:48:57 +01:00
|
|
|
inStatic: "bin:lib2,lib1; lib1:lib2,liboptional",
|
2017-09-28 02:05:30 +02:00
|
|
|
allOrdered: "bin:lib1,lib2,liboptional; lib1:lib2,liboptional",
|
|
|
|
outOrdered: "bin:lib1,lib2; lib1:lib2,liboptional",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// multiple levels of dependencies
|
2017-11-28 00:48:57 +01:00
|
|
|
inStatic: "a:b,c,d,e,f,g,h; f:b,c,d; b:c,d; c:d",
|
2017-09-28 02:05:30 +02:00
|
|
|
allOrdered: "a:e,f,b,c,d,g,h; f:b,c,d; b:c,d; c:d",
|
|
|
|
outOrdered: "a:e,f,b,c,d,g,h; f:b,c,d; b:c,d; c:d",
|
|
|
|
},
|
2017-11-28 00:48:57 +01:00
|
|
|
// shared dependencies
|
|
|
|
{
|
|
|
|
// Note that this test doesn't recurse, to minimize the amount of logic it tests.
|
|
|
|
// So, we don't actually have to check that a shared dependency of c will change the order
|
|
|
|
// of a library that depends statically on b and on c. We only need to check that if c has
|
|
|
|
// a shared dependency on b, that that shows up in allOrdered.
|
|
|
|
inShared: "c:b",
|
|
|
|
allOrdered: "c:b",
|
|
|
|
outOrdered: "c:",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// This test doesn't actually include any shared dependencies but it's a reminder of what
|
|
|
|
// the second phase of the above test would look like
|
|
|
|
inStatic: "a:b,c; c:b",
|
|
|
|
allOrdered: "a:c,b; c:b",
|
|
|
|
outOrdered: "a:c,b; c:b",
|
|
|
|
},
|
2017-09-28 02:05:30 +02:00
|
|
|
// tiebreakers for when two modules specifying different orderings and there is no dependency
|
|
|
|
// to dictate an order
|
|
|
|
{
|
|
|
|
// if the tie is between two modules at the end of a's deps, then a's order wins
|
2017-11-28 00:48:57 +01:00
|
|
|
inStatic: "a1:b,c,d,e; a2:b,c,e,d; b:d,e; c:e,d",
|
2017-09-28 02:05:30 +02:00
|
|
|
outOrdered: "a1:b,c,d,e; a2:b,c,e,d; b:d,e; c:e,d",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// if the tie is between two modules at the start of a's deps, then c's order is used
|
2017-11-28 00:48:57 +01:00
|
|
|
inStatic: "a1:d,e,b1,c1; b1:d,e; c1:e,d; a2:d,e,b2,c2; b2:d,e; c2:d,e",
|
2017-09-28 02:05:30 +02:00
|
|
|
outOrdered: "a1:b1,c1,e,d; b1:d,e; c1:e,d; a2:b2,c2,d,e; b2:d,e; c2:d,e",
|
|
|
|
},
|
|
|
|
// Tests involving duplicate dependencies
|
|
|
|
{
|
|
|
|
// simple duplicate
|
2017-11-28 00:48:57 +01:00
|
|
|
inStatic: "a:b,c,c,b",
|
2017-09-28 02:05:30 +02:00
|
|
|
outOrdered: "a:c,b",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// duplicates with reordering
|
2017-11-28 00:48:57 +01:00
|
|
|
inStatic: "a:b,c,d,c; c:b",
|
2017-09-28 02:05:30 +02:00
|
|
|
outOrdered: "a:d,c,b",
|
|
|
|
},
|
|
|
|
// Tests to confirm the nonexistence of infinite loops.
|
|
|
|
// These cases should never happen, so as long as the test terminates and the
|
|
|
|
// result is deterministic then that should be fine.
|
|
|
|
{
|
2017-11-28 00:48:57 +01:00
|
|
|
inStatic: "a:a",
|
2017-09-28 02:05:30 +02:00
|
|
|
outOrdered: "a:a",
|
|
|
|
},
|
|
|
|
{
|
2017-11-28 00:48:57 +01:00
|
|
|
inStatic: "a:b; b:c; c:a",
|
2017-09-28 02:05:30 +02:00
|
|
|
allOrdered: "a:b,c; b:c,a; c:a,b",
|
|
|
|
outOrdered: "a:b; b:c; c:a",
|
|
|
|
},
|
|
|
|
{
|
2017-11-28 00:48:57 +01:00
|
|
|
inStatic: "a:b,c; b:c,a; c:a,b",
|
2017-09-28 02:05:30 +02:00
|
|
|
allOrdered: "a:c,a,b; b:a,b,c; c:b,c,a",
|
|
|
|
outOrdered: "a:c,b; b:a,c; c:b,a",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
// converts from a string like "a:b,c; d:e" to (["a","b"], {"a":["b","c"], "d":["e"]}, [{"a", "a.o"}, {"b", "b.o"}])
|
|
|
|
func parseModuleDeps(text string) (modulesInOrder []android.Path, allDeps map[android.Path][]android.Path) {
|
|
|
|
// convert from "a:b,c; d:e" to "a:b,c;d:e"
|
|
|
|
strippedText := strings.Replace(text, " ", "", -1)
|
|
|
|
if len(strippedText) < 1 {
|
|
|
|
return []android.Path{}, make(map[android.Path][]android.Path, 0)
|
|
|
|
}
|
|
|
|
allDeps = make(map[android.Path][]android.Path, 0)
|
|
|
|
|
|
|
|
// convert from "a:b,c;d:e" to ["a:b,c", "d:e"]
|
|
|
|
moduleTexts := strings.Split(strippedText, ";")
|
|
|
|
|
|
|
|
outputForModuleName := func(moduleName string) android.Path {
|
|
|
|
return android.PathForTesting(moduleName)
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, moduleText := range moduleTexts {
|
|
|
|
// convert from "a:b,c" to ["a", "b,c"]
|
|
|
|
components := strings.Split(moduleText, ":")
|
|
|
|
if len(components) != 2 {
|
|
|
|
panic(fmt.Sprintf("illegal module dep string %q from larger string %q; must contain one ':', not %v", moduleText, text, len(components)-1))
|
|
|
|
}
|
|
|
|
moduleName := components[0]
|
|
|
|
moduleOutput := outputForModuleName(moduleName)
|
|
|
|
modulesInOrder = append(modulesInOrder, moduleOutput)
|
|
|
|
|
|
|
|
depString := components[1]
|
|
|
|
// convert from "b,c" to ["b", "c"]
|
|
|
|
depNames := strings.Split(depString, ",")
|
|
|
|
if len(depString) < 1 {
|
|
|
|
depNames = []string{}
|
|
|
|
}
|
|
|
|
var deps []android.Path
|
|
|
|
for _, depName := range depNames {
|
|
|
|
deps = append(deps, outputForModuleName(depName))
|
|
|
|
}
|
|
|
|
allDeps[moduleOutput] = deps
|
|
|
|
}
|
|
|
|
return modulesInOrder, allDeps
|
|
|
|
}
|
|
|
|
|
2017-11-28 00:48:57 +01:00
|
|
|
func TestStaticLibDepReordering(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2017-09-28 02:05:30 +02:00
|
|
|
ctx := testCc(t, `
|
|
|
|
cc_library {
|
|
|
|
name: "a",
|
|
|
|
static_libs: ["b", "c", "d"],
|
Allow platform modules to link to vendor public libraries
Normally, when building with VNDK, platform modules are not allowed to
link against vendor libraries, because the ABI of the vendor libraries
are not guaranteed to be stable and may differ across multiple vendor
images.
However, the vendor public libraries are the exceptions. Vendor public
libraries are vendor libraries that are exposed to 3rd party apps and
listed in /vendor/etc/public.libraries.txt. Since they are intended to
be exposed to public, their ABI stability is guaranteed (by definition,
though it is up to the vendor to actually guarantee it).
This change provides a way to make a vendor lib as public by defining a
module of type 'vendor_public_library' with a map file that enumerates
public symbols that are publicized:
cc_library {
name: "libvendor",
proprietary: true,
...
}
vendor_public_library {
name: "libvendor",
symbol_file: "libvendor.map.txt",
}
This defines a stub library module named libvendor.vendorpublic from the
map file. `shared_libs: ["libvendor"]` is redirected to the stub library
when it is from the outside of the vendor partition.
Bug: 74275385
Test: m -j
Test: cc_test.go passes
Change-Id: I5bed94d7c4282b777632ab2f0fb63c203ee313ba
2018-03-19 10:23:01 +01:00
|
|
|
stl: "none",
|
2017-09-28 02:05:30 +02:00
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "b",
|
Allow platform modules to link to vendor public libraries
Normally, when building with VNDK, platform modules are not allowed to
link against vendor libraries, because the ABI of the vendor libraries
are not guaranteed to be stable and may differ across multiple vendor
images.
However, the vendor public libraries are the exceptions. Vendor public
libraries are vendor libraries that are exposed to 3rd party apps and
listed in /vendor/etc/public.libraries.txt. Since they are intended to
be exposed to public, their ABI stability is guaranteed (by definition,
though it is up to the vendor to actually guarantee it).
This change provides a way to make a vendor lib as public by defining a
module of type 'vendor_public_library' with a map file that enumerates
public symbols that are publicized:
cc_library {
name: "libvendor",
proprietary: true,
...
}
vendor_public_library {
name: "libvendor",
symbol_file: "libvendor.map.txt",
}
This defines a stub library module named libvendor.vendorpublic from the
map file. `shared_libs: ["libvendor"]` is redirected to the stub library
when it is from the outside of the vendor partition.
Bug: 74275385
Test: m -j
Test: cc_test.go passes
Change-Id: I5bed94d7c4282b777632ab2f0fb63c203ee313ba
2018-03-19 10:23:01 +01:00
|
|
|
stl: "none",
|
2017-09-28 02:05:30 +02:00
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "c",
|
|
|
|
static_libs: ["b"],
|
Allow platform modules to link to vendor public libraries
Normally, when building with VNDK, platform modules are not allowed to
link against vendor libraries, because the ABI of the vendor libraries
are not guaranteed to be stable and may differ across multiple vendor
images.
However, the vendor public libraries are the exceptions. Vendor public
libraries are vendor libraries that are exposed to 3rd party apps and
listed in /vendor/etc/public.libraries.txt. Since they are intended to
be exposed to public, their ABI stability is guaranteed (by definition,
though it is up to the vendor to actually guarantee it).
This change provides a way to make a vendor lib as public by defining a
module of type 'vendor_public_library' with a map file that enumerates
public symbols that are publicized:
cc_library {
name: "libvendor",
proprietary: true,
...
}
vendor_public_library {
name: "libvendor",
symbol_file: "libvendor.map.txt",
}
This defines a stub library module named libvendor.vendorpublic from the
map file. `shared_libs: ["libvendor"]` is redirected to the stub library
when it is from the outside of the vendor partition.
Bug: 74275385
Test: m -j
Test: cc_test.go passes
Change-Id: I5bed94d7c4282b777632ab2f0fb63c203ee313ba
2018-03-19 10:23:01 +01:00
|
|
|
stl: "none",
|
2017-09-28 02:05:30 +02:00
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "d",
|
Allow platform modules to link to vendor public libraries
Normally, when building with VNDK, platform modules are not allowed to
link against vendor libraries, because the ABI of the vendor libraries
are not guaranteed to be stable and may differ across multiple vendor
images.
However, the vendor public libraries are the exceptions. Vendor public
libraries are vendor libraries that are exposed to 3rd party apps and
listed in /vendor/etc/public.libraries.txt. Since they are intended to
be exposed to public, their ABI stability is guaranteed (by definition,
though it is up to the vendor to actually guarantee it).
This change provides a way to make a vendor lib as public by defining a
module of type 'vendor_public_library' with a map file that enumerates
public symbols that are publicized:
cc_library {
name: "libvendor",
proprietary: true,
...
}
vendor_public_library {
name: "libvendor",
symbol_file: "libvendor.map.txt",
}
This defines a stub library module named libvendor.vendorpublic from the
map file. `shared_libs: ["libvendor"]` is redirected to the stub library
when it is from the outside of the vendor partition.
Bug: 74275385
Test: m -j
Test: cc_test.go passes
Change-Id: I5bed94d7c4282b777632ab2f0fb63c203ee313ba
2018-03-19 10:23:01 +01:00
|
|
|
stl: "none",
|
2017-09-28 02:05:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
`)
|
|
|
|
|
2019-11-21 01:39:12 +01:00
|
|
|
variant := "android_arm64_armv8-a_static"
|
2017-09-28 02:05:30 +02:00
|
|
|
moduleA := ctx.ModuleForTests("a", variant).Module().(*Module)
|
2023-12-14 23:46:23 +01:00
|
|
|
staticLibInfo, _ := android.SingletonModuleProvider(ctx, moduleA, StaticLibraryInfoProvider)
|
|
|
|
actual := android.Paths(staticLibInfo.TransitiveStaticLibrariesForOrdering.ToList()).RelativeToTop()
|
2021-05-20 19:01:32 +02:00
|
|
|
expected := GetOutputPaths(ctx, variant, []string{"a", "c", "b", "d"})
|
2017-09-28 02:05:30 +02:00
|
|
|
|
|
|
|
if !reflect.DeepEqual(actual, expected) {
|
|
|
|
t.Errorf("staticDeps orderings were not propagated correctly"+
|
|
|
|
"\nactual: %v"+
|
|
|
|
"\nexpected: %v",
|
|
|
|
actual,
|
|
|
|
expected,
|
|
|
|
)
|
|
|
|
}
|
2017-09-26 03:50:54 +02:00
|
|
|
}
|
2017-09-28 02:05:30 +02:00
|
|
|
|
2017-11-28 00:48:57 +01:00
|
|
|
func TestStaticLibDepReorderingWithShared(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2017-11-28 00:48:57 +01:00
|
|
|
ctx := testCc(t, `
|
|
|
|
cc_library {
|
|
|
|
name: "a",
|
|
|
|
static_libs: ["b", "c"],
|
Allow platform modules to link to vendor public libraries
Normally, when building with VNDK, platform modules are not allowed to
link against vendor libraries, because the ABI of the vendor libraries
are not guaranteed to be stable and may differ across multiple vendor
images.
However, the vendor public libraries are the exceptions. Vendor public
libraries are vendor libraries that are exposed to 3rd party apps and
listed in /vendor/etc/public.libraries.txt. Since they are intended to
be exposed to public, their ABI stability is guaranteed (by definition,
though it is up to the vendor to actually guarantee it).
This change provides a way to make a vendor lib as public by defining a
module of type 'vendor_public_library' with a map file that enumerates
public symbols that are publicized:
cc_library {
name: "libvendor",
proprietary: true,
...
}
vendor_public_library {
name: "libvendor",
symbol_file: "libvendor.map.txt",
}
This defines a stub library module named libvendor.vendorpublic from the
map file. `shared_libs: ["libvendor"]` is redirected to the stub library
when it is from the outside of the vendor partition.
Bug: 74275385
Test: m -j
Test: cc_test.go passes
Change-Id: I5bed94d7c4282b777632ab2f0fb63c203ee313ba
2018-03-19 10:23:01 +01:00
|
|
|
stl: "none",
|
2017-11-28 00:48:57 +01:00
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "b",
|
Allow platform modules to link to vendor public libraries
Normally, when building with VNDK, platform modules are not allowed to
link against vendor libraries, because the ABI of the vendor libraries
are not guaranteed to be stable and may differ across multiple vendor
images.
However, the vendor public libraries are the exceptions. Vendor public
libraries are vendor libraries that are exposed to 3rd party apps and
listed in /vendor/etc/public.libraries.txt. Since they are intended to
be exposed to public, their ABI stability is guaranteed (by definition,
though it is up to the vendor to actually guarantee it).
This change provides a way to make a vendor lib as public by defining a
module of type 'vendor_public_library' with a map file that enumerates
public symbols that are publicized:
cc_library {
name: "libvendor",
proprietary: true,
...
}
vendor_public_library {
name: "libvendor",
symbol_file: "libvendor.map.txt",
}
This defines a stub library module named libvendor.vendorpublic from the
map file. `shared_libs: ["libvendor"]` is redirected to the stub library
when it is from the outside of the vendor partition.
Bug: 74275385
Test: m -j
Test: cc_test.go passes
Change-Id: I5bed94d7c4282b777632ab2f0fb63c203ee313ba
2018-03-19 10:23:01 +01:00
|
|
|
stl: "none",
|
2017-11-28 00:48:57 +01:00
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "c",
|
|
|
|
shared_libs: ["b"],
|
Allow platform modules to link to vendor public libraries
Normally, when building with VNDK, platform modules are not allowed to
link against vendor libraries, because the ABI of the vendor libraries
are not guaranteed to be stable and may differ across multiple vendor
images.
However, the vendor public libraries are the exceptions. Vendor public
libraries are vendor libraries that are exposed to 3rd party apps and
listed in /vendor/etc/public.libraries.txt. Since they are intended to
be exposed to public, their ABI stability is guaranteed (by definition,
though it is up to the vendor to actually guarantee it).
This change provides a way to make a vendor lib as public by defining a
module of type 'vendor_public_library' with a map file that enumerates
public symbols that are publicized:
cc_library {
name: "libvendor",
proprietary: true,
...
}
vendor_public_library {
name: "libvendor",
symbol_file: "libvendor.map.txt",
}
This defines a stub library module named libvendor.vendorpublic from the
map file. `shared_libs: ["libvendor"]` is redirected to the stub library
when it is from the outside of the vendor partition.
Bug: 74275385
Test: m -j
Test: cc_test.go passes
Change-Id: I5bed94d7c4282b777632ab2f0fb63c203ee313ba
2018-03-19 10:23:01 +01:00
|
|
|
stl: "none",
|
2017-11-28 00:48:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
`)
|
|
|
|
|
2019-11-21 01:39:12 +01:00
|
|
|
variant := "android_arm64_armv8-a_static"
|
2017-11-28 00:48:57 +01:00
|
|
|
moduleA := ctx.ModuleForTests("a", variant).Module().(*Module)
|
2023-12-14 23:46:23 +01:00
|
|
|
staticLibInfo, _ := android.SingletonModuleProvider(ctx, moduleA, StaticLibraryInfoProvider)
|
|
|
|
actual := android.Paths(staticLibInfo.TransitiveStaticLibrariesForOrdering.ToList()).RelativeToTop()
|
2021-05-20 19:01:32 +02:00
|
|
|
expected := GetOutputPaths(ctx, variant, []string{"a", "c", "b"})
|
2017-11-28 00:48:57 +01:00
|
|
|
|
|
|
|
if !reflect.DeepEqual(actual, expected) {
|
|
|
|
t.Errorf("staticDeps orderings did not account for shared libs"+
|
|
|
|
"\nactual: %v"+
|
|
|
|
"\nexpected: %v",
|
|
|
|
actual,
|
|
|
|
expected,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-13 10:57:35 +01:00
|
|
|
func checkEquals(t *testing.T, message string, expected, actual interface{}) {
|
2020-08-19 03:35:15 +02:00
|
|
|
t.Helper()
|
2020-03-13 10:57:35 +01:00
|
|
|
if !reflect.DeepEqual(actual, expected) {
|
|
|
|
t.Errorf(message+
|
|
|
|
"\nactual: %v"+
|
|
|
|
"\nexpected: %v",
|
|
|
|
actual,
|
|
|
|
expected,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-21 15:21:46 +01:00
|
|
|
func TestLlndkLibrary(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2021-03-02 20:00:07 +01:00
|
|
|
result := prepareForCcTest.RunTestWithBp(t, `
|
|
|
|
cc_library {
|
|
|
|
name: "libllndk",
|
|
|
|
stubs: { versions: ["1", "2"] },
|
|
|
|
llndk: {
|
|
|
|
symbol_file: "libllndk.map.txt",
|
|
|
|
},
|
|
|
|
export_include_dirs: ["include"],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_prebuilt_library_shared {
|
|
|
|
name: "libllndkprebuilt",
|
|
|
|
stubs: { versions: ["1", "2"] },
|
|
|
|
llndk: {
|
|
|
|
symbol_file: "libllndkprebuilt.map.txt",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libllndk_with_external_headers",
|
|
|
|
stubs: { versions: ["1", "2"] },
|
|
|
|
llndk: {
|
|
|
|
symbol_file: "libllndk.map.txt",
|
|
|
|
export_llndk_headers: ["libexternal_llndk_headers"],
|
|
|
|
},
|
|
|
|
header_libs: ["libexternal_headers"],
|
|
|
|
export_header_lib_headers: ["libexternal_headers"],
|
|
|
|
}
|
|
|
|
cc_library_headers {
|
|
|
|
name: "libexternal_headers",
|
|
|
|
export_include_dirs: ["include"],
|
|
|
|
vendor_available: true,
|
2024-01-03 06:24:34 +01:00
|
|
|
product_available: true,
|
2021-03-02 20:00:07 +01:00
|
|
|
}
|
|
|
|
cc_library_headers {
|
|
|
|
name: "libexternal_llndk_headers",
|
|
|
|
export_include_dirs: ["include_llndk"],
|
|
|
|
llndk: {
|
|
|
|
symbol_file: "libllndk.map.txt",
|
|
|
|
},
|
|
|
|
vendor_available: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libllndk_with_override_headers",
|
|
|
|
stubs: { versions: ["1", "2"] },
|
|
|
|
llndk: {
|
|
|
|
symbol_file: "libllndk.map.txt",
|
|
|
|
override_export_include_dirs: ["include_llndk"],
|
|
|
|
},
|
|
|
|
export_include_dirs: ["include"],
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
actual := result.ModuleVariantsForTests("libllndk")
|
|
|
|
for i := 0; i < len(actual); i++ {
|
|
|
|
if !strings.HasPrefix(actual[i], "android_vendor.29_") {
|
|
|
|
actual = append(actual[:i], actual[i+1:]...)
|
|
|
|
i--
|
|
|
|
}
|
|
|
|
}
|
|
|
|
expected := []string{
|
|
|
|
"android_vendor.29_arm64_armv8-a_shared_current",
|
|
|
|
"android_vendor.29_arm64_armv8-a_shared",
|
|
|
|
"android_vendor.29_arm_armv7-a-neon_shared_current",
|
|
|
|
"android_vendor.29_arm_armv7-a-neon_shared",
|
|
|
|
}
|
|
|
|
android.AssertArrayString(t, "variants for llndk stubs", expected, actual)
|
|
|
|
|
|
|
|
params := result.ModuleForTests("libllndk", "android_vendor.29_arm_armv7-a-neon_shared").Description("generate stub")
|
|
|
|
android.AssertSame(t, "use VNDK version for default stubs", "current", params.Args["apiLevel"])
|
|
|
|
|
|
|
|
checkExportedIncludeDirs := func(module, variant string, expectedDirs ...string) {
|
|
|
|
t.Helper()
|
|
|
|
m := result.ModuleForTests(module, variant).Module()
|
2023-12-14 23:46:23 +01:00
|
|
|
f, _ := android.SingletonModuleProvider(result, m, FlagExporterInfoProvider)
|
2021-03-02 20:00:07 +01:00
|
|
|
android.AssertPathsRelativeToTopEquals(t, "exported include dirs for "+module+"["+variant+"]",
|
|
|
|
expectedDirs, f.IncludeDirs)
|
|
|
|
}
|
|
|
|
|
|
|
|
checkExportedIncludeDirs("libllndk", "android_arm64_armv8-a_shared", "include")
|
|
|
|
checkExportedIncludeDirs("libllndk", "android_vendor.29_arm64_armv8-a_shared", "include")
|
|
|
|
checkExportedIncludeDirs("libllndk_with_external_headers", "android_arm64_armv8-a_shared", "include")
|
|
|
|
checkExportedIncludeDirs("libllndk_with_external_headers", "android_vendor.29_arm64_armv8-a_shared", "include_llndk")
|
|
|
|
checkExportedIncludeDirs("libllndk_with_override_headers", "android_arm64_armv8-a_shared", "include")
|
|
|
|
checkExportedIncludeDirs("libllndk_with_override_headers", "android_vendor.29_arm64_armv8-a_shared", "include_llndk")
|
|
|
|
}
|
|
|
|
|
2017-12-14 11:54:34 +01:00
|
|
|
func TestLlndkHeaders(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2017-12-14 11:54:34 +01:00
|
|
|
ctx := testCc(t, `
|
2021-04-27 01:53:58 +02:00
|
|
|
cc_library_headers {
|
2017-12-14 11:54:34 +01:00
|
|
|
name: "libllndk_headers",
|
|
|
|
export_include_dirs: ["my_include"],
|
2021-04-27 01:53:58 +02:00
|
|
|
llndk: {
|
|
|
|
llndk_headers: true,
|
|
|
|
},
|
2017-12-14 11:54:34 +01:00
|
|
|
}
|
2020-10-14 03:43:54 +02:00
|
|
|
cc_library {
|
|
|
|
name: "libllndk",
|
2021-04-27 01:53:58 +02:00
|
|
|
llndk: {
|
|
|
|
symbol_file: "libllndk.map.txt",
|
|
|
|
export_llndk_headers: ["libllndk_headers"],
|
|
|
|
}
|
2020-10-14 03:43:54 +02:00
|
|
|
}
|
|
|
|
|
2017-12-14 11:54:34 +01:00
|
|
|
cc_library {
|
|
|
|
name: "libvendor",
|
|
|
|
shared_libs: ["libllndk"],
|
|
|
|
vendor: true,
|
|
|
|
srcs: ["foo.c"],
|
2019-06-02 09:53:50 +02:00
|
|
|
no_libcrt: true,
|
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
|
|
|
nocrt: true,
|
2017-12-14 11:54:34 +01:00
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
// _static variant is used since _shared reuses *.o from the static variant
|
2021-04-01 14:35:20 +02:00
|
|
|
cc := ctx.ModuleForTests("libvendor", "android_vendor.29_arm_armv7-a-neon_static").Rule("cc")
|
2017-12-14 11:54:34 +01:00
|
|
|
cflags := cc.Args["cFlags"]
|
|
|
|
if !strings.Contains(cflags, "-Imy_include") {
|
|
|
|
t.Errorf("cflags for libvendor must contain -Imy_include, but was %#v.", cflags)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-19 18:17:32 +01:00
|
|
|
func checkRuntimeLibs(t *testing.T, expected []string, module *Module) {
|
|
|
|
actual := module.Properties.AndroidMkRuntimeLibs
|
|
|
|
if !reflect.DeepEqual(actual, expected) {
|
|
|
|
t.Errorf("incorrect runtime_libs for shared libs"+
|
|
|
|
"\nactual: %v"+
|
|
|
|
"\nexpected: %v",
|
|
|
|
actual,
|
|
|
|
expected,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const runtimeLibAndroidBp = `
|
|
|
|
cc_library {
|
2020-12-07 04:44:03 +01:00
|
|
|
name: "liball_available",
|
2017-12-19 18:17:32 +01:00
|
|
|
vendor_available: true,
|
2020-12-07 04:44:03 +01:00
|
|
|
product_available: true,
|
2019-06-02 09:53:50 +02:00
|
|
|
no_libcrt : true,
|
2017-12-19 18:17:32 +01:00
|
|
|
nocrt : true,
|
|
|
|
system_shared_libs : [],
|
|
|
|
}
|
|
|
|
cc_library {
|
2020-12-07 04:44:03 +01:00
|
|
|
name: "libvendor_available1",
|
2017-12-19 18:17:32 +01:00
|
|
|
vendor_available: true,
|
2020-12-07 04:44:03 +01:00
|
|
|
runtime_libs: ["liball_available"],
|
2019-06-02 09:53:50 +02:00
|
|
|
no_libcrt : true,
|
2017-12-19 18:17:32 +01:00
|
|
|
nocrt : true,
|
|
|
|
system_shared_libs : [],
|
|
|
|
}
|
|
|
|
cc_library {
|
2020-12-07 04:44:03 +01:00
|
|
|
name: "libvendor_available2",
|
2017-12-19 18:17:32 +01:00
|
|
|
vendor_available: true,
|
2020-12-07 04:44:03 +01:00
|
|
|
runtime_libs: ["liball_available"],
|
2017-12-19 18:17:32 +01:00
|
|
|
target: {
|
|
|
|
vendor: {
|
2020-12-07 04:44:03 +01:00
|
|
|
exclude_runtime_libs: ["liball_available"],
|
2017-12-19 18:17:32 +01:00
|
|
|
}
|
|
|
|
},
|
2019-06-02 09:53:50 +02:00
|
|
|
no_libcrt : true,
|
2017-12-19 18:17:32 +01:00
|
|
|
nocrt : true,
|
|
|
|
system_shared_libs : [],
|
|
|
|
}
|
2021-02-03 11:24:13 +01:00
|
|
|
cc_library {
|
|
|
|
name: "libproduct_vendor",
|
|
|
|
product_specific: true,
|
|
|
|
vendor_available: true,
|
|
|
|
no_libcrt : true,
|
|
|
|
nocrt : true,
|
|
|
|
system_shared_libs : [],
|
|
|
|
}
|
2017-12-19 18:17:32 +01:00
|
|
|
cc_library {
|
|
|
|
name: "libcore",
|
2020-12-07 04:44:03 +01:00
|
|
|
runtime_libs: ["liball_available"],
|
2019-06-02 09:53:50 +02:00
|
|
|
no_libcrt : true,
|
2017-12-19 18:17:32 +01:00
|
|
|
nocrt : true,
|
|
|
|
system_shared_libs : [],
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libvendor1",
|
|
|
|
vendor: true,
|
2019-06-02 09:53:50 +02:00
|
|
|
no_libcrt : true,
|
2017-12-19 18:17:32 +01:00
|
|
|
nocrt : true,
|
|
|
|
system_shared_libs : [],
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libvendor2",
|
|
|
|
vendor: true,
|
2021-02-03 11:24:13 +01:00
|
|
|
runtime_libs: ["liball_available", "libvendor1", "libproduct_vendor"],
|
2020-12-07 04:44:03 +01:00
|
|
|
no_libcrt : true,
|
|
|
|
nocrt : true,
|
|
|
|
system_shared_libs : [],
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libproduct_available1",
|
|
|
|
product_available: true,
|
|
|
|
runtime_libs: ["liball_available"],
|
|
|
|
no_libcrt : true,
|
|
|
|
nocrt : true,
|
|
|
|
system_shared_libs : [],
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libproduct1",
|
|
|
|
product_specific: true,
|
|
|
|
no_libcrt : true,
|
|
|
|
nocrt : true,
|
|
|
|
system_shared_libs : [],
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libproduct2",
|
|
|
|
product_specific: true,
|
2021-02-03 11:24:13 +01:00
|
|
|
runtime_libs: ["liball_available", "libproduct1", "libproduct_vendor"],
|
2019-06-02 09:53:50 +02:00
|
|
|
no_libcrt : true,
|
2017-12-19 18:17:32 +01:00
|
|
|
nocrt : true,
|
|
|
|
system_shared_libs : [],
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
func TestRuntimeLibs(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2017-12-19 18:17:32 +01:00
|
|
|
ctx := testCc(t, runtimeLibAndroidBp)
|
|
|
|
|
|
|
|
// runtime_libs for core variants use the module names without suffixes.
|
2019-11-21 01:39:12 +01:00
|
|
|
variant := "android_arm64_armv8-a_shared"
|
2017-12-19 18:17:32 +01:00
|
|
|
|
2020-12-07 04:44:03 +01:00
|
|
|
module := ctx.ModuleForTests("libvendor_available1", variant).Module().(*Module)
|
|
|
|
checkRuntimeLibs(t, []string{"liball_available"}, module)
|
|
|
|
|
|
|
|
module = ctx.ModuleForTests("libproduct_available1", variant).Module().(*Module)
|
|
|
|
checkRuntimeLibs(t, []string{"liball_available"}, module)
|
2017-12-19 18:17:32 +01:00
|
|
|
|
|
|
|
module = ctx.ModuleForTests("libcore", variant).Module().(*Module)
|
2020-12-07 04:44:03 +01:00
|
|
|
checkRuntimeLibs(t, []string{"liball_available"}, module)
|
2017-12-19 18:17:32 +01:00
|
|
|
|
|
|
|
// runtime_libs for vendor variants have '.vendor' suffixes if the modules have both core
|
|
|
|
// and vendor variants.
|
2021-04-01 14:35:20 +02:00
|
|
|
variant = "android_vendor.29_arm64_armv8-a_shared"
|
2017-12-19 18:17:32 +01:00
|
|
|
|
2020-12-07 04:44:03 +01:00
|
|
|
module = ctx.ModuleForTests("libvendor_available1", variant).Module().(*Module)
|
|
|
|
checkRuntimeLibs(t, []string{"liball_available.vendor"}, module)
|
2017-12-19 18:17:32 +01:00
|
|
|
|
|
|
|
module = ctx.ModuleForTests("libvendor2", variant).Module().(*Module)
|
2021-02-03 11:24:13 +01:00
|
|
|
checkRuntimeLibs(t, []string{"liball_available.vendor", "libvendor1", "libproduct_vendor.vendor"}, module)
|
2020-12-07 04:44:03 +01:00
|
|
|
|
|
|
|
// runtime_libs for product variants have '.product' suffixes if the modules have both core
|
|
|
|
// and product variants.
|
2021-04-01 14:35:20 +02:00
|
|
|
variant = "android_product.29_arm64_armv8-a_shared"
|
2020-12-07 04:44:03 +01:00
|
|
|
|
|
|
|
module = ctx.ModuleForTests("libproduct_available1", variant).Module().(*Module)
|
|
|
|
checkRuntimeLibs(t, []string{"liball_available.product"}, module)
|
|
|
|
|
|
|
|
module = ctx.ModuleForTests("libproduct2", variant).Module().(*Module)
|
2021-02-03 11:43:02 +01:00
|
|
|
checkRuntimeLibs(t, []string{"liball_available.product", "libproduct1", "libproduct_vendor"}, module)
|
2017-12-19 18:17:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestExcludeRuntimeLibs(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2017-12-19 18:17:32 +01:00
|
|
|
ctx := testCc(t, runtimeLibAndroidBp)
|
|
|
|
|
2019-11-21 01:39:12 +01:00
|
|
|
variant := "android_arm64_armv8-a_shared"
|
2020-12-07 04:44:03 +01:00
|
|
|
module := ctx.ModuleForTests("libvendor_available2", variant).Module().(*Module)
|
|
|
|
checkRuntimeLibs(t, []string{"liball_available"}, module)
|
2017-12-19 18:17:32 +01:00
|
|
|
|
2021-04-01 14:35:20 +02:00
|
|
|
variant = "android_vendor.29_arm64_armv8-a_shared"
|
2020-12-07 04:44:03 +01:00
|
|
|
module = ctx.ModuleForTests("libvendor_available2", variant).Module().(*Module)
|
2017-12-19 18:17:32 +01:00
|
|
|
checkRuntimeLibs(t, nil, module)
|
|
|
|
}
|
|
|
|
|
2018-11-16 02:19:56 +01:00
|
|
|
func checkStaticLibs(t *testing.T, expected []string, module *Module) {
|
2020-02-26 14:45:42 +01:00
|
|
|
t.Helper()
|
2018-11-16 02:19:56 +01:00
|
|
|
actual := module.Properties.AndroidMkStaticLibs
|
|
|
|
if !reflect.DeepEqual(actual, expected) {
|
|
|
|
t.Errorf("incorrect static_libs"+
|
|
|
|
"\nactual: %v"+
|
|
|
|
"\nexpected: %v",
|
|
|
|
actual,
|
|
|
|
expected,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const staticLibAndroidBp = `
|
|
|
|
cc_library {
|
|
|
|
name: "lib1",
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "lib2",
|
|
|
|
static_libs: ["lib1"],
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
func TestStaticLibDepExport(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2018-11-16 02:19:56 +01:00
|
|
|
ctx := testCc(t, staticLibAndroidBp)
|
|
|
|
|
|
|
|
// Check the shared version of lib2.
|
2019-11-21 01:39:12 +01:00
|
|
|
variant := "android_arm64_armv8-a_shared"
|
2018-11-16 02:19:56 +01:00
|
|
|
module := ctx.ModuleForTests("lib2", variant).Module().(*Module)
|
2022-02-10 20:41:18 +01:00
|
|
|
checkStaticLibs(t, []string{"lib1", "libc++demangle", "libclang_rt.builtins"}, module)
|
2018-11-16 02:19:56 +01:00
|
|
|
|
|
|
|
// Check the static version of lib2.
|
2019-11-21 01:39:12 +01:00
|
|
|
variant = "android_arm64_armv8-a_static"
|
2018-11-16 02:19:56 +01:00
|
|
|
module = ctx.ModuleForTests("lib2", variant).Module().(*Module)
|
|
|
|
// libc++_static is linked additionally.
|
2022-02-10 20:41:18 +01:00
|
|
|
checkStaticLibs(t, []string{"lib1", "libc++_static", "libc++demangle", "libclang_rt.builtins"}, module)
|
2018-11-16 02:19:56 +01:00
|
|
|
}
|
|
|
|
|
2017-09-26 03:50:54 +02:00
|
|
|
var compilerFlagsTestCases = []struct {
|
|
|
|
in string
|
|
|
|
out bool
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
in: "a",
|
|
|
|
out: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
in: "-a",
|
|
|
|
out: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
in: "-Ipath/to/something",
|
|
|
|
out: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
in: "-isystempath/to/something",
|
|
|
|
out: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
in: "--coverage",
|
|
|
|
out: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
in: "-include a/b",
|
|
|
|
out: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
in: "-include a/b c/d",
|
|
|
|
out: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
in: "-DMACRO",
|
|
|
|
out: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
in: "-DMAC RO",
|
|
|
|
out: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
in: "-a -b",
|
|
|
|
out: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
in: "-DMACRO=definition",
|
|
|
|
out: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
in: "-DMACRO=defi nition",
|
|
|
|
out: true, // TODO(jiyong): this should be false
|
|
|
|
},
|
|
|
|
{
|
|
|
|
in: "-DMACRO(x)=x + 1",
|
|
|
|
out: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
in: "-DMACRO=\"defi nition\"",
|
|
|
|
out: true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
type mockContext struct {
|
|
|
|
BaseModuleContext
|
|
|
|
result bool
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ctx *mockContext) PropertyErrorf(property, format string, args ...interface{}) {
|
|
|
|
// CheckBadCompilerFlags calls this function when the flag should be rejected
|
|
|
|
ctx.result = false
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestCompilerFlags(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2017-09-26 03:50:54 +02:00
|
|
|
for _, testCase := range compilerFlagsTestCases {
|
|
|
|
ctx := &mockContext{result: true}
|
|
|
|
CheckBadCompilerFlags(ctx, "", []string{testCase.in})
|
|
|
|
if ctx.result != testCase.out {
|
|
|
|
t.Errorf("incorrect output:")
|
|
|
|
t.Errorf(" input: %#v", testCase.in)
|
|
|
|
t.Errorf(" expected: %#v", testCase.out)
|
|
|
|
t.Errorf(" got: %#v", ctx.result)
|
|
|
|
}
|
|
|
|
}
|
2017-09-28 02:05:30 +02:00
|
|
|
}
|
Allow platform modules to link to vendor public libraries
Normally, when building with VNDK, platform modules are not allowed to
link against vendor libraries, because the ABI of the vendor libraries
are not guaranteed to be stable and may differ across multiple vendor
images.
However, the vendor public libraries are the exceptions. Vendor public
libraries are vendor libraries that are exposed to 3rd party apps and
listed in /vendor/etc/public.libraries.txt. Since they are intended to
be exposed to public, their ABI stability is guaranteed (by definition,
though it is up to the vendor to actually guarantee it).
This change provides a way to make a vendor lib as public by defining a
module of type 'vendor_public_library' with a map file that enumerates
public symbols that are publicized:
cc_library {
name: "libvendor",
proprietary: true,
...
}
vendor_public_library {
name: "libvendor",
symbol_file: "libvendor.map.txt",
}
This defines a stub library module named libvendor.vendorpublic from the
map file. `shared_libs: ["libvendor"]` is redirected to the stub library
when it is from the outside of the vendor partition.
Bug: 74275385
Test: m -j
Test: cc_test.go passes
Change-Id: I5bed94d7c4282b777632ab2f0fb63c203ee313ba
2018-03-19 10:23:01 +01:00
|
|
|
|
2018-07-11 03:49:27 +02:00
|
|
|
func TestRecovery(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2018-07-11 03:49:27 +02:00
|
|
|
ctx := testCc(t, `
|
|
|
|
cc_library_shared {
|
|
|
|
name: "librecovery",
|
|
|
|
recovery: true,
|
|
|
|
}
|
|
|
|
cc_library_shared {
|
|
|
|
name: "librecovery32",
|
|
|
|
recovery: true,
|
|
|
|
compile_multilib:"32",
|
|
|
|
}
|
2018-08-28 02:55:37 +02:00
|
|
|
cc_library_shared {
|
|
|
|
name: "libHalInRecovery",
|
|
|
|
recovery_available: true,
|
|
|
|
vendor: true,
|
|
|
|
}
|
2018-07-11 03:49:27 +02:00
|
|
|
`)
|
|
|
|
|
|
|
|
variants := ctx.ModuleVariantsForTests("librecovery")
|
2019-11-21 02:12:35 +01:00
|
|
|
const arm64 = "android_recovery_arm64_armv8-a_shared"
|
2018-07-11 03:49:27 +02:00
|
|
|
if len(variants) != 1 || !android.InList(arm64, variants) {
|
|
|
|
t.Errorf("variants of librecovery must be \"%s\" only, but was %#v", arm64, variants)
|
|
|
|
}
|
|
|
|
|
|
|
|
variants = ctx.ModuleVariantsForTests("librecovery32")
|
|
|
|
if android.InList(arm64, variants) {
|
|
|
|
t.Errorf("multilib was set to 32 for librecovery32, but its variants has %s.", arm64)
|
|
|
|
}
|
2018-08-28 02:55:37 +02:00
|
|
|
|
|
|
|
recoveryModule := ctx.ModuleForTests("libHalInRecovery", recoveryVariant).Module().(*Module)
|
|
|
|
if !recoveryModule.Platform() {
|
|
|
|
t.Errorf("recovery variant of libHalInRecovery must not specific to device, soc, or product")
|
|
|
|
}
|
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
|
|
|
}
|
2018-08-28 02:55:37 +02:00
|
|
|
|
2020-06-17 22:10:42 +02:00
|
|
|
func TestDataLibsPrebuiltSharedTestLibrary(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2020-06-17 22:10:42 +02:00
|
|
|
bp := `
|
|
|
|
cc_prebuilt_test_library_shared {
|
|
|
|
name: "test_lib",
|
|
|
|
relative_install_path: "foo/bar/baz",
|
|
|
|
srcs: ["srcpath/dontusethispath/baz.so"],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_test {
|
|
|
|
name: "main_test",
|
|
|
|
data_libs: ["test_lib"],
|
|
|
|
gtest: false,
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
2021-03-23 00:21:32 +01:00
|
|
|
config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
|
2020-06-17 22:10:42 +02:00
|
|
|
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
|
2021-04-01 14:35:20 +02:00
|
|
|
config.TestProductVariables.Platform_vndk_version = StringPtr("29")
|
2020-06-17 22:10:42 +02:00
|
|
|
config.TestProductVariables.VndkUseCoreVariant = BoolPtr(true)
|
|
|
|
|
|
|
|
ctx := testCcWithConfig(t, config)
|
|
|
|
module := ctx.ModuleForTests("main_test", "android_arm_armv7-a-neon").Module()
|
|
|
|
testBinary := module.(*Module).linker.(*testBinary)
|
|
|
|
outputFiles, err := module.(android.OutputFileProducer).OutputFiles("")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("Expected cc_test to produce output files, error: %s", err)
|
|
|
|
}
|
|
|
|
if len(outputFiles) != 1 {
|
|
|
|
t.Errorf("expected exactly one output file. output files: [%s]", outputFiles)
|
|
|
|
}
|
|
|
|
if len(testBinary.dataPaths()) != 1 {
|
2023-11-16 21:56:02 +01:00
|
|
|
t.Errorf("expected exactly one test data file. test data files: [%v]", testBinary.dataPaths())
|
2020-06-17 22:10:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
outputPath := outputFiles[0].String()
|
|
|
|
|
|
|
|
if !strings.HasSuffix(outputPath, "/main_test") {
|
|
|
|
t.Errorf("expected test output file to be 'main_test', but was '%s'", outputPath)
|
|
|
|
}
|
2020-07-03 22:18:24 +02:00
|
|
|
entries := android.AndroidMkEntriesForTest(t, ctx, module)[0]
|
2020-06-17 22:10:42 +02:00
|
|
|
if !strings.HasSuffix(entries.EntryMap["LOCAL_TEST_DATA"][0], ":test_lib.so:foo/bar/baz") {
|
|
|
|
t.Errorf("expected LOCAL_TEST_DATA to end with `:test_lib.so:foo/bar/baz`,"+
|
|
|
|
" but was '%s'", entries.EntryMap["LOCAL_TEST_DATA"][0])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 TestVersionedStubs(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
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
|
|
|
ctx := testCc(t, `
|
|
|
|
cc_library_shared {
|
|
|
|
name: "libFoo",
|
2018-11-02 10:23:15 +01:00
|
|
|
srcs: ["foo.c"],
|
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: {
|
|
|
|
symbol_file: "foo.map.txt",
|
|
|
|
versions: ["1", "2", "3"],
|
|
|
|
},
|
|
|
|
}
|
2018-11-02 10:23:15 +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
|
|
|
cc_library_shared {
|
|
|
|
name: "libBar",
|
2018-11-02 10:23:15 +01:00
|
|
|
srcs: ["bar.c"],
|
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
|
|
|
shared_libs: ["libFoo#1"],
|
|
|
|
}`)
|
|
|
|
|
|
|
|
variants := ctx.ModuleVariantsForTests("libFoo")
|
|
|
|
expectedVariants := []string{
|
2019-11-21 01:39:12 +01:00
|
|
|
"android_arm64_armv8-a_shared",
|
|
|
|
"android_arm64_armv8-a_shared_1",
|
|
|
|
"android_arm64_armv8-a_shared_2",
|
|
|
|
"android_arm64_armv8-a_shared_3",
|
"current" is implicitly added to stubs.versions
So far, when a library `libfoo` has `stubs.versions: ["10", "11"]`, then
`shared_libs: ["libfoo"]` is linked to the version 11 of the stub.
This requires the author of `libfoo` to manually update the property
whenever a new version is introduced. Otherwise, clients are not able
to use the newly added APIs because the latest stub is for an old
version.
This change eliminates the need for manual updating. "current" version
is always implicitly added to `stubs.versions`. It is added even when
nothing is set on the property, if `stubs.symbol_file` is set. i.e.
```
cc_library {
name: "libfoo",
stubs: {
symbol_file: "libfoo.map.txt",
// no versions: [...] needed
},
}
cc_library {
name: "a_client",
shared_libs: ["libfoo"],
apex_available: ["myapex"],
min_sdk_version: "29",
}
apex {
name: "myapex",
native_shared_libraries: ["a_client"],
min_sdk_version: "29",
}
```
`a_client` links to the "current" stub of `libfoo` that has all symbols
shown in the map file.
Note that, above doesn't mean that the client has unlimited access to
APIs that are introduced even after the min_sdk_version of the client
(29 in this example). The use of such APIs still has to be guarded with
`__builtin_available` check.
Bug: N/A
Test: m
Change-Id: I70bb1600c18e74d36c6b24c3569d2149f02aaf96
2021-03-17 12:21:35 +01:00
|
|
|
"android_arm64_armv8-a_shared_current",
|
2019-11-21 01:39:12 +01:00
|
|
|
"android_arm_armv7-a-neon_shared",
|
|
|
|
"android_arm_armv7-a-neon_shared_1",
|
|
|
|
"android_arm_armv7-a-neon_shared_2",
|
|
|
|
"android_arm_armv7-a-neon_shared_3",
|
"current" is implicitly added to stubs.versions
So far, when a library `libfoo` has `stubs.versions: ["10", "11"]`, then
`shared_libs: ["libfoo"]` is linked to the version 11 of the stub.
This requires the author of `libfoo` to manually update the property
whenever a new version is introduced. Otherwise, clients are not able
to use the newly added APIs because the latest stub is for an old
version.
This change eliminates the need for manual updating. "current" version
is always implicitly added to `stubs.versions`. It is added even when
nothing is set on the property, if `stubs.symbol_file` is set. i.e.
```
cc_library {
name: "libfoo",
stubs: {
symbol_file: "libfoo.map.txt",
// no versions: [...] needed
},
}
cc_library {
name: "a_client",
shared_libs: ["libfoo"],
apex_available: ["myapex"],
min_sdk_version: "29",
}
apex {
name: "myapex",
native_shared_libraries: ["a_client"],
min_sdk_version: "29",
}
```
`a_client` links to the "current" stub of `libfoo` that has all symbols
shown in the map file.
Note that, above doesn't mean that the client has unlimited access to
APIs that are introduced even after the min_sdk_version of the client
(29 in this example). The use of such APIs still has to be guarded with
`__builtin_available` check.
Bug: N/A
Test: m
Change-Id: I70bb1600c18e74d36c6b24c3569d2149f02aaf96
2021-03-17 12:21:35 +01:00
|
|
|
"android_arm_armv7-a-neon_shared_current",
|
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
|
|
|
}
|
|
|
|
variantsMismatch := false
|
|
|
|
if len(variants) != len(expectedVariants) {
|
|
|
|
variantsMismatch = true
|
|
|
|
} else {
|
|
|
|
for _, v := range expectedVariants {
|
|
|
|
if !inList(v, variants) {
|
|
|
|
variantsMismatch = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if variantsMismatch {
|
|
|
|
t.Errorf("variants of libFoo expected:\n")
|
|
|
|
for _, v := range expectedVariants {
|
|
|
|
t.Errorf("%q\n", v)
|
|
|
|
}
|
|
|
|
t.Errorf(", but got:\n")
|
|
|
|
for _, v := range variants {
|
|
|
|
t.Errorf("%q\n", v)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-21 01:39:12 +01:00
|
|
|
libBarLinkRule := ctx.ModuleForTests("libBar", "android_arm64_armv8-a_shared").Rule("ld")
|
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
|
|
|
libFlags := libBarLinkRule.Args["libFlags"]
|
2019-11-21 01:39:12 +01:00
|
|
|
libFoo1StubPath := "libFoo/android_arm64_armv8-a_shared_1/libFoo.so"
|
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 !strings.Contains(libFlags, libFoo1StubPath) {
|
|
|
|
t.Errorf("%q is not found in %q", libFoo1StubPath, libFlags)
|
|
|
|
}
|
2018-11-02 10:23:15 +01:00
|
|
|
|
2019-11-21 01:39:12 +01:00
|
|
|
libBarCompileRule := ctx.ModuleForTests("libBar", "android_arm64_armv8-a_shared").Rule("cc")
|
2018-11-02 10:23:15 +01:00
|
|
|
cFlags := libBarCompileRule.Args["cFlags"]
|
|
|
|
libFoo1VersioningMacro := "-D__LIBFOO_API__=1"
|
|
|
|
if !strings.Contains(cFlags, libFoo1VersioningMacro) {
|
|
|
|
t.Errorf("%q is not found in %q", libFoo1VersioningMacro, cFlags)
|
|
|
|
}
|
2018-07-11 03:49:27 +02:00
|
|
|
}
|
2018-12-18 20:08:25 +01:00
|
|
|
|
2023-03-17 15:17:50 +01:00
|
|
|
func TestStubsForLibraryInMultipleApexes(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
ctx := testCc(t, `
|
|
|
|
cc_library_shared {
|
|
|
|
name: "libFoo",
|
|
|
|
srcs: ["foo.c"],
|
|
|
|
stubs: {
|
|
|
|
symbol_file: "foo.map.txt",
|
|
|
|
versions: ["current"],
|
|
|
|
},
|
|
|
|
apex_available: ["bar", "a1"],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library_shared {
|
|
|
|
name: "libBar",
|
|
|
|
srcs: ["bar.c"],
|
|
|
|
shared_libs: ["libFoo"],
|
|
|
|
apex_available: ["a1"],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library_shared {
|
|
|
|
name: "libA1",
|
|
|
|
srcs: ["a1.c"],
|
|
|
|
shared_libs: ["libFoo"],
|
|
|
|
apex_available: ["a1"],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library_shared {
|
|
|
|
name: "libBarA1",
|
|
|
|
srcs: ["bara1.c"],
|
|
|
|
shared_libs: ["libFoo"],
|
|
|
|
apex_available: ["bar", "a1"],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library_shared {
|
|
|
|
name: "libAnyApex",
|
|
|
|
srcs: ["anyApex.c"],
|
|
|
|
shared_libs: ["libFoo"],
|
|
|
|
apex_available: ["//apex_available:anyapex"],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library_shared {
|
|
|
|
name: "libBaz",
|
|
|
|
srcs: ["baz.c"],
|
|
|
|
shared_libs: ["libFoo"],
|
|
|
|
apex_available: ["baz"],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library_shared {
|
|
|
|
name: "libQux",
|
|
|
|
srcs: ["qux.c"],
|
|
|
|
shared_libs: ["libFoo"],
|
|
|
|
apex_available: ["qux", "bar"],
|
|
|
|
}`)
|
|
|
|
|
|
|
|
variants := ctx.ModuleVariantsForTests("libFoo")
|
|
|
|
expectedVariants := []string{
|
|
|
|
"android_arm64_armv8-a_shared",
|
|
|
|
"android_arm64_armv8-a_shared_current",
|
|
|
|
"android_arm_armv7-a-neon_shared",
|
|
|
|
"android_arm_armv7-a-neon_shared_current",
|
|
|
|
}
|
|
|
|
variantsMismatch := false
|
|
|
|
if len(variants) != len(expectedVariants) {
|
|
|
|
variantsMismatch = true
|
|
|
|
} else {
|
|
|
|
for _, v := range expectedVariants {
|
|
|
|
if !inList(v, variants) {
|
|
|
|
variantsMismatch = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if variantsMismatch {
|
|
|
|
t.Errorf("variants of libFoo expected:\n")
|
|
|
|
for _, v := range expectedVariants {
|
|
|
|
t.Errorf("%q\n", v)
|
|
|
|
}
|
|
|
|
t.Errorf(", but got:\n")
|
|
|
|
for _, v := range variants {
|
|
|
|
t.Errorf("%q\n", v)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
linkAgainstFoo := []string{"libBarA1"}
|
|
|
|
linkAgainstFooStubs := []string{"libBar", "libA1", "libBaz", "libQux", "libAnyApex"}
|
|
|
|
|
|
|
|
libFooPath := "libFoo/android_arm64_armv8-a_shared/libFoo.so"
|
|
|
|
for _, lib := range linkAgainstFoo {
|
|
|
|
libLinkRule := ctx.ModuleForTests(lib, "android_arm64_armv8-a_shared").Rule("ld")
|
|
|
|
libFlags := libLinkRule.Args["libFlags"]
|
|
|
|
if !strings.Contains(libFlags, libFooPath) {
|
|
|
|
t.Errorf("%q: %q is not found in %q", lib, libFooPath, libFlags)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
libFooStubPath := "libFoo/android_arm64_armv8-a_shared_current/libFoo.so"
|
|
|
|
for _, lib := range linkAgainstFooStubs {
|
|
|
|
libLinkRule := ctx.ModuleForTests(lib, "android_arm64_armv8-a_shared").Rule("ld")
|
|
|
|
libFlags := libLinkRule.Args["libFlags"]
|
2023-04-20 15:13:25 +02:00
|
|
|
if !strings.Contains(libFlags, libFooStubPath) {
|
|
|
|
t.Errorf("%q: %q is not found in %q", lib, libFooStubPath, libFlags)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-13 10:57:35 +01:00
|
|
|
func TestVersioningMacro(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2020-03-13 10:57:35 +01:00
|
|
|
for _, tc := range []struct{ moduleName, expected string }{
|
|
|
|
{"libc", "__LIBC_API__"},
|
|
|
|
{"libfoo", "__LIBFOO_API__"},
|
|
|
|
{"libfoo@1", "__LIBFOO_1_API__"},
|
|
|
|
{"libfoo-v1", "__LIBFOO_V1_API__"},
|
|
|
|
{"libfoo.v1", "__LIBFOO_V1_API__"},
|
|
|
|
} {
|
|
|
|
checkEquals(t, tc.moduleName, tc.expected, versioningMacroName(tc.moduleName))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-22 14:24:20 +02:00
|
|
|
func pathsToBase(paths android.Paths) []string {
|
|
|
|
var ret []string
|
|
|
|
for _, p := range paths {
|
|
|
|
ret = append(ret, p.Base())
|
|
|
|
}
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestStaticLibArchiveArgs(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2022-09-22 14:24:20 +02:00
|
|
|
ctx := testCc(t, `
|
|
|
|
cc_library_static {
|
|
|
|
name: "foo",
|
|
|
|
srcs: ["foo.c"],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library_static {
|
|
|
|
name: "bar",
|
|
|
|
srcs: ["bar.c"],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library_shared {
|
|
|
|
name: "qux",
|
|
|
|
srcs: ["qux.c"],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library_static {
|
|
|
|
name: "baz",
|
|
|
|
srcs: ["baz.c"],
|
|
|
|
static_libs: ["foo"],
|
|
|
|
shared_libs: ["qux"],
|
|
|
|
whole_static_libs: ["bar"],
|
|
|
|
}`)
|
|
|
|
|
|
|
|
variant := "android_arm64_armv8-a_static"
|
|
|
|
arRule := ctx.ModuleForTests("baz", variant).Rule("ar")
|
|
|
|
|
|
|
|
// For static libraries, the object files of a whole static dep are included in the archive
|
|
|
|
// directly
|
|
|
|
if g, w := pathsToBase(arRule.Inputs), []string{"bar.o", "baz.o"}; !reflect.DeepEqual(w, g) {
|
|
|
|
t.Errorf("Expected input objects %q, got %q", w, g)
|
|
|
|
}
|
|
|
|
|
|
|
|
// non whole static dependencies are not linked into the archive
|
|
|
|
if len(arRule.Implicits) > 0 {
|
|
|
|
t.Errorf("Expected 0 additional deps, got %q", arRule.Implicits)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSharedLibLinkingArgs(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2022-09-22 14:24:20 +02:00
|
|
|
ctx := testCc(t, `
|
|
|
|
cc_library_static {
|
|
|
|
name: "foo",
|
|
|
|
srcs: ["foo.c"],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library_static {
|
|
|
|
name: "bar",
|
|
|
|
srcs: ["bar.c"],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library_shared {
|
|
|
|
name: "qux",
|
|
|
|
srcs: ["qux.c"],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library_shared {
|
|
|
|
name: "baz",
|
|
|
|
srcs: ["baz.c"],
|
|
|
|
static_libs: ["foo"],
|
|
|
|
shared_libs: ["qux"],
|
|
|
|
whole_static_libs: ["bar"],
|
|
|
|
}`)
|
|
|
|
|
|
|
|
variant := "android_arm64_armv8-a_shared"
|
|
|
|
linkRule := ctx.ModuleForTests("baz", variant).Rule("ld")
|
|
|
|
libFlags := linkRule.Args["libFlags"]
|
|
|
|
// When dynamically linking, we expect static dependencies to be found on the command line
|
|
|
|
if expected := "foo.a"; !strings.Contains(libFlags, expected) {
|
|
|
|
t.Errorf("Static lib %q was not found in %q", expected, libFlags)
|
|
|
|
}
|
|
|
|
// When dynamically linking, we expect whole static dependencies to be found on the command line
|
|
|
|
if expected := "bar.a"; !strings.Contains(libFlags, expected) {
|
|
|
|
t.Errorf("Static lib %q was not found in %q", expected, libFlags)
|
|
|
|
}
|
|
|
|
|
|
|
|
// When dynamically linking, we expect shared dependencies to be found on the command line
|
|
|
|
if expected := "qux.so"; !strings.Contains(libFlags, expected) {
|
|
|
|
t.Errorf("Shared lib %q was not found in %q", expected, libFlags)
|
|
|
|
}
|
|
|
|
|
|
|
|
// We should only have the objects from the shared library srcs, not the whole static dependencies
|
|
|
|
if g, w := pathsToBase(linkRule.Inputs), []string{"baz.o"}; !reflect.DeepEqual(w, g) {
|
|
|
|
t.Errorf("Expected input objects %q, got %q", w, g)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-18 20:08:25 +01:00
|
|
|
func TestStaticExecutable(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2018-12-18 20:08:25 +01:00
|
|
|
ctx := testCc(t, `
|
|
|
|
cc_binary {
|
|
|
|
name: "static_test",
|
2019-08-16 21:14:32 +02:00
|
|
|
srcs: ["foo.c", "baz.o"],
|
2018-12-18 20:08:25 +01:00
|
|
|
static_executable: true,
|
|
|
|
}`)
|
|
|
|
|
2019-11-21 01:39:12 +01:00
|
|
|
variant := "android_arm64_armv8-a"
|
2018-12-18 20:08:25 +01:00
|
|
|
binModuleRule := ctx.ModuleForTests("static_test", variant).Rule("ld")
|
|
|
|
libFlags := binModuleRule.Args["libFlags"]
|
Stop linking libdl.a into static bins
libdl.a has a no-op dlopen, which breaks static libraries that need a real
dlopen. Instead of automatically linking libdl.a into static executables,
make it optional.
Until recently, the libunwind_llvm.a unwinder, used on arm32, needed the
no-op dladdr, but it's now built using -D_LIBUNWIND_USE_DLADDR=0.
The HWASan run-time uses dlsym and dladdr, so add a libdl dependency for
HWASan-built static binaries. We could also remove the dependency from
libclang_rt.hwasan_static-*.a, but this is also easy to do.
Bug: http://b/141485154
Test: bionic unit tests, device boots, verify that static and dynamic
executables can throw/catch an exception
Test: verify that a static executable using dlopen doesn't link (unless it
adds an explicit dependency on libdl)
Change-Id: Ic52c3f336b671b4ed335e99c94a64dfe8614b618
2019-10-12 00:03:34 +02:00
|
|
|
systemStaticLibs := []string{"libc.a", "libm.a"}
|
2018-12-18 20:08:25 +01:00
|
|
|
for _, lib := range systemStaticLibs {
|
|
|
|
if !strings.Contains(libFlags, lib) {
|
|
|
|
t.Errorf("Static lib %q was not found in %q", lib, libFlags)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
systemSharedLibs := []string{"libc.so", "libm.so", "libdl.so"}
|
|
|
|
for _, lib := range systemSharedLibs {
|
|
|
|
if strings.Contains(libFlags, lib) {
|
|
|
|
t.Errorf("Shared lib %q was found in %q", lib, libFlags)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-01-31 16:31:10 +01:00
|
|
|
|
|
|
|
func TestStaticDepsOrderWithStubs(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2019-01-31 16:31:10 +01:00
|
|
|
ctx := testCc(t, `
|
|
|
|
cc_binary {
|
|
|
|
name: "mybin",
|
|
|
|
srcs: ["foo.c"],
|
2020-09-18 23:15:30 +02:00
|
|
|
static_libs: ["libfooC", "libfooB"],
|
2019-01-31 16:31:10 +01:00
|
|
|
static_executable: true,
|
|
|
|
stl: "none",
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
2020-02-15 20:29:50 +01:00
|
|
|
name: "libfooB",
|
2019-01-31 16:31:10 +01:00
|
|
|
srcs: ["foo.c"],
|
2020-02-15 20:29:50 +01:00
|
|
|
shared_libs: ["libfooC"],
|
2019-01-31 16:31:10 +01:00
|
|
|
stl: "none",
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
2020-02-15 20:29:50 +01:00
|
|
|
name: "libfooC",
|
2019-01-31 16:31:10 +01:00
|
|
|
srcs: ["foo.c"],
|
|
|
|
stl: "none",
|
|
|
|
stubs: {
|
|
|
|
versions: ["1"],
|
|
|
|
},
|
|
|
|
}`)
|
|
|
|
|
2020-09-18 23:15:30 +02:00
|
|
|
mybin := ctx.ModuleForTests("mybin", "android_arm64_armv8-a").Rule("ld")
|
|
|
|
actual := mybin.Implicits[:2]
|
2021-05-20 19:01:32 +02:00
|
|
|
expected := GetOutputPaths(ctx, "android_arm64_armv8-a_static", []string{"libfooB", "libfooC"})
|
2019-01-31 16:31:10 +01:00
|
|
|
|
|
|
|
if !reflect.DeepEqual(actual, expected) {
|
|
|
|
t.Errorf("staticDeps orderings were not propagated correctly"+
|
|
|
|
"\nactual: %v"+
|
|
|
|
"\nexpected: %v",
|
|
|
|
actual,
|
|
|
|
expected,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
2019-05-15 21:01:54 +02:00
|
|
|
|
2019-08-23 04:18:57 +02:00
|
|
|
func TestErrorsIfAModuleDependsOnDisabled(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2019-08-23 04:18:57 +02:00
|
|
|
testCcError(t, `module "libA" .* depends on disabled module "libB"`, `
|
|
|
|
cc_library {
|
|
|
|
name: "libA",
|
|
|
|
srcs: ["foo.c"],
|
|
|
|
shared_libs: ["libB"],
|
|
|
|
stl: "none",
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libB",
|
|
|
|
srcs: ["foo.c"],
|
|
|
|
enabled: false,
|
|
|
|
stl: "none",
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
}
|
|
|
|
|
2022-07-22 19:22:02 +02:00
|
|
|
func VerifyAFLFuzzTargetVariant(t *testing.T, variant string) {
|
|
|
|
bp := `
|
|
|
|
cc_fuzz {
|
2022-06-07 22:12:06 +02:00
|
|
|
name: "test_afl_fuzz_target",
|
|
|
|
srcs: ["foo.c"],
|
|
|
|
host_supported: true,
|
|
|
|
static_libs: [
|
|
|
|
"afl_fuzz_static_lib",
|
|
|
|
],
|
|
|
|
shared_libs: [
|
|
|
|
"afl_fuzz_shared_lib",
|
|
|
|
],
|
2022-07-22 19:22:02 +02:00
|
|
|
fuzzing_frameworks: {
|
|
|
|
afl: true,
|
|
|
|
libfuzzer: false,
|
|
|
|
},
|
2022-06-07 22:12:06 +02:00
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "afl_fuzz_static_lib",
|
|
|
|
host_supported: true,
|
|
|
|
srcs: ["static_file.c"],
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libfuzzer_only_static_lib",
|
|
|
|
host_supported: true,
|
|
|
|
srcs: ["static_file.c"],
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "afl_fuzz_shared_lib",
|
|
|
|
host_supported: true,
|
|
|
|
srcs: ["shared_file.c"],
|
|
|
|
static_libs: [
|
|
|
|
"second_static_lib",
|
|
|
|
],
|
|
|
|
}
|
|
|
|
cc_library_headers {
|
|
|
|
name: "libafl_headers",
|
|
|
|
vendor_available: true,
|
|
|
|
host_supported: true,
|
|
|
|
export_include_dirs: [
|
|
|
|
"include",
|
|
|
|
"instrumentation",
|
|
|
|
],
|
|
|
|
}
|
|
|
|
cc_object {
|
|
|
|
name: "afl-compiler-rt",
|
|
|
|
vendor_available: true,
|
|
|
|
host_supported: true,
|
|
|
|
cflags: [
|
|
|
|
"-fPIC",
|
|
|
|
],
|
|
|
|
srcs: [
|
|
|
|
"instrumentation/afl-compiler-rt.o.c",
|
|
|
|
],
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "second_static_lib",
|
|
|
|
host_supported: true,
|
|
|
|
srcs: ["second_file.c"],
|
|
|
|
}
|
2022-07-22 19:22:02 +02:00
|
|
|
cc_object {
|
2022-06-07 22:12:06 +02:00
|
|
|
name: "aflpp_driver",
|
2022-07-22 19:22:02 +02:00
|
|
|
host_supported: true,
|
2022-06-07 22:12:06 +02:00
|
|
|
srcs: [
|
|
|
|
"aflpp_driver.c",
|
|
|
|
],
|
2022-07-22 19:22:02 +02:00
|
|
|
}`
|
|
|
|
|
|
|
|
testEnv := map[string]string{
|
|
|
|
"FUZZ_FRAMEWORK": "AFL",
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx := android.GroupFixturePreparers(prepareForCcTest, android.FixtureMergeEnv(testEnv)).RunTestWithBp(t, bp)
|
2022-06-07 22:12:06 +02:00
|
|
|
|
|
|
|
checkPcGuardFlag := func(
|
|
|
|
modName string, variantName string, shouldHave bool) {
|
|
|
|
cc := ctx.ModuleForTests(modName, variantName).Rule("cc")
|
|
|
|
|
|
|
|
cFlags, ok := cc.Args["cFlags"]
|
|
|
|
if !ok {
|
|
|
|
t.Errorf("Could not find cFlags for module %s and variant %s",
|
|
|
|
modName, variantName)
|
|
|
|
}
|
|
|
|
|
|
|
|
if strings.Contains(
|
|
|
|
cFlags, "-fsanitize-coverage=trace-pc-guard") != shouldHave {
|
|
|
|
t.Errorf("Flag was found: %t. Expected to find flag: %t. "+
|
|
|
|
"Test failed for module %s and variant %s",
|
|
|
|
!shouldHave, shouldHave, modName, variantName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
moduleName := "test_afl_fuzz_target"
|
2022-07-22 19:22:02 +02:00
|
|
|
checkPcGuardFlag(moduleName, variant+"_fuzzer", true)
|
2022-06-07 22:12:06 +02:00
|
|
|
|
|
|
|
moduleName = "afl_fuzz_static_lib"
|
2022-07-22 19:22:02 +02:00
|
|
|
checkPcGuardFlag(moduleName, variant+"_static", false)
|
|
|
|
checkPcGuardFlag(moduleName, variant+"_static_fuzzer", true)
|
2022-06-07 22:12:06 +02:00
|
|
|
|
|
|
|
moduleName = "second_static_lib"
|
2022-07-22 19:22:02 +02:00
|
|
|
checkPcGuardFlag(moduleName, variant+"_static", false)
|
|
|
|
checkPcGuardFlag(moduleName, variant+"_static_fuzzer", true)
|
2022-06-07 22:12:06 +02:00
|
|
|
|
|
|
|
ctx.ModuleForTests("afl_fuzz_shared_lib",
|
|
|
|
"android_arm64_armv8-a_shared").Rule("cc")
|
|
|
|
ctx.ModuleForTests("afl_fuzz_shared_lib",
|
2022-07-22 19:22:02 +02:00
|
|
|
"android_arm64_armv8-a_shared_fuzzer").Rule("cc")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestAFLFuzzTargetForDevice(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2022-07-22 19:22:02 +02:00
|
|
|
VerifyAFLFuzzTargetVariant(t, "android_arm64_armv8-a")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestAFLFuzzTargetForLinuxHost(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2022-07-22 19:22:02 +02:00
|
|
|
if runtime.GOOS != "linux" {
|
|
|
|
t.Skip("requires linux")
|
|
|
|
}
|
|
|
|
|
|
|
|
VerifyAFLFuzzTargetVariant(t, "linux_glibc_x86_64")
|
2022-06-07 22:12:06 +02:00
|
|
|
}
|
|
|
|
|
2019-07-15 18:34:09 +02:00
|
|
|
// Simple smoke test for the cc_fuzz target that ensures the rule compiles
|
|
|
|
// correctly.
|
|
|
|
func TestFuzzTarget(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2019-07-15 18:34:09 +02:00
|
|
|
ctx := testCc(t, `
|
|
|
|
cc_fuzz {
|
|
|
|
name: "fuzz_smoke_test",
|
|
|
|
srcs: ["foo.c"],
|
|
|
|
}`)
|
|
|
|
|
2019-12-19 20:06:13 +01:00
|
|
|
variant := "android_arm64_armv8-a_fuzzer"
|
2019-07-15 18:34:09 +02:00
|
|
|
ctx.ModuleForTests("fuzz_smoke_test", variant).Rule("cc")
|
|
|
|
}
|
|
|
|
|
2019-05-15 21:01:54 +02:00
|
|
|
func assertString(t *testing.T, got, expected string) {
|
|
|
|
t.Helper()
|
|
|
|
if got != expected {
|
|
|
|
t.Errorf("expected %q got %q", expected, got)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func assertArrayString(t *testing.T, got, expected []string) {
|
|
|
|
t.Helper()
|
|
|
|
if len(got) != len(expected) {
|
|
|
|
t.Errorf("expected %d (%q) got (%d) %q", len(expected), expected, len(got), got)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
for i := range got {
|
|
|
|
if got[i] != expected[i] {
|
|
|
|
t.Errorf("expected %d-th %q (%q) got %q (%q)",
|
|
|
|
i, expected[i], expected, got[i], got)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-09-24 23:55:04 +02:00
|
|
|
|
2019-10-30 10:43:49 +01:00
|
|
|
func assertMapKeys(t *testing.T, m map[string]string, expected []string) {
|
|
|
|
t.Helper()
|
2023-03-01 01:02:16 +01:00
|
|
|
assertArrayString(t, android.SortedKeys(m), expected)
|
2019-10-30 10:43:49 +01:00
|
|
|
}
|
|
|
|
|
2019-09-24 23:55:04 +02:00
|
|
|
func TestDefaults(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2019-09-24 23:55:04 +02:00
|
|
|
ctx := testCc(t, `
|
|
|
|
cc_defaults {
|
|
|
|
name: "defaults",
|
|
|
|
srcs: ["foo.c"],
|
|
|
|
static: {
|
|
|
|
srcs: ["bar.c"],
|
|
|
|
},
|
|
|
|
shared: {
|
|
|
|
srcs: ["baz.c"],
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library_static {
|
|
|
|
name: "libstatic",
|
|
|
|
defaults: ["defaults"],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library_shared {
|
|
|
|
name: "libshared",
|
|
|
|
defaults: ["defaults"],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libboth",
|
|
|
|
defaults: ["defaults"],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_binary {
|
|
|
|
name: "binary",
|
|
|
|
defaults: ["defaults"],
|
|
|
|
}`)
|
|
|
|
|
2019-11-21 01:39:12 +01:00
|
|
|
shared := ctx.ModuleForTests("libshared", "android_arm64_armv8-a_shared").Rule("ld")
|
2019-09-24 23:55:04 +02:00
|
|
|
if g, w := pathsToBase(shared.Inputs), []string{"foo.o", "baz.o"}; !reflect.DeepEqual(w, g) {
|
|
|
|
t.Errorf("libshared ld rule wanted %q, got %q", w, g)
|
|
|
|
}
|
2019-11-21 01:39:12 +01:00
|
|
|
bothShared := ctx.ModuleForTests("libboth", "android_arm64_armv8-a_shared").Rule("ld")
|
2019-09-24 23:55:04 +02:00
|
|
|
if g, w := pathsToBase(bothShared.Inputs), []string{"foo.o", "baz.o"}; !reflect.DeepEqual(w, g) {
|
|
|
|
t.Errorf("libboth ld rule wanted %q, got %q", w, g)
|
|
|
|
}
|
2019-11-21 01:39:12 +01:00
|
|
|
binary := ctx.ModuleForTests("binary", "android_arm64_armv8-a").Rule("ld")
|
2019-09-24 23:55:04 +02:00
|
|
|
if g, w := pathsToBase(binary.Inputs), []string{"foo.o"}; !reflect.DeepEqual(w, g) {
|
|
|
|
t.Errorf("binary ld rule wanted %q, got %q", w, g)
|
|
|
|
}
|
|
|
|
|
2019-11-21 01:39:12 +01:00
|
|
|
static := ctx.ModuleForTests("libstatic", "android_arm64_armv8-a_static").Rule("ar")
|
2019-09-24 23:55:04 +02:00
|
|
|
if g, w := pathsToBase(static.Inputs), []string{"foo.o", "bar.o"}; !reflect.DeepEqual(w, g) {
|
|
|
|
t.Errorf("libstatic ar rule wanted %q, got %q", w, g)
|
|
|
|
}
|
2019-11-21 01:39:12 +01:00
|
|
|
bothStatic := ctx.ModuleForTests("libboth", "android_arm64_armv8-a_static").Rule("ar")
|
2019-09-24 23:55:04 +02:00
|
|
|
if g, w := pathsToBase(bothStatic.Inputs), []string{"foo.o", "bar.o"}; !reflect.DeepEqual(w, g) {
|
|
|
|
t.Errorf("libboth ar rule wanted %q, got %q", w, g)
|
|
|
|
}
|
|
|
|
}
|
2020-02-07 02:01:55 +01:00
|
|
|
|
|
|
|
func TestProductVariableDefaults(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2020-02-07 02:01:55 +01:00
|
|
|
bp := `
|
|
|
|
cc_defaults {
|
|
|
|
name: "libfoo_defaults",
|
|
|
|
srcs: ["foo.c"],
|
|
|
|
cppflags: ["-DFOO"],
|
|
|
|
product_variables: {
|
|
|
|
debuggable: {
|
|
|
|
cppflags: ["-DBAR"],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libfoo",
|
|
|
|
defaults: ["libfoo_defaults"],
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
2021-03-23 01:02:06 +01:00
|
|
|
result := android.GroupFixturePreparers(
|
|
|
|
prepareForCcTest,
|
2021-03-07 16:58:39 +01:00
|
|
|
android.PrepareForTestWithVariables,
|
2020-02-07 02:01:55 +01:00
|
|
|
|
2021-03-07 16:58:39 +01:00
|
|
|
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
|
|
|
variables.Debuggable = BoolPtr(true)
|
|
|
|
}),
|
|
|
|
).RunTestWithBp(t, bp)
|
2020-02-07 02:01:55 +01:00
|
|
|
|
2021-03-07 16:58:39 +01:00
|
|
|
libfoo := result.Module("libfoo", "android_arm64_armv8-a_static").(*Module)
|
2021-03-12 12:59:43 +01:00
|
|
|
android.AssertStringListContains(t, "cppflags", libfoo.flags.Local.CppFlags, "-DBAR")
|
2020-02-07 02:01:55 +01:00
|
|
|
}
|
2020-09-23 03:11:25 +02:00
|
|
|
|
|
|
|
func TestEmptyWholeStaticLibsAllowMissingDependencies(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
bp := `
|
|
|
|
cc_library_static {
|
|
|
|
name: "libfoo",
|
|
|
|
srcs: ["foo.c"],
|
|
|
|
whole_static_libs: ["libbar"],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library_static {
|
|
|
|
name: "libbar",
|
|
|
|
whole_static_libs: ["libmissing"],
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
2021-03-23 01:02:06 +01:00
|
|
|
result := android.GroupFixturePreparers(
|
|
|
|
prepareForCcTest,
|
2021-03-07 16:58:39 +01:00
|
|
|
android.PrepareForTestWithAllowMissingDependencies,
|
|
|
|
).RunTestWithBp(t, bp)
|
2020-09-23 03:11:25 +02:00
|
|
|
|
2021-03-07 16:58:39 +01:00
|
|
|
libbar := result.ModuleForTests("libbar", "android_arm64_armv8-a_static").Output("libbar.a")
|
2021-03-12 12:59:43 +01:00
|
|
|
android.AssertDeepEquals(t, "libbar rule", android.ErrorRule, libbar.Rule)
|
2020-09-23 03:11:25 +02:00
|
|
|
|
2021-03-12 12:59:43 +01:00
|
|
|
android.AssertStringDoesContain(t, "libbar error", libbar.Args["error"], "missing dependencies: libmissing")
|
2020-09-23 03:11:25 +02:00
|
|
|
|
2021-03-07 16:58:39 +01:00
|
|
|
libfoo := result.ModuleForTests("libfoo", "android_arm64_armv8-a_static").Output("libfoo.a")
|
2021-03-12 12:59:43 +01:00
|
|
|
android.AssertStringListContains(t, "libfoo.a dependencies", libfoo.Inputs.Strings(), libbar.Output.String())
|
2020-09-23 03:11:25 +02:00
|
|
|
}
|
2020-11-11 03:12:15 +01:00
|
|
|
|
|
|
|
func TestInstallSharedLibs(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2020-11-11 03:12:15 +01:00
|
|
|
bp := `
|
|
|
|
cc_binary {
|
|
|
|
name: "bin",
|
|
|
|
host_supported: true,
|
|
|
|
shared_libs: ["libshared"],
|
|
|
|
runtime_libs: ["libruntime"],
|
|
|
|
srcs: [":gen"],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library_shared {
|
|
|
|
name: "libshared",
|
|
|
|
host_supported: true,
|
|
|
|
shared_libs: ["libtransitive"],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library_shared {
|
|
|
|
name: "libtransitive",
|
|
|
|
host_supported: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library_shared {
|
|
|
|
name: "libruntime",
|
|
|
|
host_supported: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_binary_host {
|
|
|
|
name: "tool",
|
|
|
|
srcs: ["foo.cpp"],
|
|
|
|
}
|
|
|
|
|
|
|
|
genrule {
|
|
|
|
name: "gen",
|
|
|
|
tools: ["tool"],
|
|
|
|
out: ["gen.cpp"],
|
|
|
|
cmd: "$(location tool) $(out)",
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
2021-03-23 00:21:32 +01:00
|
|
|
config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
|
2020-11-11 03:12:15 +01:00
|
|
|
ctx := testCcWithConfig(t, config)
|
|
|
|
|
|
|
|
hostBin := ctx.ModuleForTests("bin", config.BuildOSTarget.String()).Description("install")
|
|
|
|
hostShared := ctx.ModuleForTests("libshared", config.BuildOSTarget.String()+"_shared").Description("install")
|
|
|
|
hostRuntime := ctx.ModuleForTests("libruntime", config.BuildOSTarget.String()+"_shared").Description("install")
|
|
|
|
hostTransitive := ctx.ModuleForTests("libtransitive", config.BuildOSTarget.String()+"_shared").Description("install")
|
|
|
|
hostTool := ctx.ModuleForTests("tool", config.BuildOSTarget.String()).Description("install")
|
|
|
|
|
|
|
|
if g, w := hostBin.Implicits.Strings(), hostShared.Output.String(); !android.InList(w, g) {
|
|
|
|
t.Errorf("expected host bin dependency %q, got %q", w, g)
|
|
|
|
}
|
|
|
|
|
|
|
|
if g, w := hostBin.Implicits.Strings(), hostTransitive.Output.String(); !android.InList(w, g) {
|
|
|
|
t.Errorf("expected host bin dependency %q, got %q", w, g)
|
|
|
|
}
|
|
|
|
|
|
|
|
if g, w := hostShared.Implicits.Strings(), hostTransitive.Output.String(); !android.InList(w, g) {
|
|
|
|
t.Errorf("expected host bin dependency %q, got %q", w, g)
|
|
|
|
}
|
|
|
|
|
|
|
|
if g, w := hostBin.Implicits.Strings(), hostRuntime.Output.String(); !android.InList(w, g) {
|
|
|
|
t.Errorf("expected host bin dependency %q, got %q", w, g)
|
|
|
|
}
|
|
|
|
|
|
|
|
if g, w := hostBin.Implicits.Strings(), hostTool.Output.String(); android.InList(w, g) {
|
|
|
|
t.Errorf("expected no host bin dependency %q, got %q", w, g)
|
|
|
|
}
|
|
|
|
|
|
|
|
deviceBin := ctx.ModuleForTests("bin", "android_arm64_armv8-a").Description("install")
|
|
|
|
deviceShared := ctx.ModuleForTests("libshared", "android_arm64_armv8-a_shared").Description("install")
|
|
|
|
deviceTransitive := ctx.ModuleForTests("libtransitive", "android_arm64_armv8-a_shared").Description("install")
|
|
|
|
deviceRuntime := ctx.ModuleForTests("libruntime", "android_arm64_armv8-a_shared").Description("install")
|
|
|
|
|
|
|
|
if g, w := deviceBin.OrderOnly.Strings(), deviceShared.Output.String(); !android.InList(w, g) {
|
|
|
|
t.Errorf("expected device bin dependency %q, got %q", w, g)
|
|
|
|
}
|
|
|
|
|
|
|
|
if g, w := deviceBin.OrderOnly.Strings(), deviceTransitive.Output.String(); !android.InList(w, g) {
|
|
|
|
t.Errorf("expected device bin dependency %q, got %q", w, g)
|
|
|
|
}
|
|
|
|
|
|
|
|
if g, w := deviceShared.OrderOnly.Strings(), deviceTransitive.Output.String(); !android.InList(w, g) {
|
|
|
|
t.Errorf("expected device bin dependency %q, got %q", w, g)
|
|
|
|
}
|
|
|
|
|
|
|
|
if g, w := deviceBin.OrderOnly.Strings(), deviceRuntime.Output.String(); !android.InList(w, g) {
|
|
|
|
t.Errorf("expected device bin dependency %q, got %q", w, g)
|
|
|
|
}
|
|
|
|
|
|
|
|
if g, w := deviceBin.OrderOnly.Strings(), hostTool.Output.String(); android.InList(w, g) {
|
|
|
|
t.Errorf("expected no device bin dependency %q, got %q", w, g)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2020-12-01 15:40:09 +01:00
|
|
|
|
|
|
|
func TestStubsLibReexportsHeaders(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2020-12-01 15:40:09 +01:00
|
|
|
ctx := testCc(t, `
|
|
|
|
cc_library_shared {
|
|
|
|
name: "libclient",
|
|
|
|
srcs: ["foo.c"],
|
|
|
|
shared_libs: ["libfoo#1"],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library_shared {
|
|
|
|
name: "libfoo",
|
|
|
|
srcs: ["foo.c"],
|
|
|
|
shared_libs: ["libbar"],
|
|
|
|
export_shared_lib_headers: ["libbar"],
|
|
|
|
stubs: {
|
|
|
|
symbol_file: "foo.map.txt",
|
|
|
|
versions: ["1", "2", "3"],
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library_shared {
|
|
|
|
name: "libbar",
|
|
|
|
export_include_dirs: ["include/libbar"],
|
|
|
|
srcs: ["foo.c"],
|
|
|
|
}`)
|
|
|
|
|
|
|
|
cFlags := ctx.ModuleForTests("libclient", "android_arm64_armv8-a_shared").Rule("cc").Args["cFlags"]
|
|
|
|
|
|
|
|
if !strings.Contains(cFlags, "-Iinclude/libbar") {
|
|
|
|
t.Errorf("expected %q in cflags, got %q", "-Iinclude/libbar", cFlags)
|
|
|
|
}
|
|
|
|
}
|
2021-01-05 02:33:16 +01:00
|
|
|
|
2023-05-16 22:03:20 +02:00
|
|
|
func TestAidlLibraryWithHeaders(t *testing.T) {
|
2023-04-28 17:21:25 +02:00
|
|
|
t.Parallel()
|
|
|
|
ctx := android.GroupFixturePreparers(
|
|
|
|
prepareForCcTest,
|
|
|
|
aidl_library.PrepareForTestWithAidlLibrary,
|
|
|
|
android.MockFS{
|
|
|
|
"package_bar/Android.bp": []byte(`
|
|
|
|
aidl_library {
|
|
|
|
name: "bar",
|
|
|
|
srcs: ["x/y/Bar.aidl"],
|
2023-05-16 22:03:20 +02:00
|
|
|
hdrs: ["x/HeaderBar.aidl"],
|
2023-04-28 17:21:25 +02:00
|
|
|
strip_import_prefix: "x",
|
|
|
|
}
|
|
|
|
`)}.AddToFixture(),
|
|
|
|
android.MockFS{
|
|
|
|
"package_foo/Android.bp": []byte(`
|
|
|
|
aidl_library {
|
|
|
|
name: "foo",
|
|
|
|
srcs: ["a/b/Foo.aidl"],
|
2023-05-16 22:03:20 +02:00
|
|
|
hdrs: ["a/HeaderFoo.aidl"],
|
2023-04-28 17:21:25 +02:00
|
|
|
strip_import_prefix: "a",
|
|
|
|
deps: ["bar"],
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libfoo",
|
|
|
|
aidl: {
|
|
|
|
libs: ["foo"],
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`),
|
|
|
|
}.AddToFixture(),
|
|
|
|
).RunTest(t).TestContext
|
|
|
|
|
|
|
|
libfoo := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_static")
|
2023-05-16 22:03:20 +02:00
|
|
|
|
|
|
|
android.AssertPathsRelativeToTopEquals(
|
|
|
|
t,
|
|
|
|
"aidl headers",
|
|
|
|
[]string{
|
|
|
|
"package_bar/x/HeaderBar.aidl",
|
|
|
|
"package_foo/a/HeaderFoo.aidl",
|
|
|
|
"package_foo/a/b/Foo.aidl",
|
|
|
|
"out/soong/.intermediates/package_foo/libfoo/android_arm64_armv8-a_static/gen/aidl_library.sbox.textproto",
|
|
|
|
},
|
|
|
|
libfoo.Rule("aidl_library").Implicits,
|
|
|
|
)
|
|
|
|
|
2023-11-03 00:56:39 +01:00
|
|
|
manifest := android.RuleBuilderSboxProtoForTests(t, ctx, libfoo.Output("aidl_library.sbox.textproto"))
|
2023-04-28 17:21:25 +02:00
|
|
|
aidlCommand := manifest.Commands[0].GetCommand()
|
|
|
|
|
|
|
|
expectedAidlFlags := "-Ipackage_foo/a -Ipackage_bar/x"
|
|
|
|
if !strings.Contains(aidlCommand, expectedAidlFlags) {
|
|
|
|
t.Errorf("aidl command %q does not contain %q", aidlCommand, expectedAidlFlags)
|
|
|
|
}
|
|
|
|
|
|
|
|
outputs := strings.Join(libfoo.AllOutputs(), " ")
|
|
|
|
|
2023-05-16 22:03:20 +02:00
|
|
|
android.AssertStringDoesContain(t, "aidl-generated header", outputs, "gen/aidl_library/b/BpFoo.h")
|
|
|
|
android.AssertStringDoesContain(t, "aidl-generated header", outputs, "gen/aidl_library/b/BnFoo.h")
|
|
|
|
android.AssertStringDoesContain(t, "aidl-generated header", outputs, "gen/aidl_library/b/Foo.h")
|
2023-04-28 17:21:25 +02:00
|
|
|
android.AssertStringDoesContain(t, "aidl-generated cpp", outputs, "b/Foo.cpp")
|
|
|
|
// Confirm that the aidl header doesn't get compiled to cpp and h files
|
2023-05-16 22:03:20 +02:00
|
|
|
android.AssertStringDoesNotContain(t, "aidl-generated header", outputs, "gen/aidl_library/y/BpBar.h")
|
|
|
|
android.AssertStringDoesNotContain(t, "aidl-generated header", outputs, "gen/aidl_library/y/BnBar.h")
|
|
|
|
android.AssertStringDoesNotContain(t, "aidl-generated header", outputs, "gen/aidl_library/y/Bar.h")
|
2023-04-28 17:21:25 +02:00
|
|
|
android.AssertStringDoesNotContain(t, "aidl-generated cpp", outputs, "y/Bar.cpp")
|
|
|
|
}
|
|
|
|
|
2021-01-05 02:33:16 +01:00
|
|
|
func TestAidlFlagsPassedToTheAidlCompiler(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2023-04-28 17:21:25 +02:00
|
|
|
ctx := android.GroupFixturePreparers(
|
|
|
|
prepareForCcTest,
|
|
|
|
aidl_library.PrepareForTestWithAidlLibrary,
|
|
|
|
).RunTestWithBp(t, `
|
2021-01-05 02:33:16 +01:00
|
|
|
cc_library {
|
|
|
|
name: "libfoo",
|
|
|
|
srcs: ["a/Foo.aidl"],
|
|
|
|
aidl: { flags: ["-Werror"], },
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
libfoo := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_static")
|
2023-11-03 00:56:39 +01:00
|
|
|
manifest := android.RuleBuilderSboxProtoForTests(t, ctx.TestContext, libfoo.Output("aidl.sbox.textproto"))
|
2021-01-05 02:33:16 +01:00
|
|
|
aidlCommand := manifest.Commands[0].GetCommand()
|
|
|
|
expectedAidlFlag := "-Werror"
|
|
|
|
if !strings.Contains(aidlCommand, expectedAidlFlag) {
|
|
|
|
t.Errorf("aidl command %q does not contain %q", aidlCommand, expectedAidlFlag)
|
|
|
|
}
|
|
|
|
}
|
2020-04-29 00:09:12 +02:00
|
|
|
|
2021-11-05 23:08:45 +01:00
|
|
|
func TestAidlFlagsWithMinSdkVersion(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2021-11-05 23:08:45 +01:00
|
|
|
for _, tc := range []struct {
|
|
|
|
name string
|
|
|
|
sdkVersion string
|
|
|
|
variant string
|
|
|
|
expected string
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "default is current",
|
|
|
|
sdkVersion: "",
|
|
|
|
variant: "android_arm64_armv8-a_static",
|
|
|
|
expected: "platform_apis",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "use sdk_version",
|
|
|
|
sdkVersion: `sdk_version: "29"`,
|
|
|
|
variant: "android_arm64_armv8-a_static",
|
|
|
|
expected: "platform_apis",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "use sdk_version(sdk variant)",
|
|
|
|
sdkVersion: `sdk_version: "29"`,
|
|
|
|
variant: "android_arm64_armv8-a_sdk_static",
|
|
|
|
expected: "29",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "use min_sdk_version",
|
|
|
|
sdkVersion: `min_sdk_version: "29"`,
|
|
|
|
variant: "android_arm64_armv8-a_static",
|
|
|
|
expected: "29",
|
|
|
|
},
|
|
|
|
} {
|
|
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
|
|
ctx := testCc(t, `
|
|
|
|
cc_library {
|
|
|
|
name: "libfoo",
|
|
|
|
stl: "none",
|
|
|
|
srcs: ["a/Foo.aidl"],
|
|
|
|
`+tc.sdkVersion+`
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
libfoo := ctx.ModuleForTests("libfoo", tc.variant)
|
2023-11-03 00:56:39 +01:00
|
|
|
manifest := android.RuleBuilderSboxProtoForTests(t, ctx, libfoo.Output("aidl.sbox.textproto"))
|
2021-11-05 23:08:45 +01:00
|
|
|
aidlCommand := manifest.Commands[0].GetCommand()
|
|
|
|
expectedAidlFlag := "--min_sdk_version=" + tc.expected
|
|
|
|
if !strings.Contains(aidlCommand, expectedAidlFlag) {
|
|
|
|
t.Errorf("aidl command %q does not contain %q", aidlCommand, expectedAidlFlag)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-16 22:03:20 +02:00
|
|
|
func TestInvalidAidlProp(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
testCases := []struct {
|
|
|
|
description string
|
|
|
|
bp string
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
description: "Invalid use of aidl.libs and aidl.include_dirs",
|
|
|
|
bp: `
|
|
|
|
cc_library {
|
|
|
|
name: "foo",
|
|
|
|
aidl: {
|
|
|
|
libs: ["foo_aidl"],
|
|
|
|
include_dirs: ["bar/include"],
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
description: "Invalid use of aidl.libs and aidl.local_include_dirs",
|
|
|
|
bp: `
|
|
|
|
cc_library {
|
|
|
|
name: "foo",
|
|
|
|
aidl: {
|
|
|
|
libs: ["foo_aidl"],
|
|
|
|
local_include_dirs: ["include"],
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, testCase := range testCases {
|
|
|
|
t.Run(testCase.description, func(t *testing.T) {
|
|
|
|
bp := `
|
|
|
|
aidl_library {
|
|
|
|
name: "foo_aidl",
|
|
|
|
srcs: ["Foo.aidl"],
|
|
|
|
} ` + testCase.bp
|
|
|
|
android.GroupFixturePreparers(
|
|
|
|
prepareForCcTest,
|
|
|
|
aidl_library.PrepareForTestWithAidlLibrary.
|
|
|
|
ExtendWithErrorHandler(android.FixtureExpectsOneErrorPattern("For aidl headers, please only use aidl.libs prop")),
|
|
|
|
).RunTestWithBp(t, bp)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-16 09:15:53 +01:00
|
|
|
func TestMinSdkVersionInClangTriple(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2021-03-16 09:15:53 +01:00
|
|
|
ctx := testCc(t, `
|
|
|
|
cc_library_shared {
|
|
|
|
name: "libfoo",
|
|
|
|
srcs: ["foo.c"],
|
|
|
|
min_sdk_version: "29",
|
|
|
|
}`)
|
|
|
|
|
|
|
|
cFlags := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_shared").Rule("cc").Args["cFlags"]
|
|
|
|
android.AssertStringDoesContain(t, "min sdk version", cFlags, "-target aarch64-linux-android29")
|
|
|
|
}
|
|
|
|
|
2022-06-24 22:40:11 +02:00
|
|
|
func TestNonDigitMinSdkVersionInClangTriple(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2022-06-24 22:40:11 +02:00
|
|
|
bp := `
|
|
|
|
cc_library_shared {
|
|
|
|
name: "libfoo",
|
|
|
|
srcs: ["foo.c"],
|
|
|
|
min_sdk_version: "S",
|
|
|
|
}
|
|
|
|
`
|
|
|
|
result := android.GroupFixturePreparers(
|
|
|
|
prepareForCcTest,
|
|
|
|
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
|
|
|
variables.Platform_version_active_codenames = []string{"UpsideDownCake", "Tiramisu"}
|
|
|
|
}),
|
|
|
|
).RunTestWithBp(t, bp)
|
|
|
|
ctx := result.TestContext
|
|
|
|
cFlags := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_shared").Rule("cc").Args["cFlags"]
|
|
|
|
android.AssertStringDoesContain(t, "min sdk version", cFlags, "-target aarch64-linux-android31")
|
|
|
|
}
|
|
|
|
|
2021-02-19 14:57:10 +01:00
|
|
|
func TestIncludeDirsExporting(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2021-02-19 14:57:10 +01:00
|
|
|
|
|
|
|
// Trim spaces from the beginning, end and immediately after any newline characters. Leaves
|
|
|
|
// embedded newline characters alone.
|
|
|
|
trimIndentingSpaces := func(s string) string {
|
|
|
|
return strings.TrimSpace(regexp.MustCompile("(^|\n)\\s+").ReplaceAllString(s, "$1"))
|
|
|
|
}
|
|
|
|
|
|
|
|
checkPaths := func(t *testing.T, message string, expected string, paths android.Paths) {
|
|
|
|
t.Helper()
|
|
|
|
expected = trimIndentingSpaces(expected)
|
|
|
|
actual := trimIndentingSpaces(strings.Join(android.FirstUniqueStrings(android.NormalizePathsForTesting(paths)), "\n"))
|
|
|
|
if expected != actual {
|
|
|
|
t.Errorf("%s: expected:\n%s\n actual:\n%s\n", message, expected, actual)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type exportedChecker func(t *testing.T, name string, exported FlagExporterInfo)
|
|
|
|
|
|
|
|
checkIncludeDirs := func(t *testing.T, ctx *android.TestContext, module android.Module, checkers ...exportedChecker) {
|
|
|
|
t.Helper()
|
2023-12-14 23:46:23 +01:00
|
|
|
exported, _ := android.SingletonModuleProvider(ctx, module, FlagExporterInfoProvider)
|
2021-02-19 14:57:10 +01:00
|
|
|
name := module.Name()
|
|
|
|
|
|
|
|
for _, checker := range checkers {
|
|
|
|
checker(t, name, exported)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expectedIncludeDirs := func(expectedPaths string) exportedChecker {
|
|
|
|
return func(t *testing.T, name string, exported FlagExporterInfo) {
|
|
|
|
t.Helper()
|
|
|
|
checkPaths(t, fmt.Sprintf("%s: include dirs", name), expectedPaths, exported.IncludeDirs)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expectedSystemIncludeDirs := func(expectedPaths string) exportedChecker {
|
|
|
|
return func(t *testing.T, name string, exported FlagExporterInfo) {
|
|
|
|
t.Helper()
|
|
|
|
checkPaths(t, fmt.Sprintf("%s: system include dirs", name), expectedPaths, exported.SystemIncludeDirs)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expectedGeneratedHeaders := func(expectedPaths string) exportedChecker {
|
|
|
|
return func(t *testing.T, name string, exported FlagExporterInfo) {
|
|
|
|
t.Helper()
|
|
|
|
checkPaths(t, fmt.Sprintf("%s: generated headers", name), expectedPaths, exported.GeneratedHeaders)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expectedOrderOnlyDeps := func(expectedPaths string) exportedChecker {
|
|
|
|
return func(t *testing.T, name string, exported FlagExporterInfo) {
|
|
|
|
t.Helper()
|
|
|
|
checkPaths(t, fmt.Sprintf("%s: order only deps", name), expectedPaths, exported.Deps)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
genRuleModules := `
|
|
|
|
genrule {
|
|
|
|
name: "genrule_foo",
|
|
|
|
cmd: "generate-foo",
|
|
|
|
out: [
|
|
|
|
"generated_headers/foo/generated_header.h",
|
|
|
|
],
|
|
|
|
export_include_dirs: [
|
|
|
|
"generated_headers",
|
|
|
|
],
|
|
|
|
}
|
|
|
|
|
|
|
|
genrule {
|
|
|
|
name: "genrule_bar",
|
|
|
|
cmd: "generate-bar",
|
|
|
|
out: [
|
|
|
|
"generated_headers/bar/generated_header.h",
|
|
|
|
],
|
|
|
|
export_include_dirs: [
|
|
|
|
"generated_headers",
|
|
|
|
],
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
t.Run("ensure exported include dirs are not automatically re-exported from shared_libs", func(t *testing.T) {
|
|
|
|
ctx := testCc(t, genRuleModules+`
|
|
|
|
cc_library {
|
|
|
|
name: "libfoo",
|
|
|
|
srcs: ["foo.c"],
|
|
|
|
export_include_dirs: ["foo/standard"],
|
|
|
|
export_system_include_dirs: ["foo/system"],
|
|
|
|
generated_headers: ["genrule_foo"],
|
|
|
|
export_generated_headers: ["genrule_foo"],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libbar",
|
|
|
|
srcs: ["bar.c"],
|
|
|
|
shared_libs: ["libfoo"],
|
|
|
|
export_include_dirs: ["bar/standard"],
|
|
|
|
export_system_include_dirs: ["bar/system"],
|
|
|
|
generated_headers: ["genrule_bar"],
|
|
|
|
export_generated_headers: ["genrule_bar"],
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
foo := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_shared").Module()
|
|
|
|
checkIncludeDirs(t, ctx, foo,
|
|
|
|
expectedIncludeDirs(`
|
|
|
|
foo/standard
|
|
|
|
.intermediates/genrule_foo/gen/generated_headers
|
|
|
|
`),
|
|
|
|
expectedSystemIncludeDirs(`foo/system`),
|
|
|
|
expectedGeneratedHeaders(`.intermediates/genrule_foo/gen/generated_headers/foo/generated_header.h`),
|
|
|
|
expectedOrderOnlyDeps(`.intermediates/genrule_foo/gen/generated_headers/foo/generated_header.h`),
|
|
|
|
)
|
|
|
|
|
|
|
|
bar := ctx.ModuleForTests("libbar", "android_arm64_armv8-a_shared").Module()
|
|
|
|
checkIncludeDirs(t, ctx, bar,
|
|
|
|
expectedIncludeDirs(`
|
|
|
|
bar/standard
|
|
|
|
.intermediates/genrule_bar/gen/generated_headers
|
|
|
|
`),
|
|
|
|
expectedSystemIncludeDirs(`bar/system`),
|
|
|
|
expectedGeneratedHeaders(`.intermediates/genrule_bar/gen/generated_headers/bar/generated_header.h`),
|
|
|
|
expectedOrderOnlyDeps(`.intermediates/genrule_bar/gen/generated_headers/bar/generated_header.h`),
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("ensure exported include dirs are automatically re-exported from whole_static_libs", func(t *testing.T) {
|
|
|
|
ctx := testCc(t, genRuleModules+`
|
|
|
|
cc_library {
|
|
|
|
name: "libfoo",
|
|
|
|
srcs: ["foo.c"],
|
|
|
|
export_include_dirs: ["foo/standard"],
|
|
|
|
export_system_include_dirs: ["foo/system"],
|
|
|
|
generated_headers: ["genrule_foo"],
|
|
|
|
export_generated_headers: ["genrule_foo"],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libbar",
|
|
|
|
srcs: ["bar.c"],
|
|
|
|
whole_static_libs: ["libfoo"],
|
|
|
|
export_include_dirs: ["bar/standard"],
|
|
|
|
export_system_include_dirs: ["bar/system"],
|
|
|
|
generated_headers: ["genrule_bar"],
|
|
|
|
export_generated_headers: ["genrule_bar"],
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
foo := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_shared").Module()
|
|
|
|
checkIncludeDirs(t, ctx, foo,
|
|
|
|
expectedIncludeDirs(`
|
|
|
|
foo/standard
|
|
|
|
.intermediates/genrule_foo/gen/generated_headers
|
|
|
|
`),
|
|
|
|
expectedSystemIncludeDirs(`foo/system`),
|
|
|
|
expectedGeneratedHeaders(`.intermediates/genrule_foo/gen/generated_headers/foo/generated_header.h`),
|
|
|
|
expectedOrderOnlyDeps(`.intermediates/genrule_foo/gen/generated_headers/foo/generated_header.h`),
|
|
|
|
)
|
|
|
|
|
|
|
|
bar := ctx.ModuleForTests("libbar", "android_arm64_armv8-a_shared").Module()
|
|
|
|
checkIncludeDirs(t, ctx, bar,
|
|
|
|
expectedIncludeDirs(`
|
|
|
|
bar/standard
|
|
|
|
foo/standard
|
|
|
|
.intermediates/genrule_foo/gen/generated_headers
|
|
|
|
.intermediates/genrule_bar/gen/generated_headers
|
|
|
|
`),
|
|
|
|
expectedSystemIncludeDirs(`
|
|
|
|
bar/system
|
|
|
|
foo/system
|
|
|
|
`),
|
|
|
|
expectedGeneratedHeaders(`
|
|
|
|
.intermediates/genrule_foo/gen/generated_headers/foo/generated_header.h
|
|
|
|
.intermediates/genrule_bar/gen/generated_headers/bar/generated_header.h
|
|
|
|
`),
|
|
|
|
expectedOrderOnlyDeps(`
|
|
|
|
.intermediates/genrule_foo/gen/generated_headers/foo/generated_header.h
|
|
|
|
.intermediates/genrule_bar/gen/generated_headers/bar/generated_header.h
|
|
|
|
`),
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("ensure only aidl headers are exported", func(t *testing.T) {
|
2023-04-28 17:21:25 +02:00
|
|
|
ctx := android.GroupFixturePreparers(
|
|
|
|
prepareForCcTest,
|
|
|
|
aidl_library.PrepareForTestWithAidlLibrary,
|
|
|
|
).RunTestWithBp(t, `
|
|
|
|
aidl_library {
|
|
|
|
name: "libfoo_aidl",
|
|
|
|
srcs: ["x/y/Bar.aidl"],
|
|
|
|
strip_import_prefix: "x",
|
|
|
|
}
|
2021-02-19 14:57:10 +01:00
|
|
|
cc_library_shared {
|
|
|
|
name: "libfoo",
|
|
|
|
srcs: [
|
|
|
|
"foo.c",
|
|
|
|
"b.aidl",
|
|
|
|
"a.proto",
|
|
|
|
],
|
|
|
|
aidl: {
|
2023-04-28 17:21:25 +02:00
|
|
|
libs: ["libfoo_aidl"],
|
2021-02-19 14:57:10 +01:00
|
|
|
export_aidl_headers: true,
|
|
|
|
}
|
|
|
|
}
|
2023-04-28 17:21:25 +02:00
|
|
|
`).TestContext
|
2021-02-19 14:57:10 +01:00
|
|
|
foo := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_shared").Module()
|
|
|
|
checkIncludeDirs(t, ctx, foo,
|
|
|
|
expectedIncludeDirs(`
|
|
|
|
.intermediates/libfoo/android_arm64_armv8-a_shared/gen/aidl
|
2023-05-16 22:03:20 +02:00
|
|
|
.intermediates/libfoo/android_arm64_armv8-a_shared/gen/aidl_library
|
2021-02-19 14:57:10 +01:00
|
|
|
`),
|
|
|
|
expectedSystemIncludeDirs(``),
|
|
|
|
expectedGeneratedHeaders(`
|
|
|
|
.intermediates/libfoo/android_arm64_armv8-a_shared/gen/aidl/b.h
|
|
|
|
.intermediates/libfoo/android_arm64_armv8-a_shared/gen/aidl/Bnb.h
|
|
|
|
.intermediates/libfoo/android_arm64_armv8-a_shared/gen/aidl/Bpb.h
|
2023-05-16 22:03:20 +02:00
|
|
|
.intermediates/libfoo/android_arm64_armv8-a_shared/gen/aidl_library/y/Bar.h
|
|
|
|
.intermediates/libfoo/android_arm64_armv8-a_shared/gen/aidl_library/y/BnBar.h
|
|
|
|
.intermediates/libfoo/android_arm64_armv8-a_shared/gen/aidl_library/y/BpBar.h
|
2021-02-19 14:57:10 +01:00
|
|
|
`),
|
|
|
|
expectedOrderOnlyDeps(`
|
|
|
|
.intermediates/libfoo/android_arm64_armv8-a_shared/gen/aidl/b.h
|
|
|
|
.intermediates/libfoo/android_arm64_armv8-a_shared/gen/aidl/Bnb.h
|
|
|
|
.intermediates/libfoo/android_arm64_armv8-a_shared/gen/aidl/Bpb.h
|
2023-05-16 22:03:20 +02:00
|
|
|
.intermediates/libfoo/android_arm64_armv8-a_shared/gen/aidl_library/y/Bar.h
|
|
|
|
.intermediates/libfoo/android_arm64_armv8-a_shared/gen/aidl_library/y/BnBar.h
|
|
|
|
.intermediates/libfoo/android_arm64_armv8-a_shared/gen/aidl_library/y/BpBar.h
|
2021-02-19 14:57:10 +01:00
|
|
|
`),
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("ensure only proto headers are exported", func(t *testing.T) {
|
|
|
|
ctx := testCc(t, genRuleModules+`
|
|
|
|
cc_library_shared {
|
|
|
|
name: "libfoo",
|
|
|
|
srcs: [
|
|
|
|
"foo.c",
|
|
|
|
"b.aidl",
|
|
|
|
"a.proto",
|
|
|
|
],
|
|
|
|
proto: {
|
|
|
|
export_proto_headers: true,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
foo := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_shared").Module()
|
|
|
|
checkIncludeDirs(t, ctx, foo,
|
|
|
|
expectedIncludeDirs(`
|
|
|
|
.intermediates/libfoo/android_arm64_armv8-a_shared/gen/proto
|
|
|
|
`),
|
|
|
|
expectedSystemIncludeDirs(``),
|
|
|
|
expectedGeneratedHeaders(`
|
|
|
|
.intermediates/libfoo/android_arm64_armv8-a_shared/gen/proto/a.pb.h
|
|
|
|
`),
|
|
|
|
expectedOrderOnlyDeps(`
|
|
|
|
.intermediates/libfoo/android_arm64_armv8-a_shared/gen/proto/a.pb.h
|
|
|
|
`),
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
2021-02-19 14:49:08 +01:00
|
|
|
t.Run("ensure only sysprop headers are exported", func(t *testing.T) {
|
2021-02-19 14:57:10 +01:00
|
|
|
ctx := testCc(t, genRuleModules+`
|
|
|
|
cc_library_shared {
|
|
|
|
name: "libfoo",
|
|
|
|
srcs: [
|
|
|
|
"foo.c",
|
2022-08-24 17:25:25 +02:00
|
|
|
"path/to/a.sysprop",
|
2021-02-19 14:57:10 +01:00
|
|
|
"b.aidl",
|
|
|
|
"a.proto",
|
|
|
|
],
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
foo := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_shared").Module()
|
|
|
|
checkIncludeDirs(t, ctx, foo,
|
|
|
|
expectedIncludeDirs(`
|
|
|
|
.intermediates/libfoo/android_arm64_armv8-a_shared/gen/sysprop/include
|
|
|
|
`),
|
|
|
|
expectedSystemIncludeDirs(``),
|
|
|
|
expectedGeneratedHeaders(`
|
2022-08-24 17:25:25 +02:00
|
|
|
.intermediates/libfoo/android_arm64_armv8-a_shared/gen/sysprop/include/path/to/a.sysprop.h
|
2021-02-19 14:57:10 +01:00
|
|
|
`),
|
|
|
|
expectedOrderOnlyDeps(`
|
2022-08-24 17:25:25 +02:00
|
|
|
.intermediates/libfoo/android_arm64_armv8-a_shared/gen/sysprop/include/path/to/a.sysprop.h
|
|
|
|
.intermediates/libfoo/android_arm64_armv8-a_shared/gen/sysprop/public/include/path/to/a.sysprop.h
|
2021-02-19 14:57:10 +01:00
|
|
|
`),
|
|
|
|
)
|
|
|
|
})
|
|
|
|
}
|
2021-06-15 01:52:28 +02:00
|
|
|
|
|
|
|
func TestIncludeDirectoryOrdering(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2021-09-30 16:11:04 +02:00
|
|
|
baseExpectedFlags := []string{
|
|
|
|
"${config.ArmThumbCflags}",
|
|
|
|
"${config.ArmCflags}",
|
|
|
|
"${config.CommonGlobalCflags}",
|
|
|
|
"${config.DeviceGlobalCflags}",
|
|
|
|
"${config.ExternalCflags}",
|
|
|
|
"${config.ArmToolchainCflags}",
|
|
|
|
"${config.ArmArmv7ANeonCflags}",
|
|
|
|
"${config.ArmGenericCflags}",
|
|
|
|
"-target",
|
2022-08-17 22:11:57 +02:00
|
|
|
"armv7a-linux-androideabi21",
|
2021-09-30 16:11:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
expectedIncludes := []string{
|
|
|
|
"external/foo/android_arm_export_include_dirs",
|
|
|
|
"external/foo/lib32_export_include_dirs",
|
|
|
|
"external/foo/arm_export_include_dirs",
|
|
|
|
"external/foo/android_export_include_dirs",
|
|
|
|
"external/foo/linux_export_include_dirs",
|
|
|
|
"external/foo/export_include_dirs",
|
|
|
|
"external/foo/android_arm_local_include_dirs",
|
|
|
|
"external/foo/lib32_local_include_dirs",
|
|
|
|
"external/foo/arm_local_include_dirs",
|
|
|
|
"external/foo/android_local_include_dirs",
|
|
|
|
"external/foo/linux_local_include_dirs",
|
|
|
|
"external/foo/local_include_dirs",
|
|
|
|
"external/foo",
|
|
|
|
"external/foo/libheader1",
|
|
|
|
"external/foo/libheader2",
|
|
|
|
"external/foo/libwhole1",
|
|
|
|
"external/foo/libwhole2",
|
|
|
|
"external/foo/libstatic1",
|
|
|
|
"external/foo/libstatic2",
|
|
|
|
"external/foo/libshared1",
|
|
|
|
"external/foo/libshared2",
|
|
|
|
"external/foo/liblinux",
|
|
|
|
"external/foo/libandroid",
|
|
|
|
"external/foo/libarm",
|
|
|
|
"external/foo/lib32",
|
|
|
|
"external/foo/libandroid_arm",
|
|
|
|
"defaults/cc/common/ndk_libc++_shared",
|
|
|
|
}
|
|
|
|
|
|
|
|
conly := []string{"-fPIC", "${config.CommonGlobalConlyflags}"}
|
|
|
|
cppOnly := []string{"-fPIC", "${config.CommonGlobalCppflags}", "${config.DeviceGlobalCppflags}", "${config.ArmCppflags}"}
|
|
|
|
|
2022-05-18 22:15:00 +02:00
|
|
|
cflags := []string{"-Werror", "-std=candcpp"}
|
2023-06-14 19:42:45 +02:00
|
|
|
cstd := []string{"-std=gnu17", "-std=conly"}
|
2022-01-13 23:56:02 +01:00
|
|
|
cppstd := []string{"-std=gnu++20", "-std=cpp", "-fno-rtti"}
|
2021-09-30 16:11:04 +02:00
|
|
|
|
|
|
|
lastIncludes := []string{
|
|
|
|
"out/soong/ndk/sysroot/usr/include",
|
|
|
|
"out/soong/ndk/sysroot/usr/include/arm-linux-androideabi",
|
|
|
|
}
|
|
|
|
|
|
|
|
combineSlices := func(slices ...[]string) []string {
|
|
|
|
var ret []string
|
|
|
|
for _, s := range slices {
|
|
|
|
ret = append(ret, s...)
|
|
|
|
}
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
|
|
|
testCases := []struct {
|
|
|
|
name string
|
|
|
|
src string
|
|
|
|
expected []string
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "c",
|
|
|
|
src: "foo.c",
|
2023-07-14 20:09:00 +02:00
|
|
|
expected: combineSlices(baseExpectedFlags, conly, expectedIncludes, cflags, cstd, lastIncludes, []string{"${config.NoOverrideGlobalCflags}", "${config.NoOverrideExternalGlobalCflags}"}),
|
2021-09-30 16:11:04 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "cc",
|
|
|
|
src: "foo.cc",
|
2023-07-14 20:09:00 +02:00
|
|
|
expected: combineSlices(baseExpectedFlags, cppOnly, expectedIncludes, cflags, cppstd, lastIncludes, []string{"${config.NoOverrideGlobalCflags}", "${config.NoOverrideExternalGlobalCflags}"}),
|
2021-09-30 16:11:04 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "assemble",
|
|
|
|
src: "foo.s",
|
2023-07-14 20:09:00 +02:00
|
|
|
expected: combineSlices(baseExpectedFlags, []string{"${config.CommonGlobalAsflags}"}, expectedIncludes, lastIncludes),
|
2021-09-30 16:11:04 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, tc := range testCases {
|
|
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
|
|
bp := fmt.Sprintf(`
|
2021-06-15 01:52:28 +02:00
|
|
|
cc_library {
|
|
|
|
name: "libfoo",
|
2021-09-30 16:11:04 +02:00
|
|
|
srcs: ["%s"],
|
2021-12-16 17:38:50 +01:00
|
|
|
cflags: ["-std=candcpp"],
|
|
|
|
conlyflags: ["-std=conly"],
|
|
|
|
cppflags: ["-std=cpp"],
|
2021-06-15 01:52:28 +02:00
|
|
|
local_include_dirs: ["local_include_dirs"],
|
|
|
|
export_include_dirs: ["export_include_dirs"],
|
|
|
|
export_system_include_dirs: ["export_system_include_dirs"],
|
|
|
|
static_libs: ["libstatic1", "libstatic2"],
|
|
|
|
whole_static_libs: ["libwhole1", "libwhole2"],
|
|
|
|
shared_libs: ["libshared1", "libshared2"],
|
|
|
|
header_libs: ["libheader1", "libheader2"],
|
|
|
|
target: {
|
|
|
|
android: {
|
|
|
|
shared_libs: ["libandroid"],
|
|
|
|
local_include_dirs: ["android_local_include_dirs"],
|
|
|
|
export_include_dirs: ["android_export_include_dirs"],
|
|
|
|
},
|
|
|
|
android_arm: {
|
|
|
|
shared_libs: ["libandroid_arm"],
|
|
|
|
local_include_dirs: ["android_arm_local_include_dirs"],
|
|
|
|
export_include_dirs: ["android_arm_export_include_dirs"],
|
|
|
|
},
|
|
|
|
linux: {
|
|
|
|
shared_libs: ["liblinux"],
|
|
|
|
local_include_dirs: ["linux_local_include_dirs"],
|
|
|
|
export_include_dirs: ["linux_export_include_dirs"],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
multilib: {
|
|
|
|
lib32: {
|
|
|
|
shared_libs: ["lib32"],
|
|
|
|
local_include_dirs: ["lib32_local_include_dirs"],
|
|
|
|
export_include_dirs: ["lib32_export_include_dirs"],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
arch: {
|
|
|
|
arm: {
|
|
|
|
shared_libs: ["libarm"],
|
|
|
|
local_include_dirs: ["arm_local_include_dirs"],
|
|
|
|
export_include_dirs: ["arm_export_include_dirs"],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
stl: "libc++",
|
2022-08-17 22:11:57 +02:00
|
|
|
sdk_version: "minimum",
|
2021-06-15 01:52:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cc_library_headers {
|
|
|
|
name: "libheader1",
|
|
|
|
export_include_dirs: ["libheader1"],
|
2022-08-17 22:11:57 +02:00
|
|
|
sdk_version: "minimum",
|
2021-06-15 01:52:28 +02:00
|
|
|
stl: "none",
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library_headers {
|
|
|
|
name: "libheader2",
|
|
|
|
export_include_dirs: ["libheader2"],
|
2022-08-17 22:11:57 +02:00
|
|
|
sdk_version: "minimum",
|
2021-06-15 01:52:28 +02:00
|
|
|
stl: "none",
|
|
|
|
}
|
2021-09-30 16:11:04 +02:00
|
|
|
`, tc.src)
|
|
|
|
|
|
|
|
libs := []string{
|
|
|
|
"libstatic1",
|
|
|
|
"libstatic2",
|
|
|
|
"libwhole1",
|
|
|
|
"libwhole2",
|
|
|
|
"libshared1",
|
|
|
|
"libshared2",
|
|
|
|
"libandroid",
|
|
|
|
"libandroid_arm",
|
|
|
|
"liblinux",
|
|
|
|
"lib32",
|
|
|
|
"libarm",
|
|
|
|
}
|
2021-06-15 01:52:28 +02:00
|
|
|
|
2021-09-30 16:11:04 +02:00
|
|
|
for _, lib := range libs {
|
|
|
|
bp += fmt.Sprintf(`
|
2021-06-15 01:52:28 +02:00
|
|
|
cc_library {
|
|
|
|
name: "%s",
|
|
|
|
export_include_dirs: ["%s"],
|
2022-08-17 22:11:57 +02:00
|
|
|
sdk_version: "minimum",
|
2021-06-15 01:52:28 +02:00
|
|
|
stl: "none",
|
|
|
|
}
|
|
|
|
`, lib, lib)
|
2021-09-30 16:11:04 +02:00
|
|
|
}
|
2021-06-15 01:52:28 +02:00
|
|
|
|
2021-09-30 16:11:04 +02:00
|
|
|
ctx := android.GroupFixturePreparers(
|
|
|
|
PrepareForIntegrationTestWithCc,
|
|
|
|
android.FixtureAddTextFile("external/foo/Android.bp", bp),
|
|
|
|
).RunTest(t)
|
|
|
|
// Use the arm variant instead of the arm64 variant so that it gets headers from
|
|
|
|
// ndk_libandroid_support to test LateStaticLibs.
|
|
|
|
cflags := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_sdk_static").Output("obj/external/foo/foo.o").Args["cFlags"]
|
|
|
|
|
|
|
|
var includes []string
|
|
|
|
flags := strings.Split(cflags, " ")
|
|
|
|
for _, flag := range flags {
|
|
|
|
if strings.HasPrefix(flag, "-I") {
|
|
|
|
includes = append(includes, strings.TrimPrefix(flag, "-I"))
|
|
|
|
} else if flag == "-isystem" {
|
|
|
|
// skip isystem, include next
|
|
|
|
} else if len(flag) > 0 {
|
|
|
|
includes = append(includes, flag)
|
|
|
|
}
|
|
|
|
}
|
2021-06-15 01:52:28 +02:00
|
|
|
|
2021-09-30 16:11:04 +02:00
|
|
|
android.AssertArrayString(t, "includes", tc.expected, includes)
|
|
|
|
})
|
2021-06-15 01:52:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2022-04-21 01:00:58 +02:00
|
|
|
|
2023-01-12 08:26:20 +01:00
|
|
|
func TestAddnoOverride64GlobalCflags(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
ctx := testCc(t, `
|
|
|
|
cc_library_shared {
|
|
|
|
name: "libclient",
|
|
|
|
srcs: ["foo.c"],
|
|
|
|
shared_libs: ["libfoo#1"],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library_shared {
|
|
|
|
name: "libfoo",
|
|
|
|
srcs: ["foo.c"],
|
|
|
|
shared_libs: ["libbar"],
|
|
|
|
export_shared_lib_headers: ["libbar"],
|
|
|
|
stubs: {
|
|
|
|
symbol_file: "foo.map.txt",
|
|
|
|
versions: ["1", "2", "3"],
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library_shared {
|
|
|
|
name: "libbar",
|
|
|
|
export_include_dirs: ["include/libbar"],
|
|
|
|
srcs: ["foo.c"],
|
|
|
|
}`)
|
|
|
|
|
|
|
|
cFlags := ctx.ModuleForTests("libclient", "android_arm64_armv8-a_shared").Rule("cc").Args["cFlags"]
|
|
|
|
|
|
|
|
if !strings.Contains(cFlags, "${config.NoOverride64GlobalCflags}") {
|
|
|
|
t.Errorf("expected %q in cflags, got %q", "${config.NoOverride64GlobalCflags}", cFlags)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-21 01:00:58 +02:00
|
|
|
func TestCcBuildBrokenClangProperty(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2022-04-21 01:00:58 +02:00
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
clang bool
|
|
|
|
BuildBrokenClangProperty bool
|
|
|
|
err string
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "error when clang is set to false",
|
|
|
|
clang: false,
|
|
|
|
err: "is no longer supported",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "error when clang is set to true",
|
|
|
|
clang: true,
|
|
|
|
err: "property is deprecated, see Changes.md",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "no error when BuildBrokenClangProperty is explicitly set to true",
|
|
|
|
clang: true,
|
|
|
|
BuildBrokenClangProperty: true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range tests {
|
|
|
|
t.Run(test.name, func(t *testing.T) {
|
|
|
|
bp := fmt.Sprintf(`
|
|
|
|
cc_library {
|
|
|
|
name: "foo",
|
|
|
|
clang: %t,
|
|
|
|
}`, test.clang)
|
|
|
|
|
|
|
|
if test.err == "" {
|
|
|
|
android.GroupFixturePreparers(
|
|
|
|
prepareForCcTest,
|
|
|
|
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
|
|
|
if test.BuildBrokenClangProperty {
|
|
|
|
variables.BuildBrokenClangProperty = test.BuildBrokenClangProperty
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
).RunTestWithBp(t, bp)
|
|
|
|
} else {
|
|
|
|
prepareForCcTest.
|
|
|
|
ExtendWithErrorHandler(android.FixtureExpectsOneErrorPattern(test.err)).
|
|
|
|
RunTestWithBp(t, bp)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2022-09-14 21:10:51 +02:00
|
|
|
|
|
|
|
func TestCcBuildBrokenClangAsFlags(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2022-09-14 21:10:51 +02:00
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
clangAsFlags []string
|
|
|
|
BuildBrokenClangAsFlags bool
|
|
|
|
err string
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "error when clang_asflags is set",
|
|
|
|
clangAsFlags: []string{"-a", "-b"},
|
|
|
|
err: "clang_asflags: property is deprecated",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "no error when BuildBrokenClangAsFlags is explicitly set to true",
|
|
|
|
clangAsFlags: []string{"-a", "-b"},
|
|
|
|
BuildBrokenClangAsFlags: true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range tests {
|
|
|
|
t.Run(test.name, func(t *testing.T) {
|
|
|
|
bp := fmt.Sprintf(`
|
|
|
|
cc_library {
|
|
|
|
name: "foo",
|
|
|
|
clang_asflags: %s,
|
|
|
|
}`, `["`+strings.Join(test.clangAsFlags, `","`)+`"]`)
|
|
|
|
|
|
|
|
if test.err == "" {
|
|
|
|
android.GroupFixturePreparers(
|
|
|
|
prepareForCcTest,
|
|
|
|
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
|
|
|
if test.BuildBrokenClangAsFlags {
|
|
|
|
variables.BuildBrokenClangAsFlags = test.BuildBrokenClangAsFlags
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
).RunTestWithBp(t, bp)
|
|
|
|
} else {
|
|
|
|
prepareForCcTest.
|
|
|
|
ExtendWithErrorHandler(android.FixtureExpectsOneErrorPattern(test.err)).
|
|
|
|
RunTestWithBp(t, bp)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestCcBuildBrokenClangCFlags(t *testing.T) {
|
2022-10-31 21:27:38 +01:00
|
|
|
t.Parallel()
|
2022-09-14 21:10:51 +02:00
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
clangCFlags []string
|
|
|
|
BuildBrokenClangCFlags bool
|
|
|
|
err string
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "error when clang_cflags is set",
|
|
|
|
clangCFlags: []string{"-a", "-b"},
|
|
|
|
err: "clang_cflags: property is deprecated",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "no error when BuildBrokenClangCFlags is explicitly set to true",
|
|
|
|
clangCFlags: []string{"-a", "-b"},
|
|
|
|
BuildBrokenClangCFlags: true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range tests {
|
|
|
|
t.Run(test.name, func(t *testing.T) {
|
|
|
|
bp := fmt.Sprintf(`
|
|
|
|
cc_library {
|
|
|
|
name: "foo",
|
|
|
|
clang_cflags: %s,
|
|
|
|
}`, `["`+strings.Join(test.clangCFlags, `","`)+`"]`)
|
|
|
|
|
|
|
|
if test.err == "" {
|
|
|
|
android.GroupFixturePreparers(
|
|
|
|
prepareForCcTest,
|
|
|
|
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
|
|
|
if test.BuildBrokenClangCFlags {
|
|
|
|
variables.BuildBrokenClangCFlags = test.BuildBrokenClangCFlags
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
).RunTestWithBp(t, bp)
|
|
|
|
} else {
|
|
|
|
prepareForCcTest.
|
|
|
|
ExtendWithErrorHandler(android.FixtureExpectsOneErrorPattern(test.err)).
|
|
|
|
RunTestWithBp(t, bp)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2023-12-12 00:40:29 +01:00
|
|
|
|
|
|
|
func TestStrippedAllOutputFile(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
bp := `
|
|
|
|
cc_library {
|
|
|
|
name: "test_lib",
|
|
|
|
srcs: ["test_lib.cpp"],
|
|
|
|
dist: {
|
|
|
|
targets: [ "dist_target" ],
|
|
|
|
tag: "stripped_all",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`
|
|
|
|
config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
|
|
|
|
ctx := testCcWithConfig(t, config)
|
|
|
|
module := ctx.ModuleForTests("test_lib", "android_arm_armv7-a-neon_shared").Module()
|
|
|
|
outputFile, err := module.(android.OutputFileProducer).OutputFiles("stripped_all")
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("Expected cc_library to produce output files, error: %s", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if !strings.HasSuffix(outputFile.Strings()[0], "/stripped_all/test_lib.so") {
|
|
|
|
t.Errorf("Unexpected output file: %s", outputFile.Strings()[0])
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
2024-01-03 06:24:34 +01:00
|
|
|
|
|
|
|
// TODO(b/316829758) Remove this test and do not set VNDK version from other tests
|
|
|
|
func TestImageVariantsWithoutVndk(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
bp := `
|
|
|
|
cc_binary {
|
|
|
|
name: "binfoo",
|
|
|
|
srcs: ["binfoo.cc"],
|
|
|
|
vendor_available: true,
|
|
|
|
product_available: true,
|
|
|
|
shared_libs: ["libbar"]
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libbar",
|
|
|
|
srcs: ["libbar.cc"],
|
|
|
|
vendor_available: true,
|
|
|
|
product_available: true,
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
ctx := prepareForCcTestWithoutVndk.RunTestWithBp(t, bp)
|
|
|
|
|
|
|
|
hasDep := func(m android.Module, wantDep android.Module) bool {
|
|
|
|
t.Helper()
|
|
|
|
var found bool
|
|
|
|
ctx.VisitDirectDeps(m, func(dep blueprint.Module) {
|
|
|
|
if dep == wantDep {
|
|
|
|
found = true
|
|
|
|
}
|
|
|
|
})
|
|
|
|
return found
|
|
|
|
}
|
|
|
|
|
|
|
|
testDepWithVariant := func(imageVariant string) {
|
|
|
|
imageVariantStr := ""
|
|
|
|
if imageVariant != "core" {
|
|
|
|
imageVariantStr = "_" + imageVariant
|
|
|
|
}
|
|
|
|
binFooModule := ctx.ModuleForTests("binfoo", "android"+imageVariantStr+"_arm64_armv8-a").Module()
|
|
|
|
libBarModule := ctx.ModuleForTests("libbar", "android"+imageVariantStr+"_arm64_armv8-a_shared").Module()
|
|
|
|
android.AssertBoolEquals(t, "binfoo should have dependency on libbar with image variant "+imageVariant, true, hasDep(binFooModule, libBarModule))
|
|
|
|
}
|
|
|
|
|
|
|
|
testDepWithVariant("core")
|
|
|
|
testDepWithVariant("vendor")
|
|
|
|
testDepWithVariant("product")
|
|
|
|
}
|