diff --git a/apex/apex.go b/apex/apex.go index b26d1d242..8c21d3d7c 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -1685,6 +1685,7 @@ func apexFileForRustExecutable(ctx android.BaseModuleContext, rustm *rust.Module if rustm.Target().NativeBridge == android.NativeBridgeEnabled { dirInApex = filepath.Join(dirInApex, rustm.Target().NativeBridgeRelativePath) } + dirInApex = filepath.Join(dirInApex, rustm.RelativeInstallPath()) fileToCopy := android.OutputFileForModule(ctx, rustm, "") androidMkModuleName := rustm.BaseModuleName() + rustm.Properties.SubName af := newApexFile(ctx, fileToCopy, androidMkModuleName, dirInApex, nativeExecutable, rustm) @@ -1704,6 +1705,7 @@ func apexFileForRustLibrary(ctx android.BaseModuleContext, rustm *rust.Module) a if rustm.Target().NativeBridge == android.NativeBridgeEnabled { dirInApex = filepath.Join(dirInApex, rustm.Target().NativeBridgeRelativePath) } + dirInApex = filepath.Join(dirInApex, rustm.RelativeInstallPath()) fileToCopy := android.OutputFileForModule(ctx, rustm, "") androidMkModuleName := rustm.BaseModuleName() + rustm.Properties.SubName return newApexFile(ctx, fileToCopy, androidMkModuleName, dirInApex, nativeSharedLib, rustm) diff --git a/apex/apex_test.go b/apex/apex_test.go index 9dba08e46..bd19cb5ef 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -2794,7 +2794,7 @@ func TestFilesInSubDir(t *testing.T) { name: "myapex", key: "myapex.key", native_shared_libs: ["mylib"], - binaries: ["mybin"], + binaries: ["mybin", "mybin.rust"], prebuilts: ["myetc"], compile_multilib: "both", updatable: false, @@ -2829,6 +2829,13 @@ func TestFilesInSubDir(t *testing.T) { stl: "none", apex_available: [ "myapex" ], } + + rust_binary { + name: "mybin.rust", + srcs: ["foo.rs"], + relative_install_path: "rust_subdir", + apex_available: [ "myapex" ], + } `) generateFsRule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("generateFsConfig") @@ -2847,6 +2854,7 @@ func TestFilesInSubDir(t *testing.T) { ensureContains(t, cmd, "/bin ") ensureContains(t, cmd, "/bin/foo ") ensureContains(t, cmd, "/bin/foo/bar ") + ensureContains(t, cmd, "/bin/rust_subdir ") } func TestFilesInSubDirWhenNativeBridgeEnabled(t *testing.T) {