Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Aspect templating - 2/n #6815

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ public abstract ListenableFuture<ExternalWorkspaceData> dumpRepoMapping(
BuildSystemName buildSystemName,
List<String> flags);

public abstract ListenableFuture<String> getDeps(
Project project,
BuildInvoker invoker,
BlazeContext context,
BuildSystemName buildSystemName,
List<String> flags);

/**
* @param args The arguments passed into `blaze mod ...`
* @param flags The blaze flags that will be passed to {@code blaze ...}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
public class BlazeModRunnerImpl extends BlazeModRunner {

private static final String DUMP_REPO_MAPPING = "dump_repo_mapping";
private static final String DEPS = "deps";
private static final String ROOT_WORKSPACE = "";

/**
Expand Down Expand Up @@ -82,6 +83,26 @@ public ListenableFuture<ExternalWorkspaceData> dumpRepoMapping(
BlazeExecutor.getInstance().getExecutor());
}

@Override
public ListenableFuture<String> getDeps(
Project project,
BuildSystem.BuildInvoker invoker,
BlazeContext context,
BuildSystemName buildSystemName,
List<String> flags) {

// TODO: when 8.0.0 is released add this only if it's disabled explicitly for the repo
flags.add("--noenable_workspace");

return Futures.transform(
runBlazeModGetBytes(
project, invoker, context, ImmutableList.of(DEPS, ROOT_WORKSPACE, "--output=json"), flags),
bytes -> new String(bytes, StandardCharsets.UTF_8),
BlazeExecutor.getInstance().getExecutor()
);

}

@Override
protected ListenableFuture<byte[]> runBlazeModGetBytes(
Project project,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class ExternalWorkspaceDataProvider {
private final Project project;

private volatile ExternalWorkspaceData externalWorkspaceData;
private ListenableFuture<String> deps;

public ExternalWorkspaceDataProvider(Project project) {
this.project = project;
Expand Down Expand Up @@ -104,11 +105,13 @@ public ListenableFuture<ExternalWorkspaceData> getExternalWorkspaceData(
.getBuildSystem()
.getDefaultInvoker(project, context);

deps = BlazeModRunner.getInstance().getDeps(project, buildInvoker, context, importSettings.getBuildSystem(), blazeFlags);
externalWorkspaceData =
BlazeModRunner.getInstance()
.dumpRepoMapping(
project, buildInvoker, context, importSettings.getBuildSystem(), blazeFlags)
.get();
deps.get();
} catch (InterruptedException | ExecutionException e) {
context.handleExceptionAsWarning(
"Failed to run `blaze mod dump_repo_mapping` (completion of labels from module provided repos will be unavailable)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,11 @@ public ListenableFuture<ExternalWorkspaceData> dumpRepoMapping(
return Futures.immediateFuture(ExternalWorkspaceData.EMPTY);
}

@Override
public ListenableFuture<String> getDeps(Project project, BuildInvoker invoker, BlazeContext context, BuildSystemName buildSystemName, List<String> flags) {
return Futures.immediateFuture(null);
}

@Override
protected ListenableFuture<byte[]> runBlazeModGetBytes(
Project project,
Expand Down
Loading