@@ -161,7 +161,7 @@ def _cabal_toolchain_info(hs, cc, workspace_name, runghc):
161161 hsc2hs = hs .tools .hsc2hs .path ,
162162 runghc = runghc .path ,
163163 ar = ar ,
164- cc = cc .tools .cc ,
164+ cc = cc .tools .cc . executable . path ,
165165 ld = cc .tools .ld ,
166166 strip = cc .tools .strip ,
167167 is_windows = hs .toolchain .is_windows ,
@@ -179,8 +179,6 @@ def _prepare_cabal_inputs(
179179 direct_cc_info ,
180180 component ,
181181 package_id ,
182- tool_inputs ,
183- tool_input_manifests ,
184182 cabal ,
185183 setup ,
186184 setup_deps ,
@@ -252,7 +250,7 @@ def _prepare_cabal_inputs(
252250 env = dicts .add (hs .env , cc .env )
253251 env ["PATH" ] = join_path_list (
254252 hs .toolchain .is_windows ,
255- _binary_paths ( tool_inputs ) + posix .paths + hs .tools_config .path_for_cabal ,
253+ posix .paths + hs .tools_config .path_for_cabal ,
256254 )
257255 if hs .toolchain .is_darwin :
258256 env ["SDKROOT" ] = "macosx" # See haskell/private/actions/link.bzl
@@ -348,7 +346,6 @@ def _prepare_cabal_inputs(
348346 extra_ldflags_file = darwin_flags_for_linking_indirect_cc_deps (hs , cc , posix , hs .name , dynamic = True )
349347
350348 # Redundant with _binary_paths() above, but better be explicit when we can.
351- path_args .extend ([_cabal_tool_flag (tool_flag ) for tool_flag in tool_inputs .to_list () if _cabal_tool_flag (tool_flag )])
352349
353350 repo_name = "_main"
354351 if generate_paths_module and label and label .repo_name :
@@ -389,7 +386,6 @@ def _prepare_cabal_inputs(
389386 input_files ,
390387 transitive = [
391388 depset (srcs ),
392- depset (cc .files ),
393389 depset (ghc_files ),
394390 package_databases ,
395391 setup_dep_info .package_databases ,
@@ -402,18 +398,14 @@ def _prepare_cabal_inputs(
402398 setup_dep_info .hs_libraries ,
403399 dep_info .interface_dirs ,
404400 dep_info .hs_libraries ,
405- tool_inputs ,
406401 ],
407402 )
408- input_manifests = tool_input_manifests + hs .toolchain .cc_wrapper .manifests
409-
410403 runfiles_direct = runfiles_libs if static_binary else dynamic_libs
411404
412405 return struct (
413406 cabal_wrapper = cabal_wrapper ,
414407 args = args ,
415408 inputs = inputs ,
416- input_manifests = input_manifests ,
417409 env = env ,
418410 runfiles = depset (direct = runfiles_direct ),
419411 )
@@ -575,7 +567,7 @@ def _haskell_cabal_library_impl(ctx):
575567 ),
576568 sibling = cabal ,
577569 )
578- ( tool_inputs , tool_input_manifests ) = ctx . resolve_tools ( tools = ctx .attr .tools )
570+ attr_tools = [ tool [ DefaultInfo ]. files_to_run for tool in ctx .attr .tools ]
579571 c = _prepare_cabal_inputs (
580572 hs ,
581573 cc ,
@@ -586,8 +578,6 @@ def _haskell_cabal_library_impl(ctx):
586578 direct_cc_info ,
587579 component = "lib:{}" .format (ctx .attr .sublibrary_name or ctx .attr .package_name or hs .label .name ),
588580 package_id = package_id ,
589- tool_inputs = tool_inputs ,
590- tool_input_manifests = tool_input_manifests ,
591581 cabal = cabal ,
592582 setup = setup ,
593583 setup_deps = setup_deps ,
@@ -620,15 +610,23 @@ def _haskell_cabal_library_impl(ctx):
620610 if with_profiling :
621611 outputs .append (profiling_library )
622612
623- (_ , runghc_manifest ) = ctx .resolve_tools (tools = [ctx .attr ._runghc ])
624613 json_args = ctx .actions .declare_file ("{}_cabal_wrapper_args.json" .format (ctx .label .name ))
625614 ctx .actions .write (json_args , json .encode (c .args ))
615+
616+ # Ensure that dependent tools can be found.
617+ paths = []
618+ if "PATH" in c .env :
619+ paths .append (c .env ["PATH" ])
620+ paths .extend ([t .executable .dirname for t in attr_tools ])
621+ c .env ["PATH" ] = ":" .join (paths )
622+
626623 ctx .actions .run (
627624 executable = c .cabal_wrapper ,
628625 arguments = [json_args .path ],
629626 inputs = depset ([json_args ], transitive = [c .inputs ]),
630- input_manifests = c .input_manifests + runghc_manifest ,
631- tools = [c .cabal_wrapper , ctx .executable ._runghc ] + hs .tools_config .tools_for_ghc ,
627+ tools = attr_tools +
628+ [c .cabal_wrapper , ctx .executable ._runghc , hs .toolchain .cc_wrapper .as_tool ] +
629+ hs .tools_config .tools_for_ghc ,
632630 outputs = outputs ,
633631 env = c .env ,
634632 mnemonic = "HaskellCabalLibrary" ,
@@ -911,7 +909,7 @@ def _haskell_cabal_binary_impl(ctx):
911909 "_install/{}_data" .format (hs .label .name ),
912910 sibling = cabal ,
913911 )
914- ( tool_inputs , tool_input_manifests ) = ctx . resolve_tools ( tools = ctx .attr .tools )
912+ attr_tools = [ tool [ DefaultInfo ]. files_to_run for tool in ctx .attr .tools ]
915913 c = _prepare_cabal_inputs (
916914 hs ,
917915 cc ,
@@ -922,8 +920,6 @@ def _haskell_cabal_binary_impl(ctx):
922920 direct_cc_info ,
923921 component = "exe:{}" .format (exe_name ),
924922 package_id = hs .label .name ,
925- tool_inputs = tool_inputs ,
926- tool_input_manifests = tool_input_manifests ,
927923 cabal = cabal ,
928924 setup = setup ,
929925 setup_deps = setup_deps ,
@@ -942,20 +938,20 @@ def _haskell_cabal_binary_impl(ctx):
942938 static_binary = static_binary ,
943939 label = ctx .label ,
944940 )
945- (_ , runghc_manifest ) = ctx .resolve_tools (tools = [ctx .attr ._runghc ])
946941 json_args = ctx .actions .declare_file ("{}_cabal_wrapper_args.json" .format (ctx .label .name ))
947942 ctx .actions .write (json_args , json .encode (c .args ))
948943 ctx .actions .run (
949944 executable = c .cabal_wrapper ,
950945 arguments = [json_args .path ],
951946 inputs = depset ([json_args ], transitive = [c .inputs ]),
952- input_manifests = c .input_manifests + runghc_manifest ,
953947 outputs = [
954948 package_database ,
955949 binary ,
956950 data_dir ,
957951 ],
958- tools = [c .cabal_wrapper , ctx .executable ._runghc ] + hs .tools_config .tools_for_ghc ,
952+ tools = attr_tools +
953+ [c .cabal_wrapper , ctx .executable ._runghc , hs .toolchain .cc_wrapper .as_tool ] +
954+ hs .tools_config .tools_for_ghc ,
959955 env = c .env ,
960956 mnemonic = "HaskellCabalBinary" ,
961957 progress_message = "HaskellCabalBinary {}" .format (hs .label ),
0 commit comments