Allow .o files as srcs.
Test: m nothing
Test: TreeHugger
Bug: 134581881
Bug: 137267623
Change-Id: I26307dd1129e58878f0468da3b61c53f074bd674
diff --git a/cc/builder.go b/cc/builder.go
index 89c418b..14b979e 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -411,6 +411,9 @@
},
})
continue
+ case ".o":
+ objFiles[i] = srcFile
+ continue
}
var moduleCflags string
diff --git a/cc/cc_test.go b/cc/cc_test.go
index c619b5a..99a88e9 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -2203,7 +2203,7 @@
ctx := testCc(t, `
cc_binary {
name: "static_test",
- srcs: ["foo.c"],
+ srcs: ["foo.c", "baz.o"],
static_executable: true,
}`)
diff --git a/cc/library_test.go b/cc/library_test.go
index 859b05a..2acae35 100644
--- a/cc/library_test.go
+++ b/cc/library_test.go
@@ -24,23 +24,26 @@
ctx := testCc(t, `
cc_library {
name: "libfoo",
- srcs: ["foo.c"],
+ srcs: ["foo.c", "baz.o"],
}`)
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")
- if len(libfooShared.Inputs) != 1 {
+ if len(libfooShared.Inputs) != 2 {
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())
}
if libfooShared.Inputs[0] != libfooStatic.Inputs[0] {
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) {
diff --git a/cc/testing.go b/cc/testing.go
index f0ad33b..5582c8a 100644
--- a/cc/testing.go
+++ b/cc/testing.go
@@ -263,6 +263,7 @@
"Android.bp": []byte(bp),
"foo.c": nil,
"bar.c": nil,
+ "baz.o": nil,
"a.proto": nil,
"b.aidl": nil,
"sub/c.aidl": nil,