Remove the ConvertWithBp2build implementations from all the module
types, along with the related code.
Bug: 315353489
Test: m blueprint_tests
Change-Id: I212672286686a318893bc7348ddd5a5ec51e77a7
Previously, we manually re-computed crate roots inside project_json for
rendering rust-project.json. In addition to added complexity, this meant
that generated sources and glob sources would not render correctly - it
would select e.g. `src/**.rs` or `:foo` as a crate root.
Use a centralized computation of crate roots instead.
Bug: 309943184
Test: SOONG_GEN_RUST_PROJECT=1 m nothing, compare rust-project.json
Change-Id: I0caddbf600d025a0041f45e69812cdd6f1761234
This makes it possible to call crateRootPath in situations where a
ModuleContext is unavailable.
Test: m nothing
Bug: 309943184
Change-Id: Iee20b0606954a18ca516cdac40917d0016f94a05
This was frequently misused (for example, in the prebuilts module, it
was used as a complex "assert(len(srcs))==1"), and can be superceded by
getCrateRoot anywhere it was used. It's now only called from
compiler.go, and can drop the second return parameter, as it was only
actually used by the prebuilt assert misuse.
Bug: 309943184
Test: m nothing
Change-Id: I6c92580bc8f0ecb7586c544056b5409e6dd280e7
This no-op refactoring facilitates some upcoming functional changes for
"bp2build allowlist v2". The work requires that the bp2build conversion
mutator be changed from a TopDown mutator to a BottomUp mutator.
Refactoring all bp2build-related methods so that they use Bp2buildMutatorContext
makes it easier to make this functional change without touching tens of
files and multiple projects.
Bug: 285631638
Test: m bp2build
Change-Id: I3d1ef3064146e959c6f0dc315350fc9764bf2bd2
This commit adds support for compiling rust rules inside the sbox
sandbox. To compile a rust module with sandboxing enabled, the entry
point to the crate must be specified via the `crate_root` property, and
all input sources and compile-time data must be specified via the `srcs`
and `compile_data` properties.
Bug: 286077158
Change-Id: I8c9dc5cf7578037a583b4be2e2f73cf20ffd4408
Adds support for capturing rust_proc_macros as part of the host
snapshot. Proc macros target the host and can be thought of as compiler
plugins. Because of this, they don't have vendor image variants and
can't be easily captured as part of the vendor snapshot. Instead we
capture them as part of the host snapshot.
This adds a rust_prebuilt_proc_macro module type.
Bug: 204304380
Test: m HOST_FAKE_SNAPSHOT_ENABLE=true host-fake-snapshot dist
Test: python3 development/vendor_snapshot/update.py --image=host
--install-dir=vendor/vendor_name/ 31 --local out/dist
Test: Checked Android.bp for rust_prebuilt_proc_macro modules.
Change-Id: I4a8c4d9c41b7ca361b5b97d3f74973918c2a5fe3
Rust installed files reside in "$MODULE_OUT/stripped/" when they are
stripped, otherwise they reside in "$MODULE_OUT". However, other parts
of Soong assume that installed files are always in $MODULE_OUT
(cc_modules place *unstripped* files in $MODULE_OUT/unstripped).
This notably causes problems when adding Rust modules as test data in
AndroidMkDataPaths. When Rust modules are parsed by AndroidMkDataPaths,
if they are stripped then they incorrectly get installed as test data
with the path:
<install_root>/<relative_install_path>/stripped/file.
This CL refactors how we handle Rust stripped output such that the
installed file always resides in $MODULE_OUT.
Bug: 171710847
Test: Installed files now always reside in $MODULE_OUT
Change-Id: I53a6ff57a0a5a55cd95ea78ae592ce22abfa20c9
This is actually required for some code.
Test: Modify the new test so it fails and see it fail.
Test: Build crates that fail without it.
Change-Id: I527752b765e5552aa2de7e201f056955e053e1f3
Refactors the vendor snapshot support to use the LinkableInterface
so that support can be extended to Rust. This CL does not add
vendor snapshot support for Rust; that is left for a follow-on CL.
Bug: 184042776
Test: m nothing
Change-Id: Id0c4970ca00053484a52677d182153cbc454c301
Adds `m rustdoc` which generates documentation for all Rust libraries
to $OUT_DIR/soong/rustdoc.
Follow up work:
* Generate an index page that lists all modules.
* Preserve the artifacts so we can have an always-up-to-date go link.
Test: m rustdoc
Bug: None
Change-Id: Id2d6b9cbab5b02e36b575567563d7cc7606b9401
This currently expands all globs, still need to support converting glob
syntax.
Test: go build_conversion_test
Test: GENERATE_BAZEL_FILES=true m nothing
Test: m nothing
Bug: 165114590
Change-Id: If7b26e8e663d17566fad9614ca87a8da1f095284
Add a rust_fuzz module which builds a libfuzzer binary that enabes
asan+sancov. This relies on the libfuzzer-sys crate.
Bug: 147140513
Test: Local rust_fuzz example builds, fuzzes with asan+sancov.
Change-Id: I57db3b8d25869791824ccfab768d13b0bb9d42fa
Reuses the cc.Stripper logic. Abstracts Stripper to avoid the spreading
of references to the cc package.
rustc requires unstripped libraries (precisely, with the `.rustc`
section) when building dependent targets. Contrary to cc, the output of
a compiler module will remain unstripped and only an extra build rule
will be added. This rule will be referenced at install time (in
baseCompiler.install or androidmk).
This change drastically reduces the size of the installed libraries:
(unstripped, from out/target/product/crosshatch/system)
$ find . -name \*.dylib.so -print0 | du -c --files0-from=-
149996 total
(stripped, with this change)
$ find . -name \*.dylib.so -print0 | du -c --files0-from=-
42380 total
Bug: 153430439
Test: cd external/rust; mma
Change-Id: I94fd8bbcec97e0610aa325d3db4460be84d01734
Device binaries currently are linked statically by default. Instead we
should be linking these dynamic by default. To avoid conflicts when
manually specifying rlib dependencies on modules, we always link libstd
dynamically for all device modules except static libraries.
This removes the "prefer_dynamic" property entirely to avoid confusion.
Bug: 165161105
Test: m profcollectd is built dynamically.
Test: cd external/rust/; mma
Test: cd external/crosvm/; mma
Change-Id: I25ac897040acbcc2d97c791a33e8e01610632272
Modules defined in the srcs property are automatically added as
dependencies with AddDependency(), which will use any variant available.
This can cause incorrect architecture bindings to be silently pulled in,
such as when a host module uses a rust_bindgen module that doesn't
create a host variant.
This moves populating depPaths.SrcDeps over to depsToPaths and adds a
check for SourceProviders to make sure the correct OS and architecture
is being used.
Bug: 161826371
Test: Soong no longer silently pulls in bindings for the wrong
target.
Test: New Soong test to catch this case passes.
Change-Id: I2b3651cf6fc7dabf4081434df1c455e637f5b3a4
Allow rust modules to depend on and use generated source code provided
by SourceProvider modules and genrule modules without resorting to
hardcoded output paths.
All generated sources are now copied to a dependent module's
intermediates directory, then OUT_DIR is set to point to that path when
calling rustc. This matches the common convention used in most rust
crates to include generated source code from the path defined in the
OUT_DIR environment variable.
A couple other small notable changes are included in this CL:
* prebuiltLibraries can no longer include generated source files as they
should be prebuilt.
* srcPathFromModuleSrcs now excludes the main source file from the
second return value so its a list of only the generated sources.
Bug: 159064919
Test: Local example rust_library compiles with rust_bindgen dependency.
Test: Local example rust_library compiles with genrule dependency.
Test: Collision detected when multiple providers produce similar output.
Test: New Soong tests pass.
Change-Id: I59f54a25368c680b9086420c47ec24ab8cd1de6b
* "srcs" list contains one main Rust source file,
followed by optional dependent modules.
* A dependent module included in the "srcs" list is
the module name prefixed with ":".
* Add a simple test.
Bug: 160331255
Test: make and manual test build dependencies on genrule modules
Change-Id: I4f079138c2599158810b6412fce81b612a3f64a4
With proper prebuilt modules, we can avoid any rustc implicit sysroot
searching.
Asd a bonus, this should make rust-project.json generation correctly
grab otherwise implicit dependencies.
Prebuilt rlibs may include several dependency rlibs. Without a
link_dirs attribute, every dependency (even if unexported) would need a
separate module.
Previously we were casing out on exact structs, which might be OK when
libraryDecorator and procMacroDecorator were the only possibilities, but
repeating the logic for three types is too much. Using an interface
makes this logic scale better.
Bug: 159591910
Test: cd external/rust; mma; m crosvm.experimental
Change-Id: Ia1124e09f48cd05e39f094bbcb988622ebd2272f
Adds the rustlibs dependency type which will automatically select
between rlib and dylib based on the type of the library.
Bug: 143217452
Test: cd external/rust; mma
Change-Id: I97faadae98bf957090a32939cfb2d3a10f74a057
* Now the installation directories match those for C/C++ tests:
* The relative_install_path refers to path under nativetest(64).
* Device test files are installed in data/nativetest(64).
* Automatically generated configuration files and copied test binaries
are still in the "testcases" directory.
* Change host test configuration to run test binary files
in testcases/<mutated_module_name>/<arch_type>/<stem_name>
Bug: 140938178
Test: atest --include-subdirs under external/rust/crates
Change-Id: I4b29afb897f4ba8749e87f79857c5b1a959bb2b0
rustc expects libraries and proc_macro filenames to conform to
a particular format, alphanumeric with underscores and lib${crate_name}.*.
Enforce this with a check when getStem() is called.
This makes the crate_name property required for proc_macros and
libraries. This also removes the notion of a default crate name derived
from the module name. It's not needed for binaries, so this won't impact
them.
Bug: 143579265
Test: m -j crosvm.experimental
Change-Id: I2770cf7d02dd4291c3d240d58d242b940098dcee
Currently proc_macros don't pull in the correct arch dependencies when
the host arch differs from the target arch.
This fixes how proc_macro dependencies are handled by defining them as
always being host-only and including them as dependencies for
device-modules by using AddFarVariationDependencies.
Bug: 141491501
Test: Example device rust module builds with proc_macro dependency.
Change-Id: Ic037dc406ce90526f8b68c92fffc0d93a498a4ff
Adds support to Soong for building rust modules. This currently only
supports x86_64 device and x86 linux host targets. The functionality
is sufficient to build crosvm.
Bug: 136189233
Test: Test module builds.
Test: crosvm builds.
Change-Id: I6ea04615834a6d673578ab10ea1a2eb04259fe09