mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 16:37:43 +00:00
Add BlazeWorkspace.forBuild()
Change-Id: I2b896716c7dc7f53c400e6ea516ecf0439e347b3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/264723 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Reviewed-by: Samuel Rawlins <srawlins@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
177b9a9278
commit
e3f77e928f
|
@ -460,6 +460,25 @@ class BlazeWorkspace extends Workspace
|
|||
return null;
|
||||
}
|
||||
|
||||
/// Create the Blaze workspace with the given [root].
|
||||
///
|
||||
/// This method should be used during build in google3, when we know for
|
||||
/// sure the workspace root, but [file_paths.blazeWorkspaceMarker] is not
|
||||
/// available.
|
||||
static BlazeWorkspace forBuild({
|
||||
required Folder root,
|
||||
}) {
|
||||
var provider = root.provider;
|
||||
var blazeBin = root.getChildAssumingFolder('blaze-bin');
|
||||
var blazeGenfiles = root.getChildAssumingFolder('blaze-genfiles');
|
||||
|
||||
var binPaths = _findBinFolderPaths(root);
|
||||
binPaths.add(blazeBin.path);
|
||||
|
||||
return BlazeWorkspace._(provider, root.path, binPaths, blazeGenfiles.path,
|
||||
lookForBuildFileSubstitutes: true);
|
||||
}
|
||||
|
||||
/// Find the "bin" folder path, by searching for it.
|
||||
///
|
||||
/// Depending on the environment we're working in (source code tree, build
|
||||
|
|
|
@ -980,6 +980,16 @@ class BlazeWorkspaceTest with ResourceProviderMixin {
|
|||
equals: '/workspace/blaze-genfiles/my/module/test3.dart');
|
||||
}
|
||||
|
||||
void test_forBuild() {
|
||||
// We don't have to create any resources, `forBuild()` does not check.
|
||||
var workspace = BlazeWorkspace.forBuild(
|
||||
root: getFolder('/workspace'),
|
||||
);
|
||||
expect(workspace.root, convertPath('/workspace'));
|
||||
expect(workspace.binPaths.single, convertPath('/workspace/blaze-bin'));
|
||||
expect(workspace.genfiles, convertPath('/workspace/blaze-genfiles'));
|
||||
}
|
||||
|
||||
/// Create new files and directories from [paths].
|
||||
void _addResources(List<String> paths) {
|
||||
for (String path in paths) {
|
||||
|
|
Loading…
Reference in a new issue