Merge changes I2ab8f6aa,I53d58100
* changes: Add SDK member support for cc_object. Add cc_prebuilt_object.
This commit is contained in:
commit
71da478f51
7 changed files with 150 additions and 10 deletions
|
@ -304,10 +304,11 @@ type SdkMemberType interface {
|
||||||
// SdkAware and be added with an SdkMemberTypeDependencyTag tag.
|
// SdkAware and be added with an SdkMemberTypeDependencyTag tag.
|
||||||
HasTransitiveSdkMembers() bool
|
HasTransitiveSdkMembers() bool
|
||||||
|
|
||||||
// Add dependencies from the SDK module to all the variants the member
|
// Add dependencies from the SDK module to all the module variants the member
|
||||||
// contributes to the SDK. The exact set of variants required is determined
|
// type contributes to the SDK. `names` is the list of module names given in
|
||||||
// by the SDK and its properties. The dependencies must be added with the
|
// the member type property (as returned by SdkPropertyName()) in the SDK
|
||||||
// supplied tag.
|
// module. The exact set of variants required is determined by the SDK and its
|
||||||
|
// properties. The dependencies must be added with the supplied tag.
|
||||||
//
|
//
|
||||||
// The BottomUpMutatorContext provided is for the SDK module.
|
// The BottomUpMutatorContext provided is for the SDK module.
|
||||||
AddDependencies(mctx BottomUpMutatorContext, dependencyTag blueprint.DependencyTag, names []string)
|
AddDependencies(mctx BottomUpMutatorContext, dependencyTag blueprint.DependencyTag, names []string)
|
||||||
|
|
|
@ -29,7 +29,7 @@ var headersLibrarySdkMemberType = &librarySdkMemberType{
|
||||||
SupportsSdk: true,
|
SupportsSdk: true,
|
||||||
},
|
},
|
||||||
prebuiltModuleType: "cc_prebuilt_library_headers",
|
prebuiltModuleType: "cc_prebuilt_library_headers",
|
||||||
linkTypes: nil,
|
noOutputFiles: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegisterLibraryHeadersBuildComponents(ctx android.RegistrationContext) {
|
func RegisterLibraryHeadersBuildComponents(ctx android.RegistrationContext) {
|
||||||
|
|
|
@ -18,6 +18,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
|
|
||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
"github.com/google/blueprint/proptools"
|
"github.com/google/blueprint/proptools"
|
||||||
)
|
)
|
||||||
|
@ -53,7 +54,10 @@ type librarySdkMemberType struct {
|
||||||
|
|
||||||
prebuiltModuleType string
|
prebuiltModuleType string
|
||||||
|
|
||||||
// The set of link types supported, set of "static", "shared".
|
noOutputFiles bool // True if there are no srcs files.
|
||||||
|
|
||||||
|
// The set of link types supported. A set of "static", "shared", or nil to
|
||||||
|
// skip link type variations.
|
||||||
linkTypes []string
|
linkTypes []string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,7 +331,7 @@ func (p *nativeLibInfoProperties) PopulateFromVariant(variant android.SdkAware)
|
||||||
|
|
||||||
// If the library has some link types then it produces an output binary file, otherwise it
|
// If the library has some link types then it produces an output binary file, otherwise it
|
||||||
// is header only.
|
// is header only.
|
||||||
if p.memberType.linkTypes != nil {
|
if !p.memberType.noOutputFiles {
|
||||||
p.outputFile = ccModule.OutputFile().Path()
|
p.outputFile = ccModule.OutputFile().Path()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
22
cc/object.go
22
cc/object.go
|
@ -26,6 +26,16 @@ import (
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
android.RegisterModuleType("cc_object", ObjectFactory)
|
android.RegisterModuleType("cc_object", ObjectFactory)
|
||||||
|
android.RegisterSdkMemberType(ccObjectSdkMemberType)
|
||||||
|
}
|
||||||
|
|
||||||
|
var ccObjectSdkMemberType = &librarySdkMemberType{
|
||||||
|
SdkMemberTypeBase: android.SdkMemberTypeBase{
|
||||||
|
PropertyName: "native_objects",
|
||||||
|
SupportsSdk: true,
|
||||||
|
},
|
||||||
|
prebuiltModuleType: "cc_prebuilt_object",
|
||||||
|
linkTypes: nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
type objectLinker struct {
|
type objectLinker struct {
|
||||||
|
@ -47,12 +57,18 @@ type ObjectLinkerProperties struct {
|
||||||
Linker_script *string `android:"path,arch_variant"`
|
Linker_script *string `android:"path,arch_variant"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func newObject() *Module {
|
||||||
|
module := newBaseModule(android.HostAndDeviceSupported, android.MultilibBoth)
|
||||||
|
module.sanitize = &sanitize{}
|
||||||
|
module.stl = &stl{}
|
||||||
|
return module
|
||||||
|
}
|
||||||
|
|
||||||
// cc_object runs the compiler without running the linker. It is rarely
|
// cc_object runs the compiler without running the linker. It is rarely
|
||||||
// necessary, but sometimes used to generate .s files from .c files to use as
|
// necessary, but sometimes used to generate .s files from .c files to use as
|
||||||
// input to a cc_genrule module.
|
// input to a cc_genrule module.
|
||||||
func ObjectFactory() android.Module {
|
func ObjectFactory() android.Module {
|
||||||
module := newBaseModule(android.HostAndDeviceSupported, android.MultilibBoth)
|
module := newObject()
|
||||||
module.sanitize = &sanitize{}
|
|
||||||
module.linker = &objectLinker{
|
module.linker = &objectLinker{
|
||||||
baseLinker: NewBaseLinker(module.sanitize),
|
baseLinker: NewBaseLinker(module.sanitize),
|
||||||
}
|
}
|
||||||
|
@ -61,7 +77,7 @@ func ObjectFactory() android.Module {
|
||||||
// Clang's address-significance tables are incompatible with ld -r.
|
// Clang's address-significance tables are incompatible with ld -r.
|
||||||
module.compiler.appendCflags([]string{"-fno-addrsig"})
|
module.compiler.appendCflags([]string{"-fno-addrsig"})
|
||||||
|
|
||||||
module.stl = &stl{}
|
module.sdkMemberTypes = []android.SdkMemberType{ccObjectSdkMemberType}
|
||||||
return module.Init()
|
return module.Init()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ func RegisterPrebuiltBuildComponents(ctx android.RegistrationContext) {
|
||||||
ctx.RegisterModuleType("cc_prebuilt_library", PrebuiltLibraryFactory)
|
ctx.RegisterModuleType("cc_prebuilt_library", PrebuiltLibraryFactory)
|
||||||
ctx.RegisterModuleType("cc_prebuilt_library_shared", PrebuiltSharedLibraryFactory)
|
ctx.RegisterModuleType("cc_prebuilt_library_shared", PrebuiltSharedLibraryFactory)
|
||||||
ctx.RegisterModuleType("cc_prebuilt_library_static", PrebuiltStaticLibraryFactory)
|
ctx.RegisterModuleType("cc_prebuilt_library_static", PrebuiltStaticLibraryFactory)
|
||||||
|
ctx.RegisterModuleType("cc_prebuilt_object", prebuiltObjectFactory)
|
||||||
ctx.RegisterModuleType("cc_prebuilt_binary", prebuiltBinaryFactory)
|
ctx.RegisterModuleType("cc_prebuilt_binary", prebuiltBinaryFactory)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,6 +218,50 @@ func NewPrebuiltStaticLibrary(hod android.HostOrDeviceSupported) (*Module, *libr
|
||||||
return module, library
|
return module, library
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type prebuiltObjectProperties struct {
|
||||||
|
Srcs []string `android:"path,arch_variant"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type prebuiltObjectLinker struct {
|
||||||
|
android.Prebuilt
|
||||||
|
objectLinker
|
||||||
|
|
||||||
|
properties prebuiltObjectProperties
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *prebuiltObjectLinker) prebuilt() *android.Prebuilt {
|
||||||
|
return &p.Prebuilt
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ prebuiltLinkerInterface = (*prebuiltObjectLinker)(nil)
|
||||||
|
|
||||||
|
func (p *prebuiltObjectLinker) link(ctx ModuleContext,
|
||||||
|
flags Flags, deps PathDeps, objs Objects) android.Path {
|
||||||
|
if len(p.properties.Srcs) > 0 {
|
||||||
|
return p.Prebuilt.SingleSourcePath(ctx)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func newPrebuiltObject() *Module {
|
||||||
|
module := newObject()
|
||||||
|
prebuilt := &prebuiltObjectLinker{
|
||||||
|
objectLinker: objectLinker{
|
||||||
|
baseLinker: NewBaseLinker(nil),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
module.linker = prebuilt
|
||||||
|
module.AddProperties(&prebuilt.properties)
|
||||||
|
android.InitPrebuiltModule(module, &prebuilt.properties.Srcs)
|
||||||
|
android.InitSdkAwareModule(module)
|
||||||
|
return module
|
||||||
|
}
|
||||||
|
|
||||||
|
func prebuiltObjectFactory() android.Module {
|
||||||
|
module := newPrebuiltObject()
|
||||||
|
return module.Init()
|
||||||
|
}
|
||||||
|
|
||||||
type prebuiltBinaryLinker struct {
|
type prebuiltBinaryLinker struct {
|
||||||
*binaryDecorator
|
*binaryDecorator
|
||||||
prebuiltLinker
|
prebuiltLinker
|
||||||
|
|
|
@ -73,6 +73,15 @@ func TestPrebuilt(t *testing.T) {
|
||||||
srcs: ["libf.so"],
|
srcs: ["libf.so"],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cc_object {
|
||||||
|
name: "crtx",
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_prebuilt_object {
|
||||||
|
name: "crtx",
|
||||||
|
srcs: ["crtx.o"],
|
||||||
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
ctx := testPrebuilt(t, bp)
|
ctx := testPrebuilt(t, bp)
|
||||||
|
@ -84,6 +93,7 @@ func TestPrebuilt(t *testing.T) {
|
||||||
libe := ctx.ModuleForTests("libe", "android_arm64_armv8-a_static").Module()
|
libe := ctx.ModuleForTests("libe", "android_arm64_armv8-a_static").Module()
|
||||||
libfStatic := ctx.ModuleForTests("libf", "android_arm64_armv8-a_static").Module()
|
libfStatic := ctx.ModuleForTests("libf", "android_arm64_armv8-a_static").Module()
|
||||||
libfShared := ctx.ModuleForTests("libf", "android_arm64_armv8-a_shared").Module()
|
libfShared := ctx.ModuleForTests("libf", "android_arm64_armv8-a_shared").Module()
|
||||||
|
crtx := ctx.ModuleForTests("crtx", "android_arm64_armv8-a").Module()
|
||||||
|
|
||||||
prebuiltLiba := ctx.ModuleForTests("prebuilt_liba", "android_arm64_armv8-a_shared").Module()
|
prebuiltLiba := ctx.ModuleForTests("prebuilt_liba", "android_arm64_armv8-a_shared").Module()
|
||||||
prebuiltLibb := ctx.ModuleForTests("prebuilt_libb", "android_arm64_armv8-a_static").Module()
|
prebuiltLibb := ctx.ModuleForTests("prebuilt_libb", "android_arm64_armv8-a_static").Module()
|
||||||
|
@ -91,6 +101,7 @@ func TestPrebuilt(t *testing.T) {
|
||||||
prebuiltLibe := ctx.ModuleForTests("prebuilt_libe", "android_arm64_armv8-a_static").Module()
|
prebuiltLibe := ctx.ModuleForTests("prebuilt_libe", "android_arm64_armv8-a_static").Module()
|
||||||
prebuiltLibfStatic := ctx.ModuleForTests("prebuilt_libf", "android_arm64_armv8-a_static").Module()
|
prebuiltLibfStatic := ctx.ModuleForTests("prebuilt_libf", "android_arm64_armv8-a_static").Module()
|
||||||
prebuiltLibfShared := ctx.ModuleForTests("prebuilt_libf", "android_arm64_armv8-a_shared").Module()
|
prebuiltLibfShared := ctx.ModuleForTests("prebuilt_libf", "android_arm64_armv8-a_shared").Module()
|
||||||
|
prebuiltCrtx := ctx.ModuleForTests("prebuilt_crtx", "android_arm64_armv8-a").Module()
|
||||||
|
|
||||||
hasDep := func(m android.Module, wantDep android.Module) bool {
|
hasDep := func(m android.Module, wantDep android.Module) bool {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
@ -126,9 +137,14 @@ func TestPrebuilt(t *testing.T) {
|
||||||
if !hasDep(libfShared, prebuiltLibfShared) {
|
if !hasDep(libfShared, prebuiltLibfShared) {
|
||||||
t.Errorf("libf shared missing dependency on prebuilt_libf")
|
t.Errorf("libf shared missing dependency on prebuilt_libf")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !hasDep(crtx, prebuiltCrtx) {
|
||||||
|
t.Errorf("crtx missing dependency on prebuilt_crtx")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testPrebuilt(t *testing.T, bp string) *android.TestContext {
|
func testPrebuilt(t *testing.T, bp string) *android.TestContext {
|
||||||
|
|
||||||
fs := map[string][]byte{
|
fs := map[string][]byte{
|
||||||
"liba.so": nil,
|
"liba.so": nil,
|
||||||
"libb.a": nil,
|
"libb.a": nil,
|
||||||
|
@ -136,6 +152,7 @@ func testPrebuilt(t *testing.T, bp string) *android.TestContext {
|
||||||
"libe.a": nil,
|
"libe.a": nil,
|
||||||
"libf.a": nil,
|
"libf.a": nil,
|
||||||
"libf.so": nil,
|
"libf.so": nil,
|
||||||
|
"crtx.o": nil,
|
||||||
}
|
}
|
||||||
config := TestConfig(buildDir, android.Android, nil, bp, fs)
|
config := TestConfig(buildDir, android.Android, nil, bp, fs)
|
||||||
ctx := CreateTestContext()
|
ctx := CreateTestContext()
|
||||||
|
|
|
@ -225,6 +225,63 @@ func TestSdkWithCc(t *testing.T) {
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSnapshotWithObject(t *testing.T) {
|
||||||
|
result := testSdkWithCc(t, `
|
||||||
|
sdk {
|
||||||
|
name: "mysdk",
|
||||||
|
native_objects: ["crtobj"],
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_object {
|
||||||
|
name: "crtobj",
|
||||||
|
stl: "none",
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
|
||||||
|
result.CheckSnapshot("mysdk", "",
|
||||||
|
checkAndroidBpContents(`
|
||||||
|
// This is auto-generated. DO NOT EDIT.
|
||||||
|
|
||||||
|
cc_prebuilt_object {
|
||||||
|
name: "mysdk_crtobj@current",
|
||||||
|
sdk_member_name: "crtobj",
|
||||||
|
stl: "none",
|
||||||
|
arch: {
|
||||||
|
arm64: {
|
||||||
|
srcs: ["arm64/lib/crtobj.o"],
|
||||||
|
},
|
||||||
|
arm: {
|
||||||
|
srcs: ["arm/lib/crtobj.o"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_prebuilt_object {
|
||||||
|
name: "crtobj",
|
||||||
|
prefer: false,
|
||||||
|
stl: "none",
|
||||||
|
arch: {
|
||||||
|
arm64: {
|
||||||
|
srcs: ["arm64/lib/crtobj.o"],
|
||||||
|
},
|
||||||
|
arm: {
|
||||||
|
srcs: ["arm/lib/crtobj.o"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
sdk_snapshot {
|
||||||
|
name: "mysdk@current",
|
||||||
|
native_objects: ["mysdk_crtobj@current"],
|
||||||
|
}
|
||||||
|
`),
|
||||||
|
checkAllCopyRules(`
|
||||||
|
.intermediates/crtobj/android_arm64_armv8-a/crtobj.o -> arm64/lib/crtobj.o
|
||||||
|
.intermediates/crtobj/android_arm_armv7-a-neon/crtobj.o -> arm/lib/crtobj.o
|
||||||
|
`),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
func TestSnapshotWithCcDuplicateHeaders(t *testing.T) {
|
func TestSnapshotWithCcDuplicateHeaders(t *testing.T) {
|
||||||
result := testSdkWithCc(t, `
|
result := testSdkWithCc(t, `
|
||||||
sdk {
|
sdk {
|
||||||
|
|
Loading…
Reference in a new issue