bp2build: migrate export_{,system_}include_dirs -> *includes for cc_prebuilt_library{,_static,_shared}
Migrate `export_include_dirs` property to attribute `export_includes`, handling arch/os-variants Migrate `export_system_include_dirs` property to attribute `export_system_includes`, handling arch/os-variants Test: cc_prebuilt_library_{,shared_,static_}conversion_test.go Test: mixed_droid.sh Bug: 229374533 Change-Id: I658a336a71265af0545c1c2db1a4f6eb613a7366
This commit is contained in:
parent
3848896584
commit
c641cc496b
5 changed files with 489 additions and 30 deletions
|
@ -36,6 +36,7 @@ func registerCcLibrarySharedModuleTypes(ctx android.RegistrationContext) {
|
|||
|
||||
func runCcLibrarySharedTestCase(t *testing.T, tc Bp2buildTestCase) {
|
||||
t.Helper()
|
||||
t.Parallel()
|
||||
(&tc).ModuleTypeUnderTest = "cc_library_shared"
|
||||
(&tc).ModuleTypeUnderTestFactory = cc.LibrarySharedFactory
|
||||
RunBp2BuildTestCase(t, registerCcLibrarySharedModuleTypes, tc)
|
||||
|
|
|
@ -20,12 +20,17 @@ import (
|
|||
"android/soong/cc"
|
||||
)
|
||||
|
||||
func runCcPrebuiltLibraryTestCase(t *testing.T, tc Bp2buildTestCase) {
|
||||
t.Helper()
|
||||
(&tc).ModuleTypeUnderTest = "cc_prebuilt_library"
|
||||
(&tc).ModuleTypeUnderTestFactory = cc.PrebuiltLibraryFactory
|
||||
RunBp2BuildTestCaseSimple(t, tc)
|
||||
}
|
||||
|
||||
func TestPrebuiltLibraryStaticAndSharedSimple(t *testing.T) {
|
||||
RunBp2BuildTestCaseSimple(t,
|
||||
runCcPrebuiltLibraryTestCase(t,
|
||||
Bp2buildTestCase{
|
||||
Description: "prebuilt library static and shared simple",
|
||||
ModuleTypeUnderTest: "cc_prebuilt_library",
|
||||
ModuleTypeUnderTestFactory: cc.PrebuiltLibraryFactory,
|
||||
Description: "prebuilt library static and shared simple",
|
||||
Filesystem: map[string]string{
|
||||
"libf.so": "",
|
||||
},
|
||||
|
@ -51,11 +56,9 @@ cc_prebuilt_library {
|
|||
}
|
||||
|
||||
func TestPrebuiltLibraryWithArchVariance(t *testing.T) {
|
||||
RunBp2BuildTestCaseSimple(t,
|
||||
runCcPrebuiltLibraryTestCase(t,
|
||||
Bp2buildTestCase{
|
||||
Description: "prebuilt library with arch variance",
|
||||
ModuleTypeUnderTest: "cc_prebuilt_library",
|
||||
ModuleTypeUnderTestFactory: cc.PrebuiltLibraryFactory,
|
||||
Description: "prebuilt library with arch variance",
|
||||
Filesystem: map[string]string{
|
||||
"libf.so": "",
|
||||
"libg.so": "",
|
||||
|
@ -95,11 +98,9 @@ cc_prebuilt_library {
|
|||
}
|
||||
|
||||
func TestPrebuiltLibraryAdditionalAttrs(t *testing.T) {
|
||||
RunBp2BuildTestCaseSimple(t,
|
||||
runCcPrebuiltLibraryTestCase(t,
|
||||
Bp2buildTestCase{
|
||||
Description: "prebuilt library additional attributes",
|
||||
ModuleTypeUnderTest: "cc_prebuilt_library",
|
||||
ModuleTypeUnderTestFactory: cc.PrebuiltLibraryFactory,
|
||||
Description: "prebuilt library additional attributes",
|
||||
Filesystem: map[string]string{
|
||||
"libf.so": "",
|
||||
"testdir/1/include.h": "",
|
||||
|
@ -125,20 +126,19 @@ cc_prebuilt_library {
|
|||
"export_system_includes": `["testdir/2/"]`,
|
||||
"alwayslink": "True",
|
||||
}),
|
||||
// TODO(b/229374533): When fixed, update this test
|
||||
MakeBazelTarget("cc_prebuilt_library_shared", "libtest", AttrNameToString{
|
||||
"shared_library": `"libf.so"`,
|
||||
"shared_library": `"libf.so"`,
|
||||
"export_includes": `["testdir/1/"]`,
|
||||
"export_system_includes": `["testdir/2/"]`,
|
||||
}),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestPrebuiltLibrarySharedStanzaFails(t *testing.T) {
|
||||
RunBp2BuildTestCaseSimple(t,
|
||||
runCcPrebuiltLibraryTestCase(t,
|
||||
Bp2buildTestCase{
|
||||
Description: "prebuilt library with shared stanza fails because multiple sources",
|
||||
ModuleTypeUnderTest: "cc_prebuilt_library",
|
||||
ModuleTypeUnderTestFactory: cc.PrebuiltLibraryFactory,
|
||||
Description: "prebuilt library with shared stanza fails because multiple sources",
|
||||
Filesystem: map[string]string{
|
||||
"libf.so": "",
|
||||
"libg.so": "",
|
||||
|
@ -180,11 +180,9 @@ cc_prebuilt_library {
|
|||
}
|
||||
|
||||
func TestPrebuiltLibrarySharedAndStaticStanzas(t *testing.T) {
|
||||
RunBp2BuildTestCaseSimple(t,
|
||||
runCcPrebuiltLibraryTestCase(t,
|
||||
Bp2buildTestCase{
|
||||
Description: "prebuilt library with both shared and static stanzas",
|
||||
ModuleTypeUnderTest: "cc_prebuilt_library",
|
||||
ModuleTypeUnderTestFactory: cc.PrebuiltLibraryFactory,
|
||||
Description: "prebuilt library with both shared and static stanzas",
|
||||
Filesystem: map[string]string{
|
||||
"libf.so": "",
|
||||
"libg.so": "",
|
||||
|
@ -217,11 +215,9 @@ cc_prebuilt_library {
|
|||
|
||||
// TODO(b/228623543): When this bug is fixed, enable this test
|
||||
//func TestPrebuiltLibraryOnlyShared(t *testing.T) {
|
||||
// RunBp2BuildTestCaseSimple(t,
|
||||
// runCcPrebuiltLibraryTestCase(t,
|
||||
// bp2buildTestCase{
|
||||
// description: "prebuilt library shared only",
|
||||
// moduleTypeUnderTest: "cc_prebuilt_library",
|
||||
// moduleTypeUnderTestFactory: cc.PrebuiltLibraryFactory,
|
||||
// filesystem: map[string]string{
|
||||
// "libf.so": "",
|
||||
// },
|
||||
|
@ -244,11 +240,9 @@ cc_prebuilt_library {
|
|||
|
||||
// TODO(b/228623543): When this bug is fixed, enable this test
|
||||
//func TestPrebuiltLibraryOnlyStatic(t *testing.T) {
|
||||
// RunBp2BuildTestCaseSimple(t,
|
||||
// runCcPrebuiltLibraryTestCase(t,
|
||||
// bp2buildTestCase{
|
||||
// description: "prebuilt library static only",
|
||||
// moduleTypeUnderTest: "cc_prebuilt_library",
|
||||
// moduleTypeUnderTestFactory: cc.PrebuiltLibraryFactory,
|
||||
// filesystem: map[string]string{
|
||||
// "libf.so": "",
|
||||
// },
|
||||
|
@ -272,3 +266,97 @@ cc_prebuilt_library {
|
|||
// },
|
||||
// })
|
||||
//}
|
||||
|
||||
func TestPrebuiltLibraryWithExportIncludesArchVariant(t *testing.T) {
|
||||
runCcPrebuiltLibraryTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_prebuilt_library correctly translates export_includes with arch variance",
|
||||
Filesystem: map[string]string{
|
||||
"libf.so": "",
|
||||
"libg.so": "",
|
||||
},
|
||||
Blueprint: `
|
||||
cc_prebuilt_library {
|
||||
name: "libtest",
|
||||
srcs: ["libf.so"],
|
||||
arch: {
|
||||
arm: { export_include_dirs: ["testdir/1/"], },
|
||||
arm64: { export_include_dirs: ["testdir/2/"], },
|
||||
},
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("cc_prebuilt_library_shared", "libtest", AttrNameToString{
|
||||
"shared_library": `"libf.so"`,
|
||||
"export_includes": `select({
|
||||
"//build/bazel/platforms/arch:arm": ["testdir/1/"],
|
||||
"//build/bazel/platforms/arch:arm64": ["testdir/2/"],
|
||||
"//conditions:default": [],
|
||||
})`,
|
||||
}),
|
||||
MakeBazelTarget("cc_prebuilt_library_static", "libtest_bp2build_cc_library_static", AttrNameToString{
|
||||
"static_library": `"libf.so"`,
|
||||
"export_includes": `select({
|
||||
"//build/bazel/platforms/arch:arm": ["testdir/1/"],
|
||||
"//build/bazel/platforms/arch:arm64": ["testdir/2/"],
|
||||
"//conditions:default": [],
|
||||
})`,
|
||||
}),
|
||||
MakeBazelTarget("cc_prebuilt_library_static", "libtest_bp2build_cc_library_static_alwayslink", AttrNameToString{
|
||||
"alwayslink": "True",
|
||||
"static_library": `"libf.so"`,
|
||||
"export_includes": `select({
|
||||
"//build/bazel/platforms/arch:arm": ["testdir/1/"],
|
||||
"//build/bazel/platforms/arch:arm64": ["testdir/2/"],
|
||||
"//conditions:default": [],
|
||||
})`,
|
||||
}),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestPrebuiltLibraryWithExportSystemIncludesArchVariant(t *testing.T) {
|
||||
runCcPrebuiltLibraryTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_prebuilt_ibrary correctly translates export_system_includes with arch variance",
|
||||
Filesystem: map[string]string{
|
||||
"libf.so": "",
|
||||
"libg.so": "",
|
||||
},
|
||||
Blueprint: `
|
||||
cc_prebuilt_library {
|
||||
name: "libtest",
|
||||
srcs: ["libf.so"],
|
||||
arch: {
|
||||
arm: { export_system_include_dirs: ["testdir/1/"], },
|
||||
arm64: { export_system_include_dirs: ["testdir/2/"], },
|
||||
},
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("cc_prebuilt_library_shared", "libtest", AttrNameToString{
|
||||
"shared_library": `"libf.so"`,
|
||||
"export_system_includes": `select({
|
||||
"//build/bazel/platforms/arch:arm": ["testdir/1/"],
|
||||
"//build/bazel/platforms/arch:arm64": ["testdir/2/"],
|
||||
"//conditions:default": [],
|
||||
})`,
|
||||
}),
|
||||
MakeBazelTarget("cc_prebuilt_library_static", "libtest_bp2build_cc_library_static", AttrNameToString{
|
||||
"static_library": `"libf.so"`,
|
||||
"export_system_includes": `select({
|
||||
"//build/bazel/platforms/arch:arm": ["testdir/1/"],
|
||||
"//build/bazel/platforms/arch:arm64": ["testdir/2/"],
|
||||
"//conditions:default": [],
|
||||
})`,
|
||||
}),
|
||||
MakeBazelTarget("cc_prebuilt_library_static", "libtest_bp2build_cc_library_static_alwayslink", AttrNameToString{
|
||||
"alwayslink": "True",
|
||||
"static_library": `"libf.so"`,
|
||||
"export_system_includes": `select({
|
||||
"//build/bazel/platforms/arch:arm": ["testdir/1/"],
|
||||
"//build/bazel/platforms/arch:arm64": ["testdir/2/"],
|
||||
"//conditions:default": [],
|
||||
})`,
|
||||
}),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
165
bp2build/cc_prebuilt_library_shared_conversion_test.go
Normal file
165
bp2build/cc_prebuilt_library_shared_conversion_test.go
Normal file
|
@ -0,0 +1,165 @@
|
|||
// Copyright 2022 Google Inc. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
package bp2build
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"android/soong/cc"
|
||||
)
|
||||
|
||||
func runCcPrebuiltLibrarySharedTestCase(t *testing.T, tc Bp2buildTestCase) {
|
||||
t.Parallel()
|
||||
t.Helper()
|
||||
(&tc).ModuleTypeUnderTest = "cc_prebuilt_library_shared"
|
||||
(&tc).ModuleTypeUnderTestFactory = cc.PrebuiltSharedLibraryFactory
|
||||
RunBp2BuildTestCaseSimple(t, tc)
|
||||
}
|
||||
|
||||
func TestPrebuiltLibrarySharedSimple(t *testing.T) {
|
||||
runCcPrebuiltLibrarySharedTestCase(t,
|
||||
Bp2buildTestCase{
|
||||
Description: "prebuilt library shared simple",
|
||||
Filesystem: map[string]string{
|
||||
"libf.so": "",
|
||||
},
|
||||
Blueprint: `
|
||||
cc_prebuilt_library_shared {
|
||||
name: "libtest",
|
||||
srcs: ["libf.so"],
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("cc_prebuilt_library_shared", "libtest", AttrNameToString{
|
||||
"shared_library": `"libf.so"`,
|
||||
}),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestPrebuiltLibrarySharedWithArchVariance(t *testing.T) {
|
||||
runCcPrebuiltLibrarySharedTestCase(t,
|
||||
Bp2buildTestCase{
|
||||
Description: "prebuilt library shared with arch variance",
|
||||
Filesystem: map[string]string{
|
||||
"libf.so": "",
|
||||
"libg.so": "",
|
||||
},
|
||||
Blueprint: `
|
||||
cc_prebuilt_library_shared {
|
||||
name: "libtest",
|
||||
arch: {
|
||||
arm64: { srcs: ["libf.so"], },
|
||||
arm: { srcs: ["libg.so"], },
|
||||
},
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("cc_prebuilt_library_shared", "libtest", AttrNameToString{
|
||||
"shared_library": `select({
|
||||
"//build/bazel/platforms/arch:arm": "libg.so",
|
||||
"//build/bazel/platforms/arch:arm64": "libf.so",
|
||||
"//conditions:default": None,
|
||||
})`,
|
||||
}),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestPrebuiltLibrarySharedAdditionalAttrs(t *testing.T) {
|
||||
runCcPrebuiltLibrarySharedTestCase(t,
|
||||
Bp2buildTestCase{
|
||||
Description: "prebuilt library shared additional attributes",
|
||||
Filesystem: map[string]string{
|
||||
"libf.so": "",
|
||||
"testdir/1/include.h": "",
|
||||
"testdir/2/other.h": "",
|
||||
},
|
||||
Blueprint: `
|
||||
cc_prebuilt_library_shared {
|
||||
name: "libtest",
|
||||
srcs: ["libf.so"],
|
||||
export_include_dirs: ["testdir/1/"],
|
||||
export_system_include_dirs: ["testdir/2/"],
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("cc_prebuilt_library_shared", "libtest", AttrNameToString{
|
||||
"shared_library": `"libf.so"`,
|
||||
"export_includes": `["testdir/1/"]`,
|
||||
"export_system_includes": `["testdir/2/"]`,
|
||||
}),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestPrebuiltLibrarySharedWithExportIncludesArchVariant(t *testing.T) {
|
||||
runCcPrebuiltLibrarySharedTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_prebuilt_library_shared correctly translates export_includes with arch variance",
|
||||
Filesystem: map[string]string{
|
||||
"libf.so": "",
|
||||
"libg.so": "",
|
||||
},
|
||||
Blueprint: `
|
||||
cc_prebuilt_library_shared {
|
||||
name: "libtest",
|
||||
srcs: ["libf.so"],
|
||||
arch: {
|
||||
arm: { export_include_dirs: ["testdir/1/"], },
|
||||
arm64: { export_include_dirs: ["testdir/2/"], },
|
||||
},
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("cc_prebuilt_library_shared", "libtest", AttrNameToString{
|
||||
"shared_library": `"libf.so"`,
|
||||
"export_includes": `select({
|
||||
"//build/bazel/platforms/arch:arm": ["testdir/1/"],
|
||||
"//build/bazel/platforms/arch:arm64": ["testdir/2/"],
|
||||
"//conditions:default": [],
|
||||
})`,
|
||||
}),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestPrebuiltLibrarySharedWithExportSystemIncludesArchVariant(t *testing.T) {
|
||||
runCcPrebuiltLibrarySharedTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_prebuilt_library_shared correctly translates export_system_includes with arch variance",
|
||||
Filesystem: map[string]string{
|
||||
"libf.so": "",
|
||||
"libg.so": "",
|
||||
},
|
||||
Blueprint: `
|
||||
cc_prebuilt_library_shared {
|
||||
name: "libtest",
|
||||
srcs: ["libf.so"],
|
||||
arch: {
|
||||
arm: { export_system_include_dirs: ["testdir/1/"], },
|
||||
arm64: { export_system_include_dirs: ["testdir/2/"], },
|
||||
},
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("cc_prebuilt_library_shared", "libtest", AttrNameToString{
|
||||
"shared_library": `"libf.so"`,
|
||||
"export_system_includes": `select({
|
||||
"//build/bazel/platforms/arch:arm": ["testdir/1/"],
|
||||
"//build/bazel/platforms/arch:arm64": ["testdir/2/"],
|
||||
"//conditions:default": [],
|
||||
})`,
|
||||
}),
|
||||
},
|
||||
})
|
||||
}
|
199
bp2build/cc_prebuilt_library_static_conversion_test.go
Normal file
199
bp2build/cc_prebuilt_library_static_conversion_test.go
Normal file
|
@ -0,0 +1,199 @@
|
|||
// Copyright 2022 Google Inc. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
package bp2build
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"android/soong/cc"
|
||||
)
|
||||
|
||||
func runCcPrebuiltLibraryStaticTestCase(t *testing.T, tc Bp2buildTestCase) {
|
||||
t.Parallel()
|
||||
t.Helper()
|
||||
(&tc).ModuleTypeUnderTest = "cc_prebuilt_library_static"
|
||||
(&tc).ModuleTypeUnderTestFactory = cc.PrebuiltStaticLibraryFactory
|
||||
RunBp2BuildTestCaseSimple(t, tc)
|
||||
}
|
||||
|
||||
func TestPrebuiltLibraryStaticSimple(t *testing.T) {
|
||||
runCcPrebuiltLibraryStaticTestCase(t,
|
||||
Bp2buildTestCase{
|
||||
Description: "prebuilt library static simple",
|
||||
Filesystem: map[string]string{
|
||||
"libf.so": "",
|
||||
},
|
||||
Blueprint: `
|
||||
cc_prebuilt_library_static {
|
||||
name: "libtest",
|
||||
srcs: ["libf.so"],
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("cc_prebuilt_library_static", "libtest", AttrNameToString{
|
||||
"static_library": `"libf.so"`,
|
||||
}),
|
||||
MakeBazelTarget("cc_prebuilt_library_static", "libtest_alwayslink", AttrNameToString{
|
||||
"static_library": `"libf.so"`,
|
||||
"alwayslink": "True",
|
||||
}),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestPrebuiltLibraryStaticWithArchVariance(t *testing.T) {
|
||||
runCcPrebuiltLibraryStaticTestCase(t,
|
||||
Bp2buildTestCase{
|
||||
Description: "prebuilt library with arch variance",
|
||||
Filesystem: map[string]string{
|
||||
"libf.so": "",
|
||||
"libg.so": "",
|
||||
},
|
||||
Blueprint: `
|
||||
cc_prebuilt_library_static {
|
||||
name: "libtest",
|
||||
arch: {
|
||||
arm64: { srcs: ["libf.so"], },
|
||||
arm: { srcs: ["libg.so"], },
|
||||
},
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("cc_prebuilt_library_static", "libtest", AttrNameToString{
|
||||
"static_library": `select({
|
||||
"//build/bazel/platforms/arch:arm": "libg.so",
|
||||
"//build/bazel/platforms/arch:arm64": "libf.so",
|
||||
"//conditions:default": None,
|
||||
})`}),
|
||||
MakeBazelTarget("cc_prebuilt_library_static", "libtest_alwayslink", AttrNameToString{
|
||||
"alwayslink": "True",
|
||||
"static_library": `select({
|
||||
"//build/bazel/platforms/arch:arm": "libg.so",
|
||||
"//build/bazel/platforms/arch:arm64": "libf.so",
|
||||
"//conditions:default": None,
|
||||
})`}),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestPrebuiltLibraryStaticAdditionalAttrs(t *testing.T) {
|
||||
runCcPrebuiltLibraryStaticTestCase(t,
|
||||
Bp2buildTestCase{
|
||||
Description: "prebuilt library additional attributes",
|
||||
Filesystem: map[string]string{
|
||||
"libf.so": "",
|
||||
"testdir/1/include.h": "",
|
||||
"testdir/2/other.h": "",
|
||||
},
|
||||
Blueprint: `
|
||||
cc_prebuilt_library_static {
|
||||
name: "libtest",
|
||||
srcs: ["libf.so"],
|
||||
export_include_dirs: ["testdir/1/"],
|
||||
export_system_include_dirs: ["testdir/2/"],
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("cc_prebuilt_library_static", "libtest", AttrNameToString{
|
||||
"static_library": `"libf.so"`,
|
||||
"export_includes": `["testdir/1/"]`,
|
||||
"export_system_includes": `["testdir/2/"]`,
|
||||
}),
|
||||
MakeBazelTarget("cc_prebuilt_library_static", "libtest_alwayslink", AttrNameToString{
|
||||
"static_library": `"libf.so"`,
|
||||
"export_includes": `["testdir/1/"]`,
|
||||
"export_system_includes": `["testdir/2/"]`,
|
||||
"alwayslink": "True",
|
||||
}),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestPrebuiltLibraryStaticWithExportIncludesArchVariant(t *testing.T) {
|
||||
runCcPrebuiltLibraryStaticTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_prebuilt_library_static correctly translates export_includes with arch variance",
|
||||
Filesystem: map[string]string{
|
||||
"libf.so": "",
|
||||
"libg.so": "",
|
||||
},
|
||||
Blueprint: `
|
||||
cc_prebuilt_library_static {
|
||||
name: "libtest",
|
||||
srcs: ["libf.so"],
|
||||
arch: {
|
||||
arm: { export_include_dirs: ["testdir/1/"], },
|
||||
arm64: { export_include_dirs: ["testdir/2/"], },
|
||||
},
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("cc_prebuilt_library_static", "libtest", AttrNameToString{
|
||||
"static_library": `"libf.so"`,
|
||||
"export_includes": `select({
|
||||
"//build/bazel/platforms/arch:arm": ["testdir/1/"],
|
||||
"//build/bazel/platforms/arch:arm64": ["testdir/2/"],
|
||||
"//conditions:default": [],
|
||||
})`,
|
||||
}),
|
||||
MakeBazelTarget("cc_prebuilt_library_static", "libtest_alwayslink", AttrNameToString{
|
||||
"alwayslink": "True",
|
||||
"static_library": `"libf.so"`,
|
||||
"export_includes": `select({
|
||||
"//build/bazel/platforms/arch:arm": ["testdir/1/"],
|
||||
"//build/bazel/platforms/arch:arm64": ["testdir/2/"],
|
||||
"//conditions:default": [],
|
||||
})`,
|
||||
}),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestPrebuiltLibraryStaticWithExportSystemIncludesArchVariant(t *testing.T) {
|
||||
runCcPrebuiltLibraryStaticTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_prebuilt_library_static correctly translates export_system_includes with arch variance",
|
||||
Filesystem: map[string]string{
|
||||
"libf.so": "",
|
||||
"libg.so": "",
|
||||
},
|
||||
Blueprint: `
|
||||
cc_prebuilt_library_static {
|
||||
name: "libtest",
|
||||
srcs: ["libf.so"],
|
||||
arch: {
|
||||
arm: { export_system_include_dirs: ["testdir/1/"], },
|
||||
arm64: { export_system_include_dirs: ["testdir/2/"], },
|
||||
},
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("cc_prebuilt_library_static", "libtest", AttrNameToString{
|
||||
"static_library": `"libf.so"`,
|
||||
"export_system_includes": `select({
|
||||
"//build/bazel/platforms/arch:arm": ["testdir/1/"],
|
||||
"//build/bazel/platforms/arch:arm64": ["testdir/2/"],
|
||||
"//conditions:default": [],
|
||||
})`,
|
||||
}),
|
||||
MakeBazelTarget("cc_prebuilt_library_static", "libtest_alwayslink", AttrNameToString{
|
||||
"alwayslink": "True",
|
||||
"static_library": `"libf.so"`,
|
||||
"export_system_includes": `select({
|
||||
"//build/bazel/platforms/arch:arm": ["testdir/1/"],
|
||||
"//build/bazel/platforms/arch:arm64": ["testdir/2/"],
|
||||
"//conditions:default": [],
|
||||
})`,
|
||||
}),
|
||||
},
|
||||
})
|
||||
}
|
|
@ -376,6 +376,7 @@ func prebuiltLibraryStaticBp2Build(ctx android.TopDownMutatorContext, module *Mo
|
|||
Static_library: prebuiltAttrs.Src,
|
||||
Export_includes: exportedIncludes.Includes,
|
||||
Export_system_includes: exportedIncludes.SystemIncludes,
|
||||
// TODO: ¿Alwayslink?
|
||||
}
|
||||
|
||||
props := bazel.BazelTargetModuleProperties{
|
||||
|
@ -398,14 +399,19 @@ func prebuiltLibraryStaticBp2Build(ctx android.TopDownMutatorContext, module *Mo
|
|||
}
|
||||
|
||||
type bazelPrebuiltLibrarySharedAttributes struct {
|
||||
Shared_library bazel.LabelAttribute
|
||||
Shared_library bazel.LabelAttribute
|
||||
Export_includes bazel.StringListAttribute
|
||||
Export_system_includes bazel.StringListAttribute
|
||||
}
|
||||
|
||||
func prebuiltLibrarySharedBp2Build(ctx android.TopDownMutatorContext, module *Module) {
|
||||
prebuiltAttrs := Bp2BuildParsePrebuiltLibraryProps(ctx, module, false)
|
||||
exportedIncludes := bp2BuildParseExportedIncludes(ctx, module, nil)
|
||||
|
||||
attrs := &bazelPrebuiltLibrarySharedAttributes{
|
||||
Shared_library: prebuiltAttrs.Src,
|
||||
Shared_library: prebuiltAttrs.Src,
|
||||
Export_includes: exportedIncludes.Includes,
|
||||
Export_system_includes: exportedIncludes.SystemIncludes,
|
||||
}
|
||||
|
||||
props := bazel.BazelTargetModuleProperties{
|
||||
|
|
Loading…
Reference in a new issue