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

Commit e1b39a52 authored by Liz Kammer's avatar Liz Kammer
Browse files

Handle prebuilt vs source selection in bp2build

Test: enable mainline modules build from prebuilts and build
Bug: 300640274
Change-Id: Ib1d6bbca7e0ab459515d3cf6378741e8368e7327
parent 9e2a5a7d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -340,6 +340,7 @@ var (
		"prebuilts/clang/host/linux-x86":                   Bp2BuildDefaultTrueRecursively,
		"prebuilts/gradle-plugin":                          Bp2BuildDefaultTrueRecursively,
		"prebuilts/runtime/mainline/platform/sdk":          Bp2BuildDefaultTrueRecursively,
		"prebuilts/module_sdk":                             Bp2BuildDefaultTrueRecursively,
		"prebuilts/sdk":                                    Bp2BuildDefaultTrue,
		"prebuilts/sdk/current/androidx":                   Bp2BuildDefaultTrue,
		"prebuilts/sdk/current/androidx-legacy":            Bp2BuildDefaultTrue,
+3 −0
Original line number Diff line number Diff line
@@ -487,6 +487,9 @@ func bp2buildModuleLabel(ctx BazelConversionContext, module blueprint.Module) st
	if moduleDir == Bp2BuildTopLevel {
		moduleDir = ""
	}
	if a, ok := module.(Module); ok && IsModulePrebuilt(a) {
		moduleName = RemoveOptionalPrebuiltPrefix(moduleName)
	}
	return fmt.Sprintf("//%s:%s", moduleDir, moduleName)
}

+5 −0
Original line number Diff line number Diff line
@@ -2073,6 +2073,11 @@ func (c *config) GetApiLibraries() map[string]struct{} {
	return c.apiLibraries
}

// Bp2buildMode indicates whether the config is for bp2build mode of Soong
func (c *config) Bp2buildMode() bool {
	return c.BuildMode == Bp2build
}

func (c *deviceConfig) CheckVendorSeappViolations() bool {
	return Bool(c.config.productVariables.CheckVendorSeappViolations)
}
+12 −2
Original line number Diff line number Diff line
@@ -3100,11 +3100,21 @@ func (b *baseModuleContext) ModuleFromName(name string) (blueprint.Module, bool)
	if !b.isBazelConversionMode() {
		panic("cannot call ModuleFromName if not in bazel conversion mode")
	}
	var m blueprint.Module
	var ok bool
	if moduleName, _ := SrcIsModuleWithTag(name); moduleName != "" {
		return b.bp.ModuleFromName(moduleName)
		m, ok = b.bp.ModuleFromName(moduleName)
	} else {
		return b.bp.ModuleFromName(name)
		m, ok = b.bp.ModuleFromName(name)
	}
	if !ok {
		return m, ok
	}
	// If this module is not preferred, tried to get the prebuilt version instead
	if a, aOk := m.(Module); aOk && !IsModulePrebuilt(a) && !IsModulePreferred(a) {
		return b.ModuleFromName("prebuilt_" + name)
	}
	return m, ok
}

func (b *baseModuleContext) VisitDirectDepsBlueprint(visit func(blueprint.Module)) {
+1 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ func registerMutatorsForBazelConversion(ctx *Context, bp2buildMutators []Registe
		// TODO(b/165114590): this is required to resolve deps that are only prebuilts, but we should
		// evaluate the impact on conversion.
		RegisterPrebuiltsPreArchMutators,
		RegisterPrebuiltsPostDepsMutators,
	},
		bp2buildMutators...)

Loading