Loading rust/library.go +6 −1 Original line number Diff line number Diff line Loading @@ -54,9 +54,13 @@ type LibraryCompilerProperties struct { Shared VariantLibraryProperties `android:"arch_variant"` Static VariantLibraryProperties `android:"arch_variant"` // path to include directories to pass to cc_* modules, only relevant for static/shared variants. // TODO: Remove this when all instances of Include_dirs have been removed from rust_ffi modules. // path to include directories to pass to cc_* modules, only relevant for static/shared variants (deprecated, use export_include_dirs instead). Include_dirs []string `android:"path,arch_variant"` // path to include directories to export to cc_* modules, only relevant for static/shared variants. Export_include_dirs []string `android:"path,arch_variant"` // Whether this library is part of the Rust toolchain sysroot. Sysroot *bool } Loading Loading @@ -465,6 +469,7 @@ func (library *libraryDecorator) compilerFlags(ctx ModuleContext, flags Flags) F flags.RustFlags = append(flags.RustFlags, "-C metadata="+ctx.ModuleName()) if library.shared() || library.static() { library.includeDirs = append(library.includeDirs, android.PathsForModuleSrc(ctx, library.Properties.Include_dirs)...) library.includeDirs = append(library.includeDirs, android.PathsForModuleSrc(ctx, library.Properties.Export_include_dirs)...) } if library.shared() { if ctx.Darwin() { Loading rust/library_test.go +19 −0 Original line number Diff line number Diff line Loading @@ -403,3 +403,22 @@ func TestLibstdLinkage(t *testing.T) { } } func TestRustFFIExportedIncludes(t *testing.T) { ctx := testRust(t, ` rust_ffi { name: "libbar", srcs: ["foo.rs"], crate_name: "bar", export_include_dirs: ["rust_includes"], host_supported: true, } cc_library_static { name: "libfoo", srcs: ["foo.cpp"], shared_libs: ["libbar"], host_supported: true, }`) libfooStatic := ctx.ModuleForTests("libfoo", "linux_glibc_x86_64_static").Rule("cc") android.AssertStringDoesContain(t, "cFlags for lib module", libfooStatic.Args["cFlags"], " -Irust_includes ") } rust/vendor_snapshot_test.go +2 −2 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ func TestVendorSnapshotCapture(t *testing.T) { crate_name: "ffivendor_available", srcs: ["lib.rs"], vendor_available: true, include_dirs: ["rust_headers/"], export_include_dirs: ["rust_headers/"], } rust_ffi { Loading @@ -40,7 +40,7 @@ func TestVendorSnapshotCapture(t *testing.T) { crate_name: "ffivendor", srcs: ["lib.rs"], vendor: true, include_dirs: ["rust_headers/"], export_include_dirs: ["rust_headers/"], } rust_library { Loading Loading
rust/library.go +6 −1 Original line number Diff line number Diff line Loading @@ -54,9 +54,13 @@ type LibraryCompilerProperties struct { Shared VariantLibraryProperties `android:"arch_variant"` Static VariantLibraryProperties `android:"arch_variant"` // path to include directories to pass to cc_* modules, only relevant for static/shared variants. // TODO: Remove this when all instances of Include_dirs have been removed from rust_ffi modules. // path to include directories to pass to cc_* modules, only relevant for static/shared variants (deprecated, use export_include_dirs instead). Include_dirs []string `android:"path,arch_variant"` // path to include directories to export to cc_* modules, only relevant for static/shared variants. Export_include_dirs []string `android:"path,arch_variant"` // Whether this library is part of the Rust toolchain sysroot. Sysroot *bool } Loading Loading @@ -465,6 +469,7 @@ func (library *libraryDecorator) compilerFlags(ctx ModuleContext, flags Flags) F flags.RustFlags = append(flags.RustFlags, "-C metadata="+ctx.ModuleName()) if library.shared() || library.static() { library.includeDirs = append(library.includeDirs, android.PathsForModuleSrc(ctx, library.Properties.Include_dirs)...) library.includeDirs = append(library.includeDirs, android.PathsForModuleSrc(ctx, library.Properties.Export_include_dirs)...) } if library.shared() { if ctx.Darwin() { Loading
rust/library_test.go +19 −0 Original line number Diff line number Diff line Loading @@ -403,3 +403,22 @@ func TestLibstdLinkage(t *testing.T) { } } func TestRustFFIExportedIncludes(t *testing.T) { ctx := testRust(t, ` rust_ffi { name: "libbar", srcs: ["foo.rs"], crate_name: "bar", export_include_dirs: ["rust_includes"], host_supported: true, } cc_library_static { name: "libfoo", srcs: ["foo.cpp"], shared_libs: ["libbar"], host_supported: true, }`) libfooStatic := ctx.ModuleForTests("libfoo", "linux_glibc_x86_64_static").Rule("cc") android.AssertStringDoesContain(t, "cFlags for lib module", libfooStatic.Args["cFlags"], " -Irust_includes ") }
rust/vendor_snapshot_test.go +2 −2 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ func TestVendorSnapshotCapture(t *testing.T) { crate_name: "ffivendor_available", srcs: ["lib.rs"], vendor_available: true, include_dirs: ["rust_headers/"], export_include_dirs: ["rust_headers/"], } rust_ffi { Loading @@ -40,7 +40,7 @@ func TestVendorSnapshotCapture(t *testing.T) { crate_name: "ffivendor", srcs: ["lib.rs"], vendor: true, include_dirs: ["rust_headers/"], export_include_dirs: ["rust_headers/"], } rust_library { Loading