Make --experimental_resolved_file_instead_of_workspace accept path relative to the workspace
Make the option --experimental_resolved_file_instead_of_workspace also accept
paths relative to the workspace, instead of only absolute paths. In this way,
users of resolved files can simply add an entry
build --experimental_resolved_file_instead_of_workspace=resolved.bzl
to their .bazelrc file.
@@ -308,11 +308,16 @@ public class BazelRepositoryModule extends BlazeModule {
}
if (!Strings.isNullOrEmpty(repoOptions.experimentalResolvedFileInsteadOfWorkspace)) {
+ Path resolvedFile;
+ if (env.getWorkspace() != null) {
+ resolvedFile =
+ env.getWorkspace()
+ .getRelative(repoOptions.experimentalResolvedFileInsteadOfWorkspace);
+ } else {
+ resolvedFile = filesystem.getPath(repoOptions.experimentalResolvedFileInsteadOfWorkspace);
+ }
resolvedFileReplacingWorkspace =
- Optional.of(
- RootedPath.toRootedPath(
- Root.absoluteRoot(filesystem),
- filesystem.getPath(repoOptions.experimentalResolvedFileInsteadOfWorkspace)));
+ Optional.of(RootedPath.toRootedPath(Root.absoluteRoot(filesystem), resolvedFile));
}
if (repoOptions.experimentalVerifyRepositoryRules != null) {
