def test_spaces_preservend_when_populating_zinc_args_product_from_argfile( self): with temporary_file_path() as arg_file_path: compile_contexts = { self.java_target: CompileContext(self.java_target, analysis_file="", classes_dir="", jar_file="", log_dir="", args_file=arg_file_path, sources=[], post_compile_merge_dir="") } task = self.get_task() args = [ '-classpath', 'a.jar:b.jar', '-C-Xplugin:some_javac_plugin with args' ] task.context.products.safe_create_data( 'zinc_args', init_func=lambda: {self.java_target: []}) task.write_argsfile(compile_contexts[self.java_target], args) task.register_extra_products_from_contexts([self.java_target], compile_contexts) zinc_args = task.context.products.get_data('zinc_args')[ self.java_target] assert args == zinc_args
def create_compile_context(self, target, target_workdir): # workdir layout: # rsc/ # - outline/ -- semanticdbs for the current target as created by rsc # - m.jar -- reified scala signature jar # zinc/ # - classes/ -- class files # - z.analysis -- zinc analysis for the target # - z.jar -- final jar for the target # - zinc_args -- file containing the used zinc args sources = self._compute_sources_for_target(target) rsc_dir = os.path.join(target_workdir, "rsc") zinc_dir = os.path.join(target_workdir, "zinc") return [ RscCompileContext( target=target, analysis_file=None, classes_dir=None, jar_file=None, zinc_args_file=None, rsc_jar_file=os.path.join(rsc_dir, 'm.jar'), log_dir=os.path.join(rsc_dir, 'logs'), sources=sources, workflow=self._classify_target_compile_workflow(target), ), CompileContext( target=target, analysis_file=os.path.join(zinc_dir, 'z.analysis'), classes_dir=ClasspathEntry(os.path.join(zinc_dir, 'classes'), None), jar_file=ClasspathEntry(os.path.join(zinc_dir, 'z.jar'), None), log_dir=os.path.join(zinc_dir, 'logs'), zinc_args_file=os.path.join(zinc_dir, 'zinc_args'), sources=sources, ) ]
def compile_context(self, target): """Returns the default/stable compile context for the given target. Temporary compile contexts are private to the strategy. """ return CompileContext(target, self._analysis_file, self._classes_dir, self._sources_for_target(target))
def create_compile_context(self, target, target_workdir): return CompileContext( target, os.path.join(target_workdir, 'z.analysis'), ClasspathEntry(os.path.join(target_workdir, 'classes')), ClasspathEntry(os.path.join(target_workdir, 'z.jar')), os.path.join(target_workdir, 'logs'), os.path.join(target_workdir, 'zinc_args'), self._compute_sources_for_target(target))
def _compile_context(self, target, target_workdir): analysis_file = os.path.join(target_workdir, 'z.analysis') classes_dir = os.path.join(target_workdir, 'classes') jar_file = os.path.join(target_workdir, 'z.jar') log_dir = os.path.join(target_workdir, 'logs') zinc_args_file = os.path.join(target_workdir, 'zinc_args') return CompileContext(target, analysis_file, classes_dir, jar_file, log_dir, zinc_args_file, self._compute_sources_for_target(target))
def compile_context(self, target): analysis_file = JvmCompile._analysis_for_target( self._analysis_dir, target) classes_dir = os.path.join(self._classes_dir, target.id) # Generate a short unique path for the jar to allow for shorter classpaths. # TODO: likely unnecessary after https://github.com/pantsbuild/pants/issues/1988 jar_file = os.path.join( self._jars_dir, '{}.jar'.format(sha1(target.id).hexdigest()[:12])) return CompileContext(target, analysis_file, classes_dir, jar_file, self._sources_for_target(target))
def create_compile_context(self, target, target_workdir): return CompileContext(target=target, analysis_file=os.path.join(target_workdir, 'z.analysis'), classes_dir=ClasspathEntry(os.path.join(target_workdir, 'classes')), jar_file=ClasspathEntry(os.path.join(target_workdir, 'z.jar')), log_dir=os.path.join(target_workdir, 'logs'), args_file=os.path.join(target_workdir, 'zinc_args'), post_compile_merge_dir=os.path.join(target_workdir, 'post_compile_merge_dir'), sources=self._compute_sources_for_target(target))
def _compile_context(self, target, target_workdir): analysis_file = JvmCompile._analysis_for_target(target_workdir, target) portable_analysis_file = JvmCompile._portable_analysis_for_target( target_workdir, target) classes_dir = os.path.join(target_workdir, 'classes') jar_file = os.path.join(target_workdir, 'z.jar') log_file = os.path.join(target_workdir, 'debug.log') return CompileContext(target, analysis_file, portable_analysis_file, classes_dir, jar_file, log_file, self._sources_for_target(target))
def _compile_context(self, target, target_workdir): analysis_file = JvmCompile._analysis_for_target(target_workdir, target) portable_analysis_file = JvmCompile._portable_analysis_for_target( target_workdir, target) classes_dir = os.path.join(target_workdir, 'classes') jar_file = os.path.join(target_workdir, 'z.jar') log_file = os.path.join(target_workdir, 'debug.log') strict_deps = self._compute_language_property(target, lambda x: x.strict_deps) return CompileContext(target, analysis_file, portable_analysis_file, classes_dir, jar_file, log_file, self._compute_sources_for_target(target), strict_deps)
def _compile_context(self, target, target_workdir): analysis_file = JvmCompile._analysis_for_target(target_workdir, target) portable_analysis_file = JvmCompile._portable_analysis_for_target( target_workdir, target) classes_dir = os.path.join(target_workdir, 'classes') jar_file = os.path.join(target_workdir, 'z.jar') log_file = os.path.join(target_workdir, 'debug.log') zinc_args_file = os.path.join(target_workdir, 'zinc_args') strict_deps = self.strict_deps_enabled(target) return CompileContext(target, analysis_file, portable_analysis_file, classes_dir, jar_file, log_file, zinc_args_file, self._compute_sources_for_target(target), strict_deps)
def create_compile_context(self, target, target_workdir): # workdir layout: # rsc/ # - outline/ -- semanticdbs for the current target as created by rsc # - m.jar -- reified scala signature jar, also used for scalac -Youtline # zinc/ # - classes/ -- class files # - z.analysis -- zinc analysis for the target # - z.jar -- final jar for the target # - zinc_args -- file containing the used zinc args sources = self._compute_sources_for_target(target) rsc_dir = os.path.join(target_workdir, "rsc") zinc_dir = os.path.join(target_workdir, "zinc") return self.RscZincMergedCompileContexts( rsc_cc=RscCompileContext( target=target, # The analysis_file and classes_dir are not supposed to be useful # It's a hacky way of preserving most of the logic in zinc_compile.py # While allowing it to use RscCompileContexts for outlining. analysis_file=os.path.join(rsc_dir, "z.analysis.outline"), classes_dir=ClasspathEntry( os.path.join(rsc_dir, "zinc_classes"), None), jar_file=None, args_file=os.path.join(rsc_dir, "rsc_args"), rsc_jar_file=ClasspathEntry(os.path.join(rsc_dir, "m.jar")), log_dir=os.path.join(rsc_dir, "logs"), post_compile_merge_dir=os.path.join(rsc_dir, "post_compile_merge_dir"), sources=sources, workflow=self._classify_target_compile_workflow(target), diagnostics_out=None, ), zinc_cc=CompileContext( target=target, analysis_file=os.path.join(zinc_dir, "z.analysis"), classes_dir=ClasspathEntry(os.path.join(zinc_dir, "classes"), None), jar_file=ClasspathEntry(os.path.join(zinc_dir, "z.jar"), None), log_dir=os.path.join(zinc_dir, "logs"), args_file=os.path.join(zinc_dir, "zinc_args"), post_compile_merge_dir=os.path.join(zinc_dir, "post_compile_merge_dir"), sources=sources, diagnostics_out=os.path.join(zinc_dir, "diagnostics.json"), ), )