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
This commit is contained in:
Ivan Lozano
2019-10-31 19:38:29 -07:00
parent 5d0b3b7195
commit ad8b18b872
7 changed files with 89 additions and 24 deletions

View File

@@ -225,11 +225,7 @@ func DefaultsFactory(props ...interface{}) android.Module {
}
func (mod *Module) CrateName() string {
if mod.compiler != nil && mod.compiler.crateName() != "" {
return mod.compiler.crateName()
}
// Default crate names replace '-' in the name to '_'
return strings.Replace(mod.BaseModuleName(), "-", "_", -1)
return mod.compiler.crateName()
}
func (mod *Module) CcLibrary() bool {