Skip to content

Commit

Permalink
Remove R23 code generation and replace with static build and bzl files
Browse files Browse the repository at this point in the history
  • Loading branch information
ahumesky committed Nov 3, 2021
1 parent 76bbb84 commit 3de69da
Show file tree
Hide file tree
Showing 11 changed files with 989 additions and 437 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.AndroidNdkCrosstools.NdkCrosstoolsException;
import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.ApiLevel;
import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.NdkMajorRevision;
import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.NdkMajorRevision.NdkFile;
import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.NdkPaths;
import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.NdkRelease;
import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.StlImpl;
Expand Down Expand Up @@ -386,6 +387,33 @@ public RepositoryDirectoryValue.Builder fetch(
boolean siblingRepositoryLayout =
starlarkSemantics.getBool(BuildLanguageOptions.EXPERIMENTAL_SIBLING_REPOSITORY_LAYOUT);

if (ndkMajorRevision.isStatic()) {
for (NdkFile ndkFile : ndkMajorRevision.getStaticFiles()) {
writeFile(outputDirectory, ndkFile.name, ndkFile.content);
}
} else {
generateNdkFiles(
env,
ndkMajorRevision,
ruleName,
apiLevelString,
ndkRelease,
siblingRepositoryLayout,
outputDirectory);
}

return RepositoryDirectoryValue.builder().setPath(outputDirectory);
}

private void generateNdkFiles(
Environment env,
NdkMajorRevision ndkMajorRevision,
String ruleName,
String apiLevelString,
NdkRelease ndkRelease,
boolean siblingRepositoryLayout,
Path outputDirectory) throws RepositoryFunctionException {

ApiLevel apiLevel = ndkMajorRevision.apiLevel(env.getListener(), ruleName, apiLevelString);

ImmutableList.Builder<CrosstoolStlPair> crosstoolsAndStls = ImmutableList.builder();
Expand Down Expand Up @@ -424,7 +452,6 @@ public RepositoryDirectoryValue.Builder fetch(
.replaceAll(
"%big_conditional_populating_variables%",
Joiner.on("\n" + " ").join(bigConditional.build())));
return RepositoryDirectoryValue.builder().setPath(outputDirectory);
}

private ImmutableList<String> generateBzlConfigFor(String version, CToolchain toolchain) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private AndroidNdkCrosstools() {}
.put(20, new NdkMajorRevisionR20("8.0.7"))
.put(21, new NdkMajorRevisionR21("9.0.8"))
.put(22, new NdkMajorRevisionR21("11.0.5"))
.put(23, new NdkMajorRevisionR23("12.0.5"))
.put(23, new NdkMajorRevisionR23())
.build();

public static final Map.Entry<Integer, NdkMajorRevision> LATEST_KNOWN_REVISION =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

package com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools;

import com.google.common.collect.ImmutableList;
import com.google.devtools.build.lib.events.EventHandler;
import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CrosstoolRelease;

Expand All @@ -32,4 +33,22 @@ public interface NdkMajorRevision {
* and api level to architecture mappings.
*/
ApiLevel apiLevel(EventHandler eventHandler, String name, String apiLevel);

class NdkFile {
public final String name;
public final String content;

public NdkFile(String name, String content) {
this.name = name;
this.content = content;
}
}

default boolean isStatic() {
return false;
}

default ImmutableList<NdkFile> getStaticFiles() {
return ImmutableList.of();
}
}

This file was deleted.

This file was deleted.

Loading

0 comments on commit 3de69da

Please sign in to comment.