forked from angular/angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build(bazel): consolidate windows chromium path workaround
Add the hack to a central location so that it's easier to fix later.
- Loading branch information
1 parent
de48b19
commit a61397f
Showing
9 changed files
with
63 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
load("@build_bazel_rules_nodejs//:index.bzl", "js_library") | ||
|
||
package(default_visibility = ["//aio:__subpackages__"]) | ||
|
||
js_library( | ||
name = "windows-chromium-path", | ||
srcs = [ | ||
"windows-chromium-path.js", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const os = require('os'); | ||
const path = require('path'); | ||
|
||
/* | ||
TODO: this is a hack; the root cause should be found and fixed. | ||
For some unknown reason, the symlinked copy of chromium under runfiles won't run under | ||
karma on Windows. To work around this, use chromium under the execroot in the external | ||
folder and point to that instead. | ||
Return: | ||
The adjusted absolute chromium path to use on Windows. On other platforms this is a | ||
noop and returns the existing process.env.CHROME_BIN. | ||
*/ | ||
exports.getAdjustedChromeBinPathForWindows = function() { | ||
if (os.platform() === 'win32') { | ||
const runfilesWorkspaceRoot = path.join(process.env.RUNFILES, 'angular'); | ||
|
||
// Get the path to chromium from the runfiles base folder. By default, the Bazel make var | ||
// $(CHROMIUM) (which CHROME_BIN is set to) has a preceeding '../' to escape the workspace | ||
// root within runfiles. Additional '../' may have been prepended to cancel out any chdirs. | ||
const chromiumPath = process.env.CHROME_BIN.replace(/^(\.\.\/)*/, ''); | ||
|
||
// Escape from runfiles to the exec root | ||
const execRootSlashWorkspace = 'execroot' + path.sep + 'angular'; | ||
const index = runfilesWorkspaceRoot.indexOf(execRootSlashWorkspace); | ||
const execRootPath = runfilesWorkspaceRoot.substring(0, index + execRootSlashWorkspace.length); | ||
const runfilesToExecRoot = path.relative(runfilesWorkspaceRoot, execRootPath); | ||
|
||
// Resolve the path to chromium under the execroot | ||
const chromiumExecRootPath = path.resolve( | ||
runfilesWorkspaceRoot, | ||
runfilesToExecRoot, | ||
'external', | ||
chromiumPath | ||
); | ||
|
||
return chromiumExecRootPath; | ||
} | ||
return process.env.CHROME_BIN; | ||
} |