@@ -207,8 +207,15 @@ defmodule Mix.Tasks.Deps.Compile do
207
207
{ "TERM" , "dumb" }
208
208
]
209
209
210
- cmd = "#{ rebar_cmd ( dep ) } bare compile --paths #{ escape_path ( lib_path ) } "
211
- do_command ( dep , config , cmd , false , env )
210
+ rebar = Mix.Rebar . local_rebar_path ( :rebar3 ) || handle_rebar_not_found ( dep )
211
+ { exec , args } = Mix.Rebar . rebar_args ( rebar , [ "bare" , "compile" , "--paths" , lib_path ] )
212
+
213
+ if Mix . shell ( ) . cmd ( { exec , args } , opts_for_cmd ( dep , config , env ) ) != 0 do
214
+ Mix . raise (
215
+ "Could not compile dependency #{ inspect ( dep . app ) } , \" #{ Enum . join ( [ exec | args ] , " " ) } \" command failed. " <>
216
+ deps_compile_feedback ( dep . app )
217
+ )
218
+ end
212
219
213
220
# Check if we have any new symlinks after compilation
214
221
for dir <- ~w( include priv src) ,
@@ -220,21 +227,12 @@ defmodule Mix.Tasks.Deps.Compile do
220
227
true
221
228
end
222
229
223
- defp escape_path ( path ) do
224
- escape = if match? ( { :win32 , _ } , :os . type ( ) ) , do: "^ " , else: "\\ "
225
- String . replace ( path , " " , escape )
226
- end
227
-
228
230
defp rebar_config ( dep ) do
229
231
dep . extra
230
232
|> Mix.Rebar . dependency_config ( )
231
233
|> Mix.Rebar . serialize_config ( )
232
234
end
233
235
234
- defp rebar_cmd ( % Mix.Dep { manager: manager } = dep ) do
235
- Mix.Rebar . rebar_cmd ( manager ) || handle_rebar_not_found ( dep )
236
- end
237
-
238
236
defp handle_rebar_not_found ( % Mix.Dep { app: app , manager: manager } ) do
239
237
shell = Mix . shell ( )
240
238
@@ -255,12 +253,12 @@ defmodule Mix.Tasks.Deps.Compile do
255
253
end
256
254
257
255
Mix.Tasks.Local.Rebar . run ( [ "--force" ] )
258
- Mix.Rebar . local_rebar_cmd ( manager ) || Mix . raise ( "\" #{ manager } \" installation failed" )
256
+ Mix.Rebar . local_rebar_path ( manager ) || Mix . raise ( "\" #{ manager } \" installation failed" )
259
257
end
260
258
261
259
defp do_make ( dep , config ) do
262
260
command = make_command ( dep )
263
- do_command ( dep , config , command , true , [ { "IS_DEP" , "1" } ] )
261
+ shell_cmd! ( dep , config , command , [ { "IS_DEP" , "1" } ] )
264
262
build_structure ( dep , config )
265
263
true
266
264
end
@@ -289,27 +287,29 @@ defmodule Mix.Tasks.Deps.Compile do
289
287
290
288
defp do_compile ( % Mix.Dep { opts: opts } = dep , config ) do
291
289
if command = opts [ :compile ] do
292
- do_command ( dep , config , command , true )
290
+ shell_cmd! ( dep , config , command )
293
291
build_structure ( dep , config )
294
292
true
295
293
else
296
294
false
297
295
end
298
296
end
299
297
300
- defp do_command ( dep , config , command , print_app? , env \\ [ ] ) do
301
- % Mix.Dep { app: app , system_env: system_env , opts: opts } = dep
302
-
303
- env = [ { "ERL_LIBS" , Path . join ( config [ :deps_build_path ] , "lib" ) } | system_env ] ++ env
304
-
305
- if Mix . shell ( ) . cmd ( command , env: env , print_app: print_app? , cd: opts [ :dest ] ) != 0 do
298
+ defp shell_cmd! ( % Mix.Dep { app: app } = dep , config , command , env \\ [ ] ) do
299
+ if Mix . shell ( ) . cmd ( command , [ print_app: true ] ++ opts_for_cmd ( dep , config , env ) ) != 0 do
306
300
Mix . raise (
307
301
"Could not compile dependency #{ inspect ( app ) } , \" #{ command } \" command failed. " <>
308
302
deps_compile_feedback ( app )
309
303
)
310
304
end
311
305
312
- true
306
+ :ok
307
+ end
308
+
309
+ defp opts_for_cmd ( dep , config , env ) do
310
+ % Mix.Dep { system_env: system_env , opts: opts } = dep
311
+ env = [ { "ERL_LIBS" , Path . join ( config [ :deps_build_path ] , "lib" ) } | system_env ] ++ env
312
+ [ env: env , cd: opts [ :dest ] ]
313
313
end
314
314
315
315
defp build_structure ( % Mix.Dep { opts: opts } , config ) do
0 commit comments