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

Commit 96d4f455 authored by Colin Cross's avatar Colin Cross Committed by Gerrit Code Review
Browse files

Merge changes from topic "revert-1366377-prebuilt_build_tool_make-RMDAHCHNNX"

* changes:
  Revert "Add prebuilt_build_tool to allow genrules to use prebuil..."
  Revert "Switch cc's use of bison and flex to prebuilt_build_tool"
  Revert "Fix builds with absolute OUT_DIR"
parents 1b478e57 bec7f53e
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@ bootstrap_go_package {
        "paths.go",
        "phony.go",
        "prebuilt.go",
        "prebuilt_build_tool.go",
        "proto.go",
        "register.go",
        "rule_builder.go",
+1 −1
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@ var (
	// A symlink rule.
	Symlink = pctx.AndroidStaticRule("Symlink",
		blueprint.RuleParams{
			Command:     "rm -f $out && ln -f -s $fromPath $out",
			Command:     "ln -f -s $fromPath $out",
			Description: "symlink $out",
		},
		"fromPath")

android/prebuilt_build_tool.go

deleted100644 → 0
+0 −100
Original line number Diff line number Diff line
// Copyright 2020 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package android

import (
	"path"
	"path/filepath"
)

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

type prebuiltBuildToolProperties struct {
	// Source file to be executed for this build tool
	Src *string `android:"path,arch_variant"`

	// Extra files that should trigger rules using this tool to rebuild
	Deps []string `android:"path,arch_variant"`
}

type prebuiltBuildTool struct {
	ModuleBase
	prebuilt Prebuilt

	properties prebuiltBuildToolProperties

	toolPath OptionalPath
}

func (t *prebuiltBuildTool) Name() string {
	return t.prebuilt.Name(t.ModuleBase.Name())
}

func (t *prebuiltBuildTool) Prebuilt() *Prebuilt {
	return &t.prebuilt
}

func (t *prebuiltBuildTool) DepsMutator(ctx BottomUpMutatorContext) {
	if t.properties.Src == nil {
		ctx.PropertyErrorf("src", "missing prebuilt source file")
	}
}

func (t *prebuiltBuildTool) GenerateAndroidBuildActions(ctx ModuleContext) {
	sourcePath := t.prebuilt.SingleSourcePath(ctx)
	installedPath := PathForModuleOut(ctx, t.ModuleBase.Name())
	deps := PathsForModuleSrc(ctx, t.properties.Deps)

	var relPath string
	if filepath.IsAbs(installedPath.String()) {
		relPath = filepath.Join(absSrcDir, sourcePath.String())
	} else {
		var err error
		relPath, err = filepath.Rel(path.Dir(installedPath.String()), sourcePath.String())
		if err != nil {
			ctx.ModuleErrorf("Unable to generate symlink between %q and %q: %s", installedPath.String(), sourcePath.String(), err)
		}
	}

	ctx.Build(pctx, BuildParams{
		Rule:      Symlink,
		Output:    installedPath,
		Input:     sourcePath,
		Implicits: deps,
		Args: map[string]string{
			"fromPath": relPath,
		},
	})

	t.toolPath = OptionalPathForPath(installedPath)
}

func (t *prebuiltBuildTool) HostToolPath() OptionalPath {
	return t.toolPath
}

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 {
	module := &prebuiltBuildTool{}
	module.AddProperties(&module.properties)
	InitSingleSourcePrebuiltModule(module, &module.properties, "Src")
	InitAndroidArchModule(module, HostSupportedNoCross, MultilibFirst)
	return module
}
+0 −31
Original line number Diff line number Diff line
@@ -116,8 +116,6 @@ type Deps struct {
	// Used for host bionic
	LinkerFlagsFile string
	DynamicLinker   string

	Tools []string
}

type PathDeps struct {
@@ -160,8 +158,6 @@ type PathDeps struct {

	// Path to the dynamic linker binary
	DynamicLinker android.OptionalPath

	Tools map[string]android.Path
}

// LocalOrGlobalFlags contains flags that need to have values set globally by the build system or locally by the module
@@ -429,12 +425,6 @@ type xref interface {
	XrefCcFiles() android.Paths
}

type ToolDependencyTag struct {
	blueprint.BaseDependencyTag

	Name string
}

var (
	dataLibDepTag         = DependencyTag{Name: "data_lib", Library: true, Shared: true}
	sharedExportDepTag    = DependencyTag{Name: "shared", Library: true, Shared: true, ReexportFlags: true}
@@ -1704,7 +1694,6 @@ func (c *Module) deps(ctx DepsContext) Deps {
	deps.LateSharedLibs = android.LastUniqueStrings(deps.LateSharedLibs)
	deps.HeaderLibs = android.LastUniqueStrings(deps.HeaderLibs)
	deps.RuntimeLibs = android.LastUniqueStrings(deps.RuntimeLibs)
	deps.Tools = android.LastUniqueStrings(deps.Tools)

	for _, lib := range deps.ReexportSharedLibHeaders {
		if !inList(lib, deps.SharedLibs) {
@@ -2048,11 +2037,6 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
			}, vndkExtDepTag, vndkdep.getVndkExtendsModuleName())
		}
	}

	for _, tool := range deps.Tools {
		actx.AddFarVariationDependencies(ctx.Config().BuildOSTarget.Variations(),
			ToolDependencyTag{Name: tool}, tool)
	}
}

func BeginMutator(ctx android.BottomUpMutatorContext) {
@@ -2248,21 +2232,6 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
		depName := ctx.OtherModuleName(dep)
		depTag := ctx.OtherModuleDependencyTag(dep)

		if toolDep, ok := depTag.(ToolDependencyTag); ok {
			if toolMod, ok := dep.(android.HostToolProvider); ok {
				if depPaths.Tools == nil {
					depPaths.Tools = make(map[string]android.Path)
				}
				toolPath := toolMod.HostToolPath()
				if !toolPath.Valid() {
					ctx.ModuleErrorf("Failed to find path for host tool %q", toolDep.Name)
				}
				depPaths.Tools[toolDep.Name] = toolPath.Path()
			} else {
				ctx.ModuleErrorf("Found module, but not host tool for %q", toolDep.Name)
			}
		}

		ccDep, ok := dep.(LinkableInterface)
		if !ok {

+1 −9
Original line number Diff line number Diff line
@@ -251,14 +251,6 @@ func (compiler *baseCompiler) compilerDeps(ctx DepsContext, deps Deps) Deps {
		deps.StaticLibs = append(deps.StaticLibs, "libomp")
	}

	if compiler.hasSrcExt(".y") || compiler.hasSrcExt(".yy") {
		deps.Tools = append(deps.Tools, "bison", "m4")
	}

	if compiler.hasSrcExt(".l") || compiler.hasSrcExt(".ll") {
		deps.Tools = append(deps.Tools, "flex", "m4")
	}

	return deps
}

@@ -589,7 +581,7 @@ func (compiler *baseCompiler) compile(ctx ModuleContext, flags Flags, deps PathD

	srcs := append(android.Paths(nil), compiler.srcsBeforeGen...)

	srcs, genDeps := genSources(ctx, srcs, buildFlags, deps.Tools)
	srcs, genDeps := genSources(ctx, srcs, buildFlags)
	pathDeps = append(pathDeps, genDeps...)

	compiler.pathDeps = pathDeps
Loading