diff options
| author | Ivan Lozano <ivanlozano@google.com> | 2020-02-06 12:05:10 -0500 |
|---|---|---|
| committer | Ivan Lozano <ivanlozano@google.com> | 2020-02-06 13:38:50 -0500 |
| commit | d648c43fec771bffaa888734c2a9894ac31ae43f (patch) | |
| tree | e9f30a797f80139410c42e30ebb78b675b7ce99f /rust | |
| parent | 026ffecb9d1255325d074b9bd15d25d36395a2c3 (diff) | |
| download | build_soong-d648c43fec771bffaa888734c2a9894ac31ae43f.tar.gz build_soong-d648c43fec771bffaa888734c2a9894ac31ae43f.tar.bz2 build_soong-d648c43fec771bffaa888734c2a9894ac31ae43f.zip | |
Fix lib name resolution if extension is substring.
If a library happens to contain the extension as a substring in its
name, libNameFromFilePath will return a truncated library name. Change
this calculation to remove the last instance of the extension substring
instead.
Bug: 147140513
Test: Modified rust tests pass.
Change-Id: I0ed91e5f571ed5c4040ee15956a1598846aee43a
Diffstat (limited to 'rust')
| -rw-r--r-- | rust/rust.go | 4 | ||||
| -rw-r--r-- | rust/rust_test.go | 4 |
2 files changed, 5 insertions, 3 deletions
diff --git a/rust/rust.go b/rust/rust.go index e2af6f03..e4f85f0f 100644 --- a/rust/rust.go +++ b/rust/rust.go @@ -705,13 +705,15 @@ func (mod *Module) InstallInData() bool { func linkPathFromFilePath(filepath android.Path) string { return strings.Split(filepath.String(), filepath.Base())[0] } + func libNameFromFilePath(filepath android.Path) string { - libName := strings.Split(filepath.Base(), filepath.Ext())[0] + libName := strings.TrimSuffix(filepath.Base(), filepath.Ext()) if strings.HasPrefix(libName, "lib") { libName = libName[3:] } return libName } + func (mod *Module) DepsMutator(actx android.BottomUpMutatorContext) { ctx := &depsContext{ BottomUpMutatorContext: actx, diff --git a/rust/rust_test.go b/rust/rust_test.go index 3be9ee7b..afe530ab 100644 --- a/rust/rust_test.go +++ b/rust/rust_test.go @@ -114,13 +114,13 @@ func testRustError(t *testing.T, pattern string, bp string) { // Test that we can extract the lib name from a lib path. func TestLibNameFromFilePath(t *testing.T) { - libBarPath := android.PathForTesting("out/soong/.intermediates/external/libbar/libbar/linux_glibc_x86_64_shared/libbar.so") + libBarPath := android.PathForTesting("out/soong/.intermediates/external/libbar/libbar/linux_glibc_x86_64_shared/libbar.so.so") libLibPath := android.PathForTesting("out/soong/.intermediates/external/libbar/libbar/linux_glibc_x86_64_shared/liblib.dylib.so") libBarName := libNameFromFilePath(libBarPath) libLibName := libNameFromFilePath(libLibPath) - expectedResult := "bar" + expectedResult := "bar.so" if libBarName != expectedResult { t.Errorf("libNameFromFilePath returned the wrong name; expected '%#v', got '%#v'", expectedResult, libBarName) } |
