Skip to content
This repository was archived by the owner on Nov 10, 2023. It is now read-only.

Commit 7b6b03a

Browse files
IanChildsfacebook-github-bot
authored andcommitted
move D8 --intermediate to D8Options
Summary: We have a list of options, this should be one of them instead of being a random boolean Reviewed By: christolliday fbshipit-source-id: 5b9512ebceb2df0f5eaef409289f0ca85ba4605e
1 parent cb07ca6 commit 7b6b03a

6 files changed

Lines changed: 15 additions & 13 deletions

File tree

src/com/facebook/buck/android/D8Step.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ public class D8Step extends IsolatedStep {
6969
private final Set<Path> filesToDex;
7070
private final Set<D8Options> options;
7171
private final Optional<Path> primaryDexClassNamesPath;
72-
private final boolean intermediate;
7372
// used to differentiate different dexing buckets (if any)
7473
private final Optional<String> bucketId;
7574
private final Optional<Integer> minSdkVersion;
@@ -95,7 +94,6 @@ public D8Step(
9594
filesToDex,
9695
options,
9796
Optional.empty(),
98-
false,
9997
null,
10098
Optional.empty(),
10199
Optional.empty() /* minSdkVersion */);
@@ -117,7 +115,6 @@ public D8Step(
117115
Iterable<Path> filesToDex,
118116
EnumSet<D8Options> options,
119117
Optional<Path> primaryDexClassNamesPath,
120-
boolean intermediate,
121118
@Nullable Collection<Path> classpathFiles,
122119
Optional<String> bucketId,
123120
Optional<Integer> minSdkVersion) {
@@ -129,7 +126,6 @@ public D8Step(
129126
this.filesToDex = ImmutableSet.copyOf(filesToDex);
130127
this.options = Sets.immutableEnumSet(options);
131128
this.primaryDexClassNamesPath = primaryDexClassNamesPath.map(filesystem::resolve);
132-
this.intermediate = intermediate;
133129
this.bucketId = bucketId;
134130
this.minSdkVersion = minSdkVersion;
135131
}
@@ -163,7 +159,7 @@ private int executeInProcess(IsolatedExecutionContext context) throws IOExceptio
163159
D8Command.Builder builder =
164160
D8Command.builder(diagnosticsHandler)
165161
.addProgramFiles(inputs)
166-
.setIntermediate(intermediate)
162+
.setIntermediate(options.contains(D8Options.INTERMEDIATE))
167163
.addLibraryFiles(androidPlatformTarget.getAndroidJar())
168164
.setMode(
169165
options.contains(D8Options.NO_OPTIMIZE)
@@ -273,7 +269,7 @@ public String getIsolatedStepDescription(IsolatedExecutionContext context) {
273269
commandArgs.add("--force-jumbo");
274270
}
275271

276-
if (intermediate) {
272+
if (options.contains(D8Options.INTERMEDIATE)) {
277273
commandArgs.add("--intermediate");
278274
}
279275

src/com/facebook/buck/android/DexProducedFromJavaLibrary.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ public ImmutableList<Step> getBuildSteps(
202202

203203
// To be conservative, use --force-jumbo for these intermediate .dex files so that they can
204204
// be merged into a final classes.dex that uses jumbo instructions.
205-
EnumSet<D8Options> options = EnumSet.of(D8Options.NO_OPTIMIZE, D8Options.FORCE_JUMBO);
205+
EnumSet<D8Options> options =
206+
EnumSet.of(D8Options.NO_OPTIMIZE, D8Options.FORCE_JUMBO, D8Options.INTERMEDIATE);
206207
if (!desugarEnabled) {
207208
options.add(D8Options.NO_DESUGAR);
208209
}
@@ -214,7 +215,6 @@ public ImmutableList<Step> getBuildSteps(
214215
Collections.singleton(pathToOutputFile.getPath()),
215216
options,
216217
Optional.empty(),
217-
true,
218218
getAbsolutePaths(desugarDeps, sourcePathResolverAdapter),
219219
Optional.empty(),
220220
Optional.empty() /* minSdkVersion */);

src/com/facebook/buck/android/SmartDexingStep.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,6 @@ static void createDxStepForDxPseudoRule(
543543
filesToDex,
544544
dxOptions,
545545
primaryDexClassNamesPath,
546-
false,
547546
classpathFiles,
548547
buckedId,
549548
minSdkVersion));
@@ -583,7 +582,6 @@ static void createDxStepForDxPseudoRule(
583582
filesToDex,
584583
dxOptions,
585584
primaryDexClassNamesPath,
586-
false,
587585
classpathFiles,
588586
buckedId,
589587
minSdkVersion));
@@ -617,7 +615,6 @@ static void createDxStepForDxPseudoRule(
617615
filesToDex,
618616
dxOptions,
619617
primaryDexClassNamesPath,
620-
false,
621618
classpathFiles,
622619
buckedId,
623620
minSdkVersion));

src/com/facebook/buck/android/dex/D8Options.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,8 @@ public enum D8Options {
2626

2727
/** Disable java 8 desugaring when running D8 dexing tool. */
2828
NO_DESUGAR,
29+
30+
/** Compile an intermediate result intended for later merging */
31+
INTERMEDIATE,
2932
;
3033
}

test/com/facebook/buck/android/D8StepTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ public void testMinSdkVersion() throws IOException {
155155
SAMPLE_FILES_TO_DEX,
156156
EnumSet.noneOf(D8Options.class),
157157
Optional.empty(),
158-
false,
159158
ImmutableSet.of(),
160159
Optional.empty(),
161160
Optional.of(28));
@@ -196,7 +195,6 @@ public void testMainDexList() throws IOException {
196195
SAMPLE_FILES_TO_DEX,
197196
EnumSet.noneOf(D8Options.class),
198197
Optional.of(mainDexFilePath),
199-
false,
200198
ImmutableSet.of(),
201199
Optional.empty(),
202200
Optional.empty());

test/com/facebook/buck/android/DexProducedFromJavaLibraryTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,14 @@ public ImmutableSortedMap<String, HashCode> getClassNamesToHashes() {
113113
.getSourcePathResolver()
114114
.getAbsolutePath(javaLibRule.getSourcePathToOutput())
115115
.getPath()));
116+
117+
assertThat(
118+
d8Step.getIsolatedStepDescription(null),
119+
Matchers.allOf(
120+
Matchers.containsString("--no-desugaring"),
121+
Matchers.containsString("--intermediate"),
122+
Matchers.containsString("--force-jumbo"),
123+
Matchers.containsString("--debug")));
116124
}
117125

118126
private void createFiles(ProjectFilesystem filesystem, String... paths) throws IOException {

0 commit comments

Comments
 (0)