@@ -745,18 +745,18 @@ def _apple_platform_patch(compile_args: typing.List[str]):
745
745
return compile_args
746
746
747
747
748
- def _emscripten_platform_patch (compile_args : typing . List [ str ], action_env : typing . Dict [ str , str ] ):
748
+ def _emscripten_platform_patch (compile_action ):
749
749
"""De-Bazel the command into something clangd can parse.
750
750
751
751
This function has fixes specific to Emscripten platforms, but you should call it on all platforms. It'll determine whether the fixes should be applied or not
752
752
"""
753
- emcc_driver = pathlib .Path (compile_args [0 ])
753
+ emcc_driver = pathlib .Path (compile_action . arguments [0 ])
754
754
if not emcc_driver .name .startswith ('emcc' ):
755
- return compile_args
755
+ return compile_action . arguments
756
756
757
757
workspace_absolute = pathlib .PurePath (os .environ ["BUILD_WORKSPACE_DIRECTORY" ])
758
758
759
- environment = dict ( action_env )
759
+ environment = compile_action . environmentVariables . copy ( )
760
760
environment ['EXT_BUILD_ROOT' ] = str (workspace_absolute )
761
761
environment ['EMCC_SKIP_SANITY_CHECK' ] = '1'
762
762
environment ['EM_COMPILER_WRAPPER' ] = str (pathlib .PurePath ({print_args_executable }))
@@ -765,9 +765,9 @@ def _emscripten_platform_patch(compile_args: typing.List[str], action_env: typin
765
765
766
766
# We run the emcc process with the environment variable EM_COMPILER_WRAPPER to intercept the command line arguments passed to `clang`.
767
767
emcc_process = subprocess .run (
768
- # On windows , it fails to spawn the subprocess when the path uses forward slashes as a separator.
768
+ # On Windows , it fails to spawn the subprocess when the path uses forward slashes as a separator.
769
769
# Here, we convert emcc driver path to use the native path separator.
770
- [str (emcc_driver )] + compile_args [1 :],
770
+ [str (emcc_driver )] + compile_action . arguments [1 :],
771
771
# MIN_PY=3.7: Replace PIPEs with capture_output.
772
772
stdout = subprocess .PIPE ,
773
773
stderr = subprocess .PIPE ,
@@ -1043,14 +1043,12 @@ def _get_cpp_command_for_files(compile_action):
1043
1043
1044
1044
Undo Bazel-isms and figures out which files clangd should apply the command to.
1045
1045
"""
1046
- env_pairs = getattr (compile_action , 'environmentVariables' , [])
1047
- env = {}
1048
- for pair in env_pairs :
1049
- env [pair .key ] = pair .value
1046
+ # Condense aquery's environment variables into a dictionary, the format you might expect.
1047
+ compile_action .environmentVariables = {pair .key : pair .value for pair in getattr (compile_action , 'environmentVariables' , [])}
1050
1048
1051
1049
# Patch command by platform, revealing any hidden arguments.
1052
1050
compile_action .arguments = _apple_platform_patch (compile_action .arguments )
1053
- compile_action .arguments = _emscripten_platform_patch (compile_action . arguments , action_env = env )
1051
+ compile_action .arguments = _emscripten_platform_patch (compile_action )
1054
1052
# Android and Linux and grailbio LLVM toolchains: Fine as is; no special patching needed.
1055
1053
compile_action .arguments = _all_platform_patch (compile_action .arguments )
1056
1054
0 commit comments