@@ -782,19 +782,6 @@ def _apple_platform_patch(compile_args: typing.List[str]):
782
782
return compile_args
783
783
784
784
785
- def _get_sysroot (args : typing .List [str ]):
786
- """Get path to sysroot from command line arguments."""
787
- for idx , arg in enumerate (args ):
788
- if arg == '--sysroot' or arg == '-isysroot' :
789
- if idx + 1 < len (args ):
790
- return pathlib .PurePath (args [idx + 1 ])
791
- elif arg .startswith ('--sysroot=' ):
792
- return pathlib .PurePath (arg [len ('--sysroot=' ):])
793
- elif arg .startswith ('-isysroot' ):
794
- return pathlib .PurePath (arg [len ('-isysroot' ):])
795
- return None
796
-
797
-
798
785
def _emscripten_platform_patch (compile_action ):
799
786
"""De-Bazel the command into something clangd can parse.
800
787
@@ -805,8 +792,18 @@ def _emscripten_platform_patch(compile_action):
805
792
return compile_action .arguments
806
793
807
794
workspace_absolute = pathlib .PurePath (os .environ ["BUILD_WORKSPACE_DIRECTORY" ])
808
- sysroot = _get_sysroot (compile_action .arguments )
809
- assert sysroot , f'Emscripten sysroot not detected in CMD: { compile_action .arguments } '
795
+
796
+ def _get_sysroot (args : typing .List [str ]):
797
+ """Get path to sysroot from command line arguments."""
798
+ for idx , arg in enumerate (args ):
799
+ if arg == '--sysroot' or arg == '-isysroot' :
800
+ if idx + 1 < len (args ):
801
+ return pathlib .PurePath (args [idx + 1 ])
802
+ elif arg .startswith ('--sysroot=' ):
803
+ return pathlib .PurePath (arg [len ('--sysroot=' ):])
804
+ elif arg .startswith ('-isysroot' ):
805
+ return pathlib .PurePath (arg [len ('-isysroot' ):])
806
+ return None
810
807
811
808
def get_workspace_root (path_from_execroot : pathlib .PurePath ):
812
809
if path_from_execroot .parts [0 ] != 'external' :
@@ -818,6 +815,8 @@ def get_workspace_root(path_from_execroot: pathlib.PurePath):
818
815
environment ['EMCC_SKIP_SANITY_CHECK' ] = '1'
819
816
environment ['EM_COMPILER_WRAPPER' ] = str (pathlib .PurePath ({print_args_executable }))
820
817
if 'EM_BIN_PATH' not in environment :
818
+ sysroot = _get_sysroot (compile_action .arguments )
819
+ assert sysroot , f'Emscripten sysroot not detected in CMD: { compile_action .arguments } '
821
820
environment ['EM_BIN_PATH' ] = str (get_workspace_root (sysroot ))
822
821
if 'EM_CONFIG_PATH' not in environment :
823
822
environment ['EM_CONFIG_PATH' ] = str (get_workspace_root (emcc_driver ) / 'emscripten_toolchain' / 'emscripten_config' )
0 commit comments