Commit graph

117 commits

Author SHA1 Message Date
Treehugger Robot
65c74d9f89 Merge "HostToolPath should return install path" 2020-08-12 02:45:40 +00:00
Chih-Hung Hsieh
a756270ec2 HostToolPath should return install path
Bug: 163154468
Test: make; find dependencies of 'Module:  sqlite3_bindgen_x86_64'
Change-Id: Id9fc4f1937983bdf7eb1732ed6a8afd5aa3eb24c
2020-08-11 16:38:52 -07:00
Dan Albert
92fe740677 Stop using prebuilt NDK CRT objects.
We don't need the prebuilt versions. The NDK CRT objects are (now)
built from the platform sources and the only difference is that the
NDK CRT objects also include an ELF note that identifies the NDK
version, which isn't helpful for anything built by the platform.

Add a `crt` property to cc_object that allows CRT objects to identify
themselves. CRT objects, unlike other modules, will have a variant
built per-API level they support, rather than just an SDK variant and
a platform variant. This is needed because new CRT objects will rely
on APIs not available in old libcs and old CRT objects will not
support all the features of a modern one.

Test: treehugger
Bug: http://b/159925977
Change-Id: I6595485fa1bfe0ad4945193d344b863f64eec654
2020-08-11 15:06:55 -07:00
Andrei Homescu
5db69cc896 Only return the source files of a Rust module with a SourceProvider if the internal compiler has been disabled
Test: mmma system/tools/aidl with assertOutput FIXMEs re-enabled
Change-Id: I84598ae2d1181656b7d68088f86ab016563e5d80
2020-08-11 13:25:25 -07:00
Ivan Lozano
a57e56a684 Merge "Export Rust SourceProvider types and methods" 2020-08-10 12:11:16 +00:00
Treehugger Robot
2a73c2d060 Merge "Don't export link dirs from proc-macros." 2020-08-07 18:20:21 +00:00
Ivan Lozano
2bbcacf0c9 Don't export link dirs from proc-macros.
We shouldn't use exported link dirs from proc-macros as these may be
libraries for the wrong architecture or OS.

This doesn't cause a problem unless both the proc-macro and the
dependent library share a dependency. If that's the case, in some
circumstances it will cause the depdent library to fail compilation
when using a library with incorrect architecture.

Bug: 163088025
Test: Test case no longer colliding.
Test: cd external/rust/; mma
Change-Id: I46cbd850c3a89d10aa844b5c1b383e1070452d00
2020-08-07 09:00:50 -04:00
Andrei Homescu
c7767922e0 Export Rust SourceProvider types and methods
The AIDL compiler now uses SourceProvider to compiler the generated Rust
code from system/tools/aidl/build/aidl_interface.go using its own
SourceProvider object, which needs access to baseSourceProvider and all
methods of SourceProvider.

Test: mmma system/tools/aidl with 1357705 applied
Change-Id: I226609a7fccca2e7e1bfbad5d69d1821d37e43a1
2020-08-06 15:50:27 -07:00
Colin Cross
2eddd06879 Merge "Add libraryDependencyTag to track dependencies on static and shared libraries" 2020-08-06 00:06:28 +00:00
Ivan Lozano
c564d2d5a4 Add support for custom bindgen binaries.
In some cases customized logic is required to generate the expected
bindgen bindings. This adds support for rust_bindgen modules to define a
HostTool module to use instead of bindgen.

Bug: 161816141
Test: New Soong tests pass.
Test: Local test case shows custom_binary module being used for bindgen
      generation.

Change-Id: Id52aec4f25c38206d7e585d8e662be7836aa1d4b
2020-08-05 10:51:43 -04:00
Ivan Lozano
32267c88c4 [rust] Disable clippy for rust_bindgen modules.
bindgen generated code may not pass clippy checks, so preemptively
disable clippy for these.

Bug: 162828070
Test: clippy is not called when compiling rust_bindgen library variants.
Change-Id: I9632c889417bdfd1adf96d9cfbccbe6340824205
2020-08-04 16:27:16 -04:00
Ivan Lozano
26ecd6c597 [rust] Add SourceProviders as crates support.
This allows SourceProvider modules to create rust_library variants so
that generated source can be referenced as an external crate rather than
via an include macro. This is done by including rust_bindgen modules
like any other library, as a dependency in either rlibs, dylibs, or
rustlibs.

This renames the stem and flags properties for rust_bindgen modules to
source_stem and bindgen_flags, respectively. This deconflicts with the
usage in baseCompiler.

This also removes 'subName' from the Module struct and moves it over to
SourceProvider, which was the only user. This allows us to set it in
baseSourceProvider's AndroidMk; setting it in Module's AndroidMk was
causing problems finding NOTICE files for bindgen library variants.

Bug: 159064919
Test: New Soong tests pass.
Test: Local test rust_binary can use rust_bindgen module as a crate.

Change-Id: Ieb2cb614c2dd0b5aa7120541d77f6f822a6a1806
2020-08-04 08:13:24 -04:00
Ivan Lozano
89435d1a50 [rust] Clean up unused link variations.
rust_library modules no longer produce "link" variants alongside
"rust_libraries" variants as the former have been moved to rust_ffi
modules. rust_library modules however still create empty link variants
and code paths still assume that modules can support both rust linkage
and cc linkage. This adds unnecessary complexity that no longer serves a
purpose.

This cleans this up by removing the unused "link" variant for
rust_library modules and simplifies code paths that can now assume
modules are either a rust library or a cc library, but not both.

This also fixes a bug where Shared() was returning the wrong value.

Bug: 159064919
Test: cd external/rust/; mma
Test: cd external/crosvm/; mma

Change-Id: I3b5498c80b315c56b621dcb1388022fecc1bfc1b
2020-07-31 13:53:13 -04:00
Colin Cross
6e511a9a9f Add libraryDependencyTag to track dependencies on static and shared libraries
dependencyTag uses a set of predefined tags to identify different types
of dependencies.  There are already multiple bits of metadata stored
in the dependency tag (Library, Shared, ReexportFlags), and supporting
them all requires a combinatorial explosion of predefined tags and
causes issues when using equality comparisons if a new bit of metadata
is added.

Add a new libraryDependencyTag type that will contain the metadata
bits, and replace the quality comparisons with checks on the metadata
bits.

There are 5 TODOs where modifying the checks identified problems with
the existing checks.  These were left in place to produce identical
build output and will be fixed separately.

Bug: 162437057
Test: no change to build.ninja or {Android,make_vars,late}-${TARGET_PRODUCT}.mk
Change-Id: I72d4207dcf381c07c92e00e5a03968ebb5ed8d30
2020-07-29 13:22:30 -07:00
Ivan Lozano
3feff6c130 Merge changes I4efdf333,I4abaf8e7
* changes:
  Ensure hermetic device rust_bindgen.
  Generate deps file for rust_bindgen modules.
2020-07-29 00:25:42 +00:00
Ivan Lozano
45901edb9a Ensure hermetic device rust_bindgen.
rust_bindgen was not hermetic previously as it would pull in host
headers for device targets. This fixes that by using the same flags we
use when compiling with Clang. This also makes sure our rust_bindgen
headers are built as similar as possible to their respective
cc_libraries.

This also pulls in the bionic dependencies as well, which provide the
headers required for device targets.

Bug: 162007475
Test: device rust_bindgen deps file does not reference host headers.

Change-Id: I4efdf333e011a6c6d73a0345e5485823f166d17a
2020-07-28 14:53:57 -04:00
Ivan Lozano
07cbaf4d89 Enforce correct variant usage for rust_bindgen.
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
2020-07-22 20:34:22 +00:00
Ivan Lozano
43845688bc Allow rust module dependency on SourceProviders.
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
2020-07-20 13:40:31 -04:00
Ivan Lozano
4fef93c53f Add SourceProviders and a rust_bindgen module type
Add SourceProvider modules which provides a base interface for more
complex code generation usecases such as bindgen. Also adds the
rust_bindgen module type which calls bindgen to generate Rust FFI
bindings to C.

Bug: 159064919
Test: Local test module generates bindings.
Test: New Soong tests pass.

Change-Id: Ie31467bbbe423497666ad837cf5fe1acd1e76bd8
2020-07-20 13:40:14 -04:00
Chih-Hung Hsieh
bbd25aeb42 Specify module dependency in the srcs list
* "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
2020-07-08 23:50:00 -07:00
Matthew Maurer
bb3add1104 rust: Suppress default sysroot unconditionally
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
2020-07-01 11:27:12 -07:00
Matthew Maurer
c761eeca48 rust: Mutate prebuilt modules dylib/rlib
This change makes it possible to use a single module to provide both
dylib and rlib varieties of a library. This allows the use of libstd and
libtest from a rustlibs property, allowing linkage type to change
for different variants.

Bug: 159718669
Test: cd external crates; mma; m crosvm.experimental
Change-Id: I477c4d2faec63703fdc6dd42ba020747d6a50714
2020-07-01 11:27:12 -07:00
Matthew Maurer
0f003b1851 rust: Add rustlibs auto dependency selection
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
2020-07-01 11:27:12 -07:00
Chih-Hung Hsieh
5c4e48956c Enable genrule modules for Rust host binaries
* Add HostToolPath to use rust_binary_host modules as host tools.

Bug: 157666974
Test: make with local genrule examples
Change-Id: I9648313c0f0695d2e695f18ded4710350b2d6475
2020-06-30 10:23:49 -07:00
Thiébaud Weksteen
79e546f7df Merge "Remove moduleContextImpl struct" 2020-06-30 16:48:15 +00:00
Thiébaud Weksteen
92f703b084 Add clippy-driver build rule
Depending on the location of the repository (e.g. external/, vendor/), a
different set of lints will be enabled. Add the clippy property to the
rust_* modules. This property can be used to overwrite the default
behaviour.

Test: m checkbuild
Bug: 157238651
Change-Id: Ife0f723ef4a74abb102597f8486a7b9f30e7d351
2020-06-26 13:31:21 +02:00
Thiébaud Weksteen
1f7f70fe39 Remove moduleContextImpl struct
The moduleContextImpl structure contains duplicate information on the
contexts. BaseModuleContext, ModuleContext and DepsContext can already
surface which Module is being processed via Module(). Because most of
the Rust-specific methods on the *Context structures simply forward to
the Module methods, expose a RustModule() method.

Test: cd external/rust/crates; mma
Change-Id: Ifee90825d54081fc5e9a8df0b7c4580412e9158c
2020-06-24 11:56:33 +02:00
Ivan Lozano
d825990336 Merge "[Rust] Remove unused variables and deduplicate." 2020-06-17 12:28:06 +00:00
Jiyong Park
2286afd0ef Don't create version variants for SDK variants
When a lib has sdk_version set, an SDK variant and a platform variant
are created by the sdkMutator. Then by the versionMutator, if the
library had 'stubs.versions' property, one or more versioned variants
and one impl variant are created for each of the two (SDK and platform)
variants. As a concrete example,

cc_library {
    name: "foo",
    sdk_version: "current",
    stubs: { versions: ["1", "2"], },
}

would create 6 variants:

1) (sdk: "", version: "")
2) (sdk: "", version: "1")
3) (sdk: "", version: "2")
4) (sdk: "sdk", version: "")
5) (sdk: "sdk", version: "1")
6) (sdk: "sdk", version: "2")

This is somewhat uncessary because the need for the SDK mutator is to
have the platform variant (sdk:"") of a lib where sdk_version is unset,
which actually makes sens for the impl variant (version:""), but not
the versioned variants (version:"1" or version:"2").

This is not only unncessary, but also causes duplicate module
definitions in the Make side when doing an unbundled build. Specifically,
The #1 and #4 above both are emitted to Make and get the same name
"foo".

To fix the problem and not to create unnecessary variants, the versioned
variants are no longer created for the sdk variant. So, foo now has
the following variants only.

1) (sdk: "", version: "") // not emitted to Make (by versionMutator)
2) (sdk: "", version: "1") // not emitted to Make (by versionMutator)
3) (sdk: "", version: "2") // emitted to Make (by versionMutator)
4) (sdk: "sdk", version: "") // not emitted to Make (by versionMutator)

Bug: 159106705
Test: Add sdk_version:"minimum" to libnativehelper in libnativehelper/Android.bp.
m SOONG_ALLOW_MISSING_DEPENDENCIES=true TARGET_BUILD_UNBUNDLED=true libnativehelper

Change-Id: I6f02f4189e5504286174ccff1642166da82d00c9
2020-06-17 04:18:21 +00:00
Ivan Lozano
8a23fa4819 [Rust] Remove unused variables and deduplicate.
Bug: 158731826
Test: cd external/rust/crates; mma
Change-Id: I8c9e5cfeaf941b9676b92451b227c15db9a41bbc
2020-06-16 10:28:25 -04:00
Ivan Lozano
fc80fe7f2f Make rust_test file output more similar to cc_test.
This changes the way the output filename is calculated for rust_test
binaries to be more similar to cc_test.

This also removes the option to define multiple test binaries in a
single rust_test module via the TestPerSrc mutator. Now each rust_test
module corresponds to a single test binary.

Bug: 158500462
Test: m -j pin-utils_tests_pin_utils
Test: m -j unicode-xid_device_tests_unicode_xid
Change-Id: I6e0f79dcb4e49fa49d6ebb36abeef67a9eb180a0
2020-06-11 17:12:19 -04:00
Ivan Lozano
a0cd8f9acb Add gcov coverage support to Rust modules.
This adds gcov coverage support for Rust device library and binary
modules (including test modules). Support is provided to pass Rust
static library gcno files to CC modules and visa versa.

Additional changes:
 * Begin mutator added for Rust modules.
 * SuffixInList added to android package.
 * CoverageEnabled added to Coverage interface.
 * CoverageFiles added to LinkableLibrary interface.
 * Fix in coverage mutator for non-CC modules which marked the wrong
   variant as the coverage variant.
 * Added coverage libraries to the cc.GatherRequiredDepsForTest.

Bug: 146448203
Test: NATIVE_COVERAGE=true COVERAGE_PATHS='*' m -j <rust_module>
Change-Id: If20728bdde42a1dd544a35a40f0d981b80a5835f
2020-05-05 10:30:15 -04:00
Jooyung Han
624d35cb4d Skip version mutator for host/ramdisk/recovery
"version" mutator creates stubs variants for "cc" libraries with
"stubs.versions". These stubs are for APEX-APEX or APEX-Platform
boundaries.

For host/ramdisk/recovery variants, stubs are not necessary.

Exempt-From-Owner-Approval: cp from internal

Bug: 153698496
Test: m
Merged-In: Id576c4318d9d69246a4a7e2fb4145d5fd2ab9416
Change-Id: Id576c4318d9d69246a4a7e2fb4145d5fd2ab9416
(cherry picked from commit c40b5193fe)
2020-04-23 03:46:09 +00:00
Colin Cross
c511bc50dc Revert^2 "Add sdk mutator for native modules"
f8e80229fe

Change-Id: Ic30ab6b844684bfc3e8ece5a1913980d5fbf8de2
2020-04-07 16:50:32 +00:00
Colin Cross
f8e80229fe Revert "Add sdk mutator for native modules"
Revert submission 1242911-sdk_version_variant

Reason for revert: b/153394225
Reverted Changes:
Ife99745fb:Use libnativewindow for platform variant of libagq...
I1bae84c43:Use libnativewindow for platform variant of androi...
I6e6021ed3:Use stl to depend on libc++
Ife99745fb:Use libnativewindow for platform variant of libRSS...
I2c9f439b9:Fix static dependency on libprotobuf-cpp-lite-ndk
Iff2aff9cf:Set sdk_version for cc_genrules used by modules wi...
I7d72934aa:Add sdk mutator for native modules
Ief378a007:Use sdk variant of Soong modules when LOCAL_SDK_VE...

Bug: 149591340
Change-Id: I798fa902c779469c6382b6699351e5d12bf14785
Fixes: 153394225
2020-04-07 04:21:21 +00:00
Colin Cross
82e192c3ae Add sdk mutator for native modules
Compiling native modules against the NDK disables platform features
like ASAN.  For anything shipped on the system image there is no
reason to compile against the NDK.  Add a new mutator to Soong that
creates a platform and an SDK variant for modules that set
sdk_version, and ignore sdk_version for the platform variant.  The
SDK variant will be used for embedding in APKs that may be installed
on older platforms.  Apexes use their own variants that enforce
backwards compatibility.

Test: sdk_test.go
Test: TestJNIPackaging
Bug: 149591340
Change-Id: I7d72934aaee2e1326cc0ba5f29f51f14feec4521
2020-04-01 16:09:05 -07:00
Jooyung Han
03b5185b88 apex: choose stub according to min_sdk_version
Native modules within APEX should be linked with proper stub version
according to its min_sdk_version.

For example, when min_sdk_version is set to "29", libfoo in the apex
would be linked to libbar of version 29 from platform, even if it has
a newer version like 30.

Bug: 145796956
Test: m nothing (soong tests)
Change-Id: I4a0b2002587bc24b7deeb5d59b6eeba5e1db5b1f
2020-03-07 03:12:45 +09:00
Jiyong Park
2bb26d3fad Merge "<apex_name>-deps-info correctly tracks dependencies" 2020-02-12 00:47:21 +00:00
Ivan Lozano
2b2aee33a7 Merge "Pass library kind when linking native libraries." 2020-02-10 16:50:40 +00:00
Ivan Lozano
6aa660218e Pass library kind when linking native libraries.
When linking native libraries with rustc, be explicit about the
kind of native library being linked. This prevents confusion when
two kinds of one library (e.g. static/dynamic) are available in
the library search paths.

Bug: 147140513
Test: The correct prebuilt is selected when linking native prebuilts.
Change-Id: I37975bcd284e6c33ce3dd45fab8a3b5011b0803b
2020-02-07 08:29:13 -05:00
Jiyong Park
678c881a4f <apex_name>-deps-info correctly tracks dependencies
The APEX dependency is more correctly tracked. Previously, the
dependency was tracked while we gather modules that will be installed to
an APEX. This actually was incorrect because we skipped many dependency
types that we don't need to follow to gather the modules list, such as
the headers dependency.

Now, the dependency is tracked directly when a module is mutated for an
APEX. In other words, if a module is mutated for an apex X, then the
module will appear in the X-deps-into.txt file.

This change also changes the format of the txt file. It now clearly
shows why a module is included in the APEX by showing the list of
modules that depend on the module.

Bug: 146323213
Test: m
Change-Id: I0a70cf9cce56e36565f9d55683fdaace8748a081
2020-02-07 18:53:12 +09:00
Ivan Lozano
d648c43fec 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
2020-02-06 13:38:50 -05:00
Yifan Hong
1b3348d50a Add ramdisk image.
It is similar to recovery image.
Test: m nothing -j

Change-Id: I11389777c6bfb0c0d73bbb4c70091c1e70f44077
2020-01-22 16:54:18 -08:00
Jiyong Park
83dc74b770 Reland^2 "m <apex_name>-deps-info prints the internal/external deps of the APEX"
This reverts commit 7cb4d378e7.

Test: m
Test: ALLOW_MISSING_DEPENDENCIES=true DIST_DIR=out/dist ./art/tools/dist_linux_bionic.sh -j80 com.android.art.host
(in the master-art-host branch)

Change-Id: I9beca73aafdf42f03bfa19cf1634b2641dac417b
2020-01-14 18:40:56 +09:00
Jiyong Park
7cb4d378e7 Revert "Reland "m <apex_name>-deps-info prints the internal/external deps of the APEX"""
This reverts commit 956305c61c.

Reason for revert: broke master-art-host branch
Exempt-From-Owner-Approval: reverting a bad change

Change-Id: Id7faed4ee85328c7c65847a3543ea9e67a3d50b3
2020-01-14 08:58:02 +00:00
Jiyong Park
956305c61c Reland "m <apex_name>-deps-info prints the internal/external deps of the APEX""
This reverts commit 4513f703f9.

Bug: 1190898
Test: m
Test: EMMA_INSTRUMENT=true EMMA_INSTRUMENT_FRAMEWORK=true NATIVE_COVERAGE=true  m dist

Change-Id: I50fdccabb43e4751694db83ee451d388657257e0
2020-01-09 18:42:27 +09:00
Jiyong Park
4513f703f9 Revert "m <apex_name>-deps-info prints the internal/external deps of the APEX"
This reverts commit 114ff53f5e.

Reason for revert: broke cf_x86_phone-userdebug_coverage 

Change-Id: I7221fd0b0baee5407a7322240c170aef8e549e4d
2020-01-09 02:05:18 +00:00
Jiyong Park
114ff53f5e m <apex_name>-deps-info prints the internal/external deps of the APEX
We need to have a way to see the list of modules that directly or
indirectly contribute to an APEX. People find it difficult to determine
whether a module is included in which APEXes because APEX tracks
indirect dependencies as well as direct dependencies. Therefore, just
looking at Android.bp for the APEX itself doesn't give the answer.

This change adds a new make target <apex_name>-deps-info, which
generates out/soong/<apex_name>-deps-info.txt file that shows the
internal and external dependencies of the said APEX.
Here, internal means the dependencies are actually part of the
APEX, while external means the dependencies are still external to the
APEX.

Bug: 146323213
Test: m (apex_test amended)
Change-Id: I33d1ccf5d1ca335d71cd6ced0f5f66b8c3886d13
2020-01-02 09:41:30 +09:00
Chih-Hung Hsieh
9a4a7bab41 Install rust tests under nativetest(64)
* 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
2019-12-13 14:51:32 -08:00
Colin Cross
09ef474b6f Merge changes I0dcc9c7b,I9bc40642
* changes:
  Move cc.imageMutator into the android package
  Make CreateVariations return []android.Module
2019-11-25 22:30:17 +00:00
Ivan Lozano
2b26297dc7 Allow cc.LinkabeInterfaces to request "" variants.
cc.LinkableInterfaces should be able to request if an empty variant is
required from the LinkageMutator. We were previously assuming that if only
static or shared libraries were being built, then we didn't need the
empty variant. However this should be explicit to handle cases where the
default set of variants being created may not include both static and
shared libraries.

Bug: 144861059
Test: m -j crosvm.experimental
Change-Id: I66724bdc16ff350b06dfa4d049c82f33019979a5
2019-11-21 13:25:08 -08:00
Colin Cross
7228ecd5e3 Move cc.imageMutator into the android package
Prepare for making the image mutator available to all modules and
moving it between the os and arch mutators by moving it into the
android package and using an interface implemented by the module
types to control it.

Bug: 142286466
Test: No unexpected changes to out/soong/build.ninja
Change-Id: I0dcc9c7b5ec80edffade340c367f6ae4da34151b
2019-11-20 15:21:32 -08:00
Chih-hung Hsieh
8d7ae1aefe Merge "Add TestProperties, gen test config, fix names" 2019-11-15 04:28:41 +00:00
Chih-Hung Hsieh
41805bedbf Add TestProperties, gen test config, fix names
* Rename testBinaryDecorator to testDecorator
* Add TestProperties
  * Add install function for testDecorator to install config files
  * Add tradefed.AutoGenRustHostTestConfig
  * Depend on new build/make/core/rust_host_test_config_template.xml
    and new tradefed.testtype.rust.RustBinaryHostTest class
* Add autogenTemplateWithName in tradefed/autogen.go
  to generate config files with customized(mutated) executable name.
* Make rust_test module names more robust and easy to use.
  * Use crate name instead of source file name as the Stem
    for single source file modules, to match original user
    specified output file name in Cargo.toml.
  * Do not set up test module SubName when Stem is empty
    or when the module name already contains Stem suffix.
    That happens when TestPerSrcMutator is disabled or when
    there is only one source file with renamed output file name.
  * In TEST_MAPPING, references to mutated rust_test modules should be
    (1) <module_name> for single source file modules without mutation, or
    (2) <module_name>_<crate_name> for single source file modules, or
    (3) <module_name>_<source_file_base_name> for multi-file modules.

Bug: 140938178
Test: mm in rust projects, check output test file names
Change-Id: Ifdbfa14d5eed4f10b4fb983f82c93bbb9be3f899
2019-11-14 15:16:26 -08:00
Ivan Lozano
e0833b1f5c Allow cc modules to pull in rust includes.
Make sure LinkabeInterfaces can export include dirs to cc modules. This
fixes the Rust implementation and makes sure these are pulled in for cc
modules.

Bug: 144052093
Test: cc module depending on a rust library includes dirs correctly.
Change-Id: I6b5d5e6ab6afb507178b4f2cbdc45f01031dbfe4
2019-11-14 07:23:26 -08:00
Ivan Lozano
ad8b18b872 Enforce correct rust library file names.
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
2019-11-04 09:20:08 -08:00
Chih-Hung Hsieh
a5f22ed6b0 Add rust_test and rust_test_host.
* Rust tests are like binary files compiled with --test.
  New test.go follows binary.go code patterns and reuses
  some code in binary.go.
* Generate one test per source file as testPerSrc in cc/test.go.
  The "all tests" variation feature of cc/test.go is not copied yet.
  Fix some Stem and SubName settings to make testPerSrc work.
* Move cc.CheckDuplicate to android.CheckDuplicate,
  which is now shared by cc and rust.
* Refactor tests in binary_test.go and add new test_test.go.

Bug: 140938178
Test: mm in rust projects, added rust_test and rust_test_host
Change-Id: Ia6fec8b4cf2572fd352ab1938a1f3c7b5cca2212
2019-10-29 17:19:03 -07:00
Ivan Lozano
52767be335 Add support for Rust C libraries.
Adds the ability for rust modules to be compiled as C libraries, and
allows cc modules to depend on these rust-generated modules. This also
means that soong-rust should not have any dependencies on soong-cc aside
from what's required for testing.

There's a couple small fixes included as well:

 - A bug in libNameFromFilePath that caused issues when library's had
 "lib" in their name.
 - VariantName is removed from rust library MutatedProperties since this
 was unused.

Bug: 140726209
Test: Soong tests pass.
Test: Example cc_binary can include a rust shared library as a dep.
Test: m crosvm.experimental
Change-Id: Ia7deed1345d2423001089014cc65ce7934123da4
2019-10-28 22:09:01 -07:00
Ivan Lozano
183a3218e2 Add a common interface for cc linkable libraries.
Adds an interface, CcLinkableInterface, for cc linkable dependencies
which come from other toolchains such as Rust.

Bug: 140726209
Test: Soong tests pass, rust modules still compile.
Change-Id: I7378a46fad94fd0b735746aaf4e265fd2c2c04d8
2019-10-28 13:45:12 -07:00
Ivan Lozano
1c2ff86225 Add Rust darwin host support.
Support for building Rust modules on darwin hosts.

Bug: 140640858
Test: m libremain works on darwin
Change-Id: Ieb1ff9167de34cffbebebab31fa48da07081c8a6
2019-10-21 13:15:10 -07:00
Colin Cross
0f7d2ef3ac Add method to determine variations from a Target
The arch variants are hardcoded in every module type.  Refactor
them out into a Target.Variations() method in preparation for
splitting the arch mutator into two, which will require using
different variations.

Test: m checkbuild
Change-Id: I28ef7cd5168095ac888fe77f04e27f9ad81978c0
2019-10-16 14:52:30 -07:00
Ivan Lozano
f1c8433b40 Add AArch64 device Rust toolchain.
Bug: 141207434
Test: build example rust device module.
Change-Id: I0932a614942bf4a4d4b6c153fcc4fc79c7f202bd
2019-09-24 10:35:28 -07:00
Ivan Lozano
5ca5ef6788 Fix proc_macro dependency handling.
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
2019-09-24 10:35:20 -07:00
Ivan Lozano
e169ad70a5 Add OWNERS for Rust whitelist.
Splits out the Rust paths whitelist into a separate file
under config/ so that OWNERS can be defined for it.

Bug: 141207129
Test: m -j crosvm.experimental
Change-Id: I5effa6783e5c47560b4b1eae12ad0eb9e9ba96fe
2019-09-18 12:46:28 -07:00
Ivan Lozano
70e0a07b99 Check Rust dep is a Module before checking target.
The Target checks against the os type and arch type occur before we
determine a dependency is a rust.Module / cc.Module. This meant
rust_defaults would fail this check, preventing them from being used.

Bug: 140963307
Test: make a rust_binary_host using rust_defaults.
Change-Id: Ibf43635f14ad367b4ce8016a2196f8c645b36bfe
2019-09-13 14:43:57 -07:00
Ivan Lozano
de25291b6e Disable unsupported Rust targets.
Explicitly disable targets requiring unsupported toolchains when
processing Rust modules.

Bug: 140640858
Test: Darwin builds no longer breaking.
Change-Id: I8c60a2829508ae6de16bf347060818ca5c04f65e
2019-09-06 16:06:21 -07:00
Ivan Lozano
ffee334706 Add Rust support to Soong.
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
2019-08-28 14:11:07 -07:00