@@ -41,48 +41,40 @@ See the section on stamping in the README.""",
4141 ),
4242})
4343
44- def move_files ( output_name , substitutions , version_file , info_file , stamp , files , action_factory , var , assembler , root_paths ):
44+ def _move_files ( ctx , root_paths ):
4545 """Moves files into an output directory
4646
4747 Args:
48- output_name: The name of the output directory
49- substitutions: key/value pairs to replace
50- version_file: bazel-out/volatile-status.txt
51- info_file: bazel-out/stable-status.txt
52- stamp: whether the build is performed with --stamp
53- files: The files to move
54- action_factory: Bazel's actions module from ctx.actions - see https://docs.bazel.build/versions/master/skylark/lib/actions.html
55- var: environment variables
56- assembler: The assembler executable
48+ ctx: bazel's action context
5749 root_paths: Path prefixes to strip off all srcs. Longest wins.
5850
5951 Returns:
6052 The output directory tree-artifact
6153 """
62- www_dir = action_factory . declare_directory (output_name )
63- args = action_factory .args ()
64- inputs = files [:]
54+ www_dir = ctx . actions . declare_directory (ctx . label . name )
55+ args = ctx . actions .args ()
56+ inputs = ctx . files . srcs [:]
6557 args .add (www_dir .path )
66- if stamp :
67- args .add (version_file .path )
68- inputs .append (version_file )
69- args .add (info_file .path )
70- inputs .append (info_file )
58+ if ctx . attr . node_context_data [ NodeContextInfo ]. stamp :
59+ args .add (ctx . version_file .path )
60+ inputs .append (ctx . version_file )
61+ args .add (ctx . info_file .path )
62+ inputs .append (ctx . info_file )
7163 else :
7264 args .add_all (["" , "" ])
73- args .add (substitutions )
65+ args .add (ctx . attr . substitutions )
7466 args .add_all (root_paths )
7567 args .add ("--assets" )
76- args .add_all ([f .path for f in files ])
68+ args .add_all ([f .path for f in ctx . files . srcs ])
7769 args .use_param_file ("%s" , use_always = True )
7870
79- action_factory .run (
71+ ctx . actions .run (
8072 inputs = inputs ,
8173 outputs = [www_dir ],
82- executable = assembler ,
74+ executable = ctx . executable . _assembler ,
8375 arguments = [args ],
8476 execution_requirements = {"local" : "1" },
85- env = {"COMPILATION_MODE" : var ["COMPILATION_MODE" ]},
77+ env = {"COMPILATION_MODE" : ctx . var ["COMPILATION_MODE" ]},
8678 )
8779 return depset ([www_dir ])
8880
@@ -110,18 +102,7 @@ def additional_root_paths(ctx):
110102
111103def _impl (ctx ):
112104 root_paths = additional_root_paths (ctx )
113- package_layout = move_files (
114- ctx .label .name ,
115- ctx .attr .substitutions ,
116- ctx .version_file ,
117- ctx .info_file ,
118- ctx .attr .node_context_data [NodeContextInfo ].stamp ,
119- ctx .files .srcs ,
120- ctx .actions ,
121- ctx .var ,
122- ctx .executable ._assembler ,
123- root_paths ,
124- )
105+ package_layout = _move_files (ctx , root_paths )
125106 return [
126107 DefaultInfo (files = package_layout ),
127108 ]
0 commit comments