Revert "Make RuleBuilder methods take Paths"

This reverts commit acdd6940719125104dfd2f692990c99682f95f05.

Reason for revert: broke ndk build

Change-Id: I5655e48c15eb8f5f0267afdd853fbc25765b8623
diff --git a/dexpreopt/dexpreopt_gen/dexpreopt_gen.go b/dexpreopt/dexpreopt_gen/dexpreopt_gen.go
index c72f684..cc3c1f1 100644
--- a/dexpreopt/dexpreopt_gen/dexpreopt_gen.go
+++ b/dexpreopt/dexpreopt_gen/dexpreopt_gen.go
@@ -21,7 +21,6 @@
 	"os"
 	"path/filepath"
 	"runtime"
-	"strings"
 
 	"android/soong/android"
 	"android/soong/dexpreopt"
@@ -34,17 +33,8 @@
 	stripScriptPath     = flag.String("strip_script", "", "path to output strip script")
 	globalConfigPath    = flag.String("global", "", "path to global configuration file")
 	moduleConfigPath    = flag.String("module", "", "path to module configuration file")
-	outDir              = flag.String("out_dir", "", "path to output directory")
 )
 
-type pathContext struct {
-	config android.Config
-}
-
-func (x *pathContext) Fs() pathtools.FileSystem   { return pathtools.OsFs }
-func (x *pathContext) Config() android.Config     { return x.config }
-func (x *pathContext) AddNinjaFileDeps(...string) {}
-
 func main() {
 	flag.Parse()
 
@@ -76,26 +66,18 @@
 		usage("path to module configuration file is required")
 	}
 
-	ctx := &pathContext{android.TestConfig(*outDir, nil)}
-
-	globalConfig, err := dexpreopt.LoadGlobalConfig(ctx, *globalConfigPath)
+	globalConfig, err := dexpreopt.LoadGlobalConfig(*globalConfigPath)
 	if err != nil {
 		fmt.Fprintf(os.Stderr, "error loading global config %q: %s\n", *globalConfigPath, err)
 		os.Exit(2)
 	}
 
-	moduleConfig, err := dexpreopt.LoadModuleConfig(ctx, *moduleConfigPath)
+	moduleConfig, err := dexpreopt.LoadModuleConfig(*moduleConfigPath)
 	if err != nil {
 		fmt.Fprintf(os.Stderr, "error loading module config %q: %s\n", *moduleConfigPath, err)
 		os.Exit(2)
 	}
 
-	// This shouldn't be using *PathForTesting, but it's outside of soong_build so its OK for now.
-	moduleConfig.StripInputPath = android.PathForTesting("$1")
-	moduleConfig.StripOutputPath = android.WritablePathForTesting("$2")
-
-	moduleConfig.DexPath = android.PathForTesting("$1")
-
 	defer func() {
 		if r := recover(); r != nil {
 			switch x := r.(type) {
@@ -110,30 +92,30 @@
 		}
 	}()
 
-	writeScripts(ctx, globalConfig, moduleConfig, *dexpreoptScriptPath, *stripScriptPath)
+	writeScripts(globalConfig, moduleConfig, *dexpreoptScriptPath, *stripScriptPath)
 }
 
-func writeScripts(ctx android.PathContext, global dexpreopt.GlobalConfig, module dexpreopt.ModuleConfig,
+func writeScripts(global dexpreopt.GlobalConfig, module dexpreopt.ModuleConfig,
 	dexpreoptScriptPath, stripScriptPath string) {
-	dexpreoptRule, err := dexpreopt.GenerateDexpreoptRule(ctx, global, module)
+	dexpreoptRule, err := dexpreopt.GenerateDexpreoptRule(global, module)
 	if err != nil {
 		panic(err)
 	}
 
-	installDir := module.BuildPath.InSameDir(ctx, "dexpreopt_install")
+	installDir := filepath.Join(filepath.Dir(module.BuildPath), "dexpreopt_install")
 
-	dexpreoptRule.Command().FlagWithArg("rm -rf ", installDir.String())
-	dexpreoptRule.Command().FlagWithArg("mkdir -p ", installDir.String())
+	dexpreoptRule.Command().FlagWithArg("rm -rf ", installDir)
+	dexpreoptRule.Command().FlagWithArg("mkdir -p ", installDir)
 
 	for _, install := range dexpreoptRule.Installs() {
-		installPath := installDir.Join(ctx, strings.TrimPrefix(install.To, "/"))
-		dexpreoptRule.Command().Text("mkdir -p").Flag(filepath.Dir(installPath.String()))
+		installPath := filepath.Join(installDir, install.To)
+		dexpreoptRule.Command().Text("mkdir -p").Flag(filepath.Dir(installPath))
 		dexpreoptRule.Command().Text("cp -f").Input(install.From).Output(installPath)
 	}
 	dexpreoptRule.Command().Tool(global.Tools.SoongZip).
-		FlagWithArg("-o ", "$2").
-		FlagWithArg("-C ", installDir.String()).
-		FlagWithArg("-D ", installDir.String())
+		FlagWithOutput("-o ", "$2").
+		FlagWithArg("-C ", installDir).
+		FlagWithArg("-D ", installDir)
 
 	stripRule, err := dexpreopt.GenerateStripRule(global, module)
 	if err != nil {
@@ -157,7 +139,7 @@
 		for _, input := range rule.Inputs() {
 			// Assume the rule that ran the script already has a dependency on the input file passed on the
 			// command line.
-			if input.String() != "$1" {
+			if input != "$1" {
 				fmt.Fprintf(depFile, `    %s \`+"\n", input)
 			}
 		}
@@ -177,13 +159,13 @@
 	}
 
 	// The written scripts will assume the input is $1 and the output is $2
-	if module.DexPath.String() != "$1" {
+	if module.DexPath != "$1" {
 		panic(fmt.Errorf("module.DexPath must be '$1', was %q", module.DexPath))
 	}
-	if module.StripInputPath.String() != "$1" {
+	if module.StripInputPath != "$1" {
 		panic(fmt.Errorf("module.StripInputPath must be '$1', was %q", module.StripInputPath))
 	}
-	if module.StripOutputPath.String() != "$2" {
+	if module.StripOutputPath != "$2" {
 		panic(fmt.Errorf("module.StripOutputPath must be '$2', was %q", module.StripOutputPath))
 	}