@@ -90,6 +90,12 @@ def _find_main(name, srcs, main):
9090
9191 fail ("Multiple Mojo files provided, but no main file specified. Please set 'main = \" foo.mojo\" ' to disambiguate." )
9292
93+ def _format_include (arg ):
94+ return ["-I" , arg .dirname ]
95+
96+ def _format_path (arg ):
97+ return [arg .path ]
98+
9399def _mojo_binary_test_implementation (ctx , * , shared_library = False ):
94100 cc_toolchain = find_cpp_toolchain (ctx )
95101 mojo_toolchain = ctx .exec_groups ["mojo_compile" ].toolchains ["//:toolchain_type" ].mojo_toolchain_info
@@ -103,18 +109,19 @@ def _mojo_binary_test_implementation(ctx, *, shared_library = False):
103109 args .add ("build" )
104110 args .add ("-strip-file-prefix=." )
105111 args .add ("--emit" , "object" )
106- args .add ("-o" , object_file .path )
112+ args .add ("-o" , object_file )
113+ args .add ("--lld-path" , mojo_toolchain .lld )
107114
108115 main = _find_main (ctx .label .name , ctx .files .srcs , ctx .file .main )
109- args .add (main . path )
116+ args .add (main )
110117 root_directory = main .dirname
111118 for file in ctx .files .srcs :
112119 if not file .dirname .startswith (root_directory ):
113- args .add ( "-I" , file . dirname )
120+ args .add_all ([ file ], map_each = _format_include )
114121
115122 all_deps = ctx .attr .deps + mojo_toolchain .implicit_deps + ([ctx .attr ._link_extra_lib ] if ctx .attr ._link_extra_lib else [])
116- import_paths , transitive_mojodeps = collect_mojoinfo (all_deps )
117- args .add_all (import_paths , before_each = "-I" )
123+ _ , transitive_mojodeps = collect_mojoinfo (all_deps )
124+ args .add_all (transitive_mojodeps , map_each = _format_include )
118125
119126 # NOTE: Argument order:
120127 # 1. Basic functional arguments
@@ -154,13 +161,16 @@ def _mojo_binary_test_implementation(ctx, *, shared_library = False):
154161 "MODULAR_CRASH_REPORTING_ENABLED" : "false" ,
155162 "MODULAR_MOJO_MAX_COMPILERRT_PATH" : "/dev/null" , # Make sure this fails if accessed
156163 "MODULAR_MOJO_MAX_LINKER_DRIVER" : "/dev/null" , # Make sure this fails if accessed
157- "MODULAR_MOJO_MAX_LLD_PATH" : mojo_toolchain . lld . path ,
164+ "MODULAR_MOJO_MAX_LLD_PATH" : "/dev/null" , # Make sure this fails if accessed
158165 "PATH" : "/dev/null" , # Avoid using the host's PATH
159166 "TEST_TMPDIR" : "." ,
160167 } | build_env ,
161168 use_default_shell_env = True ,
162169 exec_group = "mojo_compile" ,
163170 toolchain = "//:toolchain_type" ,
171+ execution_requirements = {
172+ "supports-path-mapping" : "1" ,
173+ },
164174 )
165175
166176 feature_configuration = cc_common .configure_features (
0 commit comments