Allow .o files as srcs.
Test: m nothing Test: TreeHugger Bug: 134581881 Bug: 137267623 Change-Id: I26307dd1129e58878f0468da3b61c53f074bd674
This commit is contained in:
committed by
Colin Cross
parent
f02f30952d
commit
fcf55bf656
@@ -989,6 +989,10 @@ type ModuleOutPath struct {
|
|||||||
|
|
||||||
var _ Path = ModuleOutPath{}
|
var _ Path = ModuleOutPath{}
|
||||||
|
|
||||||
|
func (p ModuleOutPath) objPathWithExt(ctx ModuleContext, subdir, ext string) ModuleObjPath {
|
||||||
|
return PathForModuleObj(ctx, subdir, pathtools.ReplaceExtension(p.path, ext))
|
||||||
|
}
|
||||||
|
|
||||||
func pathForModule(ctx ModuleContext) OutputPath {
|
func pathForModule(ctx ModuleContext) OutputPath {
|
||||||
return PathForOutput(ctx, ".intermediates", ctx.ModuleDir(), ctx.ModuleName(), ctx.ModuleSubDir())
|
return PathForOutput(ctx, ".intermediates", ctx.ModuleDir(), ctx.ModuleName(), ctx.ModuleSubDir())
|
||||||
}
|
}
|
||||||
|
@@ -411,6 +411,9 @@ func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles and
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
continue
|
continue
|
||||||
|
case ".o":
|
||||||
|
objFiles[i] = srcFile
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
var moduleCflags string
|
var moduleCflags string
|
||||||
|
@@ -2203,7 +2203,7 @@ func TestStaticExecutable(t *testing.T) {
|
|||||||
ctx := testCc(t, `
|
ctx := testCc(t, `
|
||||||
cc_binary {
|
cc_binary {
|
||||||
name: "static_test",
|
name: "static_test",
|
||||||
srcs: ["foo.c"],
|
srcs: ["foo.c", "baz.o"],
|
||||||
static_executable: true,
|
static_executable: true,
|
||||||
}`)
|
}`)
|
||||||
|
|
||||||
|
@@ -24,23 +24,26 @@ func TestLibraryReuse(t *testing.T) {
|
|||||||
ctx := testCc(t, `
|
ctx := testCc(t, `
|
||||||
cc_library {
|
cc_library {
|
||||||
name: "libfoo",
|
name: "libfoo",
|
||||||
srcs: ["foo.c"],
|
srcs: ["foo.c", "baz.o"],
|
||||||
}`)
|
}`)
|
||||||
|
|
||||||
libfooShared := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Rule("ld")
|
libfooShared := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Rule("ld")
|
||||||
libfooStatic := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_static").Output("libfoo.a")
|
libfooStatic := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_static").Output("libfoo.a")
|
||||||
|
|
||||||
if len(libfooShared.Inputs) != 1 {
|
if len(libfooShared.Inputs) != 2 {
|
||||||
t.Fatalf("unexpected inputs to libfoo shared: %#v", libfooShared.Inputs.Strings())
|
t.Fatalf("unexpected inputs to libfoo shared: %#v", libfooShared.Inputs.Strings())
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(libfooStatic.Inputs) != 1 {
|
if len(libfooStatic.Inputs) != 2 {
|
||||||
t.Fatalf("unexpected inputs to libfoo static: %#v", libfooStatic.Inputs.Strings())
|
t.Fatalf("unexpected inputs to libfoo static: %#v", libfooStatic.Inputs.Strings())
|
||||||
}
|
}
|
||||||
|
|
||||||
if libfooShared.Inputs[0] != libfooStatic.Inputs[0] {
|
if libfooShared.Inputs[0] != libfooStatic.Inputs[0] {
|
||||||
t.Errorf("static object not reused for shared library")
|
t.Errorf("static object not reused for shared library")
|
||||||
}
|
}
|
||||||
|
if libfooShared.Inputs[1] != libfooStatic.Inputs[1] {
|
||||||
|
t.Errorf("static object not reused for shared library")
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("extra static source", func(t *testing.T) {
|
t.Run("extra static source", func(t *testing.T) {
|
||||||
|
@@ -263,6 +263,7 @@ func CreateTestContext(bp string, fs map[string][]byte,
|
|||||||
"Android.bp": []byte(bp),
|
"Android.bp": []byte(bp),
|
||||||
"foo.c": nil,
|
"foo.c": nil,
|
||||||
"bar.c": nil,
|
"bar.c": nil,
|
||||||
|
"baz.o": nil,
|
||||||
"a.proto": nil,
|
"a.proto": nil,
|
||||||
"b.aidl": nil,
|
"b.aidl": nil,
|
||||||
"sub/c.aidl": nil,
|
"sub/c.aidl": nil,
|
||||||
|
Reference in New Issue
Block a user