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

Commit b7db6b7c authored by Ivan Lozano's avatar Ivan Lozano Committed by Automerger Merge Worker
Browse files

Merge "[rust] Clean up unused link variations." am: bbec4c43

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

Change-Id: Ie8d2c3cdce43e5e07c3408cd7d20a021ffc309b2
parents efb9bb40 bbec4c43
Loading
Loading
Loading
Loading
+13 −19
Original line number Original line Diff line number Diff line
@@ -454,11 +454,6 @@ func LibraryMutator(mctx android.BottomUpMutatorContext) {
	if m, ok := mctx.Module().(*Module); ok && m.compiler != nil {
	if m, ok := mctx.Module().(*Module); ok && m.compiler != nil {
		switch library := m.compiler.(type) {
		switch library := m.compiler.(type) {
		case libraryInterface:
		case libraryInterface:

			// We only build the rust library variants here. This assumes that
			// LinkageMutator runs first and there's an empty variant
			// if rust variants are required.
			if !library.static() && !library.shared() {
			if library.buildRlib() && library.buildDylib() {
			if library.buildRlib() && library.buildDylib() {
				modules := mctx.CreateLocalVariations("rlib", "dylib")
				modules := mctx.CreateLocalVariations("rlib", "dylib")
				rlib := modules[0].(*Module)
				rlib := modules[0].(*Module)
@@ -476,4 +471,3 @@ func LibraryMutator(mctx android.BottomUpMutatorContext) {
		}
		}
	}
	}
}
}
}
+21 −28
Original line number Original line Diff line number Diff line
@@ -141,14 +141,10 @@ func (mod *Module) SelectedStl() string {


func (mod *Module) NonCcVariants() bool {
func (mod *Module) NonCcVariants() bool {
	if mod.compiler != nil {
	if mod.compiler != nil {
		if library, ok := mod.compiler.(libraryInterface); ok {
		if _, ok := mod.compiler.(libraryInterface); ok {
			if library.buildRlib() || library.buildDylib() {
				return true
			} else {
			return false
			return false
		}
		}
	}
	}
	}
	panic(fmt.Errorf("NonCcVariants called on non-library module: %q", mod.BaseModuleName()))
	panic(fmt.Errorf("NonCcVariants called on non-library module: %q", mod.BaseModuleName()))
}
}


@@ -162,16 +158,16 @@ func (mod *Module) Static() bool {
			return library.static()
			return library.static()
		}
		}
	}
	}
	panic(fmt.Errorf("Static called on non-library module: %q", mod.BaseModuleName()))
	return false
}
}


func (mod *Module) Shared() bool {
func (mod *Module) Shared() bool {
	if mod.compiler != nil {
	if mod.compiler != nil {
		if library, ok := mod.compiler.(libraryInterface); ok {
		if library, ok := mod.compiler.(libraryInterface); ok {
			return library.static()
			return library.shared()
		}
		}
	}
	}
	panic(fmt.Errorf("Shared called on non-library module: %q", mod.BaseModuleName()))
	return false
}
}


func (mod *Module) Toc() android.OptionalPath {
func (mod *Module) Toc() android.OptionalPath {
@@ -399,7 +395,9 @@ func (mod *Module) CcLibrary() bool {


func (mod *Module) CcLibraryInterface() bool {
func (mod *Module) CcLibraryInterface() bool {
	if mod.compiler != nil {
	if mod.compiler != nil {
		if _, ok := mod.compiler.(libraryInterface); ok {
		// use build{Static,Shared}() instead of {static,shared}() here because this might be called before
		// VariantIs{Static,Shared} is set.
		if lib, ok := mod.compiler.(libraryInterface); ok && (lib.buildShared() || lib.buildStatic()) {
			return true
			return true
		}
		}
	}
	}
@@ -754,7 +752,7 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
	ctx.VisitDirectDeps(func(dep android.Module) {
	ctx.VisitDirectDeps(func(dep android.Module) {
		depName := ctx.OtherModuleName(dep)
		depName := ctx.OtherModuleName(dep)
		depTag := ctx.OtherModuleDependencyTag(dep)
		depTag := ctx.OtherModuleDependencyTag(dep)
		if rustDep, ok := dep.(*Module); ok {
		if rustDep, ok := dep.(*Module); ok && !rustDep.CcLibraryInterface() {
			//Handle Rust Modules
			//Handle Rust Modules


			linkFile := rustDep.outputFile
			linkFile := rustDep.outputFile
@@ -816,17 +814,7 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
				}
				}
			}
			}


		}
		} else if ccDep, ok := dep.(cc.LinkableInterface); ok {

		if srcDep, ok := dep.(android.SourceFileProducer); ok {
			switch depTag {
			case android.SourceDepTag:
				// These are usually genrules which don't have per-target variants.
				directSrcDeps = append(directSrcDeps, srcDep)
			}
		}

		if ccDep, ok := dep.(cc.LinkableInterface); ok {
			//Handle C dependencies
			//Handle C dependencies
			if _, ok := ccDep.(*Module); !ok {
			if _, ok := ccDep.(*Module); !ok {
				if ccDep.Module().Target().Os != ctx.Os() {
				if ccDep.Module().Target().Os != ctx.Os() {
@@ -886,6 +874,14 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
				lib.exportDepFlags(depFlag)
				lib.exportDepFlags(depFlag)
			}
			}
		}
		}

		if srcDep, ok := dep.(android.SourceFileProducer); ok {
			switch depTag {
			case android.SourceDepTag:
				// These are usually genrules which don't have per-target variants.
				directSrcDeps = append(directSrcDeps, srcDep)
			}
		}
	})
	})


	var rlibDepFiles RustLibraries
	var rlibDepFiles RustLibraries
@@ -974,21 +970,18 @@ func (mod *Module) DepsMutator(actx android.BottomUpMutatorContext) {
	}
	}
	actx.AddVariationDependencies(
	actx.AddVariationDependencies(
		append(commonDepVariations, []blueprint.Variation{
		append(commonDepVariations, []blueprint.Variation{
			{Mutator: "rust_libraries", Variation: "rlib"},
			{Mutator: "rust_libraries", Variation: "rlib"}}...),
			{Mutator: "link", Variation: ""}}...),
		rlibDepTag, deps.Rlibs...)
		rlibDepTag, deps.Rlibs...)
	actx.AddVariationDependencies(
	actx.AddVariationDependencies(
		append(commonDepVariations, []blueprint.Variation{
		append(commonDepVariations, []blueprint.Variation{
			{Mutator: "rust_libraries", Variation: "dylib"},
			{Mutator: "rust_libraries", Variation: "dylib"}}...),
			{Mutator: "link", Variation: ""}}...),
		dylibDepTag, deps.Dylibs...)
		dylibDepTag, deps.Dylibs...)


	if deps.Rustlibs != nil {
	if deps.Rustlibs != nil {
		autoDep := mod.compiler.(autoDeppable).autoDep()
		autoDep := mod.compiler.(autoDeppable).autoDep()
		actx.AddVariationDependencies(
		actx.AddVariationDependencies(
			append(commonDepVariations, []blueprint.Variation{
			append(commonDepVariations, []blueprint.Variation{
				{Mutator: "rust_libraries", Variation: autoDep.variation},
				{Mutator: "rust_libraries", Variation: autoDep.variation}}...),
				{Mutator: "link", Variation: ""}}...),
			autoDep.depTag, deps.Rustlibs...)
			autoDep.depTag, deps.Rustlibs...)
	}
	}