2017-11-18 02:55:38 +08: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-29 04:30:13 +08:00
|
|
|
package cc
|
|
|
|
|
|
|
|
import (
|
2017-09-28 08:05:30 +08: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 22:05:00 +08:00
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
2019-05-09 12:29:15 +08:00
|
|
|
"path/filepath"
|
2015-04-29 04:30:13 +08:00
|
|
|
"reflect"
|
2017-09-28 08:05:30 +08:00
|
|
|
"sort"
|
|
|
|
"strings"
|
2015-04-29 04:30:13 +08:00
|
|
|
"testing"
|
2019-09-25 05:55:04 +08:00
|
|
|
|
|
|
|
"android/soong/android"
|
2015-04-29 04:30:13 +08:00
|
|
|
)
|
|
|
|
|
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 22:05:00 +08:00
|
|
|
var buildDir string
|
|
|
|
|
|
|
|
func setUp() {
|
|
|
|
var err error
|
|
|
|
buildDir, err = ioutil.TempDir("", "soong_cc_test")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func tearDown() {
|
|
|
|
os.RemoveAll(buildDir)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMain(m *testing.M) {
|
|
|
|
run := func() int {
|
|
|
|
setUp()
|
|
|
|
defer tearDown()
|
|
|
|
|
|
|
|
return m.Run()
|
|
|
|
}
|
|
|
|
|
|
|
|
os.Exit(run())
|
|
|
|
}
|
|
|
|
|
2019-12-14 12:41:13 +08:00
|
|
|
func testCcWithConfig(t *testing.T, config android.Config) *android.TestContext {
|
2019-09-25 05:55:04 +08:00
|
|
|
t.Helper()
|
2019-12-14 12:41:13 +08:00
|
|
|
ctx := CreateTestContext()
|
|
|
|
ctx.Register(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 18:04:35 +08:00
|
|
|
|
2017-08-09 08:46:01 +08:00
|
|
|
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
2018-03-12 16:29:17 +08:00
|
|
|
android.FailIfErrored(t, errs)
|
2017-09-28 08:05:30 +08:00
|
|
|
_, errs = ctx.PrepareBuildActions(config)
|
2018-03-12 16:29:17 +08:00
|
|
|
android.FailIfErrored(t, errs)
|
2017-09-28 08:05:30 +08:00
|
|
|
|
|
|
|
return ctx
|
|
|
|
}
|
|
|
|
|
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 18:04:35 +08:00
|
|
|
func testCc(t *testing.T, bp string) *android.TestContext {
|
2018-03-29 14:08:15 +08:00
|
|
|
t.Helper()
|
2019-12-14 12:41:13 +08:00
|
|
|
config := TestConfig(buildDir, android.Android, nil, bp, nil)
|
2018-03-13 09:06:05 +08:00
|
|
|
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
|
|
|
|
config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
|
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 18:04:35 +08:00
|
|
|
|
2019-12-14 12:41:13 +08:00
|
|
|
return 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 18:04:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func testCcNoVndk(t *testing.T, bp string) *android.TestContext {
|
2018-03-29 14:08:15 +08:00
|
|
|
t.Helper()
|
2019-12-14 12:41:13 +08:00
|
|
|
config := TestConfig(buildDir, android.Android, nil, bp, nil)
|
2018-03-13 09:06:05 +08:00
|
|
|
config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
|
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 18:04:35 +08:00
|
|
|
|
2019-12-14 12:41:13 +08:00
|
|
|
return 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 18:04:35 +08:00
|
|
|
}
|
|
|
|
|
2019-11-18 18:52:14 +08:00
|
|
|
func testCcErrorWithConfig(t *testing.T, pattern string, config android.Config) {
|
2018-03-29 14:08:15 +08: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 18:04:35 +08:00
|
|
|
|
2019-12-14 12:41:13 +08:00
|
|
|
ctx := CreateTestContext()
|
|
|
|
ctx.Register(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 18:04:35 +08:00
|
|
|
|
|
|
|
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
|
|
|
if len(errs) > 0 {
|
2018-03-12 16:34:26 +08:00
|
|
|
android.FailIfNoMatchingErrors(t, pattern, errs)
|
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 18:04:35 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
_, errs = ctx.PrepareBuildActions(config)
|
|
|
|
if len(errs) > 0 {
|
2018-03-12 16:34:26 +08:00
|
|
|
android.FailIfNoMatchingErrors(t, pattern, errs)
|
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 18:04:35 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Fatalf("missing expected error %q (0 errors are returned)", pattern)
|
|
|
|
}
|
|
|
|
|
2019-11-18 18:52:14 +08:00
|
|
|
func testCcError(t *testing.T, pattern string, bp string) {
|
|
|
|
config := TestConfig(buildDir, android.Android, nil, bp, nil)
|
|
|
|
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
|
|
|
|
config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
|
|
|
|
testCcErrorWithConfig(t, pattern, config)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func testCcErrorProductVndk(t *testing.T, pattern string, bp string) {
|
|
|
|
config := TestConfig(buildDir, android.Android, nil, bp, nil)
|
|
|
|
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
|
|
|
|
config.TestProductVariables.ProductVndkVersion = StringPtr("current")
|
|
|
|
config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
|
|
|
|
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 18:04:35 +08:00
|
|
|
const (
|
2019-11-21 08:39:12 +08:00
|
|
|
coreVariant = "android_arm64_armv8-a_shared"
|
2019-11-21 09:12:35 +08:00
|
|
|
vendorVariant = "android_vendor.VER_arm64_armv8-a_shared"
|
2019-11-18 18:52:14 +08:00
|
|
|
productVariant = "android_product.VER_arm64_armv8-a_shared"
|
2019-11-21 09:12:35 +08: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 18:04:35 +08:00
|
|
|
)
|
|
|
|
|
2019-01-18 06:44:05 +08:00
|
|
|
func TestFuchsiaDeps(t *testing.T) {
|
|
|
|
t.Helper()
|
|
|
|
|
|
|
|
bp := `
|
|
|
|
cc_library {
|
|
|
|
name: "libTest",
|
|
|
|
srcs: ["foo.c"],
|
|
|
|
target: {
|
|
|
|
fuchsia: {
|
|
|
|
srcs: ["bar.c"],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}`
|
|
|
|
|
2019-12-14 12:41:13 +08:00
|
|
|
config := TestConfig(buildDir, android.Fuchsia, nil, bp, nil)
|
|
|
|
ctx := testCcWithConfig(t, config)
|
2019-01-18 06:44:05 +08:00
|
|
|
|
|
|
|
rt := false
|
|
|
|
fb := false
|
|
|
|
|
|
|
|
ld := ctx.ModuleForTests("libTest", "fuchsia_arm64_shared").Rule("ld")
|
|
|
|
implicits := ld.Implicits
|
|
|
|
for _, lib := range implicits {
|
|
|
|
if strings.Contains(lib.Rel(), "libcompiler_rt") {
|
|
|
|
rt = true
|
|
|
|
}
|
|
|
|
|
|
|
|
if strings.Contains(lib.Rel(), "libbioniccompat") {
|
|
|
|
fb = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if !rt || !fb {
|
|
|
|
t.Errorf("fuchsia libs must link libcompiler_rt and libbioniccompat")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestFuchsiaTargetDecl(t *testing.T) {
|
|
|
|
t.Helper()
|
|
|
|
|
|
|
|
bp := `
|
|
|
|
cc_library {
|
|
|
|
name: "libTest",
|
|
|
|
srcs: ["foo.c"],
|
|
|
|
target: {
|
|
|
|
fuchsia: {
|
|
|
|
srcs: ["bar.c"],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}`
|
|
|
|
|
2019-12-14 12:41:13 +08:00
|
|
|
config := TestConfig(buildDir, android.Fuchsia, nil, bp, nil)
|
|
|
|
ctx := testCcWithConfig(t, config)
|
2019-01-18 06:44:05 +08:00
|
|
|
ld := ctx.ModuleForTests("libTest", "fuchsia_arm64_shared").Rule("ld")
|
|
|
|
var objs []string
|
|
|
|
for _, o := range ld.Inputs {
|
|
|
|
objs = append(objs, o.Base())
|
|
|
|
}
|
|
|
|
if len(objs) != 2 || objs[0] != "foo.o" || objs[1] != "bar.o" {
|
|
|
|
t.Errorf("inputs of libTest must be []string{\"foo.o\", \"bar.o\"}, but was %#v.", objs)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-28 08:05:30 +08:00
|
|
|
func TestVendorSrc(t *testing.T) {
|
|
|
|
ctx := testCc(t, `
|
|
|
|
cc_library {
|
|
|
|
name: "libTest",
|
|
|
|
srcs: ["foo.c"],
|
2019-06-02 15:53:50 +08: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 18:04:35 +08:00
|
|
|
nocrt: true,
|
|
|
|
system_shared_libs: [],
|
2017-09-28 08:05:30 +08: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 22:05:00 +08: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 18:04:35 +08: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 22:05:00 +08:00
|
|
|
var objs []string
|
|
|
|
for _, o := range ld.Inputs {
|
|
|
|
objs = append(objs, o.Base())
|
|
|
|
}
|
2018-01-04 05:40:46 +08: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 22:05:00 +08:00
|
|
|
t.Errorf("inputs of libTest must be []string{\"foo.o\", \"bar.o\"}, but was %#v.", objs)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 18:04:35 +08:00
|
|
|
func checkVndkModule(t *testing.T, ctx *android.TestContext, name, subDir string,
|
2020-02-28 14:07:59 +08: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 18:04:35 +08:00
|
|
|
|
2018-03-29 14:08:15 +08:00
|
|
|
t.Helper()
|
|
|
|
|
2020-02-28 14:07:59 +08:00
|
|
|
mod := ctx.ModuleForTests(name, variant).Module().(*Module)
|
2019-10-19 05:49:46 +08:00
|
|
|
if !mod.HasVendorVariant() {
|
2020-02-28 14:07:59 +08:00
|
|
|
t.Errorf("%q must have variant %q", name, variant)
|
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 18:04:35 +08: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-19 05:49:46 +08: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 18:04:35 +08:00
|
|
|
}
|
|
|
|
if mod.isVndkSp() != isVndkSp {
|
|
|
|
t.Errorf("%q isVndkSp() must equal to %t", name, isVndkSp)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check VNDK extension properties.
|
|
|
|
isVndkExt := extends != ""
|
|
|
|
if mod.isVndkExt() != isVndkExt {
|
|
|
|
t.Errorf("%q isVndkExt() must equal to %t", name, isVndkExt)
|
|
|
|
}
|
|
|
|
|
|
|
|
if actualExtends := mod.getVndkExtendsModuleName(); actualExtends != extends {
|
|
|
|
t.Errorf("%q must extend from %q but get %q", name, extends, actualExtends)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-01 07:07:58 +08:00
|
|
|
func checkSnapshotIncludeExclude(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string, include bool) {
|
|
|
|
t.Helper()
|
2019-11-06 15:53:07 +08:00
|
|
|
mod, ok := ctx.ModuleForTests(moduleName, variant).Module().(android.OutputFileProducer)
|
|
|
|
if !ok {
|
|
|
|
t.Errorf("%q must have output\n", moduleName)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
outputFiles, err := mod.OutputFiles("")
|
|
|
|
if err != nil || len(outputFiles) != 1 {
|
|
|
|
t.Errorf("%q must have single output\n", moduleName)
|
2019-05-09 12:29:15 +08:00
|
|
|
return
|
|
|
|
}
|
2019-11-06 15:53:07 +08:00
|
|
|
snapshotPath := filepath.Join(subDir, snapshotFilename)
|
2019-05-09 12:29:15 +08:00
|
|
|
|
2020-09-01 07:07:58 +08:00
|
|
|
if include {
|
|
|
|
out := singleton.Output(snapshotPath)
|
|
|
|
if out.Input.String() != outputFiles[0].String() {
|
|
|
|
t.Errorf("The input of snapshot %q must be %q, but %q", moduleName, out.Input.String(), outputFiles[0])
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
out := singleton.MaybeOutput(snapshotPath)
|
|
|
|
if out.Rule != nil {
|
|
|
|
t.Errorf("There must be no rule for module %q output file %q", moduleName, outputFiles[0])
|
|
|
|
}
|
2019-05-09 12:29:15 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-01 07:07:58 +08:00
|
|
|
func checkSnapshot(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string) {
|
|
|
|
checkSnapshotIncludeExclude(t, ctx, singleton, moduleName, snapshotFilename, subDir, variant, true)
|
|
|
|
}
|
|
|
|
|
|
|
|
func checkSnapshotExclude(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string) {
|
|
|
|
checkSnapshotIncludeExclude(t, ctx, singleton, moduleName, snapshotFilename, subDir, variant, false)
|
|
|
|
}
|
|
|
|
|
2019-11-06 15:46:15 +08:00
|
|
|
func checkWriteFileOutput(t *testing.T, params android.TestingBuildParams, expected []string) {
|
|
|
|
t.Helper()
|
|
|
|
assertString(t, params.Rule.String(), android.WriteFile.String())
|
|
|
|
actual := strings.FieldsFunc(strings.ReplaceAll(params.Args["content"], "\\n", "\n"), func(r rune) bool { return r == '\n' })
|
|
|
|
assertArrayString(t, actual, expected)
|
|
|
|
}
|
|
|
|
|
2019-10-22 18:32:18 +08:00
|
|
|
func checkVndkOutput(t *testing.T, ctx *android.TestContext, output string, expected []string) {
|
|
|
|
t.Helper()
|
|
|
|
vndkSnapshot := ctx.SingletonForTests("vndk-snapshot")
|
2019-11-06 15:46:15 +08:00
|
|
|
checkWriteFileOutput(t, vndkSnapshot.Output(output), expected)
|
|
|
|
}
|
|
|
|
|
|
|
|
func checkVndkLibrariesOutput(t *testing.T, ctx *android.TestContext, module string, expected []string) {
|
|
|
|
t.Helper()
|
|
|
|
vndkLibraries := ctx.ModuleForTests(module, "")
|
2019-12-30 10:12:55 +08:00
|
|
|
|
|
|
|
var output string
|
|
|
|
if module != "vndkcorevariant.libraries.txt" {
|
|
|
|
output = insertVndkVersion(module, "VER")
|
|
|
|
} else {
|
|
|
|
output = module
|
|
|
|
}
|
|
|
|
|
2019-11-06 15:46:15 +08:00
|
|
|
checkWriteFileOutput(t, vndkLibraries.Output(output), expected)
|
2019-10-22 18:32:18 +08: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 18:04:35 +08:00
|
|
|
func TestVndk(t *testing.T) {
|
2019-12-14 12:41:13 +08: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 18:04:35 +08:00
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_private",
|
|
|
|
vendor_available: false,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
2019-10-30 17:43:49 +08: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 18:04:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_sp",
|
|
|
|
vendor_available: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
support_system_process: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
2019-10-30 17:43:49 +08: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 18:04:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_sp_private",
|
|
|
|
vendor_available: false,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
support_system_process: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
2019-10-30 17:43:49 +08:00
|
|
|
target: {
|
|
|
|
vendor: {
|
|
|
|
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 18:04:35 +08:00
|
|
|
}
|
2019-11-06 15:46:15 +08:00
|
|
|
vndk_libraries_txt {
|
|
|
|
name: "llndk.libraries.txt",
|
|
|
|
}
|
|
|
|
vndk_libraries_txt {
|
|
|
|
name: "vndkcore.libraries.txt",
|
|
|
|
}
|
|
|
|
vndk_libraries_txt {
|
|
|
|
name: "vndksp.libraries.txt",
|
|
|
|
}
|
|
|
|
vndk_libraries_txt {
|
|
|
|
name: "vndkprivate.libraries.txt",
|
|
|
|
}
|
|
|
|
vndk_libraries_txt {
|
|
|
|
name: "vndkcorevariant.libraries.txt",
|
|
|
|
}
|
2019-12-14 12:41:13 +08:00
|
|
|
`
|
|
|
|
|
|
|
|
config := TestConfig(buildDir, android.Android, nil, bp, nil)
|
|
|
|
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
|
|
|
|
config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
|
|
|
|
|
|
|
|
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 18:04:35 +08:00
|
|
|
|
2020-02-28 14:07:59 +08:00
|
|
|
checkVndkModule(t, ctx, "libvndk", "vndk-VER", false, "", vendorVariant)
|
|
|
|
checkVndkModule(t, ctx, "libvndk_private", "vndk-VER", false, "", vendorVariant)
|
|
|
|
checkVndkModule(t, ctx, "libvndk_sp", "vndk-sp-VER", true, "", vendorVariant)
|
|
|
|
checkVndkModule(t, ctx, "libvndk_sp_private", "vndk-sp-VER", true, "", vendorVariant)
|
2019-05-09 12:29:15 +08:00
|
|
|
|
|
|
|
// Check VNDK snapshot output.
|
|
|
|
|
|
|
|
snapshotDir := "vndk-snapshot"
|
|
|
|
snapshotVariantPath := filepath.Join(buildDir, snapshotDir, "arm64")
|
|
|
|
|
|
|
|
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")
|
|
|
|
vndkCoreLib2ndPath := filepath.Join(vndkLib2ndPath, "shared", "vndk-core")
|
|
|
|
vndkSpLib2ndPath := filepath.Join(vndkLib2ndPath, "shared", "vndk-sp")
|
|
|
|
|
2019-11-21 09:12:35 +08:00
|
|
|
variant := "android_vendor.VER_arm64_armv8-a_shared"
|
|
|
|
variant2nd := "android_vendor.VER_arm_armv7-a-neon_shared"
|
2019-05-09 12:29:15 +08:00
|
|
|
|
2020-06-01 20:53:49 +08:00
|
|
|
snapshotSingleton := ctx.SingletonForTests("vndk-snapshot")
|
|
|
|
|
|
|
|
checkSnapshot(t, ctx, snapshotSingleton, "libvndk", "libvndk.so", vndkCoreLibPath, variant)
|
|
|
|
checkSnapshot(t, ctx, snapshotSingleton, "libvndk", "libvndk.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)
|
2019-11-06 15:53:07 +08:00
|
|
|
|
|
|
|
snapshotConfigsPath := filepath.Join(snapshotVariantPath, "configs")
|
2020-06-01 20:53:49 +08:00
|
|
|
checkSnapshot(t, ctx, snapshotSingleton, "llndk.libraries.txt", "llndk.libraries.txt", snapshotConfigsPath, "")
|
|
|
|
checkSnapshot(t, ctx, snapshotSingleton, "vndkcore.libraries.txt", "vndkcore.libraries.txt", snapshotConfigsPath, "")
|
|
|
|
checkSnapshot(t, ctx, snapshotSingleton, "vndksp.libraries.txt", "vndksp.libraries.txt", snapshotConfigsPath, "")
|
|
|
|
checkSnapshot(t, ctx, snapshotSingleton, "vndkprivate.libraries.txt", "vndkprivate.libraries.txt", snapshotConfigsPath, "")
|
2019-10-22 18:32:18 +08:00
|
|
|
|
|
|
|
checkVndkOutput(t, ctx, "vndk/vndk.libraries.txt", []string{
|
|
|
|
"LLNDK: libc.so",
|
|
|
|
"LLNDK: libdl.so",
|
|
|
|
"LLNDK: libft2.so",
|
|
|
|
"LLNDK: libm.so",
|
|
|
|
"VNDK-SP: libc++.so",
|
2019-10-30 17:43:49 +08:00
|
|
|
"VNDK-SP: libvndk_sp-x.so",
|
|
|
|
"VNDK-SP: libvndk_sp_private-x.so",
|
|
|
|
"VNDK-core: libvndk-private.so",
|
2019-10-22 18:32:18 +08:00
|
|
|
"VNDK-core: libvndk.so",
|
|
|
|
"VNDK-private: libft2.so",
|
2019-10-30 17:43:49 +08:00
|
|
|
"VNDK-private: libvndk-private.so",
|
|
|
|
"VNDK-private: libvndk_sp_private-x.so",
|
|
|
|
})
|
2019-11-06 15:46:15 +08:00
|
|
|
checkVndkLibrariesOutput(t, ctx, "llndk.libraries.txt", []string{"libc.so", "libdl.so", "libft2.so", "libm.so"})
|
|
|
|
checkVndkLibrariesOutput(t, ctx, "vndkcore.libraries.txt", []string{"libvndk-private.so", "libvndk.so"})
|
|
|
|
checkVndkLibrariesOutput(t, ctx, "vndkprivate.libraries.txt", []string{"libft2.so", "libvndk-private.so", "libvndk_sp_private-x.so"})
|
|
|
|
checkVndkLibrariesOutput(t, ctx, "vndksp.libraries.txt", []string{"libc++.so", "libvndk_sp-x.so", "libvndk_sp_private-x.so"})
|
|
|
|
checkVndkLibrariesOutput(t, ctx, "vndkcorevariant.libraries.txt", nil)
|
|
|
|
}
|
|
|
|
|
2020-06-09 16:15:37 +08:00
|
|
|
func TestVndkWithHostSupported(t *testing.T) {
|
|
|
|
ctx := testCc(t, `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_host_supported",
|
|
|
|
vendor_available: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
host_supported: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_host_supported_but_disabled_on_device",
|
|
|
|
vendor_available: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
host_supported: true,
|
|
|
|
enabled: false,
|
|
|
|
target: {
|
|
|
|
host: {
|
|
|
|
enabled: true,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
vndk_libraries_txt {
|
|
|
|
name: "vndkcore.libraries.txt",
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
checkVndkLibrariesOutput(t, ctx, "vndkcore.libraries.txt", []string{"libvndk_host_supported.so"})
|
|
|
|
}
|
|
|
|
|
2019-11-06 15:46:15 +08:00
|
|
|
func TestVndkLibrariesTxtAndroidMk(t *testing.T) {
|
2019-12-14 12:41:13 +08:00
|
|
|
bp := `
|
2019-11-06 15:46:15 +08:00
|
|
|
vndk_libraries_txt {
|
|
|
|
name: "llndk.libraries.txt",
|
2019-12-14 12:41:13 +08:00
|
|
|
}`
|
|
|
|
config := TestConfig(buildDir, android.Android, nil, bp, nil)
|
|
|
|
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
|
|
|
|
config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
|
|
|
|
ctx := testCcWithConfig(t, config)
|
2019-11-06 15:46:15 +08:00
|
|
|
|
|
|
|
module := ctx.ModuleForTests("llndk.libraries.txt", "")
|
2019-12-03 12:24:29 +08:00
|
|
|
entries := android.AndroidMkEntriesForTest(t, config, "", module.Module())[0]
|
2019-11-06 15:46:15 +08:00
|
|
|
assertArrayString(t, entries.EntryMap["LOCAL_MODULE_STEM"], []string{"llndk.libraries.VER.txt"})
|
2019-10-22 18:32:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestVndkUsingCoreVariant(t *testing.T) {
|
2019-12-14 12:41:13 +08:00
|
|
|
bp := `
|
2019-10-22 18:32:18 +08:00
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_sp",
|
|
|
|
vendor_available: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
support_system_process: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk2",
|
|
|
|
vendor_available: false,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
2019-11-06 15:46:15 +08:00
|
|
|
|
|
|
|
vndk_libraries_txt {
|
|
|
|
name: "vndkcorevariant.libraries.txt",
|
|
|
|
}
|
2019-12-14 12:41:13 +08:00
|
|
|
`
|
|
|
|
|
|
|
|
config := TestConfig(buildDir, android.Android, nil, bp, nil)
|
|
|
|
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
|
|
|
|
config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
|
|
|
|
config.TestProductVariables.VndkUseCoreVariant = BoolPtr(true)
|
|
|
|
|
|
|
|
setVndkMustUseVendorVariantListForTest(config, []string{"libvndk"})
|
|
|
|
|
|
|
|
ctx := testCcWithConfig(t, config)
|
2019-10-22 18:32:18 +08:00
|
|
|
|
2019-11-06 15:46:15 +08:00
|
|
|
checkVndkLibrariesOutput(t, ctx, "vndkcorevariant.libraries.txt", []string{"libc++.so", "libvndk2.so", "libvndk_sp.so"})
|
2019-10-30 17:43:49 +08:00
|
|
|
}
|
|
|
|
|
2020-06-06 05:26:16 +08:00
|
|
|
func TestDataLibs(t *testing.T) {
|
|
|
|
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-10 05:12:52 +08:00
|
|
|
`
|
2020-06-06 05:26:16 +08:00
|
|
|
|
|
|
|
config := TestConfig(buildDir, android.Android, nil, bp, nil)
|
|
|
|
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
|
|
|
|
config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
|
|
|
|
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 {
|
|
|
|
t.Errorf("expected exactly one test data file. test data files: [%s]", testBinary.dataPaths())
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
outputPath := outputFiles[0].String()
|
2020-07-10 05:12:52 +08:00
|
|
|
testBinaryPath := testBinary.dataPaths()[0].SrcPath.String()
|
2020-06-06 05:26:16 +08: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-10 05:12:52 +08:00
|
|
|
func TestDataLibsRelativeInstallPath(t *testing.T) {
|
|
|
|
bp := `
|
|
|
|
cc_test_library {
|
|
|
|
name: "test_lib",
|
|
|
|
srcs: ["test_lib.cpp"],
|
|
|
|
relative_install_path: "foo/bar/baz",
|
|
|
|
gtest: false,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_test {
|
|
|
|
name: "main_test",
|
|
|
|
data_libs: ["test_lib"],
|
|
|
|
gtest: false,
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
config := TestConfig(buildDir, android.Android, nil, bp, nil)
|
|
|
|
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
|
|
|
|
config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
|
|
|
|
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 {
|
|
|
|
t.Errorf("expected exactly one test data file. test data files: [%s]", testBinary.dataPaths())
|
|
|
|
}
|
|
|
|
|
|
|
|
outputPath := outputFiles[0].String()
|
|
|
|
|
|
|
|
if !strings.HasSuffix(outputPath, "/main_test") {
|
|
|
|
t.Errorf("expected test output file to be 'main_test', but was '%s'", outputPath)
|
|
|
|
}
|
|
|
|
entries := android.AndroidMkEntriesForTest(t, config, "", module)[0]
|
|
|
|
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-18 04:10:42 +08:00
|
|
|
" but was '%s'", entries.EntryMap["LOCAL_TEST_DATA"][0])
|
2020-07-10 05:12:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-30 17:43:49 +08:00
|
|
|
func TestVndkWhenVndkVersionIsNotSet(t *testing.T) {
|
2019-11-06 15:46:15 +08:00
|
|
|
ctx := testCcNoVndk(t, `
|
2019-10-30 17:43:49 +08:00
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
2019-11-06 15:46:15 +08:00
|
|
|
`)
|
2019-10-30 17:43:49 +08:00
|
|
|
|
|
|
|
checkVndkOutput(t, ctx, "vndk/vndk.libraries.txt", []string{
|
|
|
|
"LLNDK: libc.so",
|
|
|
|
"LLNDK: libdl.so",
|
|
|
|
"LLNDK: libft2.so",
|
|
|
|
"LLNDK: libm.so",
|
|
|
|
"VNDK-SP: libc++.so",
|
|
|
|
"VNDK-core: libvndk.so",
|
|
|
|
"VNDK-private: libft2.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 18:04:35 +08:00
|
|
|
}
|
|
|
|
|
2018-03-29 14:08:15 +08:00
|
|
|
func TestVndkDepError(t *testing.T) {
|
|
|
|
// 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,
|
|
|
|
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,
|
|
|
|
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,
|
|
|
|
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,
|
|
|
|
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,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
support_system_process: true,
|
|
|
|
},
|
|
|
|
shared_libs: ["libvndk"], // Cause error
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
2019-01-18 14:20:43 +08: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,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
shared_libs: ["libnonvndk"],
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libnonvndk",
|
|
|
|
vendor_available: true,
|
|
|
|
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",
|
|
|
|
vendor_available: false,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
shared_libs: ["libnonvndk"],
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libnonvndk",
|
|
|
|
vendor_available: true,
|
|
|
|
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,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
support_system_process: true,
|
|
|
|
},
|
|
|
|
shared_libs: ["libnonvndk"],
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libnonvndk",
|
|
|
|
vendor_available: true,
|
|
|
|
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",
|
|
|
|
vendor_available: false,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
support_system_process: true,
|
|
|
|
},
|
|
|
|
shared_libs: ["libnonvndk"],
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libnonvndk",
|
|
|
|
vendor_available: true,
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDoubleLoadbleDep(t *testing.T) {
|
|
|
|
// okay to link : LLNDK -> double_loadable VNDK
|
|
|
|
testCc(t, `
|
|
|
|
cc_library {
|
|
|
|
name: "libllndk",
|
|
|
|
shared_libs: ["libdoubleloadable"],
|
|
|
|
}
|
|
|
|
|
|
|
|
llndk_library {
|
|
|
|
name: "libllndk",
|
|
|
|
symbol_file: "",
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libdoubleloadable",
|
|
|
|
vendor_available: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
double_loadable: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
// okay to link : LLNDK -> VNDK-SP
|
|
|
|
testCc(t, `
|
|
|
|
cc_library {
|
|
|
|
name: "libllndk",
|
|
|
|
shared_libs: ["libvndksp"],
|
|
|
|
}
|
|
|
|
|
|
|
|
llndk_library {
|
|
|
|
name: "libllndk",
|
|
|
|
symbol_file: "",
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndksp",
|
|
|
|
vendor_available: true,
|
|
|
|
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,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
double_loadable: true,
|
|
|
|
shared_libs: ["libnondoubleloadable"],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libnondoubleloadable",
|
|
|
|
vendor_available: false,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
double_loadable: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
// okay to link : LLNDK -> core-only -> vendor_available & double_loadable
|
|
|
|
testCc(t, `
|
|
|
|
cc_library {
|
|
|
|
name: "libllndk",
|
|
|
|
shared_libs: ["libcoreonly"],
|
|
|
|
}
|
|
|
|
|
|
|
|
llndk_library {
|
|
|
|
name: "libllndk",
|
|
|
|
symbol_file: "",
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libcoreonly",
|
|
|
|
shared_libs: ["libvendoravailable"],
|
|
|
|
}
|
|
|
|
|
|
|
|
// indirect dependency of LLNDK
|
|
|
|
cc_library {
|
|
|
|
name: "libvendoravailable",
|
|
|
|
vendor_available: true,
|
|
|
|
double_loadable: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
}
|
|
|
|
|
2020-09-07 18:53:31 +08:00
|
|
|
func TestVendorSnapshotCapture(t *testing.T) {
|
2019-11-15 08:59:12 +08:00
|
|
|
bp := `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvendor",
|
|
|
|
vendor: true,
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvendor_available",
|
|
|
|
vendor_available: true,
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library_headers {
|
|
|
|
name: "libvendor_headers",
|
|
|
|
vendor_available: true,
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_binary {
|
|
|
|
name: "vendor_bin",
|
|
|
|
vendor: true,
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_binary {
|
|
|
|
name: "vendor_available_bin",
|
|
|
|
vendor_available: true,
|
|
|
|
nocrt: true,
|
|
|
|
}
|
2020-06-01 20:53:49 +08:00
|
|
|
|
|
|
|
toolchain_library {
|
|
|
|
name: "libb",
|
|
|
|
vendor_available: true,
|
|
|
|
src: "libb.a",
|
|
|
|
}
|
2020-06-01 22:23:05 +08:00
|
|
|
|
|
|
|
cc_object {
|
|
|
|
name: "obj",
|
|
|
|
vendor_available: true,
|
|
|
|
}
|
2019-11-15 08:59:12 +08:00
|
|
|
`
|
|
|
|
config := TestConfig(buildDir, android.Android, nil, bp, nil)
|
|
|
|
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
|
|
|
|
config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
|
|
|
|
ctx := testCcWithConfig(t, config)
|
|
|
|
|
|
|
|
// Check Vendor snapshot output.
|
|
|
|
|
|
|
|
snapshotDir := "vendor-snapshot"
|
|
|
|
snapshotVariantPath := filepath.Join(buildDir, snapshotDir, "arm64")
|
2020-06-01 20:53:49 +08:00
|
|
|
snapshotSingleton := ctx.SingletonForTests("vendor-snapshot")
|
|
|
|
|
|
|
|
var jsonFiles []string
|
2019-11-15 08:59:12 +08:00
|
|
|
|
|
|
|
for _, arch := range [][]string{
|
|
|
|
[]string{"arm64", "armv8-a"},
|
|
|
|
[]string{"arm", "armv7-a-neon"},
|
|
|
|
} {
|
|
|
|
archType := arch[0]
|
|
|
|
archVariant := arch[1]
|
|
|
|
archDir := fmt.Sprintf("arch-%s-%s", archType, archVariant)
|
|
|
|
|
|
|
|
// For shared libraries, only non-VNDK vendor_available modules are captured
|
|
|
|
sharedVariant := fmt.Sprintf("android_vendor.VER_%s_%s_shared", archType, archVariant)
|
|
|
|
sharedDir := filepath.Join(snapshotVariantPath, archDir, "shared")
|
2020-06-01 20:53:49 +08:00
|
|
|
checkSnapshot(t, ctx, snapshotSingleton, "libvendor", "libvendor.so", sharedDir, sharedVariant)
|
|
|
|
checkSnapshot(t, ctx, snapshotSingleton, "libvendor_available", "libvendor_available.so", sharedDir, sharedVariant)
|
|
|
|
jsonFiles = append(jsonFiles,
|
|
|
|
filepath.Join(sharedDir, "libvendor.so.json"),
|
|
|
|
filepath.Join(sharedDir, "libvendor_available.so.json"))
|
2019-11-15 08:59:12 +08:00
|
|
|
|
|
|
|
// For static libraries, all vendor:true and vendor_available modules (including VNDK) are captured.
|
Add cfi static libraries to vendor snapshot
CFI modules can't link against non-CFI static libraries, and vice versa.
So without capturing both CFI and non-CFI static libraries, vendor
modules won't be able to use CFI, which will be a critical security
hole.
This captures both CFI and non-CFI variants of all static libraries for
vendor snapshot, except for those whose cfi are explicitly disabled.
For example, suppose that "libfoo" is defined as follows.
cc_library_static {
name: "libfoo",
vendor_available: true,
}
As it doesn't have cfi disabled, two libraries "libfoo.a" and
"libfoo.cfi.a" will be captured. When installed, vendor snapshot module
for "libfoo" will look like:
vendor_snapshot_static {
name: "libfoo",
src: "libfoo.a",
cfi: {
src: "libfoo.cfi.a",
},
}
The build system will recognize the "cfi" property, and will create both
CFI and non-CFI variant, allowing any modules to link against "libfoo"
safely, no matter whether CFI is enabled or not.
Two clarification:
1) The reason why we don't create separate modules is that DepsMutator
runs before sanitize mutators. CFI and non-CFI variant of a library
should exist in a single module.
2) We can't capture CFI variant if the source module explicitly disables
cfi variant by specifying the following.
sanitize: {
cfi: false,
}
In this case, only non-CFI variant will be created for the vendor
snapshot module.
Bug: 65377115
Test: m dist vendor-snapshot && install && build against snapshot
Change-Id: Idbf3e3205d581800d6093c8d6cf6152374129ba4
2020-07-29 19:32:10 +08:00
|
|
|
// Also cfi variants are captured, except for prebuilts like toolchain_library
|
2019-11-15 08:59:12 +08:00
|
|
|
staticVariant := fmt.Sprintf("android_vendor.VER_%s_%s_static", archType, archVariant)
|
Add cfi static libraries to vendor snapshot
CFI modules can't link against non-CFI static libraries, and vice versa.
So without capturing both CFI and non-CFI static libraries, vendor
modules won't be able to use CFI, which will be a critical security
hole.
This captures both CFI and non-CFI variants of all static libraries for
vendor snapshot, except for those whose cfi are explicitly disabled.
For example, suppose that "libfoo" is defined as follows.
cc_library_static {
name: "libfoo",
vendor_available: true,
}
As it doesn't have cfi disabled, two libraries "libfoo.a" and
"libfoo.cfi.a" will be captured. When installed, vendor snapshot module
for "libfoo" will look like:
vendor_snapshot_static {
name: "libfoo",
src: "libfoo.a",
cfi: {
src: "libfoo.cfi.a",
},
}
The build system will recognize the "cfi" property, and will create both
CFI and non-CFI variant, allowing any modules to link against "libfoo"
safely, no matter whether CFI is enabled or not.
Two clarification:
1) The reason why we don't create separate modules is that DepsMutator
runs before sanitize mutators. CFI and non-CFI variant of a library
should exist in a single module.
2) We can't capture CFI variant if the source module explicitly disables
cfi variant by specifying the following.
sanitize: {
cfi: false,
}
In this case, only non-CFI variant will be created for the vendor
snapshot module.
Bug: 65377115
Test: m dist vendor-snapshot && install && build against snapshot
Change-Id: Idbf3e3205d581800d6093c8d6cf6152374129ba4
2020-07-29 19:32:10 +08:00
|
|
|
staticCfiVariant := fmt.Sprintf("android_vendor.VER_%s_%s_static_cfi", archType, archVariant)
|
2019-11-15 08:59:12 +08:00
|
|
|
staticDir := filepath.Join(snapshotVariantPath, archDir, "static")
|
2020-06-01 20:53:49 +08:00
|
|
|
checkSnapshot(t, ctx, snapshotSingleton, "libb", "libb.a", staticDir, staticVariant)
|
|
|
|
checkSnapshot(t, ctx, snapshotSingleton, "libvndk", "libvndk.a", staticDir, staticVariant)
|
Add cfi static libraries to vendor snapshot
CFI modules can't link against non-CFI static libraries, and vice versa.
So without capturing both CFI and non-CFI static libraries, vendor
modules won't be able to use CFI, which will be a critical security
hole.
This captures both CFI and non-CFI variants of all static libraries for
vendor snapshot, except for those whose cfi are explicitly disabled.
For example, suppose that "libfoo" is defined as follows.
cc_library_static {
name: "libfoo",
vendor_available: true,
}
As it doesn't have cfi disabled, two libraries "libfoo.a" and
"libfoo.cfi.a" will be captured. When installed, vendor snapshot module
for "libfoo" will look like:
vendor_snapshot_static {
name: "libfoo",
src: "libfoo.a",
cfi: {
src: "libfoo.cfi.a",
},
}
The build system will recognize the "cfi" property, and will create both
CFI and non-CFI variant, allowing any modules to link against "libfoo"
safely, no matter whether CFI is enabled or not.
Two clarification:
1) The reason why we don't create separate modules is that DepsMutator
runs before sanitize mutators. CFI and non-CFI variant of a library
should exist in a single module.
2) We can't capture CFI variant if the source module explicitly disables
cfi variant by specifying the following.
sanitize: {
cfi: false,
}
In this case, only non-CFI variant will be created for the vendor
snapshot module.
Bug: 65377115
Test: m dist vendor-snapshot && install && build against snapshot
Change-Id: Idbf3e3205d581800d6093c8d6cf6152374129ba4
2020-07-29 19:32:10 +08:00
|
|
|
checkSnapshot(t, ctx, snapshotSingleton, "libvndk", "libvndk.cfi.a", staticDir, staticCfiVariant)
|
2020-06-01 20:53:49 +08:00
|
|
|
checkSnapshot(t, ctx, snapshotSingleton, "libvendor", "libvendor.a", staticDir, staticVariant)
|
Add cfi static libraries to vendor snapshot
CFI modules can't link against non-CFI static libraries, and vice versa.
So without capturing both CFI and non-CFI static libraries, vendor
modules won't be able to use CFI, which will be a critical security
hole.
This captures both CFI and non-CFI variants of all static libraries for
vendor snapshot, except for those whose cfi are explicitly disabled.
For example, suppose that "libfoo" is defined as follows.
cc_library_static {
name: "libfoo",
vendor_available: true,
}
As it doesn't have cfi disabled, two libraries "libfoo.a" and
"libfoo.cfi.a" will be captured. When installed, vendor snapshot module
for "libfoo" will look like:
vendor_snapshot_static {
name: "libfoo",
src: "libfoo.a",
cfi: {
src: "libfoo.cfi.a",
},
}
The build system will recognize the "cfi" property, and will create both
CFI and non-CFI variant, allowing any modules to link against "libfoo"
safely, no matter whether CFI is enabled or not.
Two clarification:
1) The reason why we don't create separate modules is that DepsMutator
runs before sanitize mutators. CFI and non-CFI variant of a library
should exist in a single module.
2) We can't capture CFI variant if the source module explicitly disables
cfi variant by specifying the following.
sanitize: {
cfi: false,
}
In this case, only non-CFI variant will be created for the vendor
snapshot module.
Bug: 65377115
Test: m dist vendor-snapshot && install && build against snapshot
Change-Id: Idbf3e3205d581800d6093c8d6cf6152374129ba4
2020-07-29 19:32:10 +08:00
|
|
|
checkSnapshot(t, ctx, snapshotSingleton, "libvendor", "libvendor.cfi.a", staticDir, staticCfiVariant)
|
2020-06-01 20:53:49 +08:00
|
|
|
checkSnapshot(t, ctx, snapshotSingleton, "libvendor_available", "libvendor_available.a", staticDir, staticVariant)
|
Add cfi static libraries to vendor snapshot
CFI modules can't link against non-CFI static libraries, and vice versa.
So without capturing both CFI and non-CFI static libraries, vendor
modules won't be able to use CFI, which will be a critical security
hole.
This captures both CFI and non-CFI variants of all static libraries for
vendor snapshot, except for those whose cfi are explicitly disabled.
For example, suppose that "libfoo" is defined as follows.
cc_library_static {
name: "libfoo",
vendor_available: true,
}
As it doesn't have cfi disabled, two libraries "libfoo.a" and
"libfoo.cfi.a" will be captured. When installed, vendor snapshot module
for "libfoo" will look like:
vendor_snapshot_static {
name: "libfoo",
src: "libfoo.a",
cfi: {
src: "libfoo.cfi.a",
},
}
The build system will recognize the "cfi" property, and will create both
CFI and non-CFI variant, allowing any modules to link against "libfoo"
safely, no matter whether CFI is enabled or not.
Two clarification:
1) The reason why we don't create separate modules is that DepsMutator
runs before sanitize mutators. CFI and non-CFI variant of a library
should exist in a single module.
2) We can't capture CFI variant if the source module explicitly disables
cfi variant by specifying the following.
sanitize: {
cfi: false,
}
In this case, only non-CFI variant will be created for the vendor
snapshot module.
Bug: 65377115
Test: m dist vendor-snapshot && install && build against snapshot
Change-Id: Idbf3e3205d581800d6093c8d6cf6152374129ba4
2020-07-29 19:32:10 +08:00
|
|
|
checkSnapshot(t, ctx, snapshotSingleton, "libvendor_available", "libvendor_available.cfi.a", staticDir, staticCfiVariant)
|
2020-06-01 20:53:49 +08:00
|
|
|
jsonFiles = append(jsonFiles,
|
|
|
|
filepath.Join(staticDir, "libb.a.json"),
|
|
|
|
filepath.Join(staticDir, "libvndk.a.json"),
|
Add cfi static libraries to vendor snapshot
CFI modules can't link against non-CFI static libraries, and vice versa.
So without capturing both CFI and non-CFI static libraries, vendor
modules won't be able to use CFI, which will be a critical security
hole.
This captures both CFI and non-CFI variants of all static libraries for
vendor snapshot, except for those whose cfi are explicitly disabled.
For example, suppose that "libfoo" is defined as follows.
cc_library_static {
name: "libfoo",
vendor_available: true,
}
As it doesn't have cfi disabled, two libraries "libfoo.a" and
"libfoo.cfi.a" will be captured. When installed, vendor snapshot module
for "libfoo" will look like:
vendor_snapshot_static {
name: "libfoo",
src: "libfoo.a",
cfi: {
src: "libfoo.cfi.a",
},
}
The build system will recognize the "cfi" property, and will create both
CFI and non-CFI variant, allowing any modules to link against "libfoo"
safely, no matter whether CFI is enabled or not.
Two clarification:
1) The reason why we don't create separate modules is that DepsMutator
runs before sanitize mutators. CFI and non-CFI variant of a library
should exist in a single module.
2) We can't capture CFI variant if the source module explicitly disables
cfi variant by specifying the following.
sanitize: {
cfi: false,
}
In this case, only non-CFI variant will be created for the vendor
snapshot module.
Bug: 65377115
Test: m dist vendor-snapshot && install && build against snapshot
Change-Id: Idbf3e3205d581800d6093c8d6cf6152374129ba4
2020-07-29 19:32:10 +08:00
|
|
|
filepath.Join(staticDir, "libvndk.cfi.a.json"),
|
2020-06-01 20:53:49 +08:00
|
|
|
filepath.Join(staticDir, "libvendor.a.json"),
|
Add cfi static libraries to vendor snapshot
CFI modules can't link against non-CFI static libraries, and vice versa.
So without capturing both CFI and non-CFI static libraries, vendor
modules won't be able to use CFI, which will be a critical security
hole.
This captures both CFI and non-CFI variants of all static libraries for
vendor snapshot, except for those whose cfi are explicitly disabled.
For example, suppose that "libfoo" is defined as follows.
cc_library_static {
name: "libfoo",
vendor_available: true,
}
As it doesn't have cfi disabled, two libraries "libfoo.a" and
"libfoo.cfi.a" will be captured. When installed, vendor snapshot module
for "libfoo" will look like:
vendor_snapshot_static {
name: "libfoo",
src: "libfoo.a",
cfi: {
src: "libfoo.cfi.a",
},
}
The build system will recognize the "cfi" property, and will create both
CFI and non-CFI variant, allowing any modules to link against "libfoo"
safely, no matter whether CFI is enabled or not.
Two clarification:
1) The reason why we don't create separate modules is that DepsMutator
runs before sanitize mutators. CFI and non-CFI variant of a library
should exist in a single module.
2) We can't capture CFI variant if the source module explicitly disables
cfi variant by specifying the following.
sanitize: {
cfi: false,
}
In this case, only non-CFI variant will be created for the vendor
snapshot module.
Bug: 65377115
Test: m dist vendor-snapshot && install && build against snapshot
Change-Id: Idbf3e3205d581800d6093c8d6cf6152374129ba4
2020-07-29 19:32:10 +08:00
|
|
|
filepath.Join(staticDir, "libvendor.cfi.a.json"),
|
|
|
|
filepath.Join(staticDir, "libvendor_available.a.json"),
|
|
|
|
filepath.Join(staticDir, "libvendor_available.cfi.a.json"))
|
2020-06-01 20:53:49 +08:00
|
|
|
|
|
|
|
// For binary executables, all vendor:true and vendor_available modules are captured.
|
2019-11-15 08:59:12 +08:00
|
|
|
if archType == "arm64" {
|
|
|
|
binaryVariant := fmt.Sprintf("android_vendor.VER_%s_%s", archType, archVariant)
|
|
|
|
binaryDir := filepath.Join(snapshotVariantPath, archDir, "binary")
|
2020-06-01 20:53:49 +08:00
|
|
|
checkSnapshot(t, ctx, snapshotSingleton, "vendor_bin", "vendor_bin", binaryDir, binaryVariant)
|
|
|
|
checkSnapshot(t, ctx, snapshotSingleton, "vendor_available_bin", "vendor_available_bin", binaryDir, binaryVariant)
|
|
|
|
jsonFiles = append(jsonFiles,
|
|
|
|
filepath.Join(binaryDir, "vendor_bin.json"),
|
|
|
|
filepath.Join(binaryDir, "vendor_available_bin.json"))
|
|
|
|
}
|
|
|
|
|
|
|
|
// For header libraries, all vendor:true and vendor_available modules are captured.
|
|
|
|
headerDir := filepath.Join(snapshotVariantPath, archDir, "header")
|
|
|
|
jsonFiles = append(jsonFiles, filepath.Join(headerDir, "libvendor_headers.json"))
|
2020-06-01 22:23:05 +08:00
|
|
|
|
|
|
|
// For object modules, all vendor:true and vendor_available modules are captured.
|
|
|
|
objectVariant := fmt.Sprintf("android_vendor.VER_%s_%s", archType, archVariant)
|
|
|
|
objectDir := filepath.Join(snapshotVariantPath, archDir, "object")
|
|
|
|
checkSnapshot(t, ctx, snapshotSingleton, "obj", "obj.o", objectDir, objectVariant)
|
|
|
|
jsonFiles = append(jsonFiles, filepath.Join(objectDir, "obj.o.json"))
|
2020-06-01 20:53:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, jsonFile := range jsonFiles {
|
|
|
|
// verify all json files exist
|
|
|
|
if snapshotSingleton.MaybeOutput(jsonFile).Rule == nil {
|
|
|
|
t.Errorf("%q expected but not found", jsonFile)
|
2019-11-15 08:59:12 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-07 18:53:31 +08:00
|
|
|
func TestVendorSnapshotUse(t *testing.T) {
|
|
|
|
frameworkBp := `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
compile_multilib: "64",
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvendor",
|
|
|
|
vendor: true,
|
|
|
|
nocrt: true,
|
|
|
|
no_libcrt: true,
|
|
|
|
stl: "none",
|
|
|
|
system_shared_libs: [],
|
|
|
|
compile_multilib: "64",
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_binary {
|
|
|
|
name: "bin",
|
|
|
|
vendor: true,
|
|
|
|
nocrt: true,
|
|
|
|
no_libcrt: true,
|
|
|
|
stl: "none",
|
|
|
|
system_shared_libs: [],
|
|
|
|
compile_multilib: "64",
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
vndkBp := `
|
|
|
|
vndk_prebuilt_shared {
|
|
|
|
name: "libvndk",
|
|
|
|
version: "BOARD",
|
|
|
|
target_arch: "arm64",
|
|
|
|
vendor_available: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
arch: {
|
|
|
|
arm64: {
|
|
|
|
srcs: ["libvndk.so"],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
vendorProprietaryBp := `
|
|
|
|
cc_library {
|
|
|
|
name: "libvendor_without_snapshot",
|
|
|
|
vendor: true,
|
|
|
|
nocrt: true,
|
|
|
|
no_libcrt: true,
|
|
|
|
stl: "none",
|
|
|
|
system_shared_libs: [],
|
|
|
|
compile_multilib: "64",
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library_shared {
|
|
|
|
name: "libclient",
|
|
|
|
vendor: true,
|
|
|
|
nocrt: true,
|
|
|
|
no_libcrt: true,
|
|
|
|
stl: "none",
|
|
|
|
system_shared_libs: [],
|
|
|
|
shared_libs: ["libvndk"],
|
|
|
|
static_libs: ["libvendor", "libvendor_without_snapshot"],
|
|
|
|
compile_multilib: "64",
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_binary {
|
|
|
|
name: "bin_without_snapshot",
|
|
|
|
vendor: true,
|
|
|
|
nocrt: true,
|
|
|
|
no_libcrt: true,
|
|
|
|
stl: "none",
|
|
|
|
system_shared_libs: [],
|
|
|
|
static_libs: ["libvndk"],
|
|
|
|
compile_multilib: "64",
|
|
|
|
}
|
|
|
|
|
|
|
|
vendor_snapshot_static {
|
|
|
|
name: "libvndk",
|
|
|
|
version: "BOARD",
|
|
|
|
target_arch: "arm64",
|
|
|
|
vendor: true,
|
|
|
|
arch: {
|
|
|
|
arm64: {
|
|
|
|
src: "libvndk.a",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
vendor_snapshot_shared {
|
|
|
|
name: "libvendor",
|
|
|
|
version: "BOARD",
|
|
|
|
target_arch: "arm64",
|
|
|
|
vendor: true,
|
|
|
|
arch: {
|
|
|
|
arm64: {
|
|
|
|
src: "libvendor.so",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
vendor_snapshot_static {
|
|
|
|
name: "libvendor",
|
|
|
|
version: "BOARD",
|
|
|
|
target_arch: "arm64",
|
|
|
|
vendor: true,
|
|
|
|
arch: {
|
|
|
|
arm64: {
|
|
|
|
src: "libvendor.a",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
vendor_snapshot_binary {
|
|
|
|
name: "bin",
|
|
|
|
version: "BOARD",
|
|
|
|
target_arch: "arm64",
|
|
|
|
vendor: true,
|
|
|
|
arch: {
|
|
|
|
arm64: {
|
|
|
|
src: "bin",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
`
|
|
|
|
depsBp := GatherRequiredDepsForTest(android.Android)
|
|
|
|
|
|
|
|
mockFS := map[string][]byte{
|
|
|
|
"deps/Android.bp": []byte(depsBp),
|
|
|
|
"framework/Android.bp": []byte(frameworkBp),
|
|
|
|
"vendor/Android.bp": []byte(vendorProprietaryBp),
|
|
|
|
"vendor/libvndk.a": nil,
|
|
|
|
"vendor/libvendor.a": nil,
|
|
|
|
"vendor/libvendor.so": nil,
|
|
|
|
"vendor/bin": nil,
|
|
|
|
"vndk/Android.bp": []byte(vndkBp),
|
|
|
|
"vndk/libvndk.so": nil,
|
|
|
|
}
|
|
|
|
|
|
|
|
config := TestConfig(buildDir, android.Android, nil, "", mockFS)
|
|
|
|
config.TestProductVariables.DeviceVndkVersion = StringPtr("BOARD")
|
|
|
|
config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
|
|
|
|
ctx := CreateTestContext()
|
|
|
|
ctx.Register(config)
|
|
|
|
|
|
|
|
_, errs := ctx.ParseFileList(".", []string{"deps/Android.bp", "framework/Android.bp", "vendor/Android.bp", "vndk/Android.bp"})
|
|
|
|
android.FailIfErrored(t, errs)
|
|
|
|
_, errs = ctx.PrepareBuildActions(config)
|
|
|
|
android.FailIfErrored(t, errs)
|
|
|
|
|
|
|
|
sharedVariant := "android_vendor.BOARD_arm64_armv8-a_shared"
|
|
|
|
staticVariant := "android_vendor.BOARD_arm64_armv8-a_static"
|
|
|
|
binaryVariant := "android_vendor.BOARD_arm64_armv8-a"
|
|
|
|
|
|
|
|
// libclient uses libvndk.vndk.BOARD.arm64, libvendor.vendor_static.BOARD.arm64, libvendor_without_snapshot
|
|
|
|
libclientLdRule := ctx.ModuleForTests("libclient", sharedVariant).Rule("ld")
|
|
|
|
libclientFlags := libclientLdRule.Args["libFlags"]
|
|
|
|
|
|
|
|
for _, input := range [][]string{
|
|
|
|
[]string{sharedVariant, "libvndk.vndk.BOARD.arm64"},
|
|
|
|
[]string{staticVariant, "libvendor.vendor_static.BOARD.arm64"},
|
|
|
|
[]string{staticVariant, "libvendor_without_snapshot"},
|
|
|
|
} {
|
|
|
|
outputPaths := getOutputPaths(ctx, input[0] /* variant */, []string{input[1]} /* module name */)
|
|
|
|
if !strings.Contains(libclientFlags, outputPaths[0].String()) {
|
|
|
|
t.Errorf("libflags for libclient must contain %#v, but was %#v", outputPaths[0], libclientFlags)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// bin_without_snapshot uses libvndk.vendor_static.BOARD.arm64
|
|
|
|
binWithoutSnapshotLdRule := ctx.ModuleForTests("bin_without_snapshot", binaryVariant).Rule("ld")
|
|
|
|
binWithoutSnapshotFlags := binWithoutSnapshotLdRule.Args["libFlags"]
|
|
|
|
libVndkStaticOutputPaths := getOutputPaths(ctx, staticVariant, []string{"libvndk.vendor_static.BOARD.arm64"})
|
|
|
|
if !strings.Contains(binWithoutSnapshotFlags, libVndkStaticOutputPaths[0].String()) {
|
|
|
|
t.Errorf("libflags for bin_without_snapshot must contain %#v, but was %#v",
|
|
|
|
libVndkStaticOutputPaths[0], binWithoutSnapshotFlags)
|
|
|
|
}
|
|
|
|
|
|
|
|
// libvendor.so is installed by libvendor.vendor_shared.BOARD.arm64
|
|
|
|
ctx.ModuleForTests("libvendor.vendor_shared.BOARD.arm64", sharedVariant).Output("libvendor.so")
|
|
|
|
|
|
|
|
// libvendor_without_snapshot.so is installed by libvendor_without_snapshot
|
|
|
|
ctx.ModuleForTests("libvendor_without_snapshot", sharedVariant).Output("libvendor_without_snapshot.so")
|
|
|
|
|
|
|
|
// bin is installed by bin.vendor_binary.BOARD.arm64
|
|
|
|
ctx.ModuleForTests("bin.vendor_binary.BOARD.arm64", binaryVariant).Output("bin")
|
|
|
|
|
|
|
|
// bin_without_snapshot is installed by bin_without_snapshot
|
|
|
|
ctx.ModuleForTests("bin_without_snapshot", binaryVariant).Output("bin_without_snapshot")
|
|
|
|
|
|
|
|
// libvendor and bin don't have vendor.BOARD variant
|
|
|
|
libvendorVariants := ctx.ModuleVariantsForTests("libvendor")
|
|
|
|
if inList(sharedVariant, libvendorVariants) {
|
|
|
|
t.Errorf("libvendor must not have variant %#v, but it does", sharedVariant)
|
|
|
|
}
|
|
|
|
|
|
|
|
binVariants := ctx.ModuleVariantsForTests("bin")
|
|
|
|
if inList(binaryVariant, binVariants) {
|
|
|
|
t.Errorf("bin must not have variant %#v, but it does", sharedVariant)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Add cfi static libraries to vendor snapshot
CFI modules can't link against non-CFI static libraries, and vice versa.
So without capturing both CFI and non-CFI static libraries, vendor
modules won't be able to use CFI, which will be a critical security
hole.
This captures both CFI and non-CFI variants of all static libraries for
vendor snapshot, except for those whose cfi are explicitly disabled.
For example, suppose that "libfoo" is defined as follows.
cc_library_static {
name: "libfoo",
vendor_available: true,
}
As it doesn't have cfi disabled, two libraries "libfoo.a" and
"libfoo.cfi.a" will be captured. When installed, vendor snapshot module
for "libfoo" will look like:
vendor_snapshot_static {
name: "libfoo",
src: "libfoo.a",
cfi: {
src: "libfoo.cfi.a",
},
}
The build system will recognize the "cfi" property, and will create both
CFI and non-CFI variant, allowing any modules to link against "libfoo"
safely, no matter whether CFI is enabled or not.
Two clarification:
1) The reason why we don't create separate modules is that DepsMutator
runs before sanitize mutators. CFI and non-CFI variant of a library
should exist in a single module.
2) We can't capture CFI variant if the source module explicitly disables
cfi variant by specifying the following.
sanitize: {
cfi: false,
}
In this case, only non-CFI variant will be created for the vendor
snapshot module.
Bug: 65377115
Test: m dist vendor-snapshot && install && build against snapshot
Change-Id: Idbf3e3205d581800d6093c8d6cf6152374129ba4
2020-07-29 19:32:10 +08:00
|
|
|
func TestVendorSnapshotSanitizer(t *testing.T) {
|
|
|
|
bp := `
|
|
|
|
vendor_snapshot_static {
|
|
|
|
name: "libsnapshot",
|
|
|
|
vendor: true,
|
|
|
|
target_arch: "arm64",
|
|
|
|
version: "BOARD",
|
|
|
|
arch: {
|
|
|
|
arm64: {
|
|
|
|
src: "libsnapshot.a",
|
|
|
|
cfi: {
|
|
|
|
src: "libsnapshot.cfi.a",
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
`
|
|
|
|
config := TestConfig(buildDir, android.Android, nil, bp, nil)
|
|
|
|
config.TestProductVariables.DeviceVndkVersion = StringPtr("BOARD")
|
|
|
|
config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
|
|
|
|
ctx := testCcWithConfig(t, config)
|
|
|
|
|
|
|
|
// Check non-cfi and cfi variant.
|
|
|
|
staticVariant := "android_vendor.BOARD_arm64_armv8-a_static"
|
|
|
|
staticCfiVariant := "android_vendor.BOARD_arm64_armv8-a_static_cfi"
|
|
|
|
|
|
|
|
staticModule := ctx.ModuleForTests("libsnapshot.vendor_static.BOARD.arm64", staticVariant).Module().(*Module)
|
|
|
|
assertString(t, staticModule.outputFile.Path().Base(), "libsnapshot.a")
|
|
|
|
|
|
|
|
staticCfiModule := ctx.ModuleForTests("libsnapshot.vendor_static.BOARD.arm64", staticCfiVariant).Module().(*Module)
|
|
|
|
assertString(t, staticCfiModule.outputFile.Path().Base(), "libsnapshot.cfi.a")
|
|
|
|
}
|
|
|
|
|
2020-09-01 07:07:58 +08:00
|
|
|
func assertExcludeFromVendorSnapshotIs(t *testing.T, c *Module, expected bool) {
|
|
|
|
t.Helper()
|
|
|
|
if c.ExcludeFromVendorSnapshot() != expected {
|
|
|
|
t.Errorf("expected %q ExcludeFromVendorSnapshot to be %t", c.String(), expected)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestVendorSnapshotExclude(t *testing.T) {
|
|
|
|
|
|
|
|
// This test verifies that the exclude_from_vendor_snapshot property
|
|
|
|
// makes its way from the Android.bp source file into the module data
|
|
|
|
// structure. It also verifies that modules are correctly included or
|
|
|
|
// excluded in the vendor snapshot based on their path (framework or
|
|
|
|
// vendor) and the exclude_from_vendor_snapshot property.
|
|
|
|
|
|
|
|
frameworkBp := `
|
|
|
|
cc_library_shared {
|
|
|
|
name: "libinclude",
|
|
|
|
srcs: ["src/include.cpp"],
|
|
|
|
vendor_available: true,
|
|
|
|
}
|
|
|
|
cc_library_shared {
|
|
|
|
name: "libexclude",
|
|
|
|
srcs: ["src/exclude.cpp"],
|
|
|
|
vendor: true,
|
|
|
|
exclude_from_vendor_snapshot: true,
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
vendorProprietaryBp := `
|
|
|
|
cc_library_shared {
|
|
|
|
name: "libvendor",
|
|
|
|
srcs: ["vendor.cpp"],
|
|
|
|
vendor: true,
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
depsBp := GatherRequiredDepsForTest(android.Android)
|
|
|
|
|
|
|
|
mockFS := map[string][]byte{
|
|
|
|
"deps/Android.bp": []byte(depsBp),
|
|
|
|
"framework/Android.bp": []byte(frameworkBp),
|
|
|
|
"framework/include.cpp": nil,
|
|
|
|
"framework/exclude.cpp": nil,
|
|
|
|
"device/Android.bp": []byte(vendorProprietaryBp),
|
|
|
|
"device/vendor.cpp": nil,
|
|
|
|
}
|
|
|
|
|
|
|
|
config := TestConfig(buildDir, android.Android, nil, "", mockFS)
|
|
|
|
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
|
|
|
|
config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
|
|
|
|
ctx := CreateTestContext()
|
|
|
|
ctx.Register(config)
|
|
|
|
|
|
|
|
_, errs := ctx.ParseFileList(".", []string{"deps/Android.bp", "framework/Android.bp", "device/Android.bp"})
|
|
|
|
android.FailIfErrored(t, errs)
|
|
|
|
_, errs = ctx.PrepareBuildActions(config)
|
|
|
|
android.FailIfErrored(t, errs)
|
|
|
|
|
|
|
|
// Test an include and exclude framework module.
|
|
|
|
assertExcludeFromVendorSnapshotIs(t, ctx.ModuleForTests("libinclude", coreVariant).Module().(*Module), false)
|
|
|
|
assertExcludeFromVendorSnapshotIs(t, ctx.ModuleForTests("libinclude", vendorVariant).Module().(*Module), false)
|
|
|
|
assertExcludeFromVendorSnapshotIs(t, ctx.ModuleForTests("libexclude", vendorVariant).Module().(*Module), true)
|
|
|
|
|
|
|
|
// A vendor module is excluded, but by its path, not the
|
|
|
|
// exclude_from_vendor_snapshot property.
|
|
|
|
assertExcludeFromVendorSnapshotIs(t, ctx.ModuleForTests("libvendor", vendorVariant).Module().(*Module), false)
|
|
|
|
|
|
|
|
// Verify the content of the vendor snapshot.
|
|
|
|
|
|
|
|
snapshotDir := "vendor-snapshot"
|
|
|
|
snapshotVariantPath := filepath.Join(buildDir, snapshotDir, "arm64")
|
|
|
|
snapshotSingleton := ctx.SingletonForTests("vendor-snapshot")
|
|
|
|
|
|
|
|
var includeJsonFiles []string
|
|
|
|
var excludeJsonFiles []string
|
|
|
|
|
|
|
|
for _, arch := range [][]string{
|
|
|
|
[]string{"arm64", "armv8-a"},
|
|
|
|
[]string{"arm", "armv7-a-neon"},
|
|
|
|
} {
|
|
|
|
archType := arch[0]
|
|
|
|
archVariant := arch[1]
|
|
|
|
archDir := fmt.Sprintf("arch-%s-%s", archType, archVariant)
|
|
|
|
|
|
|
|
sharedVariant := fmt.Sprintf("android_vendor.VER_%s_%s_shared", archType, archVariant)
|
|
|
|
sharedDir := filepath.Join(snapshotVariantPath, archDir, "shared")
|
|
|
|
|
|
|
|
// Included modules
|
|
|
|
checkSnapshot(t, ctx, snapshotSingleton, "libinclude", "libinclude.so", sharedDir, sharedVariant)
|
|
|
|
includeJsonFiles = append(includeJsonFiles, filepath.Join(sharedDir, "libinclude.so.json"))
|
|
|
|
|
|
|
|
// Excluded modules
|
|
|
|
checkSnapshotExclude(t, ctx, snapshotSingleton, "libexclude", "libexclude.so", sharedDir, sharedVariant)
|
|
|
|
excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libexclude.so.json"))
|
|
|
|
checkSnapshotExclude(t, ctx, snapshotSingleton, "libvendor", "libvendor.so", sharedDir, sharedVariant)
|
|
|
|
excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libvendor.so.json"))
|
|
|
|
}
|
|
|
|
|
|
|
|
// Verify that each json file for an included module has a rule.
|
|
|
|
for _, jsonFile := range includeJsonFiles {
|
|
|
|
if snapshotSingleton.MaybeOutput(jsonFile).Rule == nil {
|
|
|
|
t.Errorf("include json file %q not found", jsonFile)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Verify that each json file for an excluded module has no rule.
|
|
|
|
for _, jsonFile := range excludeJsonFiles {
|
|
|
|
if snapshotSingleton.MaybeOutput(jsonFile).Rule != nil {
|
|
|
|
t.Errorf("exclude json file %q found", jsonFile)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestVendorSnapshotExcludeInVendorProprietaryPathErrors(t *testing.T) {
|
|
|
|
|
|
|
|
// This test verifies that using the exclude_from_vendor_snapshot
|
|
|
|
// property on a module in a vendor proprietary path generates an
|
|
|
|
// error. These modules are already excluded, so we prohibit using the
|
|
|
|
// property in this way, which could add to confusion.
|
|
|
|
|
|
|
|
vendorProprietaryBp := `
|
|
|
|
cc_library_shared {
|
|
|
|
name: "libvendor",
|
|
|
|
srcs: ["vendor.cpp"],
|
|
|
|
vendor: true,
|
|
|
|
exclude_from_vendor_snapshot: true,
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
depsBp := GatherRequiredDepsForTest(android.Android)
|
|
|
|
|
|
|
|
mockFS := map[string][]byte{
|
|
|
|
"deps/Android.bp": []byte(depsBp),
|
|
|
|
"device/Android.bp": []byte(vendorProprietaryBp),
|
|
|
|
"device/vendor.cpp": nil,
|
|
|
|
}
|
|
|
|
|
|
|
|
config := TestConfig(buildDir, android.Android, nil, "", mockFS)
|
|
|
|
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
|
|
|
|
config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
|
|
|
|
ctx := CreateTestContext()
|
|
|
|
ctx.Register(config)
|
|
|
|
|
|
|
|
_, errs := ctx.ParseFileList(".", []string{"deps/Android.bp", "device/Android.bp"})
|
|
|
|
android.FailIfErrored(t, errs)
|
|
|
|
|
|
|
|
_, errs = ctx.PrepareBuildActions(config)
|
|
|
|
android.CheckErrorsAgainstExpectations(t, errs, []string{
|
|
|
|
`module "libvendor\{.+,image:vendor.+,arch:arm64_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`,
|
|
|
|
`module "libvendor\{.+,image:vendor.+,arch:arm_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestVendorSnapshotExcludeWithVendorAvailable(t *testing.T) {
|
|
|
|
|
|
|
|
// This test verifies that using the exclude_from_vendor_snapshot
|
|
|
|
// property on a module that is vendor available generates an error. A
|
|
|
|
// vendor available module must be captured in the vendor snapshot and
|
|
|
|
// must not built from source when building the vendor image against
|
|
|
|
// the vendor snapshot.
|
|
|
|
|
|
|
|
frameworkBp := `
|
|
|
|
cc_library_shared {
|
|
|
|
name: "libinclude",
|
|
|
|
srcs: ["src/include.cpp"],
|
|
|
|
vendor_available: true,
|
|
|
|
exclude_from_vendor_snapshot: true,
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
depsBp := GatherRequiredDepsForTest(android.Android)
|
|
|
|
|
|
|
|
mockFS := map[string][]byte{
|
|
|
|
"deps/Android.bp": []byte(depsBp),
|
|
|
|
"framework/Android.bp": []byte(frameworkBp),
|
|
|
|
"framework/include.cpp": nil,
|
|
|
|
}
|
|
|
|
|
|
|
|
config := TestConfig(buildDir, android.Android, nil, "", mockFS)
|
|
|
|
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
|
|
|
|
config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
|
|
|
|
ctx := CreateTestContext()
|
|
|
|
ctx.Register(config)
|
|
|
|
|
|
|
|
_, errs := ctx.ParseFileList(".", []string{"deps/Android.bp", "framework/Android.bp"})
|
|
|
|
android.FailIfErrored(t, errs)
|
|
|
|
|
|
|
|
_, errs = ctx.PrepareBuildActions(config)
|
|
|
|
android.CheckErrorsAgainstExpectations(t, errs, []string{
|
|
|
|
`module "libinclude\{.+,image:,arch:arm64_.+\}" may not use both "vendor_available: true" and "exclude_from_vendor_snapshot: true"`,
|
|
|
|
`module "libinclude\{.+,image:,arch:arm_.+\}" may not use both "vendor_available: true" and "exclude_from_vendor_snapshot: true"`,
|
|
|
|
`module "libinclude\{.+,image:vendor.+,arch:arm64_.+\}" may not use both "vendor_available: true" and "exclude_from_vendor_snapshot: true"`,
|
|
|
|
`module "libinclude\{.+,image:vendor.+,arch:arm_.+\}" may not use both "vendor_available: true" and "exclude_from_vendor_snapshot: true"`,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-01-18 14:20:43 +08:00
|
|
|
func TestDoubleLoadableDepError(t *testing.T) {
|
|
|
|
// 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"],
|
|
|
|
}
|
|
|
|
|
|
|
|
llndk_library {
|
|
|
|
name: "libllndk",
|
|
|
|
symbol_file: "",
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libnondoubleloadable",
|
|
|
|
vendor_available: true,
|
|
|
|
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 15:53:50 +08:00
|
|
|
no_libcrt: true,
|
2019-01-18 14:20:43 +08:00
|
|
|
shared_libs: ["libnondoubleloadable"],
|
|
|
|
}
|
|
|
|
|
|
|
|
llndk_library {
|
|
|
|
name: "libllndk",
|
|
|
|
symbol_file: "",
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libnondoubleloadable",
|
|
|
|
vendor_available: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
// Check whether an error is emitted when a double_loadable lib 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: "libdoubleloadable",
|
|
|
|
vendor_available: true,
|
|
|
|
double_loadable: true,
|
|
|
|
shared_libs: ["libnondoubleloadable"],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libnondoubleloadable",
|
|
|
|
vendor_available: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
// Check whether an error is emitted when a double_loadable lib 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: "libdoubleloadable",
|
|
|
|
vendor_available: true,
|
|
|
|
double_loadable: true,
|
|
|
|
shared_libs: ["libnondoubleloadable"],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libnondoubleloadable",
|
|
|
|
vendor_available: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
// Check whether an error is emitted when a double_loadable VNDK depends on a non-double_loadable VNDK private lib.
|
|
|
|
testCcError(t, "module \".*\" variant \".*\": link.* \".*\" which is not LL-NDK, VNDK-SP, .*double_loadable", `
|
|
|
|
cc_library {
|
|
|
|
name: "libdoubleloadable",
|
|
|
|
vendor_available: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
double_loadable: true,
|
|
|
|
shared_libs: ["libnondoubleloadable"],
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libnondoubleloadable",
|
|
|
|
vendor_available: false,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
// Check whether an error is emitted when a LLNDK depends on a non-double_loadable indirectly.
|
|
|
|
testCcError(t, "module \".*\" variant \".*\": link.* \".*\" which is not LL-NDK, VNDK-SP, .*double_loadable", `
|
|
|
|
cc_library {
|
|
|
|
name: "libllndk",
|
|
|
|
shared_libs: ["libcoreonly"],
|
|
|
|
}
|
|
|
|
|
|
|
|
llndk_library {
|
|
|
|
name: "libllndk",
|
|
|
|
symbol_file: "",
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libcoreonly",
|
|
|
|
shared_libs: ["libvendoravailable"],
|
|
|
|
}
|
|
|
|
|
|
|
|
// indirect dependency of LLNDK
|
|
|
|
cc_library {
|
|
|
|
name: "libvendoravailable",
|
|
|
|
vendor_available: true,
|
|
|
|
}
|
|
|
|
`)
|
2018-03-29 14:08:15 +08: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 18:04:35 +08:00
|
|
|
func TestVndkExt(t *testing.T) {
|
|
|
|
// This test checks the VNDK-Ext properties.
|
2020-02-28 14:07:59 +08: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 18:04:35 +08:00
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
2019-10-22 18:53:47 +08:00
|
|
|
cc_library {
|
|
|
|
name: "libvndk2",
|
|
|
|
vendor_available: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
target: {
|
|
|
|
vendor: {
|
|
|
|
suffix: "-suffix",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
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 18:04:35 +08:00
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_ext",
|
|
|
|
vendor: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
extends: "libvndk",
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
2019-10-22 18:53:47 +08: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 18:04:35 +08:00
|
|
|
|
2020-02-28 14:07:59 +08:00
|
|
|
cc_library {
|
|
|
|
name: "libvndk_ext_product",
|
|
|
|
product_specific: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
extends: "libvndk",
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
2019-10-22 18:53:47 +08:00
|
|
|
|
2020-02-28 14:07:59 +08:00
|
|
|
cc_library {
|
|
|
|
name: "libvndk2_ext_product",
|
|
|
|
product_specific: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
extends: "libvndk2",
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`
|
|
|
|
config := TestConfig(buildDir, android.Android, nil, bp, nil)
|
|
|
|
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
|
|
|
|
config.TestProductVariables.ProductVndkVersion = StringPtr("current")
|
|
|
|
config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
|
|
|
|
|
|
|
|
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 18:04:35 +08:00
|
|
|
}
|
|
|
|
|
2018-03-29 14:08:15 +08:00
|
|
|
func TestVndkExtWithoutBoardVndkVersion(t *testing.T) {
|
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 18:04:35 +08:00
|
|
|
// This test checks the VNDK-Ext properties when BOARD_VNDK_VERSION is not set.
|
|
|
|
ctx := testCcNoVndk(t, `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_ext",
|
|
|
|
vendor: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
extends: "libvndk",
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
// Ensures that the core variant of "libvndk_ext" can be found.
|
|
|
|
mod := ctx.ModuleForTests("libvndk_ext", coreVariant).Module().(*Module)
|
|
|
|
if extends := mod.getVndkExtendsModuleName(); extends != "libvndk" {
|
|
|
|
t.Errorf("\"libvndk_ext\" must extend from \"libvndk\" but get %q", extends)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-28 14:07:59 +08:00
|
|
|
func TestVndkExtWithoutProductVndkVersion(t *testing.T) {
|
|
|
|
// This test checks the VNDK-Ext properties when PRODUCT_PRODUCT_VNDK_VERSION is not set.
|
|
|
|
ctx := testCc(t, `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_ext_product",
|
|
|
|
product_specific: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
extends: "libvndk",
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
// Ensures that the core variant of "libvndk_ext_product" can be found.
|
|
|
|
mod := ctx.ModuleForTests("libvndk_ext_product", coreVariant).Module().(*Module)
|
|
|
|
if extends := mod.getVndkExtendsModuleName(); extends != "libvndk" {
|
|
|
|
t.Errorf("\"libvndk_ext_product\" must extend from \"libvndk\" but get %q", 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 18:04:35 +08:00
|
|
|
func TestVndkExtError(t *testing.T) {
|
|
|
|
// This test ensures an error is emitted in ill-formed vndk-ext definition.
|
2020-02-28 14:07:59 +08: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 18:04:35 +08:00
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
|
|
|
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,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_ext",
|
|
|
|
vendor: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
2020-02-28 14:07:59 +08:00
|
|
|
|
|
|
|
testCcErrorProductVndk(t, "must set `extends: \"\\.\\.\\.\"` to vndk extension", `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
|
|
|
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,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_ext_product",
|
|
|
|
product_specific: true,
|
|
|
|
vendor_available: 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 18:04:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestVndkExtInconsistentSupportSystemProcessError(t *testing.T) {
|
|
|
|
// 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,
|
|
|
|
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,
|
|
|
|
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) {
|
2018-03-29 14:08:15 +08:00
|
|
|
// This test ensures an error is emitted when a VNDK-Ext library extends a VNDK 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 18:04:35 +08:00
|
|
|
// with `vendor_available: false`.
|
|
|
|
testCcError(t, "`extends` refers module \".*\" which does not have `vendor_available: true`", `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: false,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_ext",
|
|
|
|
vendor: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
extends: "libvndk",
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
2020-02-28 14:07:59 +08:00
|
|
|
|
|
|
|
testCcErrorProductVndk(t, "`extends` refers module \".*\" which does not have `vendor_available: true`", `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: false,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
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 18:04:35 +08:00
|
|
|
}
|
|
|
|
|
2018-03-29 14:08:15 +08:00
|
|
|
func TestVendorModuleUseVndkExt(t *testing.T) {
|
|
|
|
// 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 18:04:35 +08:00
|
|
|
testCc(t, `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
|
|
|
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,
|
|
|
|
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 14:08:15 +08:00
|
|
|
func TestVndkExtUseVendorLib(t *testing.T) {
|
|
|
|
// 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 18:04:35 +08:00
|
|
|
testCc(t, `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
|
|
|
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 14:08:15 +08: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,
|
|
|
|
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 18:04:35 +08:00
|
|
|
}
|
|
|
|
|
2020-02-28 14:07:59 +08:00
|
|
|
func TestProductVndkExtDependency(t *testing.T) {
|
|
|
|
bp := `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
|
|
|
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,
|
|
|
|
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,
|
|
|
|
}
|
|
|
|
`
|
|
|
|
config := TestConfig(buildDir, android.Android, nil, bp, nil)
|
|
|
|
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
|
|
|
|
config.TestProductVariables.ProductVndkVersion = StringPtr("current")
|
|
|
|
config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
|
|
|
|
|
|
|
|
testCcWithConfig(t, config)
|
|
|
|
}
|
|
|
|
|
2018-03-29 14:08:15 +08:00
|
|
|
func TestVndkSpExtUseVndkError(t *testing.T) {
|
|
|
|
// 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 18:04:35 +08:00
|
|
|
// library.
|
|
|
|
testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", `
|
2018-03-29 14:08:15 +08:00
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
|
|
|
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 18:04:35 +08:00
|
|
|
cc_library {
|
|
|
|
name: "libvndk_sp",
|
|
|
|
vendor_available: true,
|
|
|
|
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 14:08:15 +08: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 18:04:35 +08:00
|
|
|
nocrt: true,
|
|
|
|
}
|
2018-03-29 14:08:15 +08: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 18:04:35 +08:00
|
|
|
|
2018-03-29 14:08:15 +08: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 18:04:35 +08:00
|
|
|
cc_library {
|
2018-03-29 14:08:15 +08:00
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
|
|
|
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,
|
|
|
|
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 18:04:35 +08:00
|
|
|
vendor: true,
|
2018-03-29 14:08:15 +08: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 18:04:35 +08:00
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
}
|
|
|
|
|
2018-03-29 14:08:15 +08:00
|
|
|
func TestVndkUseVndkExtError(t *testing.T) {
|
|
|
|
// 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 18:04:35 +08:00
|
|
|
testCcError(t, "dependency \".*\" of \".*\" missing variant", `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
|
|
|
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,
|
|
|
|
},
|
|
|
|
shared_libs: ["libvndk_ext"],
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
2018-11-07 00:12:13 +08: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 18:04:35 +08:00
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
|
|
|
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,
|
|
|
|
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,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
support_system_process: true,
|
|
|
|
},
|
|
|
|
shared_libs: ["libvndk_sp_ext"],
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
2018-11-07 00:12:13 +08: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 18:04:35 +08:00
|
|
|
cc_library {
|
|
|
|
name: "libvndk_sp",
|
|
|
|
vendor_available: true,
|
|
|
|
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 18:52:14 +08:00
|
|
|
func TestEnforceProductVndkVersion(t *testing.T) {
|
|
|
|
bp := `
|
|
|
|
cc_library {
|
|
|
|
name: "libllndk",
|
|
|
|
}
|
|
|
|
llndk_library {
|
|
|
|
name: "libllndk",
|
|
|
|
symbol_file: "",
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_sp",
|
|
|
|
vendor_available: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
support_system_process: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libva",
|
|
|
|
vendor_available: true,
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
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",
|
|
|
|
"libva",
|
|
|
|
"libproduct_va",
|
|
|
|
],
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libvendor",
|
|
|
|
vendor: true,
|
|
|
|
shared_libs: [
|
|
|
|
"libllndk",
|
|
|
|
"libvndk",
|
|
|
|
"libvndk_sp",
|
|
|
|
"libva",
|
|
|
|
"libproduct_va",
|
|
|
|
],
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
config := TestConfig(buildDir, android.Android, nil, bp, nil)
|
|
|
|
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
|
|
|
|
config.TestProductVariables.ProductVndkVersion = StringPtr("current")
|
|
|
|
config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
|
|
|
|
|
|
|
|
ctx := testCcWithConfig(t, config)
|
|
|
|
|
2020-02-28 14:07:59 +08:00
|
|
|
checkVndkModule(t, ctx, "libvndk", "vndk-VER", false, "", productVariant)
|
|
|
|
checkVndkModule(t, ctx, "libvndk_sp", "vndk-sp-VER", true, "", productVariant)
|
2019-11-18 18:52:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestEnforceProductVndkVersionErrors(t *testing.T) {
|
|
|
|
testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:product.VER", `
|
|
|
|
cc_library {
|
|
|
|
name: "libprod",
|
|
|
|
product_specific: true,
|
|
|
|
shared_libs: [
|
|
|
|
"libvendor",
|
|
|
|
],
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libvendor",
|
|
|
|
vendor: true,
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:product.VER", `
|
|
|
|
cc_library {
|
|
|
|
name: "libprod",
|
|
|
|
product_specific: true,
|
|
|
|
shared_libs: [
|
|
|
|
"libsystem",
|
|
|
|
],
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libsystem",
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
testCcErrorProductVndk(t, "Vendor module that is not VNDK should not link to \".*\" which is marked as `vendor_available: false`", `
|
|
|
|
cc_library {
|
|
|
|
name: "libprod",
|
|
|
|
product_specific: true,
|
|
|
|
shared_libs: [
|
|
|
|
"libvndk_private",
|
|
|
|
],
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk_private",
|
|
|
|
vendor_available: false,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:product.VER", `
|
|
|
|
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-16 03:01:54 +08:00
|
|
|
func TestMakeLinkType(t *testing.T) {
|
2019-12-14 12:41:13 +08:00
|
|
|
bp := `
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
vendor_available: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libvndksp",
|
|
|
|
vendor_available: true,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
support_system_process: true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libvndkprivate",
|
|
|
|
vendor_available: false,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
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,
|
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
arch: {
|
|
|
|
arm: {
|
|
|
|
srcs: ["liba.so"],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libllndk",
|
|
|
|
}
|
|
|
|
llndk_library {
|
|
|
|
name: "libllndk",
|
|
|
|
symbol_file: "",
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libllndkprivate",
|
|
|
|
}
|
|
|
|
llndk_library {
|
|
|
|
name: "libllndkprivate",
|
|
|
|
vendor_available: false,
|
|
|
|
symbol_file: "",
|
|
|
|
}`
|
|
|
|
|
|
|
|
config := TestConfig(buildDir, android.Android, nil, bp, nil)
|
2019-05-16 03:01:54 +08:00
|
|
|
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
|
|
|
|
config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
|
|
|
|
// native:vndk
|
2019-12-14 12:41:13 +08:00
|
|
|
ctx := testCcWithConfig(t, config)
|
2019-05-16 03:01:54 +08:00
|
|
|
|
2019-10-30 17:43:49 +08:00
|
|
|
assertMapKeys(t, vndkCoreLibraries(config),
|
2019-05-16 03:01:54 +08:00
|
|
|
[]string{"libvndk", "libvndkprivate"})
|
2019-10-30 17:43:49 +08:00
|
|
|
assertMapKeys(t, vndkSpLibraries(config),
|
2019-05-16 03:01:54 +08:00
|
|
|
[]string{"libc++", "libvndksp"})
|
2019-10-30 17:43:49 +08:00
|
|
|
assertMapKeys(t, llndkLibraries(config),
|
2019-10-22 18:32:18 +08:00
|
|
|
[]string{"libc", "libdl", "libft2", "libllndk", "libllndkprivate", "libm"})
|
2019-10-30 17:43:49 +08:00
|
|
|
assertMapKeys(t, vndkPrivateLibraries(config),
|
2019-10-22 18:32:18 +08:00
|
|
|
[]string{"libft2", "libllndkprivate", "libvndkprivate"})
|
2019-05-16 03:01:54 +08:00
|
|
|
|
2019-11-21 09:12:35 +08:00
|
|
|
vendorVariant27 := "android_vendor.27_arm64_armv8-a_shared"
|
2019-08-26 15:52:35 +08:00
|
|
|
|
2019-05-16 03:01:54 +08: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"},
|
|
|
|
{vendorVariant, "libllndk.llndk", "native:vndk"},
|
2019-08-26 15:52:35 +08:00
|
|
|
{vendorVariant27, "prevndk.vndk.27.arm.binder32", "native:vndk"},
|
2019-05-16 03:01:54 +08: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)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-01 07:36:18 +08:00
|
|
|
var (
|
|
|
|
str11 = "01234567891"
|
|
|
|
str10 = str11[:10]
|
|
|
|
str9 = str11[:9]
|
|
|
|
str5 = str11[:5]
|
|
|
|
str4 = str11[:4]
|
|
|
|
)
|
|
|
|
|
|
|
|
var splitListForSizeTestCases = []struct {
|
|
|
|
in []string
|
|
|
|
out [][]string
|
|
|
|
size int
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
in: []string{str10},
|
|
|
|
out: [][]string{{str10}},
|
|
|
|
size: 10,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
in: []string{str9},
|
|
|
|
out: [][]string{{str9}},
|
|
|
|
size: 10,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
in: []string{str5},
|
|
|
|
out: [][]string{{str5}},
|
|
|
|
size: 10,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
in: []string{str11},
|
|
|
|
out: nil,
|
|
|
|
size: 10,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
in: []string{str10, str10},
|
|
|
|
out: [][]string{{str10}, {str10}},
|
|
|
|
size: 10,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
in: []string{str9, str10},
|
|
|
|
out: [][]string{{str9}, {str10}},
|
|
|
|
size: 10,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
in: []string{str10, str9},
|
|
|
|
out: [][]string{{str10}, {str9}},
|
|
|
|
size: 10,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
in: []string{str5, str4},
|
|
|
|
out: [][]string{{str5, str4}},
|
|
|
|
size: 10,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
in: []string{str5, str4, str5},
|
|
|
|
out: [][]string{{str5, str4}, {str5}},
|
|
|
|
size: 10,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
in: []string{str5, str4, str5, str4},
|
|
|
|
out: [][]string{{str5, str4}, {str5, str4}},
|
|
|
|
size: 10,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
in: []string{str5, str4, str5, str5},
|
|
|
|
out: [][]string{{str5, str4}, {str5}, {str5}},
|
|
|
|
size: 10,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
in: []string{str5, str5, str5, str4},
|
|
|
|
out: [][]string{{str5}, {str5}, {str5, str4}},
|
|
|
|
size: 10,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
in: []string{str9, str11},
|
|
|
|
out: nil,
|
|
|
|
size: 10,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
in: []string{str11, str9},
|
|
|
|
out: nil,
|
|
|
|
size: 10,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSplitListForSize(t *testing.T) {
|
|
|
|
for _, testCase := range splitListForSizeTestCases {
|
2019-02-16 03:08:35 +08:00
|
|
|
out, _ := splitListForSize(android.PathsForTesting(testCase.in...), testCase.size)
|
2017-05-10 04:34:34 +08:00
|
|
|
|
|
|
|
var outStrings [][]string
|
|
|
|
|
|
|
|
if len(out) > 0 {
|
|
|
|
outStrings = make([][]string, len(out))
|
|
|
|
for i, o := range out {
|
|
|
|
outStrings[i] = o.Strings()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(outStrings, testCase.out) {
|
2015-05-01 07:36:18 +08:00
|
|
|
t.Errorf("incorrect output:")
|
|
|
|
t.Errorf(" input: %#v", testCase.in)
|
|
|
|
t.Errorf(" size: %d", testCase.size)
|
|
|
|
t.Errorf(" expected: %#v", testCase.out)
|
2017-05-10 04:34:34 +08:00
|
|
|
t.Errorf(" got: %#v", outStrings)
|
2015-05-01 07:36:18 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-09-28 08:05:30 +08: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 07:48:57 +08: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 08:05:30 +08: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 07:48:57 +08:00
|
|
|
inStatic: "",
|
2017-09-28 08:05:30 +08:00
|
|
|
outOrdered: "",
|
|
|
|
},
|
|
|
|
{
|
2017-11-28 07:48:57 +08:00
|
|
|
inStatic: "a:",
|
2017-09-28 08:05:30 +08:00
|
|
|
outOrdered: "a:",
|
|
|
|
},
|
|
|
|
{
|
2017-11-28 07:48:57 +08:00
|
|
|
inStatic: "a:b; b:",
|
2017-09-28 08:05:30 +08:00
|
|
|
outOrdered: "a:b; b:",
|
|
|
|
},
|
|
|
|
// Tests of reordering
|
|
|
|
{
|
|
|
|
// diamond example
|
2017-11-28 07:48:57 +08:00
|
|
|
inStatic: "a:d,b,c; b:d; c:d; d:",
|
2017-09-28 08:05:30 +08:00
|
|
|
outOrdered: "a:b,c,d; b:d; c:d; d:",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// somewhat real example
|
2017-11-28 07:48:57 +08:00
|
|
|
inStatic: "bsdiff_unittest:b,c,d,e,f,g,h,i; e:b",
|
2017-09-28 08:05:30 +08:00
|
|
|
outOrdered: "bsdiff_unittest:c,d,e,b,f,g,h,i; e:b",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// multiple reorderings
|
2017-11-28 07:48:57 +08:00
|
|
|
inStatic: "a:b,c,d,e; d:b; e:c",
|
2017-09-28 08:05:30 +08:00
|
|
|
outOrdered: "a:d,b,e,c; d:b; e:c",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// should reorder without adding new transitive dependencies
|
2017-11-28 07:48:57 +08:00
|
|
|
inStatic: "bin:lib2,lib1; lib1:lib2,liboptional",
|
2017-09-28 08:05:30 +08:00
|
|
|
allOrdered: "bin:lib1,lib2,liboptional; lib1:lib2,liboptional",
|
|
|
|
outOrdered: "bin:lib1,lib2; lib1:lib2,liboptional",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// multiple levels of dependencies
|
2017-11-28 07:48:57 +08:00
|
|
|
inStatic: "a:b,c,d,e,f,g,h; f:b,c,d; b:c,d; c:d",
|
2017-09-28 08:05:30 +08: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 07:48:57 +08: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 08:05:30 +08: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 07:48:57 +08:00
|
|
|
inStatic: "a1:b,c,d,e; a2:b,c,e,d; b:d,e; c:e,d",
|
2017-09-28 08:05:30 +08: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 07:48:57 +08: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 08:05:30 +08: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 07:48:57 +08:00
|
|
|
inStatic: "a:b,c,c,b",
|
2017-09-28 08:05:30 +08:00
|
|
|
outOrdered: "a:c,b",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// duplicates with reordering
|
2017-11-28 07:48:57 +08:00
|
|
|
inStatic: "a:b,c,d,c; c:b",
|
2017-09-28 08:05:30 +08: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 07:48:57 +08:00
|
|
|
inStatic: "a:a",
|
2017-09-28 08:05:30 +08:00
|
|
|
outOrdered: "a:a",
|
|
|
|
},
|
|
|
|
{
|
2017-11-28 07:48:57 +08:00
|
|
|
inStatic: "a:b; b:c; c:a",
|
2017-09-28 08:05:30 +08:00
|
|
|
allOrdered: "a:b,c; b:c,a; c:a,b",
|
|
|
|
outOrdered: "a:b; b:c; c:a",
|
|
|
|
},
|
|
|
|
{
|
2017-11-28 07:48:57 +08:00
|
|
|
inStatic: "a:b,c; b:c,a; c:a,b",
|
2017-09-28 08:05:30 +08: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 07:48:57 +08:00
|
|
|
func TestLinkReordering(t *testing.T) {
|
2017-09-28 08:05:30 +08:00
|
|
|
for _, testCase := range staticLinkDepOrderTestCases {
|
|
|
|
errs := []string{}
|
|
|
|
|
|
|
|
// parse testcase
|
2017-11-28 07:48:57 +08:00
|
|
|
_, givenTransitiveDeps := parseModuleDeps(testCase.inStatic)
|
2017-09-28 08:05:30 +08:00
|
|
|
expectedModuleNames, expectedTransitiveDeps := parseModuleDeps(testCase.outOrdered)
|
|
|
|
if testCase.allOrdered == "" {
|
|
|
|
// allow the test case to skip specifying allOrdered
|
|
|
|
testCase.allOrdered = testCase.outOrdered
|
|
|
|
}
|
|
|
|
_, expectedAllDeps := parseModuleDeps(testCase.allOrdered)
|
2017-11-28 07:48:57 +08:00
|
|
|
_, givenAllSharedDeps := parseModuleDeps(testCase.inShared)
|
2017-09-28 08:05:30 +08:00
|
|
|
|
|
|
|
// For each module whose post-reordered dependencies were specified, validate that
|
|
|
|
// reordering the inputs produces the expected outputs.
|
|
|
|
for _, moduleName := range expectedModuleNames {
|
|
|
|
moduleDeps := givenTransitiveDeps[moduleName]
|
2017-11-28 07:48:57 +08:00
|
|
|
givenSharedDeps := givenAllSharedDeps[moduleName]
|
|
|
|
orderedAllDeps, orderedDeclaredDeps := orderDeps(moduleDeps, givenSharedDeps, givenTransitiveDeps)
|
2017-09-28 08:05:30 +08:00
|
|
|
|
|
|
|
correctAllOrdered := expectedAllDeps[moduleName]
|
|
|
|
if !reflect.DeepEqual(orderedAllDeps, correctAllOrdered) {
|
|
|
|
errs = append(errs, fmt.Sprintf("orderDeps returned incorrect orderedAllDeps."+
|
2017-11-28 07:48:57 +08:00
|
|
|
"\nin static:%q"+
|
|
|
|
"\nin shared:%q"+
|
2017-09-28 08:05:30 +08:00
|
|
|
"\nmodule: %v"+
|
|
|
|
"\nexpected: %s"+
|
|
|
|
"\nactual: %s",
|
2017-11-28 07:48:57 +08:00
|
|
|
testCase.inStatic, testCase.inShared, moduleName, correctAllOrdered, orderedAllDeps))
|
2017-09-28 08:05:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
correctOutputDeps := expectedTransitiveDeps[moduleName]
|
|
|
|
if !reflect.DeepEqual(correctOutputDeps, orderedDeclaredDeps) {
|
|
|
|
errs = append(errs, fmt.Sprintf("orderDeps returned incorrect orderedDeclaredDeps."+
|
2017-11-28 07:48:57 +08:00
|
|
|
"\nin static:%q"+
|
|
|
|
"\nin shared:%q"+
|
2017-09-28 08:05:30 +08:00
|
|
|
"\nmodule: %v"+
|
|
|
|
"\nexpected: %s"+
|
|
|
|
"\nactual: %s",
|
2017-11-28 07:48:57 +08:00
|
|
|
testCase.inStatic, testCase.inShared, moduleName, correctOutputDeps, orderedDeclaredDeps))
|
2017-09-28 08:05:30 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(errs) > 0 {
|
|
|
|
sort.Strings(errs)
|
|
|
|
for _, err := range errs {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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 18:04:35 +08:00
|
|
|
|
2017-09-28 08:05:30 +08:00
|
|
|
func getOutputPaths(ctx *android.TestContext, variant string, moduleNames []string) (paths android.Paths) {
|
|
|
|
for _, moduleName := range moduleNames {
|
|
|
|
module := ctx.ModuleForTests(moduleName, variant).Module().(*Module)
|
|
|
|
output := module.outputFile.Path()
|
|
|
|
paths = append(paths, output)
|
|
|
|
}
|
|
|
|
return paths
|
|
|
|
}
|
|
|
|
|
2017-11-28 07:48:57 +08:00
|
|
|
func TestStaticLibDepReordering(t *testing.T) {
|
2017-09-28 08:05:30 +08: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 17:23:01 +08:00
|
|
|
stl: "none",
|
2017-09-28 08:05:30 +08: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 17:23:01 +08:00
|
|
|
stl: "none",
|
2017-09-28 08:05:30 +08: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 17:23:01 +08:00
|
|
|
stl: "none",
|
2017-09-28 08:05:30 +08: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 17:23:01 +08:00
|
|
|
stl: "none",
|
2017-09-28 08:05:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
`)
|
|
|
|
|
2019-11-21 08:39:12 +08:00
|
|
|
variant := "android_arm64_armv8-a_static"
|
2017-09-28 08:05:30 +08:00
|
|
|
moduleA := ctx.ModuleForTests("a", variant).Module().(*Module)
|
2017-11-28 07:48:57 +08:00
|
|
|
actual := moduleA.depsInLinkOrder
|
2017-09-28 08:05:30 +08:00
|
|
|
expected := getOutputPaths(ctx, variant, []string{"c", "b", "d"})
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(actual, expected) {
|
|
|
|
t.Errorf("staticDeps orderings were not propagated correctly"+
|
|
|
|
"\nactual: %v"+
|
|
|
|
"\nexpected: %v",
|
|
|
|
actual,
|
|
|
|
expected,
|
|
|
|
)
|
|
|
|
}
|
2017-09-26 09:50:54 +08:00
|
|
|
}
|
2017-09-28 08:05:30 +08:00
|
|
|
|
2017-11-28 07:48:57 +08:00
|
|
|
func TestStaticLibDepReorderingWithShared(t *testing.T) {
|
|
|
|
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 17:23:01 +08:00
|
|
|
stl: "none",
|
2017-11-28 07:48:57 +08: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 17:23:01 +08:00
|
|
|
stl: "none",
|
2017-11-28 07:48:57 +08: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 17:23:01 +08:00
|
|
|
stl: "none",
|
2017-11-28 07:48:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
`)
|
|
|
|
|
2019-11-21 08:39:12 +08:00
|
|
|
variant := "android_arm64_armv8-a_static"
|
2017-11-28 07:48:57 +08:00
|
|
|
moduleA := ctx.ModuleForTests("a", variant).Module().(*Module)
|
|
|
|
actual := moduleA.depsInLinkOrder
|
|
|
|
expected := getOutputPaths(ctx, variant, []string{"c", "b"})
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(actual, expected) {
|
|
|
|
t.Errorf("staticDeps orderings did not account for shared libs"+
|
|
|
|
"\nactual: %v"+
|
|
|
|
"\nexpected: %v",
|
|
|
|
actual,
|
|
|
|
expected,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-13 17:57:35 +08:00
|
|
|
func checkEquals(t *testing.T, message string, expected, actual interface{}) {
|
2020-08-19 09:35:15 +08:00
|
|
|
t.Helper()
|
2020-03-13 17:57:35 +08:00
|
|
|
if !reflect.DeepEqual(actual, expected) {
|
|
|
|
t.Errorf(message+
|
|
|
|
"\nactual: %v"+
|
|
|
|
"\nexpected: %v",
|
|
|
|
actual,
|
|
|
|
expected,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-21 22:21:46 +08:00
|
|
|
func TestLlndkLibrary(t *testing.T) {
|
|
|
|
ctx := testCc(t, `
|
|
|
|
cc_library {
|
|
|
|
name: "libllndk",
|
|
|
|
stubs: { versions: ["1", "2"] },
|
|
|
|
}
|
|
|
|
llndk_library {
|
|
|
|
name: "libllndk",
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
actual := ctx.ModuleVariantsForTests("libllndk.llndk")
|
|
|
|
expected := []string{
|
|
|
|
"android_vendor.VER_arm64_armv8-a_shared",
|
|
|
|
"android_vendor.VER_arm64_armv8-a_shared_1",
|
|
|
|
"android_vendor.VER_arm64_armv8-a_shared_2",
|
|
|
|
"android_vendor.VER_arm_armv7-a-neon_shared",
|
|
|
|
"android_vendor.VER_arm_armv7-a-neon_shared_1",
|
|
|
|
"android_vendor.VER_arm_armv7-a-neon_shared_2",
|
|
|
|
}
|
|
|
|
checkEquals(t, "variants for llndk stubs", expected, actual)
|
|
|
|
|
|
|
|
params := ctx.ModuleForTests("libllndk.llndk", "android_vendor.VER_arm_armv7-a-neon_shared").Description("generate stub")
|
|
|
|
checkEquals(t, "use VNDK version for default stubs", "current", params.Args["apiLevel"])
|
|
|
|
|
|
|
|
params = ctx.ModuleForTests("libllndk.llndk", "android_vendor.VER_arm_armv7-a-neon_shared_1").Description("generate stub")
|
|
|
|
checkEquals(t, "override apiLevel for versioned stubs", "1", params.Args["apiLevel"])
|
|
|
|
}
|
|
|
|
|
2017-12-14 18:54:34 +08:00
|
|
|
func TestLlndkHeaders(t *testing.T) {
|
|
|
|
ctx := testCc(t, `
|
|
|
|
llndk_headers {
|
|
|
|
name: "libllndk_headers",
|
|
|
|
export_include_dirs: ["my_include"],
|
|
|
|
}
|
|
|
|
llndk_library {
|
|
|
|
name: "libllndk",
|
|
|
|
export_llndk_headers: ["libllndk_headers"],
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libvendor",
|
|
|
|
shared_libs: ["libllndk"],
|
|
|
|
vendor: true,
|
|
|
|
srcs: ["foo.c"],
|
2019-06-02 15:53:50 +08: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 18:04:35 +08:00
|
|
|
nocrt: true,
|
2017-12-14 18:54:34 +08:00
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
// _static variant is used since _shared reuses *.o from the static variant
|
2019-11-21 09:12:35 +08:00
|
|
|
cc := ctx.ModuleForTests("libvendor", "android_vendor.VER_arm_armv7-a-neon_static").Rule("cc")
|
2017-12-14 18:54:34 +08: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-20 01:17:32 +08: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 {
|
|
|
|
name: "libvendor_available1",
|
|
|
|
vendor_available: true,
|
2019-06-02 15:53:50 +08:00
|
|
|
no_libcrt : true,
|
2017-12-20 01:17:32 +08:00
|
|
|
nocrt : true,
|
|
|
|
system_shared_libs : [],
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libvendor_available2",
|
|
|
|
vendor_available: true,
|
|
|
|
runtime_libs: ["libvendor_available1"],
|
2019-06-02 15:53:50 +08:00
|
|
|
no_libcrt : true,
|
2017-12-20 01:17:32 +08:00
|
|
|
nocrt : true,
|
|
|
|
system_shared_libs : [],
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libvendor_available3",
|
|
|
|
vendor_available: true,
|
|
|
|
runtime_libs: ["libvendor_available1"],
|
|
|
|
target: {
|
|
|
|
vendor: {
|
|
|
|
exclude_runtime_libs: ["libvendor_available1"],
|
|
|
|
}
|
|
|
|
},
|
2019-06-02 15:53:50 +08:00
|
|
|
no_libcrt : true,
|
2017-12-20 01:17:32 +08:00
|
|
|
nocrt : true,
|
|
|
|
system_shared_libs : [],
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libcore",
|
|
|
|
runtime_libs: ["libvendor_available1"],
|
2019-06-02 15:53:50 +08:00
|
|
|
no_libcrt : true,
|
2017-12-20 01:17:32 +08:00
|
|
|
nocrt : true,
|
|
|
|
system_shared_libs : [],
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libvendor1",
|
|
|
|
vendor: true,
|
2019-06-02 15:53:50 +08:00
|
|
|
no_libcrt : true,
|
2017-12-20 01:17:32 +08:00
|
|
|
nocrt : true,
|
|
|
|
system_shared_libs : [],
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libvendor2",
|
|
|
|
vendor: true,
|
|
|
|
runtime_libs: ["libvendor_available1", "libvendor1"],
|
2019-06-02 15:53:50 +08:00
|
|
|
no_libcrt : true,
|
2017-12-20 01:17:32 +08:00
|
|
|
nocrt : true,
|
|
|
|
system_shared_libs : [],
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
func TestRuntimeLibs(t *testing.T) {
|
|
|
|
ctx := testCc(t, runtimeLibAndroidBp)
|
|
|
|
|
|
|
|
// runtime_libs for core variants use the module names without suffixes.
|
2019-11-21 08:39:12 +08:00
|
|
|
variant := "android_arm64_armv8-a_shared"
|
2017-12-20 01:17:32 +08:00
|
|
|
|
|
|
|
module := ctx.ModuleForTests("libvendor_available2", variant).Module().(*Module)
|
|
|
|
checkRuntimeLibs(t, []string{"libvendor_available1"}, module)
|
|
|
|
|
|
|
|
module = ctx.ModuleForTests("libcore", variant).Module().(*Module)
|
|
|
|
checkRuntimeLibs(t, []string{"libvendor_available1"}, module)
|
|
|
|
|
|
|
|
// runtime_libs for vendor variants have '.vendor' suffixes if the modules have both core
|
|
|
|
// and vendor variants.
|
2019-11-21 09:12:35 +08:00
|
|
|
variant = "android_vendor.VER_arm64_armv8-a_shared"
|
2017-12-20 01:17:32 +08:00
|
|
|
|
|
|
|
module = ctx.ModuleForTests("libvendor_available2", variant).Module().(*Module)
|
|
|
|
checkRuntimeLibs(t, []string{"libvendor_available1.vendor"}, module)
|
|
|
|
|
|
|
|
module = ctx.ModuleForTests("libvendor2", variant).Module().(*Module)
|
|
|
|
checkRuntimeLibs(t, []string{"libvendor_available1.vendor", "libvendor1"}, module)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestExcludeRuntimeLibs(t *testing.T) {
|
|
|
|
ctx := testCc(t, runtimeLibAndroidBp)
|
|
|
|
|
2019-11-21 08:39:12 +08:00
|
|
|
variant := "android_arm64_armv8-a_shared"
|
2017-12-20 01:17:32 +08:00
|
|
|
module := ctx.ModuleForTests("libvendor_available3", variant).Module().(*Module)
|
|
|
|
checkRuntimeLibs(t, []string{"libvendor_available1"}, module)
|
|
|
|
|
2019-11-21 09:12:35 +08:00
|
|
|
variant = "android_vendor.VER_arm64_armv8-a_shared"
|
2017-12-20 01:17:32 +08:00
|
|
|
module = ctx.ModuleForTests("libvendor_available3", variant).Module().(*Module)
|
|
|
|
checkRuntimeLibs(t, nil, module)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestRuntimeLibsNoVndk(t *testing.T) {
|
|
|
|
ctx := testCcNoVndk(t, runtimeLibAndroidBp)
|
|
|
|
|
|
|
|
// If DeviceVndkVersion is not defined, then runtime_libs are copied as-is.
|
|
|
|
|
2019-11-21 08:39:12 +08:00
|
|
|
variant := "android_arm64_armv8-a_shared"
|
2017-12-20 01:17:32 +08:00
|
|
|
|
|
|
|
module := ctx.ModuleForTests("libvendor_available2", variant).Module().(*Module)
|
|
|
|
checkRuntimeLibs(t, []string{"libvendor_available1"}, module)
|
|
|
|
|
|
|
|
module = ctx.ModuleForTests("libvendor2", variant).Module().(*Module)
|
|
|
|
checkRuntimeLibs(t, []string{"libvendor_available1", "libvendor1"}, module)
|
|
|
|
}
|
|
|
|
|
2018-11-16 09:19:56 +08:00
|
|
|
func checkStaticLibs(t *testing.T, expected []string, module *Module) {
|
2020-02-26 21:45:42 +08:00
|
|
|
t.Helper()
|
2018-11-16 09:19:56 +08: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) {
|
|
|
|
ctx := testCc(t, staticLibAndroidBp)
|
|
|
|
|
|
|
|
// Check the shared version of lib2.
|
2019-11-21 08:39:12 +08:00
|
|
|
variant := "android_arm64_armv8-a_shared"
|
2018-11-16 09:19:56 +08:00
|
|
|
module := ctx.ModuleForTests("lib2", variant).Module().(*Module)
|
2019-12-11 10:37:45 +08:00
|
|
|
checkStaticLibs(t, []string{"lib1", "libc++demangle", "libclang_rt.builtins-aarch64-android", "libatomic"}, module)
|
2018-11-16 09:19:56 +08:00
|
|
|
|
|
|
|
// Check the static version of lib2.
|
2019-11-21 08:39:12 +08:00
|
|
|
variant = "android_arm64_armv8-a_static"
|
2018-11-16 09:19:56 +08:00
|
|
|
module = ctx.ModuleForTests("lib2", variant).Module().(*Module)
|
|
|
|
// libc++_static is linked additionally.
|
2019-12-11 10:37:45 +08:00
|
|
|
checkStaticLibs(t, []string{"lib1", "libc++_static", "libc++demangle", "libclang_rt.builtins-aarch64-android", "libatomic"}, module)
|
2018-11-16 09:19:56 +08:00
|
|
|
}
|
|
|
|
|
2017-09-26 09:50:54 +08: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) {
|
|
|
|
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 08:05:30 +08: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 17:23:01 +08:00
|
|
|
|
|
|
|
func TestVendorPublicLibraries(t *testing.T) {
|
|
|
|
ctx := testCc(t, `
|
|
|
|
cc_library_headers {
|
|
|
|
name: "libvendorpublic_headers",
|
|
|
|
export_include_dirs: ["my_include"],
|
|
|
|
}
|
|
|
|
vendor_public_library {
|
|
|
|
name: "libvendorpublic",
|
|
|
|
symbol_file: "",
|
|
|
|
export_public_headers: ["libvendorpublic_headers"],
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libvendorpublic",
|
|
|
|
srcs: ["foo.c"],
|
|
|
|
vendor: true,
|
2019-06-02 15:53:50 +08:00
|
|
|
no_libcrt: true,
|
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 17:23:01 +08:00
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libsystem",
|
|
|
|
shared_libs: ["libvendorpublic"],
|
|
|
|
vendor: false,
|
|
|
|
srcs: ["foo.c"],
|
2019-06-02 15:53:50 +08:00
|
|
|
no_libcrt: true,
|
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 17:23:01 +08:00
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libvendor",
|
|
|
|
shared_libs: ["libvendorpublic"],
|
|
|
|
vendor: true,
|
|
|
|
srcs: ["foo.c"],
|
2019-06-02 15:53:50 +08:00
|
|
|
no_libcrt: true,
|
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 17:23:01 +08:00
|
|
|
nocrt: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
2019-11-21 08:39:12 +08:00
|
|
|
coreVariant := "android_arm64_armv8-a_shared"
|
2019-11-21 09:12:35 +08:00
|
|
|
vendorVariant := "android_vendor.VER_arm64_armv8-a_shared"
|
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 17:23:01 +08:00
|
|
|
|
|
|
|
// test if header search paths are correctly added
|
|
|
|
// _static variant is used since _shared reuses *.o from the static variant
|
2019-11-21 08:39:12 +08:00
|
|
|
cc := ctx.ModuleForTests("libsystem", strings.Replace(coreVariant, "_shared", "_static", 1)).Rule("cc")
|
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 17:23:01 +08:00
|
|
|
cflags := cc.Args["cFlags"]
|
|
|
|
if !strings.Contains(cflags, "-Imy_include") {
|
|
|
|
t.Errorf("cflags for libsystem must contain -Imy_include, but was %#v.", cflags)
|
|
|
|
}
|
|
|
|
|
|
|
|
// test if libsystem is linked to the stub
|
2019-11-21 08:39:12 +08:00
|
|
|
ld := ctx.ModuleForTests("libsystem", coreVariant).Rule("ld")
|
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 17:23:01 +08:00
|
|
|
libflags := ld.Args["libFlags"]
|
2019-11-21 08:39:12 +08:00
|
|
|
stubPaths := getOutputPaths(ctx, coreVariant, []string{"libvendorpublic" + vendorPublicLibrarySuffix})
|
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 17:23:01 +08:00
|
|
|
if !strings.Contains(libflags, stubPaths[0].String()) {
|
|
|
|
t.Errorf("libflags for libsystem must contain %#v, but was %#v", stubPaths[0], libflags)
|
|
|
|
}
|
|
|
|
|
|
|
|
// test if libvendor is linked to the real shared lib
|
2019-11-21 08:39:12 +08:00
|
|
|
ld = ctx.ModuleForTests("libvendor", vendorVariant).Rule("ld")
|
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 17:23:01 +08:00
|
|
|
libflags = ld.Args["libFlags"]
|
2019-11-21 08:39:12 +08:00
|
|
|
stubPaths = getOutputPaths(ctx, vendorVariant, []string{"libvendorpublic"})
|
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 17:23:01 +08:00
|
|
|
if !strings.Contains(libflags, stubPaths[0].String()) {
|
|
|
|
t.Errorf("libflags for libvendor must contain %#v, but was %#v", stubPaths[0], libflags)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2018-07-11 09:49:27 +08:00
|
|
|
|
|
|
|
func TestRecovery(t *testing.T) {
|
|
|
|
ctx := testCc(t, `
|
|
|
|
cc_library_shared {
|
|
|
|
name: "librecovery",
|
|
|
|
recovery: true,
|
|
|
|
}
|
|
|
|
cc_library_shared {
|
|
|
|
name: "librecovery32",
|
|
|
|
recovery: true,
|
|
|
|
compile_multilib:"32",
|
|
|
|
}
|
2018-08-28 08:55:37 +08:00
|
|
|
cc_library_shared {
|
|
|
|
name: "libHalInRecovery",
|
|
|
|
recovery_available: true,
|
|
|
|
vendor: true,
|
|
|
|
}
|
2018-07-11 09:49:27 +08:00
|
|
|
`)
|
|
|
|
|
|
|
|
variants := ctx.ModuleVariantsForTests("librecovery")
|
2019-11-21 09:12:35 +08:00
|
|
|
const arm64 = "android_recovery_arm64_armv8-a_shared"
|
2018-07-11 09:49:27 +08: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 08:55:37 +08: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 21:25:07 +08:00
|
|
|
}
|
2018-08-28 08:55:37 +08:00
|
|
|
|
2020-06-18 04:10:42 +08:00
|
|
|
func TestDataLibsPrebuiltSharedTestLibrary(t *testing.T) {
|
|
|
|
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,
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
config := TestConfig(buildDir, android.Android, nil, bp, nil)
|
|
|
|
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
|
|
|
|
config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
|
|
|
|
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 {
|
|
|
|
t.Errorf("expected exactly one test data file. test data files: [%s]", testBinary.dataPaths())
|
|
|
|
}
|
|
|
|
|
|
|
|
outputPath := outputFiles[0].String()
|
|
|
|
|
|
|
|
if !strings.HasSuffix(outputPath, "/main_test") {
|
|
|
|
t.Errorf("expected test output file to be 'main_test', but was '%s'", outputPath)
|
|
|
|
}
|
|
|
|
entries := android.AndroidMkEntriesForTest(t, config, "", module)[0]
|
|
|
|
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 21:25:07 +08:00
|
|
|
func TestVersionedStubs(t *testing.T) {
|
|
|
|
ctx := testCc(t, `
|
|
|
|
cc_library_shared {
|
|
|
|
name: "libFoo",
|
2018-11-02 17:23:15 +08: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 21:25:07 +08:00
|
|
|
stubs: {
|
|
|
|
symbol_file: "foo.map.txt",
|
|
|
|
versions: ["1", "2", "3"],
|
|
|
|
},
|
|
|
|
}
|
2018-11-02 17:23:15 +08: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 21:25:07 +08:00
|
|
|
cc_library_shared {
|
|
|
|
name: "libBar",
|
2018-11-02 17:23:15 +08: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 21:25:07 +08:00
|
|
|
shared_libs: ["libFoo#1"],
|
|
|
|
}`)
|
|
|
|
|
|
|
|
variants := ctx.ModuleVariantsForTests("libFoo")
|
|
|
|
expectedVariants := []string{
|
2019-11-21 08:39:12 +08:00
|
|
|
"android_arm64_armv8-a_shared",
|
|
|
|
"android_arm64_armv8-a_shared_1",
|
|
|
|
"android_arm64_armv8-a_shared_2",
|
|
|
|
"android_arm64_armv8-a_shared_3",
|
|
|
|
"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",
|
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 21:25:07 +08: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 08:39:12 +08: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 21:25:07 +08:00
|
|
|
libFlags := libBarLinkRule.Args["libFlags"]
|
2019-11-21 08:39:12 +08: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 21:25:07 +08:00
|
|
|
if !strings.Contains(libFlags, libFoo1StubPath) {
|
|
|
|
t.Errorf("%q is not found in %q", libFoo1StubPath, libFlags)
|
|
|
|
}
|
2018-11-02 17:23:15 +08:00
|
|
|
|
2019-11-21 08:39:12 +08:00
|
|
|
libBarCompileRule := ctx.ModuleForTests("libBar", "android_arm64_armv8-a_shared").Rule("cc")
|
2018-11-02 17:23:15 +08: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 09:49:27 +08:00
|
|
|
}
|
2018-12-19 03:08:25 +08:00
|
|
|
|
2020-03-13 17:57:35 +08:00
|
|
|
func TestVersioningMacro(t *testing.T) {
|
|
|
|
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))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-19 03:08:25 +08:00
|
|
|
func TestStaticExecutable(t *testing.T) {
|
|
|
|
ctx := testCc(t, `
|
|
|
|
cc_binary {
|
|
|
|
name: "static_test",
|
2019-08-17 03:14:32 +08:00
|
|
|
srcs: ["foo.c", "baz.o"],
|
2018-12-19 03:08:25 +08:00
|
|
|
static_executable: true,
|
|
|
|
}`)
|
|
|
|
|
2019-11-21 08:39:12 +08:00
|
|
|
variant := "android_arm64_armv8-a"
|
2018-12-19 03:08:25 +08: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 06:03:34 +08:00
|
|
|
systemStaticLibs := []string{"libc.a", "libm.a"}
|
2018-12-19 03:08:25 +08: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 23:31:10 +08:00
|
|
|
|
|
|
|
func TestStaticDepsOrderWithStubs(t *testing.T) {
|
|
|
|
ctx := testCc(t, `
|
|
|
|
cc_binary {
|
|
|
|
name: "mybin",
|
|
|
|
srcs: ["foo.c"],
|
2020-02-16 03:29:50 +08:00
|
|
|
static_libs: ["libfooB"],
|
2019-01-31 23:31:10 +08:00
|
|
|
static_executable: true,
|
|
|
|
stl: "none",
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
2020-02-16 03:29:50 +08:00
|
|
|
name: "libfooB",
|
2019-01-31 23:31:10 +08:00
|
|
|
srcs: ["foo.c"],
|
2020-02-16 03:29:50 +08:00
|
|
|
shared_libs: ["libfooC"],
|
2019-01-31 23:31:10 +08:00
|
|
|
stl: "none",
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
2020-02-16 03:29:50 +08:00
|
|
|
name: "libfooC",
|
2019-01-31 23:31:10 +08:00
|
|
|
srcs: ["foo.c"],
|
|
|
|
stl: "none",
|
|
|
|
stubs: {
|
|
|
|
versions: ["1"],
|
|
|
|
},
|
|
|
|
}`)
|
|
|
|
|
2019-11-21 08:39:12 +08:00
|
|
|
mybin := ctx.ModuleForTests("mybin", "android_arm64_armv8-a").Module().(*Module)
|
2019-01-31 23:31:10 +08:00
|
|
|
actual := mybin.depsInLinkOrder
|
2020-02-16 03:29:50 +08:00
|
|
|
expected := getOutputPaths(ctx, "android_arm64_armv8-a_static", []string{"libfooB", "libfooC"})
|
2019-01-31 23:31:10 +08:00
|
|
|
|
|
|
|
if !reflect.DeepEqual(actual, expected) {
|
|
|
|
t.Errorf("staticDeps orderings were not propagated correctly"+
|
|
|
|
"\nactual: %v"+
|
|
|
|
"\nexpected: %v",
|
|
|
|
actual,
|
|
|
|
expected,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
2019-05-16 03:01:54 +08:00
|
|
|
|
2019-08-23 10:18:57 +08:00
|
|
|
func TestErrorsIfAModuleDependsOnDisabled(t *testing.T) {
|
|
|
|
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",
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
}
|
|
|
|
|
2019-07-16 00:34:09 +08:00
|
|
|
// Simple smoke test for the cc_fuzz target that ensures the rule compiles
|
|
|
|
// correctly.
|
|
|
|
func TestFuzzTarget(t *testing.T) {
|
|
|
|
ctx := testCc(t, `
|
|
|
|
cc_fuzz {
|
|
|
|
name: "fuzz_smoke_test",
|
|
|
|
srcs: ["foo.c"],
|
|
|
|
}`)
|
|
|
|
|
2019-12-20 03:06:13 +08:00
|
|
|
variant := "android_arm64_armv8-a_fuzzer"
|
2019-07-16 00:34:09 +08:00
|
|
|
ctx.ModuleForTests("fuzz_smoke_test", variant).Rule("cc")
|
|
|
|
}
|
|
|
|
|
2019-07-07 15:27:47 +08:00
|
|
|
func TestAidl(t *testing.T) {
|
|
|
|
}
|
|
|
|
|
2019-05-16 03:01:54 +08: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-25 05:55:04 +08:00
|
|
|
|
2019-10-30 17:43:49 +08:00
|
|
|
func assertMapKeys(t *testing.T, m map[string]string, expected []string) {
|
|
|
|
t.Helper()
|
|
|
|
assertArrayString(t, android.SortedStringKeys(m), expected)
|
|
|
|
}
|
|
|
|
|
2019-09-25 05:55:04 +08:00
|
|
|
func TestDefaults(t *testing.T) {
|
|
|
|
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"],
|
|
|
|
}`)
|
|
|
|
|
|
|
|
pathsToBase := func(paths android.Paths) []string {
|
|
|
|
var ret []string
|
|
|
|
for _, p := range paths {
|
|
|
|
ret = append(ret, p.Base())
|
|
|
|
}
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
2019-11-21 08:39:12 +08:00
|
|
|
shared := ctx.ModuleForTests("libshared", "android_arm64_armv8-a_shared").Rule("ld")
|
2019-09-25 05:55:04 +08: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 08:39:12 +08:00
|
|
|
bothShared := ctx.ModuleForTests("libboth", "android_arm64_armv8-a_shared").Rule("ld")
|
2019-09-25 05:55:04 +08: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 08:39:12 +08:00
|
|
|
binary := ctx.ModuleForTests("binary", "android_arm64_armv8-a").Rule("ld")
|
2019-09-25 05:55:04 +08: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 08:39:12 +08:00
|
|
|
static := ctx.ModuleForTests("libstatic", "android_arm64_armv8-a_static").Rule("ar")
|
2019-09-25 05:55:04 +08: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 08:39:12 +08:00
|
|
|
bothStatic := ctx.ModuleForTests("libboth", "android_arm64_armv8-a_static").Rule("ar")
|
2019-09-25 05:55:04 +08: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 09:01:55 +08:00
|
|
|
|
|
|
|
func TestProductVariableDefaults(t *testing.T) {
|
|
|
|
bp := `
|
|
|
|
cc_defaults {
|
|
|
|
name: "libfoo_defaults",
|
|
|
|
srcs: ["foo.c"],
|
|
|
|
cppflags: ["-DFOO"],
|
|
|
|
product_variables: {
|
|
|
|
debuggable: {
|
|
|
|
cppflags: ["-DBAR"],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libfoo",
|
|
|
|
defaults: ["libfoo_defaults"],
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
config := TestConfig(buildDir, android.Android, nil, bp, nil)
|
|
|
|
config.TestProductVariables.Debuggable = BoolPtr(true)
|
|
|
|
|
|
|
|
ctx := CreateTestContext()
|
|
|
|
ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
|
|
|
|
ctx.BottomUp("variable", android.VariableMutator).Parallel()
|
|
|
|
})
|
|
|
|
ctx.Register(config)
|
|
|
|
|
|
|
|
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
|
|
|
android.FailIfErrored(t, errs)
|
|
|
|
_, errs = ctx.PrepareBuildActions(config)
|
|
|
|
android.FailIfErrored(t, errs)
|
|
|
|
|
|
|
|
libfoo := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_static").Module().(*Module)
|
|
|
|
if !android.InList("-DBAR", libfoo.flags.Local.CppFlags) {
|
|
|
|
t.Errorf("expected -DBAR in cppflags, got %q", libfoo.flags.Local.CppFlags)
|
|
|
|
}
|
|
|
|
}
|
2020-09-23 09:11:25 +08: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"],
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
config := TestConfig(buildDir, android.Android, nil, bp, nil)
|
|
|
|
config.TestProductVariables.Allow_missing_dependencies = BoolPtr(true)
|
|
|
|
|
|
|
|
ctx := CreateTestContext()
|
|
|
|
ctx.SetAllowMissingDependencies(true)
|
|
|
|
ctx.Register(config)
|
|
|
|
|
|
|
|
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
|
|
|
android.FailIfErrored(t, errs)
|
|
|
|
_, errs = ctx.PrepareBuildActions(config)
|
|
|
|
android.FailIfErrored(t, errs)
|
|
|
|
|
|
|
|
libbar := ctx.ModuleForTests("libbar", "android_arm64_armv8-a_static").Output("libbar.a")
|
|
|
|
if g, w := libbar.Rule, android.ErrorRule; g != w {
|
|
|
|
t.Fatalf("Expected libbar rule to be %q, got %q", w, g)
|
|
|
|
}
|
|
|
|
|
|
|
|
if g, w := libbar.Args["error"], "missing dependencies: libmissing"; !strings.Contains(g, w) {
|
|
|
|
t.Errorf("Expected libbar error to contain %q, was %q", w, g)
|
|
|
|
}
|
|
|
|
|
|
|
|
libfoo := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_static").Output("libfoo.a")
|
|
|
|
if g, w := libfoo.Inputs.Strings(), libbar.Output.String(); !android.InList(w, g) {
|
|
|
|
t.Errorf("Expected libfoo.a to depend on %q, got %q", w, g)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|