@@ -25,17 +25,11 @@ def additional_file_dest_relative_path(dep_label, f):
2525 else :
2626 return f .short_path
2727
28- def _copy (ctx , source , dest ):
28+ def _link (ctx , source , dest ):
2929 out = ctx .actions .declare_file (dest )
30- args = ctx .actions .args ()
31- args .add (source )
32- args .add (out )
33- ctx .actions .run (
34- outputs = [out ],
35- inputs = [source ],
36- executable = "cp" ,
37- arguments = [args ],
38- mnemonic = "RulesErlangCopyErlLibsContentsFile" ,
30+ ctx .actions .symlink (
31+ output = out ,
32+ target_file = source ,
3933 )
4034 return out
4135
@@ -52,15 +46,15 @@ def erl_libs_contents(
5246 dep_path = path_join (dir , target_info .app_name )
5347 for hdr in target_info .include :
5448 rp = additional_file_dest_relative_path (ctx .label , hdr )
55- dest = _copy (ctx , hdr , path_join (dep_path , rp ))
49+ dest = _link (ctx , hdr , path_join (dep_path , rp ))
5650 erl_libs_files .append (dest )
5751 for dep in deps :
5852 lib_info = dep [ErlangAppInfo ]
5953 dep_path = path_join (dir , lib_info .app_name )
6054 if headers :
6155 for hdr in lib_info .include :
6256 rp = additional_file_dest_relative_path (dep .label , hdr )
63- dest = _copy (ctx , hdr , path_join (dep_path , rp ))
57+ dest = _link (ctx , hdr , path_join (dep_path , rp ))
6458 erl_libs_files .append (dest )
6559 for src in lib_info .beam :
6660 if src .is_directory :
@@ -74,11 +68,11 @@ def erl_libs_contents(
7468 mnemonic = "RulesErlangCopyErlLibsContentsSubdir" ,
7569 )
7670 else :
77- dest = _copy (ctx , src , path_join (dep_path , "ebin" , src .basename ))
71+ dest = _link (ctx , src , path_join (dep_path , "ebin" , src .basename ))
7872 erl_libs_files .append (dest )
7973 for src in lib_info .priv :
8074 rp = additional_file_dest_relative_path (dep .label , src )
81- dest = _copy (ctx , src , path_join (dep_path , rp ))
75+ dest = _link (ctx , src , path_join (dep_path , rp ))
8276 erl_libs_files .append (dest )
8377 for ez in ez_deps :
8478 if expand_ezs :
@@ -95,7 +89,7 @@ def erl_libs_contents(
9589 )
9690 else :
9791 dest = ctx .actions .declare_file (path_join (dir , ez .basename ))
98- dest = _copy (ctx , ez , path_join (dir , ez .basename ))
92+ dest = _link (ctx , ez , path_join (dir , ez .basename ))
9993 erl_libs_files .append (dest )
10094 return erl_libs_files
10195
0 commit comments