-
Notifications
You must be signed in to change notification settings - Fork 522
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: don't bake COMPILATION_MODE into launcher as exported environmen…
…t var This approach is incorrect as tools that are build for host such as "rollup_bin" in the rollup_bundle rule will see the --host_compilation_mode and not the --compilation_mode configuration value when built by Bazel as their cfg in the rule is correctly set to "host". ``` "rollup_bin": attr.label( doc = "Target that executes the rollup binary", executable = True, cfg = "host", default = "@npm//rollup/bin:rollup", ), ``` The correct approach is to pass COMPILATION_MODE via the actions.run env attribute. For the rollup_bundle rollup_bin tool, this is passed via run_node: ``` def run_node(ctx, inputs, arguments, executable, **kwargs): """Helper to replace ctx.actions.run This calls node programs with a node_modules directory in place""" .... # Forward the COMPILATION_MODE to node process as an environment variable env = kwargs.pop("env", {}) if "COMPILATION_MODE" not in env.keys(): env["COMPILATION_MODE"] = ctx.var["COMPILATION_MODE"] ctx.actions.run( inputs = inputs + extra_inputs, arguments = arguments, executable = exec_exec, env = env, **kwargs ) ``` for other tools such the terser_minified terser_bin tool, this is done directly in ctx.actions.run: ``` ctx.actions.run( inputs = inputs, outputs = outputs, executable = ctx.executable.terser_bin, arguments = [args], env = {"COMPILATION_MODE": ctx.var["COMPILATION_MODE"]}, progress_message = "Minifying JavaScript %s [terser]" % (outputs[0].short_path), ) ``` Accordingly `COMPILATION_MODE` is removed from default_env_vars so it is not baked into the launcher.sh. `DEBUG` is also removed as a DEBUG define should not be default be passed to all nodejs_binary targets as it may unexpectantly affect the build outputs and if you do want to pass --define=DEBUG=1 to a tool such as the bazel_integration_test test_runner.js, also forwarding it to all nodejs_binaries will result in a massive cache invalidation.
- Loading branch information
1 parent
0abc7f2
commit 8a931d8
Showing
13 changed files
with
38 additions
and
17 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
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,7 @@ | ||
/** | ||
* @license A dummy license banner that goes at the top of the file. | ||
* This is version v1.2.3_debug | ||
*/ | ||
|
||
// License banner with version stamp will appear here | ||
console.error('stamp'); |
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