Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fdf99b1a authored by Seth Moore's avatar Seth Moore Committed by Automerger Merge Worker
Browse files

Merge "Flag an error on empty rust module srcs" am: 6ec96b81 am: 2e2fb66e

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1852788

Change-Id: Ie077120f67aa8e01954bedf0534d2530618aa235
parents 74f79ad8 2e2fb66e
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -449,6 +449,10 @@ func (compiler *baseCompiler) relativeInstallPath() string {

// Returns the Path for the main source file along with Paths for generated source files from modules listed in srcs.
func srcPathFromModuleSrcs(ctx ModuleContext, srcs []string) (android.Path, android.Paths) {
	if len(srcs) == 0 {
		ctx.PropertyErrorf("srcs", "srcs must not be empty")
	}

	// The srcs can contain strings with prefix ":".
	// They are dependent modules of this module, with android.SourceDepTag.
	// They are not the main source file compiled by rustc.
+35 −0
Original line number Diff line number Diff line
@@ -98,6 +98,41 @@ func TestEnforceSingleSourceFile(t *testing.T) {
		}`)
}

// Test that we reject _no_ source files.
func TestEnforceMissingSourceFiles(t *testing.T) {

	singleSrcError := "srcs must not be empty"

	// Test libraries
	testRustError(t, singleSrcError, `
		rust_library_host {
			name: "foo-bar-library",
			crate_name: "foo",
		}`)

	// Test binaries
	testRustError(t, singleSrcError, `
		rust_binary_host {
			name: "foo-bar-binary",
			crate_name: "foo",
		}`)

	// Test proc_macros
	testRustError(t, singleSrcError, `
		rust_proc_macro {
			name: "foo-bar-proc-macro",
			crate_name: "foo",
		}`)

	// Test prebuilts
	testRustError(t, singleSrcError, `
		rust_prebuilt_dylib {
			name: "foo-bar-prebuilt",
			crate_name: "foo",
		  host_supported: true,
		}`)
}

// Test environment vars for Cargo compat are set.
func TestCargoCompat(t *testing.T) {
	ctx := testRust(t, `