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

Commit 455e3a08 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Move/dedupe some host path functions in package_ctx.go."

parents 8fc9eeac 7260d066
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -418,6 +418,18 @@ func (c *config) HostToolPath(ctx PathContext, tool string) Path {
	return PathForOutput(ctx, "host", c.PrebuiltOS(), "bin", tool)
}

func (c *config) HostJNIToolPath(ctx PathContext, path string) Path {
	ext := ".so"
	if runtime.GOOS == "darwin" {
		ext = ".dylib"
	}
	return PathForOutput(ctx, "host", c.PrebuiltOS(), "lib64", path+ext)
}

func (c *config) HostJavaToolPath(ctx PathContext, path string) Path {
	return PathForOutput(ctx, "host", c.PrebuiltOS(), "framework", path)
}

// HostSystemTool looks for non-hermetic tools from the system we're running on.
// Generally shouldn't be used, but useful to find the XCode SDK, etc.
func (c *config) HostSystemTool(name string) string {
+3 −20
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@ package android

import (
	"fmt"
	"runtime"
	"strings"

	"github.com/google/blueprint"
@@ -177,46 +176,30 @@ func (p PackageContext) SourcePathVariableWithEnvOverride(name, path, env string
// package-scoped variable's initialization.
func (p PackageContext) HostBinToolVariable(name, path string) blueprint.Variable {
	return p.VariableFunc(name, func(ctx PackageVarContext) string {
		return p.HostBinToolPath(ctx, path).String()
		return ctx.Config().HostToolPath(ctx, path).String()
	})
}

func (p PackageContext) HostBinToolPath(ctx PackageVarContext, path string) Path {
	return PathForOutput(ctx, "host", ctx.Config().PrebuiltOS(), "bin", path)
}

// HostJNIToolVariable returns a Variable whose value is the path to a host tool
// in the lib directory for host targets. It may only be called during a Go
// package's initialization - either from the init() function or as part of a
// package-scoped variable's initialization.
func (p PackageContext) HostJNIToolVariable(name, path string) blueprint.Variable {
	return p.VariableFunc(name, func(ctx PackageVarContext) string {
		return p.HostJNIToolPath(ctx, path).String()
		return ctx.Config().HostJNIToolPath(ctx, path).String()
	})
}

func (p PackageContext) HostJNIToolPath(ctx PackageVarContext, path string) Path {
	ext := ".so"
	if runtime.GOOS == "darwin" {
		ext = ".dylib"
	}
	return PathForOutput(ctx, "host", ctx.Config().PrebuiltOS(), "lib64", path+ext)
}

// HostJavaToolVariable returns a Variable whose value is the path to a host
// tool in the frameworks directory for host targets. It may only be called
// during a Go package's initialization - either from the init() function or as
// part of a package-scoped variable's initialization.
func (p PackageContext) HostJavaToolVariable(name, path string) blueprint.Variable {
	return p.VariableFunc(name, func(ctx PackageVarContext) string {
		return p.HostJavaToolPath(ctx, path).String()
		return ctx.Config().HostJavaToolPath(ctx, path).String()
	})
}

func (p PackageContext) HostJavaToolPath(ctx PackageVarContext, path string) Path {
	return PathForOutput(ctx, "host", ctx.Config().PrebuiltOS(), "framework", path)
}

// IntermediatesPathVariable returns a Variable whose value is the intermediate
// directory appended with the supplied path. It may only be called during a Go
// package's initialization - either from the init() function or as part of a
+1 −1
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ func init() {
			if !ctx.Config().FrameworksBaseDirExists(ctx) {
				return filepath.Join(prebuiltDir, runtime.GOOS, "bin", tool)
			} else {
				return pctx.HostBinToolPath(ctx, tool).String()
				return ctx.Config().HostToolPath(ctx, tool).String()
			}
		})
	}
+1 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ func init() {
			// Use RenderScript prebuilts for unbundled builds but not PDK builds
			return filepath.Join("prebuilts/sdk/tools", runtime.GOOS, "bin/llvm-rs-cc")
		} else {
			return pctx.HostBinToolPath(ctx, "llvm-rs-cc").String()
			return ctx.Config().HostToolPath(ctx, "llvm-rs-cc").String()
		}
	})
}
+5 −5
Original line number Diff line number Diff line
@@ -124,7 +124,7 @@ func init() {
		if ctx.Config().UnbundledBuild() {
			return "prebuilts/build-tools/common/framework/" + turbine
		} else {
			return pctx.HostJavaToolPath(ctx, turbine).String()
			return ctx.Config().HostJavaToolPath(ctx, turbine).String()
		}
	})

@@ -170,7 +170,7 @@ func hostBinToolVariableWithSdkToolsPrebuilt(name, tool string) {
		if ctx.Config().UnbundledBuild() || ctx.Config().IsPdkBuild() {
			return filepath.Join("prebuilts/sdk/tools", runtime.GOOS, "bin", tool)
		} else {
			return pctx.HostBinToolPath(ctx, tool).String()
			return ctx.Config().HostToolPath(ctx, tool).String()
		}
	})
}
@@ -180,7 +180,7 @@ func hostJavaToolVariableWithSdkToolsPrebuilt(name, tool string) {
		if ctx.Config().UnbundledBuild() || ctx.Config().IsPdkBuild() {
			return filepath.Join("prebuilts/sdk/tools/lib", tool+".jar")
		} else {
			return pctx.HostJavaToolPath(ctx, tool+".jar").String()
			return ctx.Config().HostJavaToolPath(ctx, tool+".jar").String()
		}
	})
}
@@ -194,7 +194,7 @@ func hostJNIToolVariableWithSdkToolsPrebuilt(name, tool string) {
			}
			return filepath.Join("prebuilts/sdk/tools", runtime.GOOS, "lib64", tool+ext)
		} else {
			return pctx.HostJNIToolPath(ctx, tool).String()
			return ctx.Config().HostJNIToolPath(ctx, tool).String()
		}
	})
}
@@ -204,7 +204,7 @@ func hostBinToolVariableWithBuildToolsPrebuilt(name, tool string) {
		if ctx.Config().UnbundledBuild() || ctx.Config().IsPdkBuild() {
			return filepath.Join("prebuilts/build-tools", ctx.Config().PrebuiltOS(), "bin", tool)
		} else {
			return pctx.HostBinToolPath(ctx, tool).String()
			return ctx.Config().HostToolPath(ctx, tool).String()
		}
	})
}
Loading