def __init__(self, context, java_runner, color): self._context = context self._java_runner = java_runner self._color = color self._pants_home = get_buildroot() self._compile_profile = context.config.get( 'scala-compile', 'compile-profile') # The target scala version. self._zinc_profile = context.config.get('scala-compile', 'zinc-profile') self._plugins_profile = context.config.get('scala-compile', 'scalac-plugins-profile') self._main = context.config.get('scala-compile', 'main') self._scalac_args = context.config.getlist('scala-compile', 'args') self._jvm_args = context.config.getlist('scala-compile', 'jvm_args') if context.options.scala_compile_warnings: self._scalac_args.extend( context.config.getlist('scala-compile', 'warning_args')) else: self._scalac_args.extend( context.config.getlist('scala-compile', 'no_warning_args')) def classpath_for_profile(profile): return profile_classpath(profile, java_runner=self._java_runner, config=self._context.config) self._zinc_classpath = classpath_for_profile(self._zinc_profile) self._compiler_classpath = classpath_for_profile(self._compile_profile) self._plugin_jars = (classpath_for_profile(self._plugins_profile) if self._plugins_profile else []) zinc_jars = ZincUtils.identify_zinc_jars(self._compiler_classpath, self._zinc_classpath) self._zinc_jar_args = [] for (name, jarpath) in zinc_jars.items( ): # The zinc jar names are also the flag names. self._zinc_jar_args.extend(['-%s' % name, jarpath]) # Allow multiple flags and also comma-separated values in a single flag. plugin_names = [p for val in context.options.plugins for p in val.split(',')]\ if context.options.plugins is not None\ else context.config.getlist('scala-compile', 'scalac-plugins', default=[]) plugin_args = context.config.getdict('scala-compile', 'scalac-plugin-args', default={}) active_plugins = self.find_plugins(plugin_names) for name, jar in active_plugins.items(): self._scalac_args.append('-Xplugin:%s' % jar) for arg in plugin_args.get(name, []): self._scalac_args.append('-P:%s:%s' % (name, arg)) # For localizing/relativizing analysis files. self._java_home = os.path.dirname(find_java_home()) self._ivy_home = context.config.get('ivy', 'cache_dir')
def __init__(self, context, nailgun_task, color): self.context = context self._nailgun_task = nailgun_task # We run zinc on this task's behalf. self._color = color self._pants_home = get_buildroot() # The target scala version. self._compile_profile = context.config.get('scala-compile', 'compile-profile') # The zinc version (and the scala version it needs, which may differ from the target version). self._zinc_profile = context.config.get('scala-compile', 'zinc-profile') # Compiler plugins. self._plugins_profile = context.config.get('scala-compile', 'scalac-plugins-profile') self._main = context.config.get('scala-compile', 'main') self._scalac_args = context.config.getlist('scala-compile', 'args') self._jvm_args = context.config.getlist('scala-compile', 'jvm_args') if context.options.scala_compile_warnings: self._scalac_args.extend(context.config.getlist('scala-compile', 'warning_args')) else: self._scalac_args.extend(context.config.getlist('scala-compile', 'no_warning_args')) cp_for_profile = self._nailgun_task.profile_classpath self._zinc_classpath = cp_for_profile(self._zinc_profile) self._compiler_classpath = cp_for_profile(self._compile_profile) self._plugin_jars = cp_for_profile(self._plugins_profile) if self._plugins_profile else [] zinc_jars = ZincUtils.identify_zinc_jars(self._zinc_classpath) self._zinc_jar_args = [] self._zinc_jar_args.extend(['-scala-path', ':'.join(self._compiler_classpath)]) for (name, jarpath) in zinc_jars.items(): # The zinc jar names are also the flag names. self._zinc_jar_args.extend(['-%s' % name, jarpath]) # Allow multiple flags and also comma-separated values in a single flag. plugin_names = [p for val in context.options.plugins for p in val.split(',')] \ if context.options.plugins is not None \ else context.config.getlist('scala-compile', 'scalac-plugins', default=[]) plugin_args = context.config.getdict('scala-compile', 'scalac-plugin-args', default={}) active_plugins = self.find_plugins(plugin_names) for name, jar in active_plugins.items(): self._scalac_args.append('-Xplugin:%s' % jar) for arg in plugin_args.get(name, []): self._scalac_args.append('-P:%s:%s' % (name, arg)) # For localizing/relativizing analysis files. self._java_home = os.path.realpath(os.path.dirname(find_java_home())) self._ivy_home = os.path.realpath(context.config.get('ivy', 'cache_dir'))
def __init__(self, context, java_runner, color): self._context = context self._java_runner = java_runner self._color = color self._pants_home = get_buildroot() # The target scala version. self._compile_profile = context.config.get("scala-compile", "compile-profile") self._zinc_profile = context.config.get("scala-compile", "zinc-profile") self._plugins_profile = context.config.get("scala-compile", "scalac-plugins-profile") self._main = context.config.get("scala-compile", "main") self._scalac_args = context.config.getlist("scala-compile", "args") self._jvm_args = context.config.getlist("scala-compile", "jvm_args") if context.options.scala_compile_warnings: self._scalac_args.extend(context.config.getlist("scala-compile", "warning_args")) else: self._scalac_args.extend(context.config.getlist("scala-compile", "no_warning_args")) def cp_for_profile(profile): return profile_classpath(profile, java_runner=self._java_runner, config=self._context.config) self._zinc_classpath = cp_for_profile(self._zinc_profile) self._compiler_classpath = cp_for_profile(self._compile_profile) self._plugin_jars = cp_for_profile(self._plugins_profile) if self._plugins_profile else [] zinc_jars = ZincUtils.identify_zinc_jars(self._compiler_classpath, self._zinc_classpath) self._zinc_jar_args = [] for (name, jarpath) in zinc_jars.items(): # The zinc jar names are also the flag names. self._zinc_jar_args.extend(["-%s" % name, jarpath]) # Allow multiple flags and also comma-separated values in a single flag. plugin_names = ( [p for val in context.options.plugins for p in val.split(",")] if context.options.plugins is not None else context.config.getlist("scala-compile", "scalac-plugins", default=[]) ) plugin_args = context.config.getdict("scala-compile", "scalac-plugin-args", default={}) active_plugins = self.find_plugins(plugin_names) for name, jar in active_plugins.items(): self._scalac_args.append("-Xplugin:%s" % jar) for arg in plugin_args.get(name, []): self._scalac_args.append("-P:%s:%s" % (name, arg)) # For localizing/relativizing analysis files. self._java_home = os.path.realpath(os.path.dirname(find_java_home())) self._ivy_home = os.path.realpath(context.config.get("ivy", "cache_dir"))
def java_home(self): if self._java_home is None: self._java_home = os.path.realpath( os.path.dirname(find_java_home())) return self._java_home
def java_home(self): if self._java_home is None: self._java_home = os.path.realpath(os.path.dirname(find_java_home())) return self._java_home
def __init__(self, context, nailgun_task, color): self.context = context self._nailgun_task = nailgun_task # We run zinc on this task's behalf. self._color = color self._pants_home = get_buildroot() # The target scala version. self._compile_profile = context.config.get('scala-compile', 'compile-profile') # The zinc version (and the scala version it needs, which may differ from the target version). self._zinc_profile = context.config.get('scala-compile', 'zinc-profile') # Compiler plugins. self._plugins_profile = context.config.get('scala-compile', 'scalac-plugins-profile') self._main = context.config.get('scala-compile', 'main') self._scalac_args = context.config.getlist('scala-compile', 'args') self._jvm_args = context.config.getlist('scala-compile', 'jvm_args') if context.options.scala_compile_warnings: self._scalac_args.extend( context.config.getlist('scala-compile', 'warning_args')) else: self._scalac_args.extend( context.config.getlist('scala-compile', 'no_warning_args')) cp_for_profile = self._nailgun_task.profile_classpath self._zinc_classpath = cp_for_profile(self._zinc_profile) self._compiler_classpath = cp_for_profile(self._compile_profile) self._plugin_jars = cp_for_profile( self._plugins_profile) if self._plugins_profile else [] zinc_jars = ZincUtils.identify_zinc_jars(self._zinc_classpath) self._zinc_jar_args = [] self._zinc_jar_args.extend( ['-scala-path', ':'.join(self._compiler_classpath)]) for (name, jarpath) in zinc_jars.items( ): # The zinc jar names are also the flag names. self._zinc_jar_args.extend(['-%s' % name, jarpath]) # Allow multiple flags and also comma-separated values in a single flag. plugin_names = [p for val in context.options.plugins for p in val.split(',')] \ if context.options.plugins is not None \ else context.config.getlist('scala-compile', 'scalac-plugins', default=[]) plugin_args = context.config.getdict('scala-compile', 'scalac-plugin-args', default={}) active_plugins = self.find_plugins(plugin_names) for name, jar in active_plugins.items(): self._scalac_args.append('-Xplugin:%s' % jar) for arg in plugin_args.get(name, []): self._scalac_args.append('-P:%s:%s' % (name, arg)) # For localizing/relativizing analysis files. self._java_home = os.path.realpath(os.path.dirname(find_java_home())) self._ivy_home = os.path.realpath( context.config.get('ivy', 'cache_dir'))