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

Commit 40c7bae1 authored by Colin Cross's avatar Colin Cross Committed by Gerrit Code Review
Browse files

Merge changes from topics "revert-2629131-sandbox-rust-inputs-JRFPQTIPEY",...

Merge changes from topics "revert-2629131-sandbox-rust-inputs-JRFPQTIPEY", "revert-2758566-WBNIADIEXA" into main

* changes:
  Revert^3 "add rust_toolchain_rustc_prebuilt module type"
  Revert^3 "add crate_root property to rust modules"
  Revert^3 "allow Ninja variables in RuleBuilder API"
  Revert "conditionally escape rule builder command"
  Revert "support sandboxed rust rules"
  Revert "fix failing rust_aconfig_library test"
  Revert "rustSetToolchainSource to use linux-x86 srcs"
  Revert "remove rust deps on clang prebuilts"
parents 4ad574cc 930fd8bf
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -50,11 +50,11 @@ func TestRustAconfigLibrary(t *testing.T) {
	}

	for _, variant := range variants {
		android.AssertStringListContains(
		android.AssertStringEquals(
			t,
			"dylib variant builds from generated rust code",
			variant.Rule("rustc").Implicits.RelativeToTop().Strings(),
			"out/soong/.intermediates/libmy_rust_aconfig_library/android_arm64_armv8-a_source/gen/src/lib.rs",
			variant.Rule("rustc").Inputs[0].RelativeToTop().String(),
		)
	}
}
+0 −17
Original line number Diff line number Diff line
@@ -95,12 +95,6 @@ func NewDepSet[T depSettableType](order DepSetOrder, direct []T, transitive []*D
	}
}

// AddDirectToDepSet returns a new DepSet with additional elements added to its direct set.
// The transitive sets remain untouched.
func AddDirectToDepSet[T depSettableType](d *DepSet[T], direct ...T) *DepSet[T] {
	return NewDepSet[T](d.order, Concat(d.direct, direct), d.transitive)
}

// DepSetBuilder is used to create an immutable DepSet.
type DepSetBuilder[T depSettableType] struct {
	order      DepSetOrder
@@ -194,14 +188,3 @@ func (d *DepSet[T]) ToList() []T {
	}
	return list
}

// ToListDirect returns the direct elements of a DepSet flattened to a list.
func (d *DepSet[T]) ToListDirect() []T {
	if d == nil {
		return nil
	}
	list := make([]T, len(d.direct))
	copy(list, d.direct)
	list = firstUniqueInPlace(list)
	return list
}
+0 −60
Original line number Diff line number Diff line
@@ -171,9 +171,6 @@ type Path interface {
	// Base returns the last element of the path
	Base() string

	// Dir returns a path pointing the directory containing the path
	Dir() Path

	// Rel returns the portion of the path relative to the directory it was created from.  For
	// example, Rel on a PathsForModuleSrc would return the path relative to the module source
	// directory, and OutputPath.Join("foo").Rel() would return "foo".
@@ -1015,12 +1012,6 @@ func (p basePath) Base() string {
	return filepath.Base(p.path)
}

func (p basePath) Dir() Path {
	p.path = filepath.Dir(p.path)
	p.rel = filepath.Dir(p.rel)
	return p
}

func (p basePath) Rel() string {
	if p.rel != "" {
		return p.rel
@@ -1055,11 +1046,6 @@ func (p SourcePath) withRel(rel string) SourcePath {
	return p
}

func (p SourcePath) Dir() Path {
	p.basePath = p.basePath.Dir().(basePath)
	return p
}

// safePathForSource is for paths that we expect are safe -- only for use by go
// code that is embedding ninja variables in paths
func safePathForSource(ctx PathContext, pathComponents ...string) (SourcePath, error) {
@@ -1262,12 +1248,6 @@ func (p OutputPath) withRel(rel string) OutputPath {
	return p
}

func (p OutputPath) Dir() Path {
	p.basePath = p.basePath.Dir().(basePath)
	p.fullPath = filepath.Dir(p.fullPath)
	return p
}

func (p OutputPath) WithoutRel() OutputPath {
	p.basePath.rel = filepath.Base(p.basePath.path)
	return p
@@ -1300,11 +1280,6 @@ type toolDepPath struct {
	basePath
}

func (p toolDepPath) Dir() Path {
	p.basePath = p.basePath.Dir().(basePath)
	return p
}

func (t toolDepPath) RelativeToTop() Path {
	ensureTestOnly()
	return t
@@ -1488,11 +1463,6 @@ type ModuleOutPath struct {
	OutputPath
}

func (p ModuleOutPath) Dir() Path {
	p.OutputPath = p.OutputPath.Dir().(OutputPath)
	return p
}

func (p ModuleOutPath) RelativeToTop() Path {
	p.OutputPath = p.outputPathRelativeToTop()
	return p
@@ -1537,11 +1507,6 @@ type ModuleGenPath struct {
	ModuleOutPath
}

func (p ModuleGenPath) Dir() Path {
	p.ModuleOutPath = p.ModuleOutPath.Dir().(ModuleOutPath)
	return p
}

func (p ModuleGenPath) RelativeToTop() Path {
	p.OutputPath = p.outputPathRelativeToTop()
	return p
@@ -1581,11 +1546,6 @@ type ModuleObjPath struct {
	ModuleOutPath
}

func (p ModuleObjPath) Dir() Path {
	p.ModuleOutPath = p.ModuleOutPath.Dir().(ModuleOutPath)
	return p
}

func (p ModuleObjPath) RelativeToTop() Path {
	p.OutputPath = p.outputPathRelativeToTop()
	return p
@@ -1610,11 +1570,6 @@ type ModuleResPath struct {
	ModuleOutPath
}

func (p ModuleResPath) Dir() Path {
	p.ModuleOutPath = p.ModuleOutPath.Dir().(ModuleOutPath)
	return p
}

func (p ModuleResPath) RelativeToTop() Path {
	p.OutputPath = p.outputPathRelativeToTop()
	return p
@@ -1651,11 +1606,6 @@ type InstallPath struct {
	makePath bool
}

func (p InstallPath) Dir() Path {
	p.basePath = p.basePath.Dir().(basePath)
	return p
}

// Will panic if called from outside a test environment.
func ensureTestOnly() {
	if PrefixInList(os.Args, "-test.") {
@@ -1972,11 +1922,6 @@ type PhonyPath struct {
	basePath
}

func (p PhonyPath) Dir() Path {
	p.basePath = p.basePath.Dir().(basePath)
	return p
}

func (p PhonyPath) writablePath() {}

func (p PhonyPath) getSoongOutDir() string {
@@ -2002,11 +1947,6 @@ type testPath struct {
	basePath
}

func (p testPath) Dir() Path {
	p.basePath = p.basePath.Dir().(basePath)
	return p
}

func (p testPath) RelativeToTop() Path {
	ensureTestOnly()
	return p
+6 −18
Original line number Diff line number Diff line
@@ -14,14 +14,10 @@

package android

import (
	"path/filepath"

	"github.com/google/blueprint"
)
import "path/filepath"

func init() {
	RegisterModuleType("prebuilt_build_tool", NewPrebuiltBuildTool)
	RegisterModuleType("prebuilt_build_tool", prebuiltBuildToolFactory)
}

type prebuiltBuildToolProperties struct {
@@ -59,13 +55,6 @@ func (t *prebuiltBuildTool) DepsMutator(ctx BottomUpMutatorContext) {
	}
}

type PrebuiltBuildToolInfo struct {
	Src  Path
	Deps Paths
}

var PrebuiltBuildToolInfoProvider = blueprint.NewProvider(PrebuiltBuildToolInfo{})

func (t *prebuiltBuildTool) GenerateAndroidBuildActions(ctx ModuleContext) {
	sourcePath := t.prebuilt.SingleSourcePath(ctx)
	installedPath := PathForModuleOut(ctx, t.BaseModuleName())
@@ -93,11 +82,6 @@ func (t *prebuiltBuildTool) GenerateAndroidBuildActions(ctx ModuleContext) {
	}

	t.toolPath = OptionalPathForPath(installedPath)

	ctx.SetProvider(PrebuiltBuildToolInfoProvider, PrebuiltBuildToolInfo{
		Src:  sourcePath,
		Deps: deps,
	})
}

func (t *prebuiltBuildTool) MakeVars(ctx MakeVarsModuleContext) {
@@ -117,6 +101,10 @@ var _ HostToolProvider = &prebuiltBuildTool{}

// prebuilt_build_tool is to declare prebuilts to be used during the build, particularly for use
// in genrules with the "tools" property.
func prebuiltBuildToolFactory() Module {
	return NewPrebuiltBuildTool()
}

func NewPrebuiltBuildTool() Module {
	module := &prebuiltBuildTool{}
	module.AddProperties(&module.properties)
+5 −42
Original line number Diff line number Diff line
@@ -474,23 +474,13 @@ func (r *RuleBuilder) depFileMergerCmd(depFiles WritablePaths) *RuleBuilderComma
		Inputs(depFiles.Paths())
}

// BuildWithNinjaVars adds the built command line to the build graph, with dependencies on Inputs and Tools, and output files for
// Outputs. This function will not escape Ninja variables, so it may be used to write sandbox manifests using Ninja variables.
func (r *RuleBuilder) BuildWithUnescapedNinjaVars(name string, desc string) {
	r.build(name, desc, false)
}

// Build adds the built command line to the build graph, with dependencies on Inputs and Tools, and output files for
// Outputs.
func (r *RuleBuilder) Build(name string, desc string) {
	r.build(name, desc, true)
}

func (r *RuleBuilder) build(name string, desc string, ninjaEscapeCommandString bool) {
	name = ninjaNameEscape(name)

	if len(r.missingDeps) > 0 {
		r.ctx.Build(r.pctx, BuildParams{
		r.ctx.Build(pctx, BuildParams{
			Rule:        ErrorRule,
			Outputs:     r.Outputs(),
			Description: desc,
@@ -629,35 +619,12 @@ func (r *RuleBuilder) build(name string, desc string, ninjaEscapeCommandString b
				name, r.sboxManifestPath.String(), r.outDir.String())
		}

		// Create a rule to write the manifest as textproto.
		// Create a rule to write the manifest as a the textproto.
		pbText, err := prototext.Marshal(&manifest)
		if err != nil {
			ReportPathErrorf(r.ctx, "sbox manifest failed to marshal: %q", err)
		}
		if ninjaEscapeCommandString {
		WriteFileRule(r.ctx, r.sboxManifestPath, string(pbText))
		} else {
			// We need  to have a rule to write files that is
			// defined on the RuleBuilder's pctx in order to
			// write Ninja variables in the string.
			// The WriteFileRule function above rule can only write
			// raw strings because it is defined on the android
			// package's pctx, and it can't access variables defined
			// in another context.
			r.ctx.Build(r.pctx, BuildParams{
				Rule: r.ctx.Rule(r.pctx, "unescapedWriteFile", blueprint.RuleParams{
					Command:        `rm -rf ${out} && cat ${out}.rsp > ${out}`,
					Rspfile:        "${out}.rsp",
					RspfileContent: "${content}",
					Description:    "write file",
				}, "content"),
				Output:      r.sboxManifestPath,
				Description: "write sbox manifest " + r.sboxManifestPath.Base(),
				Args: map[string]string{
					"content": string(pbText),
				},
			})
		}

		// Generate a new string to use as the command line of the sbox rule.  This uses
		// a RuleBuilderCommand as a convenience method of building the command line, then
@@ -756,13 +723,9 @@ func (r *RuleBuilder) build(name string, desc string, ninjaEscapeCommandString b
		pool = localPool
	}

	if ninjaEscapeCommandString {
		commandString = proptools.NinjaEscape(commandString)
	}

	r.ctx.Build(r.pctx, BuildParams{
		Rule: r.ctx.Rule(r.pctx, name, blueprint.RuleParams{
			Command:        commandString,
		Rule: r.ctx.Rule(pctx, name, blueprint.RuleParams{
			Command:        proptools.NinjaEscape(commandString),
			CommandDeps:    proptools.NinjaEscapeList(tools.Strings()),
			Restat:         r.restat,
			Rspfile:        proptools.NinjaEscape(rspFile),
Loading