2019-12-03 23:25:00 +08:00
|
|
|
// Copyright (C) 2019 The Android Open Source Project
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package sdk
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2019-12-01 01:49:09 +08:00
|
|
|
func testSdkWithJava(t *testing.T, bp string) *testSdkResult {
|
|
|
|
t.Helper()
|
|
|
|
|
|
|
|
fs := map[string][]byte{
|
|
|
|
"Test.java": nil,
|
|
|
|
"aidl/foo/bar/Test.aidl": nil,
|
|
|
|
}
|
|
|
|
return testSdkWithFs(t, bp, fs)
|
|
|
|
}
|
|
|
|
|
2019-12-03 23:25:00 +08:00
|
|
|
// Contains tests for SDK members provided by the java package.
|
|
|
|
|
|
|
|
func TestBasicSdkWithJavaLibrary(t *testing.T) {
|
2019-12-01 01:49:09 +08:00
|
|
|
result := testSdkWithJava(t, `
|
2019-12-03 23:25:00 +08:00
|
|
|
sdk {
|
|
|
|
name: "mysdk",
|
apex_available tracks static dependencies
This change fixes a bug that apex_available is not enforced for static
dependencies. For example, a module with 'apex_available:
["//apex_available:platform"]' was able to be statically linked to any
APEX. This was happening because the check was done on the modules that
are actually installed to an APEX. Static dependencies of the modules
were not counted as they are not installed to the APEX as files.
Fixing this bug by doing the check by traversing the tree in the method
checkApexAvailability.
This change includes a few number of related changes:
1) DepIsInSameApex implementation for cc.Module was changed as well.
Previuosly, it returned false only when the dependency is actually a
stub variant of a lib. Now, it returns false when the dependency has one
or more stub variants. To understand why, we need to recall that when
there is a dependency to a lib having stubs, we actually create two
dependencies: to the non-stub variant and to the stub variant during the
DepsMutator phase. And later in the build action generation phase, we
choose one of them depending on the context. Also recall that an APEX
variant is created only when DepIsInSameApex returns true. Given these,
with the previous implementatin of DepIsInSameApex, we did create apex
variants of the non-stub variant of the dependency, while not creating
the apex variant for the stub variant. This is not right; we needlessly
created the apex variant. The extra apex variant has caused no harm so
far, but since the apex_available check became more correct, it actually
breaks the build. To fix the issue, we stop creating the APEX variant
both for non-stub and stub variants.
2) platform variant is created regardless of the apex_available value.
This is required for the case when a library X that provides stub is in
an APEX A and is configured to be available only for A. In that case,
libs in other APEX can't use the stub library since the stub library is
mutated only for apex A. By creating the platform variant for the stub
library, it can be used from outside as the default dependency variation
is set to the platform variant when creating the APEX variations.
3) The ApexAvailableWhitelist is added with the dependencies that were
revealed with this change.
Exempt-From-Owner-Approval: cherry-pick from internal
Bug: 147671264
Test: m
Merged-In: Iaedc05494085ff4e8af227a6392bdd0c338b8e6e
(cherry picked from commit fa89944c79f19552e906b41fd03a4981903eee7e)
Change-Id: Iaedc05494085ff4e8af227a6392bdd0c338b8e6e
2020-01-31 01:49:53 +08:00
|
|
|
java_header_libs: ["sdkmember"],
|
2019-12-03 23:25:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
sdk_snapshot {
|
|
|
|
name: "mysdk@1",
|
2019-12-05 19:25:53 +08:00
|
|
|
java_header_libs: ["sdkmember_mysdk_1"],
|
2019-12-03 23:25:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
sdk_snapshot {
|
|
|
|
name: "mysdk@2",
|
2019-12-05 19:25:53 +08:00
|
|
|
java_header_libs: ["sdkmember_mysdk_2"],
|
2019-12-03 23:25:00 +08:00
|
|
|
}
|
|
|
|
|
apex_available tracks static dependencies
This change fixes a bug that apex_available is not enforced for static
dependencies. For example, a module with 'apex_available:
["//apex_available:platform"]' was able to be statically linked to any
APEX. This was happening because the check was done on the modules that
are actually installed to an APEX. Static dependencies of the modules
were not counted as they are not installed to the APEX as files.
Fixing this bug by doing the check by traversing the tree in the method
checkApexAvailability.
This change includes a few number of related changes:
1) DepIsInSameApex implementation for cc.Module was changed as well.
Previuosly, it returned false only when the dependency is actually a
stub variant of a lib. Now, it returns false when the dependency has one
or more stub variants. To understand why, we need to recall that when
there is a dependency to a lib having stubs, we actually create two
dependencies: to the non-stub variant and to the stub variant during the
DepsMutator phase. And later in the build action generation phase, we
choose one of them depending on the context. Also recall that an APEX
variant is created only when DepIsInSameApex returns true. Given these,
with the previous implementatin of DepIsInSameApex, we did create apex
variants of the non-stub variant of the dependency, while not creating
the apex variant for the stub variant. This is not right; we needlessly
created the apex variant. The extra apex variant has caused no harm so
far, but since the apex_available check became more correct, it actually
breaks the build. To fix the issue, we stop creating the APEX variant
both for non-stub and stub variants.
2) platform variant is created regardless of the apex_available value.
This is required for the case when a library X that provides stub is in
an APEX A and is configured to be available only for A. In that case,
libs in other APEX can't use the stub library since the stub library is
mutated only for apex A. By creating the platform variant for the stub
library, it can be used from outside as the default dependency variation
is set to the platform variant when creating the APEX variations.
3) The ApexAvailableWhitelist is added with the dependencies that were
revealed with this change.
Exempt-From-Owner-Approval: cherry-pick from internal
Bug: 147671264
Test: m
Merged-In: Iaedc05494085ff4e8af227a6392bdd0c338b8e6e
(cherry picked from commit fa89944c79f19552e906b41fd03a4981903eee7e)
Change-Id: Iaedc05494085ff4e8af227a6392bdd0c338b8e6e
2020-01-31 01:49:53 +08:00
|
|
|
java_library {
|
2019-12-03 23:25:00 +08:00
|
|
|
name: "sdkmember",
|
apex_available tracks static dependencies
This change fixes a bug that apex_available is not enforced for static
dependencies. For example, a module with 'apex_available:
["//apex_available:platform"]' was able to be statically linked to any
APEX. This was happening because the check was done on the modules that
are actually installed to an APEX. Static dependencies of the modules
were not counted as they are not installed to the APEX as files.
Fixing this bug by doing the check by traversing the tree in the method
checkApexAvailability.
This change includes a few number of related changes:
1) DepIsInSameApex implementation for cc.Module was changed as well.
Previuosly, it returned false only when the dependency is actually a
stub variant of a lib. Now, it returns false when the dependency has one
or more stub variants. To understand why, we need to recall that when
there is a dependency to a lib having stubs, we actually create two
dependencies: to the non-stub variant and to the stub variant during the
DepsMutator phase. And later in the build action generation phase, we
choose one of them depending on the context. Also recall that an APEX
variant is created only when DepIsInSameApex returns true. Given these,
with the previous implementatin of DepIsInSameApex, we did create apex
variants of the non-stub variant of the dependency, while not creating
the apex variant for the stub variant. This is not right; we needlessly
created the apex variant. The extra apex variant has caused no harm so
far, but since the apex_available check became more correct, it actually
breaks the build. To fix the issue, we stop creating the APEX variant
both for non-stub and stub variants.
2) platform variant is created regardless of the apex_available value.
This is required for the case when a library X that provides stub is in
an APEX A and is configured to be available only for A. In that case,
libs in other APEX can't use the stub library since the stub library is
mutated only for apex A. By creating the platform variant for the stub
library, it can be used from outside as the default dependency variation
is set to the platform variant when creating the APEX variations.
3) The ApexAvailableWhitelist is added with the dependencies that were
revealed with this change.
Exempt-From-Owner-Approval: cherry-pick from internal
Bug: 147671264
Test: m
Merged-In: Iaedc05494085ff4e8af227a6392bdd0c338b8e6e
(cherry picked from commit fa89944c79f19552e906b41fd03a4981903eee7e)
Change-Id: Iaedc05494085ff4e8af227a6392bdd0c338b8e6e
2020-01-31 01:49:53 +08:00
|
|
|
srcs: ["Test.java"],
|
|
|
|
system_modules: "none",
|
|
|
|
sdk_version: "none",
|
2019-12-03 23:25:00 +08:00
|
|
|
host_supported: true,
|
apex_available tracks static dependencies
This change fixes a bug that apex_available is not enforced for static
dependencies. For example, a module with 'apex_available:
["//apex_available:platform"]' was able to be statically linked to any
APEX. This was happening because the check was done on the modules that
are actually installed to an APEX. Static dependencies of the modules
were not counted as they are not installed to the APEX as files.
Fixing this bug by doing the check by traversing the tree in the method
checkApexAvailability.
This change includes a few number of related changes:
1) DepIsInSameApex implementation for cc.Module was changed as well.
Previuosly, it returned false only when the dependency is actually a
stub variant of a lib. Now, it returns false when the dependency has one
or more stub variants. To understand why, we need to recall that when
there is a dependency to a lib having stubs, we actually create two
dependencies: to the non-stub variant and to the stub variant during the
DepsMutator phase. And later in the build action generation phase, we
choose one of them depending on the context. Also recall that an APEX
variant is created only when DepIsInSameApex returns true. Given these,
with the previous implementatin of DepIsInSameApex, we did create apex
variants of the non-stub variant of the dependency, while not creating
the apex variant for the stub variant. This is not right; we needlessly
created the apex variant. The extra apex variant has caused no harm so
far, but since the apex_available check became more correct, it actually
breaks the build. To fix the issue, we stop creating the APEX variant
both for non-stub and stub variants.
2) platform variant is created regardless of the apex_available value.
This is required for the case when a library X that provides stub is in
an APEX A and is configured to be available only for A. In that case,
libs in other APEX can't use the stub library since the stub library is
mutated only for apex A. By creating the platform variant for the stub
library, it can be used from outside as the default dependency variation
is set to the platform variant when creating the APEX variations.
3) The ApexAvailableWhitelist is added with the dependencies that were
revealed with this change.
Exempt-From-Owner-Approval: cherry-pick from internal
Bug: 147671264
Test: m
Merged-In: Iaedc05494085ff4e8af227a6392bdd0c338b8e6e
(cherry picked from commit fa89944c79f19552e906b41fd03a4981903eee7e)
Change-Id: Iaedc05494085ff4e8af227a6392bdd0c338b8e6e
2020-01-31 01:49:53 +08:00
|
|
|
apex_available: [
|
|
|
|
"//apex_available:platform",
|
|
|
|
"//apex_available:anyapex",
|
|
|
|
],
|
2019-12-03 23:25:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
java_import {
|
|
|
|
name: "sdkmember_mysdk_1",
|
|
|
|
sdk_member_name: "sdkmember",
|
|
|
|
host_supported: true,
|
apex_available tracks static dependencies
This change fixes a bug that apex_available is not enforced for static
dependencies. For example, a module with 'apex_available:
["//apex_available:platform"]' was able to be statically linked to any
APEX. This was happening because the check was done on the modules that
are actually installed to an APEX. Static dependencies of the modules
were not counted as they are not installed to the APEX as files.
Fixing this bug by doing the check by traversing the tree in the method
checkApexAvailability.
This change includes a few number of related changes:
1) DepIsInSameApex implementation for cc.Module was changed as well.
Previuosly, it returned false only when the dependency is actually a
stub variant of a lib. Now, it returns false when the dependency has one
or more stub variants. To understand why, we need to recall that when
there is a dependency to a lib having stubs, we actually create two
dependencies: to the non-stub variant and to the stub variant during the
DepsMutator phase. And later in the build action generation phase, we
choose one of them depending on the context. Also recall that an APEX
variant is created only when DepIsInSameApex returns true. Given these,
with the previous implementatin of DepIsInSameApex, we did create apex
variants of the non-stub variant of the dependency, while not creating
the apex variant for the stub variant. This is not right; we needlessly
created the apex variant. The extra apex variant has caused no harm so
far, but since the apex_available check became more correct, it actually
breaks the build. To fix the issue, we stop creating the APEX variant
both for non-stub and stub variants.
2) platform variant is created regardless of the apex_available value.
This is required for the case when a library X that provides stub is in
an APEX A and is configured to be available only for A. In that case,
libs in other APEX can't use the stub library since the stub library is
mutated only for apex A. By creating the platform variant for the stub
library, it can be used from outside as the default dependency variation
is set to the platform variant when creating the APEX variations.
3) The ApexAvailableWhitelist is added with the dependencies that were
revealed with this change.
Exempt-From-Owner-Approval: cherry-pick from internal
Bug: 147671264
Test: m
Merged-In: Iaedc05494085ff4e8af227a6392bdd0c338b8e6e
(cherry picked from commit fa89944c79f19552e906b41fd03a4981903eee7e)
Change-Id: Iaedc05494085ff4e8af227a6392bdd0c338b8e6e
2020-01-31 01:49:53 +08:00
|
|
|
apex_available: [
|
|
|
|
"//apex_available:platform",
|
|
|
|
"//apex_available:anyapex",
|
|
|
|
],
|
2019-12-03 23:25:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
java_import {
|
|
|
|
name: "sdkmember_mysdk_2",
|
|
|
|
sdk_member_name: "sdkmember",
|
|
|
|
host_supported: true,
|
apex_available tracks static dependencies
This change fixes a bug that apex_available is not enforced for static
dependencies. For example, a module with 'apex_available:
["//apex_available:platform"]' was able to be statically linked to any
APEX. This was happening because the check was done on the modules that
are actually installed to an APEX. Static dependencies of the modules
were not counted as they are not installed to the APEX as files.
Fixing this bug by doing the check by traversing the tree in the method
checkApexAvailability.
This change includes a few number of related changes:
1) DepIsInSameApex implementation for cc.Module was changed as well.
Previuosly, it returned false only when the dependency is actually a
stub variant of a lib. Now, it returns false when the dependency has one
or more stub variants. To understand why, we need to recall that when
there is a dependency to a lib having stubs, we actually create two
dependencies: to the non-stub variant and to the stub variant during the
DepsMutator phase. And later in the build action generation phase, we
choose one of them depending on the context. Also recall that an APEX
variant is created only when DepIsInSameApex returns true. Given these,
with the previous implementatin of DepIsInSameApex, we did create apex
variants of the non-stub variant of the dependency, while not creating
the apex variant for the stub variant. This is not right; we needlessly
created the apex variant. The extra apex variant has caused no harm so
far, but since the apex_available check became more correct, it actually
breaks the build. To fix the issue, we stop creating the APEX variant
both for non-stub and stub variants.
2) platform variant is created regardless of the apex_available value.
This is required for the case when a library X that provides stub is in
an APEX A and is configured to be available only for A. In that case,
libs in other APEX can't use the stub library since the stub library is
mutated only for apex A. By creating the platform variant for the stub
library, it can be used from outside as the default dependency variation
is set to the platform variant when creating the APEX variations.
3) The ApexAvailableWhitelist is added with the dependencies that were
revealed with this change.
Exempt-From-Owner-Approval: cherry-pick from internal
Bug: 147671264
Test: m
Merged-In: Iaedc05494085ff4e8af227a6392bdd0c338b8e6e
(cherry picked from commit fa89944c79f19552e906b41fd03a4981903eee7e)
Change-Id: Iaedc05494085ff4e8af227a6392bdd0c338b8e6e
2020-01-31 01:49:53 +08:00
|
|
|
apex_available: [
|
|
|
|
"//apex_available:platform",
|
|
|
|
"//apex_available:anyapex",
|
|
|
|
],
|
2019-12-03 23:25:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
java_library {
|
|
|
|
name: "myjavalib",
|
|
|
|
srcs: ["Test.java"],
|
|
|
|
libs: ["sdkmember"],
|
|
|
|
system_modules: "none",
|
|
|
|
sdk_version: "none",
|
|
|
|
compile_dex: true,
|
|
|
|
host_supported: true,
|
2020-01-10 23:12:39 +08:00
|
|
|
apex_available: [
|
|
|
|
"myapex",
|
|
|
|
"myapex2",
|
|
|
|
],
|
2019-12-03 23:25:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
apex {
|
|
|
|
name: "myapex",
|
|
|
|
java_libs: ["myjavalib"],
|
|
|
|
uses_sdks: ["mysdk@1"],
|
|
|
|
key: "myapex.key",
|
|
|
|
certificate: ":myapex.cert",
|
|
|
|
}
|
|
|
|
|
|
|
|
apex {
|
|
|
|
name: "myapex2",
|
|
|
|
java_libs: ["myjavalib"],
|
|
|
|
uses_sdks: ["mysdk@2"],
|
|
|
|
key: "myapex.key",
|
|
|
|
certificate: ":myapex.cert",
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
sdkMemberV1 := result.ctx.ModuleForTests("sdkmember_mysdk_1", "android_common_myapex").Rule("combineJar").Output
|
|
|
|
sdkMemberV2 := result.ctx.ModuleForTests("sdkmember_mysdk_2", "android_common_myapex2").Rule("combineJar").Output
|
|
|
|
|
|
|
|
javalibForMyApex := result.ctx.ModuleForTests("myjavalib", "android_common_myapex")
|
|
|
|
javalibForMyApex2 := result.ctx.ModuleForTests("myjavalib", "android_common_myapex2")
|
|
|
|
|
|
|
|
// Depending on the uses_sdks value, different libs are linked
|
|
|
|
ensureListContains(t, pathsToStrings(javalibForMyApex.Rule("javac").Implicits), sdkMemberV1.String())
|
|
|
|
ensureListContains(t, pathsToStrings(javalibForMyApex2.Rule("javac").Implicits), sdkMemberV2.String())
|
|
|
|
}
|
|
|
|
|
2019-12-05 19:25:53 +08:00
|
|
|
func TestSnapshotWithJavaHeaderLibrary(t *testing.T) {
|
|
|
|
result := testSdkWithJava(t, `
|
|
|
|
sdk {
|
|
|
|
name: "mysdk",
|
|
|
|
java_header_libs: ["myjavalib"],
|
|
|
|
}
|
|
|
|
|
|
|
|
java_library {
|
|
|
|
name: "myjavalib",
|
|
|
|
srcs: ["Test.java"],
|
|
|
|
aidl: {
|
|
|
|
export_include_dirs: ["aidl"],
|
|
|
|
},
|
|
|
|
system_modules: "none",
|
|
|
|
sdk_version: "none",
|
|
|
|
compile_dex: true,
|
|
|
|
host_supported: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
2019-12-05 22:31:48 +08:00
|
|
|
result.CheckSnapshot("mysdk", "android_common", "",
|
2019-12-05 19:25:53 +08:00
|
|
|
checkAndroidBpContents(`
|
|
|
|
// This is auto-generated. DO NOT EDIT.
|
|
|
|
|
|
|
|
java_import {
|
|
|
|
name: "mysdk_myjavalib@current",
|
|
|
|
sdk_member_name: "myjavalib",
|
|
|
|
jars: ["java/myjavalib.jar"],
|
|
|
|
}
|
|
|
|
|
|
|
|
java_import {
|
|
|
|
name: "myjavalib",
|
|
|
|
prefer: false,
|
|
|
|
jars: ["java/myjavalib.jar"],
|
|
|
|
}
|
|
|
|
|
|
|
|
sdk_snapshot {
|
|
|
|
name: "mysdk@current",
|
|
|
|
java_header_libs: ["mysdk_myjavalib@current"],
|
|
|
|
}
|
|
|
|
|
|
|
|
`),
|
|
|
|
checkAllCopyRules(`
|
|
|
|
.intermediates/myjavalib/android_common/turbine-combined/myjavalib.jar -> java/myjavalib.jar
|
|
|
|
aidl/foo/bar/Test.aidl -> aidl/aidl/foo/bar/Test.aidl
|
|
|
|
`),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestHostSnapshotWithJavaHeaderLibrary(t *testing.T) {
|
|
|
|
// b/145598135 - Generating host snapshots for anything other than linux is not supported.
|
|
|
|
SkipIfNotLinux(t)
|
|
|
|
|
|
|
|
result := testSdkWithJava(t, `
|
|
|
|
sdk {
|
|
|
|
name: "mysdk",
|
|
|
|
device_supported: false,
|
|
|
|
host_supported: true,
|
|
|
|
java_header_libs: ["myjavalib"],
|
|
|
|
}
|
|
|
|
|
|
|
|
java_library {
|
|
|
|
name: "myjavalib",
|
|
|
|
device_supported: false,
|
|
|
|
host_supported: true,
|
|
|
|
srcs: ["Test.java"],
|
|
|
|
aidl: {
|
|
|
|
export_include_dirs: ["aidl"],
|
|
|
|
},
|
|
|
|
system_modules: "none",
|
|
|
|
sdk_version: "none",
|
|
|
|
compile_dex: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
2019-12-05 22:31:48 +08:00
|
|
|
result.CheckSnapshot("mysdk", "linux_glibc_common", "",
|
2019-12-05 19:25:53 +08:00
|
|
|
checkAndroidBpContents(`
|
|
|
|
// This is auto-generated. DO NOT EDIT.
|
|
|
|
|
|
|
|
java_import {
|
|
|
|
name: "mysdk_myjavalib@current",
|
|
|
|
sdk_member_name: "myjavalib",
|
|
|
|
device_supported: false,
|
|
|
|
host_supported: true,
|
|
|
|
jars: ["java/myjavalib.jar"],
|
|
|
|
}
|
|
|
|
|
|
|
|
java_import {
|
|
|
|
name: "myjavalib",
|
|
|
|
prefer: false,
|
|
|
|
device_supported: false,
|
|
|
|
host_supported: true,
|
|
|
|
jars: ["java/myjavalib.jar"],
|
|
|
|
}
|
|
|
|
|
|
|
|
sdk_snapshot {
|
|
|
|
name: "mysdk@current",
|
|
|
|
device_supported: false,
|
|
|
|
host_supported: true,
|
|
|
|
java_header_libs: ["mysdk_myjavalib@current"],
|
|
|
|
}
|
|
|
|
`),
|
|
|
|
checkAllCopyRules(`
|
|
|
|
.intermediates/myjavalib/linux_glibc_common/javac/myjavalib.jar -> java/myjavalib.jar
|
|
|
|
aidl/foo/bar/Test.aidl -> aidl/aidl/foo/bar/Test.aidl
|
|
|
|
`),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSnapshotWithJavaImplLibrary(t *testing.T) {
|
2019-12-01 01:49:09 +08:00
|
|
|
result := testSdkWithJava(t, `
|
2019-12-17 01:43:48 +08:00
|
|
|
module_exports {
|
|
|
|
name: "myexports",
|
2019-12-03 23:25:00 +08:00
|
|
|
java_libs: ["myjavalib"],
|
|
|
|
}
|
|
|
|
|
|
|
|
java_library {
|
|
|
|
name: "myjavalib",
|
|
|
|
srcs: ["Test.java"],
|
|
|
|
aidl: {
|
|
|
|
export_include_dirs: ["aidl"],
|
|
|
|
},
|
|
|
|
system_modules: "none",
|
|
|
|
sdk_version: "none",
|
|
|
|
compile_dex: true,
|
|
|
|
host_supported: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
2019-12-17 01:43:48 +08:00
|
|
|
result.CheckSnapshot("myexports", "android_common", "",
|
2019-12-03 23:25:00 +08:00
|
|
|
checkAndroidBpContents(`
|
|
|
|
// This is auto-generated. DO NOT EDIT.
|
|
|
|
|
|
|
|
java_import {
|
2019-12-17 01:43:48 +08:00
|
|
|
name: "myexports_myjavalib@current",
|
2019-12-03 23:25:00 +08:00
|
|
|
sdk_member_name: "myjavalib",
|
|
|
|
jars: ["java/myjavalib.jar"],
|
|
|
|
}
|
|
|
|
|
|
|
|
java_import {
|
|
|
|
name: "myjavalib",
|
|
|
|
prefer: false,
|
|
|
|
jars: ["java/myjavalib.jar"],
|
|
|
|
}
|
|
|
|
|
2019-12-17 01:43:48 +08:00
|
|
|
module_exports_snapshot {
|
|
|
|
name: "myexports@current",
|
|
|
|
java_libs: ["myexports_myjavalib@current"],
|
2019-12-03 23:25:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
`),
|
|
|
|
checkAllCopyRules(`
|
2019-12-05 19:25:53 +08:00
|
|
|
.intermediates/myjavalib/android_common/javac/myjavalib.jar -> java/myjavalib.jar
|
2019-12-03 23:25:00 +08:00
|
|
|
aidl/foo/bar/Test.aidl -> aidl/aidl/foo/bar/Test.aidl
|
|
|
|
`),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2019-12-05 19:25:53 +08:00
|
|
|
func TestHostSnapshotWithJavaImplLibrary(t *testing.T) {
|
2019-12-03 23:25:00 +08:00
|
|
|
// b/145598135 - Generating host snapshots for anything other than linux is not supported.
|
|
|
|
SkipIfNotLinux(t)
|
|
|
|
|
2019-12-01 01:49:09 +08:00
|
|
|
result := testSdkWithJava(t, `
|
2019-12-17 01:43:48 +08:00
|
|
|
module_exports {
|
|
|
|
name: "myexports",
|
2019-12-03 23:25:00 +08:00
|
|
|
device_supported: false,
|
|
|
|
host_supported: true,
|
|
|
|
java_libs: ["myjavalib"],
|
|
|
|
}
|
|
|
|
|
|
|
|
java_library {
|
|
|
|
name: "myjavalib",
|
|
|
|
device_supported: false,
|
|
|
|
host_supported: true,
|
|
|
|
srcs: ["Test.java"],
|
|
|
|
aidl: {
|
|
|
|
export_include_dirs: ["aidl"],
|
|
|
|
},
|
|
|
|
system_modules: "none",
|
|
|
|
sdk_version: "none",
|
|
|
|
compile_dex: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
2019-12-17 01:43:48 +08:00
|
|
|
result.CheckSnapshot("myexports", "linux_glibc_common", "",
|
2019-12-03 23:25:00 +08:00
|
|
|
checkAndroidBpContents(`
|
|
|
|
// This is auto-generated. DO NOT EDIT.
|
|
|
|
|
|
|
|
java_import {
|
2019-12-17 01:43:48 +08:00
|
|
|
name: "myexports_myjavalib@current",
|
2019-12-03 23:25:00 +08:00
|
|
|
sdk_member_name: "myjavalib",
|
|
|
|
device_supported: false,
|
|
|
|
host_supported: true,
|
|
|
|
jars: ["java/myjavalib.jar"],
|
|
|
|
}
|
|
|
|
|
|
|
|
java_import {
|
|
|
|
name: "myjavalib",
|
|
|
|
prefer: false,
|
|
|
|
device_supported: false,
|
|
|
|
host_supported: true,
|
|
|
|
jars: ["java/myjavalib.jar"],
|
|
|
|
}
|
|
|
|
|
2019-12-17 01:43:48 +08:00
|
|
|
module_exports_snapshot {
|
|
|
|
name: "myexports@current",
|
2019-12-03 23:25:00 +08:00
|
|
|
device_supported: false,
|
|
|
|
host_supported: true,
|
2019-12-17 01:43:48 +08:00
|
|
|
java_libs: ["myexports_myjavalib@current"],
|
2019-12-03 23:25:00 +08:00
|
|
|
}
|
|
|
|
`),
|
|
|
|
checkAllCopyRules(`
|
|
|
|
.intermediates/myjavalib/linux_glibc_common/javac/myjavalib.jar -> java/myjavalib.jar
|
|
|
|
aidl/foo/bar/Test.aidl -> aidl/aidl/foo/bar/Test.aidl
|
|
|
|
`),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2019-12-04 02:06:47 +08:00
|
|
|
func TestSnapshotWithJavaTest(t *testing.T) {
|
|
|
|
result := testSdkWithJava(t, `
|
|
|
|
module_exports {
|
|
|
|
name: "myexports",
|
|
|
|
java_tests: ["myjavatests"],
|
|
|
|
}
|
|
|
|
|
|
|
|
java_test {
|
|
|
|
name: "myjavatests",
|
|
|
|
srcs: ["Test.java"],
|
|
|
|
system_modules: "none",
|
|
|
|
sdk_version: "none",
|
|
|
|
compile_dex: true,
|
|
|
|
host_supported: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
result.CheckSnapshot("myexports", "android_common", "",
|
|
|
|
checkAndroidBpContents(`
|
|
|
|
// This is auto-generated. DO NOT EDIT.
|
|
|
|
|
|
|
|
java_test_import {
|
|
|
|
name: "myexports_myjavatests@current",
|
|
|
|
sdk_member_name: "myjavatests",
|
|
|
|
jars: ["java/myjavatests.jar"],
|
|
|
|
test_config: "java/myjavatests-AndroidTest.xml",
|
|
|
|
}
|
|
|
|
|
|
|
|
java_test_import {
|
|
|
|
name: "myjavatests",
|
|
|
|
prefer: false,
|
|
|
|
jars: ["java/myjavatests.jar"],
|
|
|
|
test_config: "java/myjavatests-AndroidTest.xml",
|
|
|
|
}
|
|
|
|
|
|
|
|
module_exports_snapshot {
|
|
|
|
name: "myexports@current",
|
|
|
|
java_tests: ["myexports_myjavatests@current"],
|
|
|
|
}
|
|
|
|
`),
|
|
|
|
checkAllCopyRules(`
|
|
|
|
.intermediates/myjavatests/android_common/javac/myjavatests.jar -> java/myjavatests.jar
|
|
|
|
.intermediates/myjavatests/android_common/myjavatests.config -> java/myjavatests-AndroidTest.xml
|
|
|
|
`),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestHostSnapshotWithJavaTest(t *testing.T) {
|
|
|
|
// b/145598135 - Generating host snapshots for anything other than linux is not supported.
|
|
|
|
SkipIfNotLinux(t)
|
|
|
|
|
|
|
|
result := testSdkWithJava(t, `
|
|
|
|
module_exports {
|
|
|
|
name: "myexports",
|
|
|
|
device_supported: false,
|
|
|
|
host_supported: true,
|
|
|
|
java_tests: ["myjavatests"],
|
|
|
|
}
|
|
|
|
|
|
|
|
java_test {
|
|
|
|
name: "myjavatests",
|
|
|
|
device_supported: false,
|
|
|
|
host_supported: true,
|
|
|
|
srcs: ["Test.java"],
|
|
|
|
system_modules: "none",
|
|
|
|
sdk_version: "none",
|
|
|
|
compile_dex: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
result.CheckSnapshot("myexports", "linux_glibc_common", "",
|
|
|
|
checkAndroidBpContents(`
|
|
|
|
// This is auto-generated. DO NOT EDIT.
|
|
|
|
|
|
|
|
java_test_import {
|
|
|
|
name: "myexports_myjavatests@current",
|
|
|
|
sdk_member_name: "myjavatests",
|
|
|
|
device_supported: false,
|
|
|
|
host_supported: true,
|
|
|
|
jars: ["java/myjavatests.jar"],
|
|
|
|
test_config: "java/myjavatests-AndroidTest.xml",
|
|
|
|
}
|
|
|
|
|
|
|
|
java_test_import {
|
|
|
|
name: "myjavatests",
|
|
|
|
prefer: false,
|
|
|
|
device_supported: false,
|
|
|
|
host_supported: true,
|
|
|
|
jars: ["java/myjavatests.jar"],
|
|
|
|
test_config: "java/myjavatests-AndroidTest.xml",
|
|
|
|
}
|
|
|
|
|
|
|
|
module_exports_snapshot {
|
|
|
|
name: "myexports@current",
|
|
|
|
device_supported: false,
|
|
|
|
host_supported: true,
|
|
|
|
java_tests: ["myexports_myjavatests@current"],
|
|
|
|
}
|
|
|
|
`),
|
|
|
|
checkAllCopyRules(`
|
|
|
|
.intermediates/myjavatests/linux_glibc_common/javac/myjavatests.jar -> java/myjavatests.jar
|
|
|
|
.intermediates/myjavatests/linux_glibc_common/myjavatests.config -> java/myjavatests-AndroidTest.xml
|
|
|
|
`),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2019-12-01 01:49:09 +08:00
|
|
|
func testSdkWithDroidstubs(t *testing.T, bp string) *testSdkResult {
|
|
|
|
t.Helper()
|
|
|
|
|
|
|
|
fs := map[string][]byte{
|
|
|
|
"foo/bar/Foo.java": nil,
|
|
|
|
"stubs-sources/foo/bar/Foo.java": nil,
|
|
|
|
}
|
|
|
|
return testSdkWithFs(t, bp, fs)
|
|
|
|
}
|
|
|
|
|
2019-12-03 23:25:00 +08:00
|
|
|
// Note: This test does not verify that a droidstubs can be referenced, either
|
|
|
|
// directly or indirectly from an APEX as droidstubs can never be a part of an
|
|
|
|
// apex.
|
|
|
|
func TestBasicSdkWithDroidstubs(t *testing.T) {
|
2019-12-01 01:49:09 +08:00
|
|
|
testSdkWithDroidstubs(t, `
|
2019-12-03 23:25:00 +08:00
|
|
|
sdk {
|
|
|
|
name: "mysdk",
|
|
|
|
stubs_sources: ["mystub"],
|
|
|
|
}
|
|
|
|
sdk_snapshot {
|
|
|
|
name: "mysdk@10",
|
|
|
|
stubs_sources: ["mystub_mysdk@10"],
|
|
|
|
}
|
|
|
|
prebuilt_stubs_sources {
|
|
|
|
name: "mystub_mysdk@10",
|
|
|
|
sdk_member_name: "mystub",
|
|
|
|
srcs: ["stubs-sources/foo/bar/Foo.java"],
|
|
|
|
}
|
|
|
|
droidstubs {
|
|
|
|
name: "mystub",
|
|
|
|
srcs: ["foo/bar/Foo.java"],
|
|
|
|
sdk_version: "none",
|
|
|
|
system_modules: "none",
|
|
|
|
}
|
|
|
|
java_library {
|
|
|
|
name: "myjavalib",
|
|
|
|
srcs: [":mystub"],
|
|
|
|
sdk_version: "none",
|
|
|
|
system_modules: "none",
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSnapshotWithDroidstubs(t *testing.T) {
|
2019-12-01 01:49:09 +08:00
|
|
|
result := testSdkWithDroidstubs(t, `
|
2019-12-17 01:43:48 +08:00
|
|
|
module_exports {
|
|
|
|
name: "myexports",
|
2019-12-03 23:25:00 +08:00
|
|
|
stubs_sources: ["myjavaapistubs"],
|
|
|
|
}
|
|
|
|
|
|
|
|
droidstubs {
|
|
|
|
name: "myjavaapistubs",
|
|
|
|
srcs: ["foo/bar/Foo.java"],
|
|
|
|
system_modules: "none",
|
|
|
|
sdk_version: "none",
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
2019-12-17 01:43:48 +08:00
|
|
|
result.CheckSnapshot("myexports", "android_common", "",
|
2019-12-03 23:25:00 +08:00
|
|
|
checkAndroidBpContents(`
|
|
|
|
// This is auto-generated. DO NOT EDIT.
|
|
|
|
|
|
|
|
prebuilt_stubs_sources {
|
2019-12-17 01:43:48 +08:00
|
|
|
name: "myexports_myjavaapistubs@current",
|
2019-12-03 23:25:00 +08:00
|
|
|
sdk_member_name: "myjavaapistubs",
|
|
|
|
srcs: ["java/myjavaapistubs_stubs_sources"],
|
|
|
|
}
|
|
|
|
|
|
|
|
prebuilt_stubs_sources {
|
|
|
|
name: "myjavaapistubs",
|
|
|
|
prefer: false,
|
|
|
|
srcs: ["java/myjavaapistubs_stubs_sources"],
|
|
|
|
}
|
|
|
|
|
2019-12-17 01:43:48 +08:00
|
|
|
module_exports_snapshot {
|
|
|
|
name: "myexports@current",
|
|
|
|
stubs_sources: ["myexports_myjavaapistubs@current"],
|
2019-12-03 23:25:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
`),
|
|
|
|
checkAllCopyRules(""),
|
2019-12-17 01:43:48 +08:00
|
|
|
checkMergeZip(".intermediates/myexports/android_common/tmp/java/myjavaapistubs_stubs_sources.zip"),
|
2019-12-03 23:25:00 +08:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestHostSnapshotWithDroidstubs(t *testing.T) {
|
|
|
|
// b/145598135 - Generating host snapshots for anything other than linux is not supported.
|
|
|
|
SkipIfNotLinux(t)
|
|
|
|
|
2019-12-01 01:49:09 +08:00
|
|
|
result := testSdkWithDroidstubs(t, `
|
2019-12-17 01:43:48 +08:00
|
|
|
module_exports {
|
|
|
|
name: "myexports",
|
2019-12-03 23:25:00 +08:00
|
|
|
device_supported: false,
|
|
|
|
host_supported: true,
|
|
|
|
stubs_sources: ["myjavaapistubs"],
|
|
|
|
}
|
|
|
|
|
|
|
|
droidstubs {
|
|
|
|
name: "myjavaapistubs",
|
|
|
|
device_supported: false,
|
|
|
|
host_supported: true,
|
|
|
|
srcs: ["foo/bar/Foo.java"],
|
|
|
|
system_modules: "none",
|
|
|
|
sdk_version: "none",
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
2019-12-17 01:43:48 +08:00
|
|
|
result.CheckSnapshot("myexports", "linux_glibc_common", "",
|
2019-12-03 23:25:00 +08:00
|
|
|
checkAndroidBpContents(`
|
|
|
|
// This is auto-generated. DO NOT EDIT.
|
|
|
|
|
|
|
|
prebuilt_stubs_sources {
|
2019-12-17 01:43:48 +08:00
|
|
|
name: "myexports_myjavaapistubs@current",
|
2019-12-03 23:25:00 +08:00
|
|
|
sdk_member_name: "myjavaapistubs",
|
|
|
|
device_supported: false,
|
|
|
|
host_supported: true,
|
|
|
|
srcs: ["java/myjavaapistubs_stubs_sources"],
|
|
|
|
}
|
|
|
|
|
|
|
|
prebuilt_stubs_sources {
|
|
|
|
name: "myjavaapistubs",
|
|
|
|
prefer: false,
|
|
|
|
device_supported: false,
|
|
|
|
host_supported: true,
|
|
|
|
srcs: ["java/myjavaapistubs_stubs_sources"],
|
|
|
|
}
|
|
|
|
|
2019-12-17 01:43:48 +08:00
|
|
|
module_exports_snapshot {
|
|
|
|
name: "myexports@current",
|
2019-12-03 23:25:00 +08:00
|
|
|
device_supported: false,
|
|
|
|
host_supported: true,
|
2019-12-17 01:43:48 +08:00
|
|
|
stubs_sources: ["myexports_myjavaapistubs@current"],
|
2019-12-03 23:25:00 +08:00
|
|
|
}
|
|
|
|
`),
|
|
|
|
checkAllCopyRules(""),
|
2019-12-17 01:43:48 +08:00
|
|
|
checkMergeZip(".intermediates/myexports/linux_glibc_common/tmp/java/myjavaapistubs_stubs_sources.zip"),
|
2019-12-03 23:25:00 +08:00
|
|
|
)
|
|
|
|
}
|