Skip to content

Commit a966f89

Browse files
ajsinclaircopybara-github
authored andcommitted
Add a min_sdk_version flag to the AK dex command.
PiperOrigin-RevId: 603456210 Change-Id: I725a150d4dda992fa2c957f598429c349b939a73
1 parent b5f360d commit a966f89

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/tools/ak/dex/dex.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"os"
2626
"os/exec"
2727
"path/filepath"
28+
"strconv"
2829
"strings"
2930
"sync"
3031

@@ -48,6 +49,7 @@ var (
4849
"dexbuilder",
4950
"in",
5051
"out",
52+
"min_sdk_version",
5153
},
5254
}
5355

@@ -59,6 +61,7 @@ var (
5961
desugar, androidJar, dexbuilder, in string
6062
classpaths, outs, outputDir flags.StringList
6163
desugarCoreLibs bool
64+
minSdkVersion int
6265

6366
initOnce sync.Once
6467
)
@@ -73,6 +76,7 @@ func Init() {
7376
flag.StringVar(&dexbuilder, "dexbuilder", "", "Path to dexbuilder")
7477
flag.StringVar(&in, "in", "", "Path to input")
7578
flag.Var(&outs, "out", "Path to output, if more than one specified, output is sharded across files.")
79+
flag.IntVar(&minSdkVersion, "min_sdk_version", 0, "Passthrough to d8 for desugaring and dexing.")
7680
})
7781
}
7882

@@ -176,6 +180,9 @@ func desugarJar(in, out string) error {
176180
"--output",
177181
out,
178182
}
183+
if minSdkVersion > 0 {
184+
args = append(args, "--min_sdk_version", strconv.Itoa(minSdkVersion))
185+
}
179186
if desugarCoreLibs {
180187
args = append(args, "--desugar_supported_core_libs")
181188
}
@@ -192,7 +199,9 @@ func dexBuilder(in, out string) error {
192199
"--output_zip",
193200
out,
194201
}
195-
202+
if minSdkVersion > 0 {
203+
args = append(args, "--min_sdk_version", strconv.Itoa(minSdkVersion))
204+
}
196205
return runCmd(dexbuilder, args)
197206
}
198207

0 commit comments

Comments
 (0)