From ad8b18b87260a83aeadb28d637f77474158fcdb1 Mon Sep 17 00:00:00 2001 From: Ivan Lozano Date: Thu, 31 Oct 2019 19:38:29 -0700 Subject: 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 --- rust/proc_macro.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'rust/proc_macro.go') diff --git a/rust/proc_macro.go b/rust/proc_macro.go index 1a247d9b3..0da87dad1 100644 --- a/rust/proc_macro.go +++ b/rust/proc_macro.go @@ -77,3 +77,10 @@ func (procMacro *procMacroDecorator) compile(ctx ModuleContext, flags Flags, dep TransformSrctoProcMacro(ctx, srcPath, deps, flags, outputFile, deps.linkDirs) return outputFile } + +func (procMacro *procMacroDecorator) getStem(ctx ModuleContext) string { + stem := procMacro.baseCompiler.getStemWithoutSuffix(ctx) + validateLibraryStem(ctx, stem, procMacro.crateName()) + + return stem + String(procMacro.baseCompiler.Properties.Suffix) +} -- cgit v1.2.3-59-g8ed1b