예제 #1
0
  def __init__(self, context):
    NailgunTask.__init__(self, context, workdir=context.config.get('java-compile', 'nailgun_dir'))

    self._flatten = \
      context.options.java_compile_flatten if context.options.java_compile_flatten is not None else \
      context.config.getbool('java-compile', 'default_to_flatten')

    workdir = context.config.get('java-compile', 'workdir')
    self._classes_dir = os.path.join(workdir, 'classes')
    self._resources_dir = os.path.join(workdir, 'resources')
    self._depfile_dir = os.path.join(workdir, 'depfiles')
    self._deps = Dependencies(self._classes_dir)

    self._jmake_profile = context.config.get('java-compile', 'jmake-profile')
    self._compiler_profile = context.config.get('java-compile', 'compiler-profile')

    self._args = context.config.getlist('java-compile', 'args')
    self._jvm_args = context.config.getlist('java-compile', 'jvm_args')

    if context.options.java_compile_warnings:
      self._args.extend(context.config.getlist('java-compile', 'warning_args'))
    else:
      self._args.extend(context.config.getlist('java-compile', 'no_warning_args'))

    self._confs = context.config.getlist('java-compile', 'confs')
예제 #2
0
    def __init__(self, context):
        NailgunTask.__init__(self,
                             context,
                             workdir=context.config.get(
                                 'java-compile', 'nailgun_dir'))

        workdir = context.config.get('java-compile', 'workdir')
        self._classes_dir = os.path.join(workdir, 'classes')
        self._resources_dir = os.path.join(workdir, 'resources')
        self._dependencies_file = os.path.join(workdir, 'dependencies')

        self._jmake_profile = context.config.get('java-compile',
                                                 'jmake-profile')
        self._compiler_profile = context.config.get('java-compile',
                                                    'compiler-profile')

        self._args = context.config.getlist('java-compile', 'args')
        self._jvm_args = context.config.getlist('java-compile', 'jvm_args')

        if context.options.java_compile_warnings:
            self._args.extend(
                context.config.getlist('java-compile', 'warning_args'))
        else:
            self._args.extend(
                context.config.getlist('java-compile', 'no_warning_args'))

        self._flatten = context.options.java_compile_flatten
        self._confs = context.config.getlist('java-compile', 'confs')
예제 #3
0
  def __init__(self, context, workdir=None):
    NailgunTask.__init__(self, context, workdir=context.config.get('scala-compile', 'nailgun_dir'))

    # Set up the zinc utils.
    color = context.options.scala_compile_color or \
            context.config.getbool('scala-compile', 'color', default=True)

    self._zinc_utils = ZincUtils(context=context, java_runner=self.runjava, color=color)

    # The rough number of source files to build in each compiler pass.
    self._partition_size_hint = \
      context.options.scala_compile_partition_size_hint \
      if context.options.scala_compile_partition_size_hint != -1 else \
      context.config.getint('scala-compile', 'partition_size_hint')

    # Set up dep checking if needed.
    if context.options.scala_check_missing_deps:
      JvmDependencyCache.init_product_requirements(self)

    # Various output directories.
    self._buildroot = get_buildroot()
    workdir = context.config.get('scala-compile', 'workdir') if workdir is None else workdir
    self._resources_dir = os.path.join(workdir, 'resources')
    self._artifact_factory = ZincArtifactFactory(workdir, self.context, self._zinc_utils)

    # The ivy confs for which we're building.
    self._confs = context.config.getlist('scala-compile', 'confs')

    # The artifact cache to read from/write to.
    artifact_cache_spec = context.config.getlist('scala-compile', 'artifact_caches')
    self.setup_artifact_cache(artifact_cache_spec)
예제 #4
0
  def __init__(self, context, output_dir=None, classpath=None, main=None, args=None, confs=None):
    workdir = context.config.get('scala-compile', 'nailgun_dir')
    NailgunTask.__init__(self, context, workdir=workdir)

    self._compile_profile = context.config.get('scala-compile', 'compile-profile')

    # All scala targets implicitly depend on the selected scala runtime.
    scaladeps = []
    for spec in context.config.getlist('scala-compile', 'scaladeps'):
      scaladeps.extend(context.resolve(spec))
    for target in context.targets(is_scala):
      target.update_dependencies(scaladeps)

    self._compiler_classpath = classpath
    self._output_dir = output_dir or context.config.get('scala-compile', 'workdir')
    self._main = main or context.config.get('scala-compile', 'main')

    self._args = args or context.config.getlist('scala-compile', 'args')
    if context.options.scala_compile_warnings:
      self._args.extend(context.config.getlist('scala-compile', 'warning_args'))
    else:
      self._args.extend(context.config.getlist('scala-compile', 'no_warning_args'))

    self._confs = confs or context.config.getlist('scala-compile', 'confs')
    self._depfile = os.path.join(self._output_dir, 'dependencies')
예제 #5
0
    def __init__(self, context):
        NailgunTask.__init__(self,
                             context,
                             workdir=context.config.get(
                                 'java-compile', 'nailgun_dir'))

        self._partition_size_hint = \
          context.options.java_compile_partition_size_hint \
          if context.options.java_compile_partition_size_hint != -1 \
          else context.config.getint('java-compile', 'partition_size_hint')

        workdir = context.config.get('java-compile', 'workdir')
        self._classes_dir = os.path.join(workdir, 'classes')
        self._resources_dir = os.path.join(workdir, 'resources')
        self._depfile_dir = os.path.join(workdir, 'depfiles')
        self._deps = Dependencies(self._classes_dir)

        self._jmake_profile = context.config.get('java-compile',
                                                 'jmake-profile')
        self._compiler_profile = context.config.get('java-compile',
                                                    'compiler-profile')

        self._args = context.config.getlist('java-compile', 'args')
        self._jvm_args = context.config.getlist('java-compile', 'jvm_args')

        if context.options.java_compile_warnings:
            self._args.extend(
                context.config.getlist('java-compile', 'warning_args'))
        else:
            self._args.extend(
                context.config.getlist('java-compile', 'no_warning_args'))

        self._confs = context.config.getlist('java-compile', 'confs')
예제 #6
0
    def __init__(self, context):
        NailgunTask.__init__(self, context)
        self._scalastyle_config = self.context.config.get_required(
            Scalastyle._CONFIG_SECTION, 'config')
        if not os.path.exists(self._scalastyle_config):
            raise Config.ConfigError(
                'Scalastyle config file does not exist: %s' %
                self._scalastyle_config)

        excludes_file = self.context.config.get(Scalastyle._CONFIG_SECTION,
                                                'excludes')
        self._excludes = set()
        if excludes_file:
            if not os.path.exists(excludes_file):
                raise Config.ConfigError(
                    'Scalastyle excludes file does not exist: %s' %
                    excludes_file)
            self.context.log.debug('Using scalastyle excludes file %s' %
                                   excludes_file)
            with open(excludes_file) as fh:
                for pattern in fh.readlines():
                    self._excludes.add(re.compile(pattern.strip()))

        self._scalastyle_bootstrap_key = 'scalastyle'
        self.register_jvm_tool(self._scalastyle_bootstrap_key, [':scalastyle'])
예제 #7
0
  def __init__(self, context, confs=None):
    classpath = context.config.getlist('ivy', 'classpath')
    nailgun_dir = context.config.get('ivy-resolve', 'nailgun_dir')
    NailgunTask.__init__(self, context, classpath=classpath, workdir=nailgun_dir)

    self._cachedir = context.options.ivy_resolve_cache or context.config.get('ivy', 'cache_dir')
    self._confs = confs or context.config.getlist('ivy-resolve', 'confs')
    self._work_dir = context.config.get('ivy-resolve', 'workdir')
    self._classpath_dir = os.path.join(self._work_dir, 'mapped')

    self._outdir = context.options.ivy_resolve_outdir or os.path.join(self._work_dir, 'reports')
    self._open = context.options.ivy_resolve_open
    self._report = self._open or context.options.ivy_resolve_report

    self._ivy_bootstrap_key = 'ivy'
    ivy_bootstrap_tools = context.config.getlist('ivy-resolve', 'bootstrap-tools', ':xalan')
    self._bootstrap_utils.register_jvm_build_tools(self._ivy_bootstrap_key, ivy_bootstrap_tools)

    self._ivy_utils = IvyUtils(config=context.config,
                               options=context.options,
                               log=context.log)
    context.products.require_data('exclusives_groups')

    # Typically this should be a local cache only, since classpaths aren't portable.
    artifact_cache_spec = context.config.getlist('ivy-resolve', 'artifact_caches', default=[])
    self.setup_artifact_cache(artifact_cache_spec)
예제 #8
0
  def __init__(self, context):
    NailgunTask.__init__(self, context, workdir=context.config.get('scala-compile', 'nailgun_dir'))

    self._compile_profile = context.config.get('scala-compile', 'compile-profile')
    self._depemitter_profile = context.config.get('scala-compile', 'dependencies-plugin-profile')

    # All scala targets implicitly depend on the selected scala runtime.
    scaladeps = []
    for spec in context.config.getlist('scala-compile', 'scaladeps'):
      scaladeps.extend(context.resolve(spec))
    for target in context.targets(is_scala):
      target.update_dependencies(scaladeps)

    workdir = context.config.get('scala-compile', 'workdir')
    self._classes_dir = os.path.join(workdir, 'classes')
    self._resources_dir = os.path.join(workdir, 'resources')

    self._main = context.config.get('scala-compile', 'main')

    self._args = context.config.getlist('scala-compile', 'args')
    if context.options.scala_compile_warnings:
      self._args.extend(context.config.getlist('scala-compile', 'warning_args'))
    else:
      self._args.extend(context.config.getlist('scala-compile', 'no_warning_args'))

    self._confs = context.config.getlist('scala-compile', 'confs')
    self._depfile = os.path.join(workdir, 'dependencies')
예제 #9
0
    def __init__(self, context, workdir):
        NailgunTask.__init__(self, context, workdir=workdir)

        # Set up dep checking if needed.
        def get_lang_specific_option(opt):
            full_opt_name = self.language() + '_' + opt
            return getattr(context.options, full_opt_name, None)

        def munge_flag(flag):
            return None if flag == 'off' else flag

        check_missing_deps = munge_flag(
            get_lang_specific_option('missing_deps'))
        check_missing_direct_deps = munge_flag(
            get_lang_specific_option('missing_direct_deps'))
        check_unnecessary_deps = munge_flag(
            get_lang_specific_option('unnecessary_deps'))

        if check_missing_deps or check_missing_direct_deps or check_unnecessary_deps:
            # Must init it here, so it can set requirements on the context.
            self._dep_analyzer = JvmDependencyAnalyzer(
                self.context, check_missing_deps, check_missing_direct_deps,
                check_unnecessary_deps)
        else:
            self._dep_analyzer = None
예제 #10
0
  def __init__(self, context):
    NailgunTask.__init__(self, context, workdir=context.config.get('java-compile', 'nailgun_dir'))

    self._partition_size_hint = \
      context.options.java_compile_partition_size_hint \
      if context.options.java_compile_partition_size_hint != -1 \
      else context.config.getint('java-compile', 'partition_size_hint')

    workdir = context.config.get('java-compile', 'workdir')
    self._classes_dir = os.path.join(workdir, 'classes')
    self._resources_dir = os.path.join(workdir, 'resources')
    self._depfile_dir = os.path.join(workdir, 'depfiles')
    self._deps = Dependencies(self._classes_dir)

    self._jmake_profile = context.config.get('java-compile', 'jmake-profile')
    self._compiler_profile = context.config.get('java-compile', 'compiler-profile')

    self._args = context.config.getlist('java-compile', 'args')
    self._jvm_args = context.config.getlist('java-compile', 'jvm_args')

    if context.options.java_compile_warnings:
      self._args.extend(context.config.getlist('java-compile', 'warning_args'))
    else:
      self._args.extend(context.config.getlist('java-compile', 'no_warning_args'))

    self._confs = context.config.getlist('java-compile', 'confs')

    # The artifact cache to read from/write to.
    artifact_cache_spec = context.config.getlist('java-compile', 'artifact_caches')
    self.setup_artifact_cache(artifact_cache_spec)
예제 #11
0
    def __init__(self, context):
        NailgunTask.__init__(self,
                             context,
                             workdir=context.config.get(
                                 'scala-compile', 'nailgun_dir'))

        self._compile_profile = context.config.get('scala-compile',
                                                   'compile-profile')
        self._depemitter_profile = context.config.get(
            'scala-compile', 'dependencies-plugin-profile')

        # All scala targets implicitly depend on the selected scala runtime.
        scaladeps = []
        for spec in context.config.getlist('scala-compile', 'scaladeps'):
            scaladeps.extend(context.resolve(spec))
        for target in context.targets(is_scala):
            target.update_dependencies(scaladeps)

        workdir = context.config.get('scala-compile', 'workdir')
        self._classes_dir = os.path.join(workdir, 'classes')
        self._resources_dir = os.path.join(workdir, 'resources')

        self._main = context.config.get('scala-compile', 'main')

        self._args = context.config.getlist('scala-compile', 'args')
        if context.options.scala_compile_warnings:
            self._args.extend(
                context.config.getlist('scala-compile', 'warning_args'))
        else:
            self._args.extend(
                context.config.getlist('scala-compile', 'no_warning_args'))

        self._flatten = context.options.scala_compile_flatten
        self._confs = context.config.getlist('scala-compile', 'confs')
        self._depfile = os.path.join(workdir, 'dependencies')
예제 #12
0
    def __init__(self, context):
        NailgunTask.__init__(self, context, workdir=context.config.get("java-compile", "nailgun_dir"))

        self._partition_size_hint = (
            context.options.java_compile_partition_size_hint
            if context.options.java_compile_partition_size_hint != -1
            else context.config.getint("java-compile", "partition_size_hint")
        )

        workdir = context.config.get("java-compile", "workdir")
        self._classes_dir = os.path.join(workdir, "classes")
        self._resources_dir = os.path.join(workdir, "resources")
        self._depfile_dir = os.path.join(workdir, "depfiles")
        self._deps = Dependencies(self._classes_dir)

        self._jmake_profile = context.config.get("java-compile", "jmake-profile")
        self._compiler_profile = context.config.get("java-compile", "compiler-profile")

        self._args = context.config.getlist("java-compile", "args")
        self._jvm_args = context.config.getlist("java-compile", "jvm_args")

        if context.options.java_compile_warnings:
            self._args.extend(context.config.getlist("java-compile", "warning_args"))
        else:
            self._args.extend(context.config.getlist("java-compile", "no_warning_args"))

        self._confs = context.config.getlist("java-compile", "confs")

        # The artifact cache to read from/write to.
        artifact_cache_spec = context.config.getlist("java-compile", "artifact_caches")
        self.setup_artifact_cache(artifact_cache_spec)
예제 #13
0
  def __init__(self, context, workdir=None):
    NailgunTask.__init__(self, context, workdir=context.config.get('scala-compile', 'nailgun_dir'))

    color = context.options.scala_compile_color or \
            context.config.getbool('scala-compile', 'color', default=True)

    self._zinc_utils = ZincUtils(context=context, java_runner=self.runjava, color=color)

    self._partition_size_hint = \
      context.options.scala_compile_partition_size_hint \
      if context.options.scala_compile_partition_size_hint != -1 else \
      context.config.getint('scala-compile', 'partition_size_hint')

    self.check_missing_deps = context.options.scala_check_missing_deps
    self.check_intransitive_deps = context.options.scala_check_intransitive_deps
    self.check_unnecessary_deps = context.options.scala_check_unnecessary_deps
    if self.check_missing_deps:
      JvmDependencyCache.init_product_requirements(self)

    # for dependency analysis, we need to record the list of analysis cache files generated by splitting
    self.generated_caches = set()

    workdir = context.config.get('scala-compile', 'workdir') if workdir is None else workdir
    self._classes_dir = os.path.join(workdir, 'classes')
    self._analysis_cache_dir = os.path.join(workdir, 'analysis_cache')
    self._resources_dir = os.path.join(workdir, 'resources')
    self._depfile_dir = os.path.join(workdir, 'depfiles')

    self._confs = context.config.getlist('scala-compile', 'confs')

    artifact_cache_spec = context.config.getlist('scala-compile', 'artifact_caches')
    self.setup_artifact_cache(artifact_cache_spec)
예제 #14
0
  def __init__(self, context, workdir):
    NailgunTask.__init__(self, context, workdir=workdir)
    concrete_class = self.__class__
    config_section = concrete_class._config_section

    def get_lang_specific_option(opt):
      full_opt_name = self.language() + '_' + opt
      return getattr(context.options, full_opt_name, None)

    # Various working directories.
    workdir = context.config.get(config_section, 'workdir')
    self._classes_dir = os.path.join(workdir, 'classes')
    self._resources_dir = os.path.join(workdir, 'resources')
    self._analysis_dir = os.path.join(workdir, 'analysis')

    safe_mkdir(self._classes_dir)
    safe_mkdir(self._analysis_dir)

    # A temporary, but well-known, dir to munge analysis/dependency files in before caching.
    # It must be well-known so we know where to find the files when we retrieve them from the cache.
    self._analysis_tmpdir = os.path.join(self._analysis_dir, 'artifact_cache_tmpdir')

    # Compiler options.
    self._opts = context.config.getlist(config_section, 'args')
    if get_lang_specific_option('compile_warnings'):
      self._opts.extend(context.config.getlist(config_section, 'warning_args'))
    else:
      self._opts.extend(context.config.getlist(config_section, 'no_warning_args'))

    # The rough number of source files to build in each compiler pass.
    self._partition_size_hint = get_lang_specific_option('partition_size_hint')
    if self._partition_size_hint == -1:
      self._partition_size_hint = \
        context.config.getint(config_section, 'partition_size_hint', default=1000)

    # JVM args for running the compiler.
    self._jvm_args = context.config.getlist(config_section, 'jvm_args')

    # The ivy confs for which we're building.
    self._confs = context.config.getlist(config_section, 'confs')

    # Set up dep checking if needed.
    def munge_flag(flag):
      return None if flag == 'off' else flag
    check_missing_deps = munge_flag(get_lang_specific_option('missing_deps'))
    check_missing_direct_deps = munge_flag(get_lang_specific_option('missing_direct_deps'))
    check_unnecessary_deps = munge_flag(get_lang_specific_option('unnecessary_deps'))

    if check_missing_deps or check_missing_direct_deps or check_unnecessary_deps:
      # Must init it here, so it can set requirements on the context.
      self._dep_analyzer = JvmDependencyAnalyzer(self.context,
                                                 check_missing_deps,
                                                 check_missing_direct_deps,
                                                 check_unnecessary_deps)
    else:
      self._dep_analyzer = None

    self.context.products.require_data('exclusives_groups')
    self.setup_artifact_cache_from_config(config_section=config_section)
예제 #15
0
  def __init__(self, context):
    NailgunTask.__init__(self, context, workdir=context.config.get('scala-compile', 'nailgun_dir'))

    # Set up the zinc utils.
    color = not context.options.no_color
    self._zinc_utils = ZincUtils(context=context, nailgun_task=self, color=color)

    # The rough number of source files to build in each compiler pass.
    self._partition_size_hint = (context.options.scala_compile_partition_size_hint
                                 if context.options.scala_compile_partition_size_hint != -1
                                 else context.config.getint('scala-compile', 'partition_size_hint',
                                                            default=1000))

    # Set up dep checking if needed.
    if context.options.scala_check_missing_deps:
      JvmDependencyCache.init_product_requirements(self)

    self._opts = context.config.getlist('scala-compile', 'args')
    if context.options.scala_compile_warnings:
      self._opts.extend(context.config.getlist('scala-compile', 'warning_args'))
    else:
      self._opts.extend(context.config.getlist('scala-compile', 'no_warning_args'))

    # Various output directories.
    workdir = context.config.get('scala-compile', 'workdir')
    self._classes_dir = os.path.join(workdir, 'classes')
    self._analysis_dir = os.path.join(workdir, 'analysis')

    safe_mkdir(self._classes_dir)
    safe_mkdir(self._analysis_dir)

    self._analysis_file = os.path.join(self._analysis_dir, 'global_analysis.valid')
    self._invalid_analysis_file = os.path.join(self._analysis_dir, 'global_analysis.invalid')
    self._resources_dir = os.path.join(workdir, 'resources')

    # The ivy confs for which we're building.
    self._confs = context.config.getlist('scala-compile', 'confs')

    self.context.products.require_data('exclusives_groups')

    self._local_artifact_cache_spec = \
      context.config.getlist('scala-compile', 'local_artifact_caches2', default=[])
    self._remote_artifact_cache_spec = \
      context.config.getlist('scala-compile', 'remote_artifact_caches2', default=[])

    # A temporary, but well-known, dir to munge analysis files in before caching. It must be
    # well-known so we know where to find the files when we retrieve them from the cache.
    self._analysis_tmpdir = os.path.join(self._analysis_dir, 'artifact_cache_tmpdir')

    # If we are compiling scala libraries with circular deps on java libraries we need to make sure
    # those cycle deps are present.
    self._inject_java_cycles()

    # Sources present in the last analysis that have since been deleted.
    # Generated lazily, so do not access directly. Call self._get_deleted_sources().
    self._deleted_sources = None
예제 #16
0
  def __init__(self, context):
    self._profile = context.config.get('checkstyle', 'profile')
    workdir = context.config.get('checkstyle', 'nailgun_dir')
    NailgunTask.__init__(self, context, workdir=workdir)

    self._configuration_file = context.config.get('checkstyle', 'configuration')

    self._work_dir = context.config.get('checkstyle', 'workdir')
    self._properties = context.config.getdict('checkstyle', 'properties')
    self._confs = context.config.getlist('checkstyle', 'confs')
예제 #17
0
  def __init__(self, context, strict=False, verbose=True):
    NailgunTask.__init__(self, context)
    self.strict = strict
    self.verbose = verbose

    for info in INFO_FOR_COMPILER.values():
      config = info['config']
      bootstrap_tools = context.config.getlist(config, 'bootstrap-tools',
                                               default=[':%s' % config])
      self._jvm_tool_bootstrapper.register_jvm_tool(config, bootstrap_tools)
예제 #18
0
  def __init__(self, context):
    self._profile = context.config.get('checkstyle', 'profile')
    workdir = context.config.get('checkstyle', 'nailgun_dir')
    NailgunTask.__init__(self, context, workdir=workdir)

    self._configuration_file = context.config.get('checkstyle', 'configuration')

    self._work_dir = context.config.get('checkstyle', 'workdir')
    self._properties = context.config.getdict('checkstyle', 'properties')
    self._confs = context.config.getlist('checkstyle', 'confs')
    self.context.products.require_data('exclusives_groups')
예제 #19
0
  def __init__(self, context):
    self._profile = context.config.get('checkstyle', 'profile')
    workdir = context.config.get('checkstyle', 'nailgun_dir')
    NailgunTask.__init__(self, context, workdir=workdir)

    self._configuration_file = context.config.get('checkstyle', 'configuration')

    self._work_dir = context.config.get('checkstyle', 'workdir')
    self._properties = context.config.getdict('checkstyle', 'properties')
    self._confs = context.config.getlist('checkstyle', 'confs')
    self.context.products.require_data('exclusives_groups')
예제 #20
0
    def __init__(self, context):
        self._profile = context.config.get('checkstyle', 'profile')
        workdir = context.config.get('checkstyle', 'nailgun_dir')
        NailgunTask.__init__(self, context, workdir=workdir)

        self._configuration_file = context.config.get('checkstyle',
                                                      'configuration')

        self._work_dir = context.config.get('checkstyle', 'workdir')
        self._properties = context.config.getdict('checkstyle', 'properties')
        self._confs = context.config.getlist('checkstyle', 'confs')
예제 #21
0
  def __init__(self, context):
    CodeGen.__init__(self, context)
    NailgunTask.__init__(self, context)

    # TODO(John Sirois): kill if not needed by prepare_gen
    self._classpath_by_compiler = {}

    active_compilers = set(map(lambda t: t.compiler, context.targets(predicate=self.is_gentarget)))
    for compiler, tools in self._all_possible_antlr_bootstrap_tools():
      if compiler in active_compilers:
        self._jvm_tool_bootstrapper.register_jvm_tool(compiler, tools)
예제 #22
0
    def __init__(self, context, workdir=None):
        NailgunTask.__init__(self,
                             context,
                             workdir=context.config.get(
                                 'scala-compile', 'nailgun_dir'))

        self._flatten = \
          context.options.scala_compile_flatten if context.options.scala_compile_flatten is not None else \
          context.config.getbool('scala-compile', 'default_to_flatten')

        # We use the scala_compile_color flag if it is explicitly set on the command line.
        self._color = \
          context.options.scala_compile_color if context.options.scala_compile_color is not None else \
          context.config.getbool('scala-compile', 'color', default=True)

        self._compile_profile = context.config.get(
            'scala-compile', 'compile-profile')  # The target scala version.
        self._zinc_profile = context.config.get('scala-compile',
                                                'zinc-profile')

        # All scala targets implicitly depend on the selected scala runtime.
        scaladeps = []
        for spec in context.config.getlist('scala-compile', 'scaladeps'):
            scaladeps.extend(context.resolve(spec))
        for target in context.targets(is_scala):
            target.update_dependencies(scaladeps)

        self._workdir = context.config.get(
            'scala-compile', 'workdir') if workdir is None else workdir
        self._incremental_classes_dir = os.path.join(self._workdir,
                                                     'incremental.classes')
        self._flat_classes_dir = os.path.join(self._workdir, 'classes')
        self._analysis_cache_dir = os.path.join(self._workdir,
                                                'analysis_cache')
        self._resources_dir = os.path.join(self._workdir, 'resources')

        self._main = context.config.get('scala-compile', 'main')

        self._args = context.config.getlist('scala-compile', 'args')
        self._jvm_args = context.config.getlist('scala-compile', 'jvm_args')
        if context.options.scala_compile_warnings:
            self._args.extend(
                context.config.getlist('scala-compile', 'warning_args'))
        else:
            self._args.extend(
                context.config.getlist('scala-compile', 'no_warning_args'))

        self._confs = context.config.getlist('scala-compile', 'confs')
        self._depfile_dir = os.path.join(self._workdir, 'depfiles')

        artifact_cache_spec = context.config.getlist('scala-compile',
                                                     'artifact_caches')
        self.setup_artifact_cache(artifact_cache_spec)
예제 #23
0
    def __init__(self, context):
        classpath = context.config.getlist("ivy", "classpath")
        nailgun_dir = context.config.get("ivy-resolve", "nailgun_dir")
        NailgunTask.__init__(self, context, classpath=classpath, workdir=nailgun_dir)

        self._ivy_settings = context.config.get("ivy", "ivy_settings")
        self._cachedir = context.options.ivy_resolve_cache or context.config.get("ivy", "cache_dir")
        self._confs = context.config.getlist("ivy-resolve", "confs")
        self._transitive = context.config.getbool("ivy-resolve", "transitive")
        self._args = context.config.getlist("ivy-resolve", "args")

        self._profile = context.config.get("ivy-resolve", "profile")

        self._template_path = os.path.join("ivy_resolve", "ivy.mustache")

        self._work_dir = context.config.get("ivy-resolve", "workdir")
        self._classpath_file = os.path.join(self._work_dir, "classpath")
        self._classpath_dir = os.path.join(self._work_dir, "mapped")

        self._outdir = context.options.ivy_resolve_outdir or os.path.join(self._work_dir, "reports")
        self._open = context.options.ivy_resolve_open
        self._report = self._open or context.options.ivy_resolve_report
        self._ivy_utils = IvyUtils(context, self._cachedir)

        def parse_override(override):
            match = re.match(r"^([^#]+)#([^=]+)=([^\s]+)$", override)
            if not match:
                raise TaskError("Invalid dependency override: %s" % override)

            org, name, rev_or_url = match.groups()

            def fmt_message(message, template):
                return message % dict(
                    overridden="%s#%s;%s" % (template.org, template.module, template.version),
                    rev=rev_or_url,
                    url=rev_or_url,
                )

            def replace_rev(template):
                context.log.info(fmt_message("Overrode %(overridden)s with rev %(rev)s", template))
                return template.extend(version=rev_or_url, url=None, force=True)

            def replace_url(template):
                context.log.info(fmt_message("Overrode %(overridden)s with snapshot at %(url)s", template))
                return template.extend(version="SNAPSHOT", url=rev_or_url, force=True)

            replace = replace_url if re.match(r"^\w+://.+", rev_or_url) else replace_rev
            return (org, name), replace

        self._overrides = {}
        if context.options.ivy_resolve_overrides:
            self._overrides.update(parse_override(o) for o in context.options.ivy_resolve_overrides)
예제 #24
0
  def __init__(self, context):
    classpath = context.config.getlist('ivy', 'classpath')
    nailgun_dir = context.config.get('ivy-resolve', 'nailgun_dir')
    NailgunTask.__init__(self, context, classpath=classpath, workdir=nailgun_dir)

    self._ivy_settings = context.config.get('ivy', 'ivy_settings')
    self._cachedir = context.options.ivy_resolve_cache or context.config.get('ivy', 'cache_dir')
    self._confs = context.config.getlist('ivy-resolve', 'confs')
    self._transitive = context.config.getbool('ivy-resolve', 'transitive')
    self._args = context.config.getlist('ivy-resolve', 'args')

    self._profile = context.config.get('ivy-resolve', 'profile')

    self._template_path = os.path.join('ivy_resolve', 'ivy.mustache')

    self._work_dir = context.config.get('ivy-resolve', 'workdir')
    self._classpath_file = os.path.join(self._work_dir, 'classpath')
    self._classpath_dir = os.path.join(self._work_dir, 'mapped')

    self._outdir = context.options.ivy_resolve_outdir or os.path.join(self._work_dir, 'reports')
    self._open = context.options.ivy_resolve_open
    self._report = self._open or context.options.ivy_resolve_report
    self._ivy_utils = IvyUtils(context, self._cachedir)

    def parse_override(override):
      match = re.match(r'^([^#]+)#([^=]+)=([^\s]+)$', override)
      if not match:
        raise TaskError('Invalid dependency override: %s' % override)

      org, name, rev_or_url = match.groups()

      def fmt_message(message, template):
        return message % dict(
          overridden='%s#%s;%s' % (template.org, template.module, template.version),
          rev=rev_or_url,
          url=rev_or_url
        )

      def replace_rev(template):
        context.log.info(fmt_message('Overrode %(overridden)s with rev %(rev)s', template))
        return template.extend(version=rev_or_url, url=None, force=True)

      def replace_url(template):
        context.log.info(fmt_message('Overrode %(overridden)s with snapshot at %(url)s', template))
        return template.extend(version='SNAPSHOT', url=rev_or_url, force=True)

      replace = replace_url if re.match(r'^\w+://.+', rev_or_url) else replace_rev
      return (org, name), replace

    self._overrides = {}
    if context.options.ivy_resolve_overrides:
      self._overrides.update(parse_override(o) for o in context.options.ivy_resolve_overrides)
예제 #25
0
    def __init__(self, context):
        CodeGen.__init__(self, context)
        NailgunTask.__init__(self, context)

        # TODO(John Sirois): kill if not needed by prepare_gen
        self._classpath_by_compiler = {}

        active_compilers = set(
            map(lambda t: t.compiler,
                context.targets(predicate=self.is_gentarget)))
        for compiler, tools in self._all_possible_antlr_bootstrap_tools():
            if compiler in active_compilers:
                self._jvm_tool_bootstrapper.register_jvm_tool(compiler, tools)
예제 #26
0
    def __init__(self, context):
        NailgunTask.__init__(self,
                             context,
                             workdir=context.config.get(
                                 'java-compile', 'nailgun_dir'))

        if context.options.java_compile_partition_size_hint != -1:
            self._partition_size_hint = context.options.java_compile_partition_size_hint
        else:
            self._partition_size_hint = context.config.getint(
                'java-compile', 'partition_size_hint', default=1000)

        workdir = context.config.get('java-compile', 'workdir')
        self._classes_dir = os.path.join(workdir, 'classes')
        self._resources_dir = os.path.join(workdir, 'resources')
        self._depfile_dir = os.path.join(workdir, 'depfiles')
        self._deps = Dependencies(self._classes_dir)

        self._jmake_profile = context.config.get('java-compile',
                                                 'jmake-profile')
        self._compiler_profile = context.config.get('java-compile',
                                                    'compiler-profile')

        self._opts = context.config.getlist('java-compile', 'args')
        self._jvm_args = context.config.getlist('java-compile', 'jvm_args')

        self._javac_opts = []
        if context.options.java_compile_args:
            for arg in context.options.java_compile_args:
                self._javac_opts.extend(shlex.split(arg))
        else:
            self._javac_opts.extend(
                context.config.getlist('java-compile',
                                       'javac_args',
                                       default=[]))

        if context.options.java_compile_warnings:
            self._opts.extend(
                context.config.getlist('java-compile', 'warning_args'))
        else:
            self._opts.extend(
                context.config.getlist('java-compile', 'no_warning_args'))

        self._confs = context.config.getlist('java-compile', 'confs')

        # The artifact cache to read from/write to.
        artifact_cache_spec = context.config.getlist('java-compile',
                                                     'artifact_caches',
                                                     default=[])
        self.setup_artifact_cache(artifact_cache_spec)
예제 #27
0
    def __init__(self, context):
        NailgunTask.__init__(self,
                             context,
                             workdir=context.config.get(
                                 'scala-compile', 'nailgun_dir'))

        # Set up the zinc utils.
        color = not context.options.no_color
        self._zinc_utils = ZincUtils(context=context,
                                     nailgun_task=self,
                                     color=color)

        # The rough number of source files to build in each compiler pass.
        self._partition_size_hint = (
            context.options.scala_compile_partition_size_hint
            if context.options.scala_compile_partition_size_hint != -1 else
            context.config.getint(
                'scala-compile', 'partition_size_hint', default=1000))

        # Set up dep checking if needed.
        if context.options.scala_check_missing_deps:
            JvmDependencyCache.init_product_requirements(self)

        self._opts = context.config.getlist('scala-compile', 'args')
        if context.options.scala_compile_warnings:
            self._opts.extend(
                context.config.getlist('scala-compile', 'warning_args'))
        else:
            self._opts.extend(
                context.config.getlist('scala-compile', 'no_warning_args'))

        # Various output directories.
        workdir = context.config.get('scala-compile', 'workdir')
        self._resources_dir = os.path.join(workdir, 'resources')
        self._artifact_factory = ZincArtifactFactory(workdir, self.context,
                                                     self._zinc_utils)

        # The ivy confs for which we're building.
        self._confs = context.config.getlist('scala-compile', 'confs')

        # The artifact cache to read from/write to.
        artifact_cache_spec = context.config.getlist('scala-compile',
                                                     'artifact_caches',
                                                     default=[])
        self.setup_artifact_cache(artifact_cache_spec)

        # If we are compiling scala libraries with circular deps on java libraries we need to make sure
        # those cycle deps are present.
        self._inject_java_cycles()
예제 #28
0
  def __init__(self, context):
    workdir = context.config.get('checkstyle', 'nailgun_dir')
    NailgunTask.__init__(self, context, workdir=workdir)

    self._checkstyle_bootstrap_key = 'checkstyle'
    bootstrap_tools = context.config.getlist('checkstyle', 'bootstrap-tools',
                                             default=[':twitter-checkstyle'])
    self._bootstrap_utils.register_jvm_build_tools(self._checkstyle_bootstrap_key, bootstrap_tools)

    self._configuration_file = context.config.get('checkstyle', 'configuration')

    self._work_dir = context.config.get('checkstyle', 'workdir')
    self._properties = context.config.getdict('checkstyle', 'properties')
    self._confs = context.config.getlist('checkstyle', 'confs')
    self.context.products.require_data('exclusives_groups')
예제 #29
0
    def __init__(self, context):
        workdir = context.config.get('checkstyle', 'nailgun_dir')
        NailgunTask.__init__(self, context, workdir=workdir)

        self._checkstyle_bootstrap_key = 'checkstyle'
        bootstrap_tools = context.config.getlist(
            'checkstyle', 'bootstrap-tools', default=[':twitter-checkstyle'])
        self._bootstrap_utils.register_jvm_build_tools(
            self._checkstyle_bootstrap_key, bootstrap_tools)

        self._configuration_file = context.config.get('checkstyle',
                                                      'configuration')

        self._work_dir = context.config.get('checkstyle', 'workdir')
        self._properties = context.config.getdict('checkstyle', 'properties')
        self._confs = context.config.getlist('checkstyle', 'confs')
        self.context.products.require_data('exclusives_groups')
예제 #30
0
  def __init__(self, context, output_dir=None, classpath=None, main=None, args=None, confs=None):
    self._profile = context.config.get('scala-compile', 'profile')
    workdir = context.config.get('scala-compile', 'nailgun_dir')
    NailgunTask.__init__(self, context, workdir=workdir)

    self._compiler_classpath = classpath
    self._output_dir = output_dir or context.config.get('scala-compile', 'workdir')
    self._main = main or context.config.get('scala-compile', 'main')

    self._args = args or context.config.getlist('scala-compile', 'args')
    if context.options.scala_compile_warnings:
      self._args.extend(context.config.getlist('scala-compile', 'warning_args'))
    else:
      self._args.extend(context.config.getlist('scala-compile', 'no_warning_args'))

    self._confs = confs or context.config.getlist('scala-compile', 'confs')
    self._depfile = os.path.join(self._output_dir, 'dependencies')
예제 #31
0
    def __init__(self, context):
        NailgunTask.__init__(self, context, workdir=context.config.get("scala-compile", "nailgun_dir"))

        # Set up the zinc utils.
        # Command line switch overrides color setting set in pants.ini
        color = (
            context.options.scala_compile_color
            if context.options.scala_compile_color is not None
            else context.config.getbool("scala-compile", "color", default=True)
        )

        self._zinc_utils = ZincUtils(context=context, java_runner=self.runjava, color=color)

        # The rough number of source files to build in each compiler pass.
        self._partition_size_hint = (
            context.options.scala_compile_partition_size_hint
            if context.options.scala_compile_partition_size_hint != -1
            else context.config.getint("scala-compile", "partition_size_hint", default=1000)
        )

        # Set up dep checking if needed.
        if context.options.scala_check_missing_deps:
            JvmDependencyCache.init_product_requirements(self)

        self._opts = context.config.getlist("scala-compile", "args")
        if context.options.scala_compile_warnings:
            self._opts.extend(context.config.getlist("scala-compile", "warning_args"))
        else:
            self._opts.extend(context.config.getlist("scala-compile", "no_warning_args"))

        # Various output directories.
        workdir = context.config.get("scala-compile", "workdir")
        self._resources_dir = os.path.join(workdir, "resources")
        self._artifact_factory = ZincArtifactFactory(workdir, self.context, self._zinc_utils)

        # The ivy confs for which we're building.
        self._confs = context.config.getlist("scala-compile", "confs")

        # The artifact cache to read from/write to.
        artifact_cache_spec = context.config.getlist("scala-compile", "artifact_caches")
        self.setup_artifact_cache(artifact_cache_spec)

        # If we are compiling scala libraries with circular deps on java libraries we need to make sure
        # those cycle deps are present.
        self._inject_java_cycles()
예제 #32
0
  def __init__(self, context):
    NailgunTask.__init__(self, context, workdir=context.config.get('java-compile', 'nailgun_dir'))

    if context.options.java_compile_partition_size_hint != -1:
      self._partition_size_hint = context.options.java_compile_partition_size_hint
    else:
      self._partition_size_hint = context.config.getint('java-compile', 'partition_size_hint',
                                                        default=1000)

    workdir = context.config.get('java-compile', 'workdir')
    self._classes_dir = os.path.join(workdir, 'classes')
    self._resources_dir = os.path.join(workdir, 'resources')
    self._depfile_dir = os.path.join(workdir, 'depfiles')
    self._depfile = os.path.join(self._depfile_dir, 'global_depfile')

    safe_mkdir(self._classes_dir)
    safe_mkdir(self._depfile_dir)

    self._jmake_profile = context.config.get('java-compile', 'jmake-profile')
    self._compiler_profile = context.config.get('java-compile', 'compiler-profile')

    self._opts = context.config.getlist('java-compile', 'args')
    self._jvm_args = context.config.getlist('java-compile', 'jvm_args')

    self._javac_opts = []
    if context.options.java_compile_args:
      for arg in context.options.java_compile_args:
        self._javac_opts.extend(shlex.split(arg))
    else:
      self._javac_opts.extend(context.config.getlist('java-compile', 'javac_args', default=[]))

    if context.options.java_compile_warnings:
      self._opts.extend(context.config.getlist('java-compile', 'warning_args'))
    else:
      self._opts.extend(context.config.getlist('java-compile', 'no_warning_args'))

    self._confs = context.config.getlist('java-compile', 'confs')
    self.context.products.require_data('exclusives_groups')

    artifact_cache_spec = context.config.getlist('java-compile', 'artifact_caches2', default=[])
    self.setup_artifact_cache(artifact_cache_spec)

    # A temporary, but well-known, dir to munge analysis files in before caching. It must be
    # well-known so we know where to find the files when we retrieve them from the cache.
    self._depfile_tmpdir = os.path.join(self._depfile_dir, 'depfile_tmpdir')
예제 #33
0
  def __init__(self, context):
    NailgunTask.__init__(self, context, workdir=context.config.get('java-compile', 'nailgun_dir'))

    workdir = context.config.get('java-compile', 'workdir')
    self._classes_dir = os.path.join(workdir, 'classes')
    self._resources_dir = os.path.join(workdir, 'resources')
    self._dependencies_file = os.path.join(workdir, 'dependencies')

    self._jmake_profile = context.config.get('java-compile', 'jmake-profile')
    self._compiler_profile = context.config.get('java-compile', 'compiler-profile')

    self._args = context.config.getlist('java-compile', 'args')
    if context.options.java_compile_warnings:
      self._args.extend(context.config.getlist('java-compile', 'warning_args'))
    else:
      self._args.extend(context.config.getlist('java-compile', 'no_warning_args'))

    self._confs = context.config.getlist('java-compile', 'confs')
예제 #34
0
  def __init__(self, context, output_dir=None, classpath=None, main=None, args=None, confs=None):
    self._profile = context.config.get('java-compile', 'profile')
    workdir = context.config.get('java-compile', 'nailgun_dir')
    NailgunTask.__init__(self, context, workdir=workdir)

    self._compiler_classpath = classpath
    self._output_dir = output_dir or context.config.get('java-compile', 'workdir')
    self._processor_service_info_file = \
        os.path.join(self._output_dir, 'META-INF/services/javax.annotation.processing.Processor')
    self._main = main or context.config.get('java-compile', 'main')

    self._args = args or context.config.getlist('java-compile', 'args')
    if context.options.java_compile_warnings:
      self._args.extend(context.config.getlist('java-compile', 'warning_args'))
    else:
      self._args.extend(context.config.getlist('java-compile', 'no_warning_args'))

    self._confs = confs or context.config.getlist('java-compile', 'confs')
예제 #35
0
  def __init__(self, context):
    NailgunTask.__init__(self, context, workdir=context.config.get('scala-compile', 'nailgun_dir'))
    self._incremental = \
      context.options.scala_compile_incremental if context.options.scala_compile_incremental is not None else \
      context.config.getbool('scala-compile', 'default_to_incremental')

    self._flatten = \
      context.options.scala_compile_flatten if context.options.scala_compile_flatten is not None else \
      context.config.getbool('scala-compile', 'default_to_flatten')

    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._depemitter_profile = context.config.get('scala-compile', 'dependencies-plugin-profile')

    # All scala targets implicitly depend on the selected scala runtime.
    scaladeps = []
    for spec in context.config.getlist('scala-compile', 'scaladeps'):
      scaladeps.extend(context.resolve(spec))
    for target in context.targets(is_scala):
      target.update_dependencies(scaladeps)

    workdir = context.config.get('scala-compile', 'workdir')
    self._incremental_classes_dir = os.path.join(workdir, 'incremental.classes')
    self._classes_dir = os.path.join(workdir, 'classes')
    self._analysis_cache_dir = os.path.join(workdir, 'analysis_cache')
    self._resources_dir = os.path.join(workdir, 'resources')

    if self._incremental:
      self._main = context.config.get('scala-compile', 'zinc-main')
    else:
      self._main = context.config.get('scala-compile', 'main')

    self._args = context.config.getlist('scala-compile', 'args')
    self._jvm_args = context.config.getlist('scala-compile', 'jvm_args')
    if context.options.scala_compile_warnings:
      self._args.extend(context.config.getlist('scala-compile', 'warning_args'))
    else:
      self._args.extend(context.config.getlist('scala-compile', 'no_warning_args'))

    self._confs = context.config.getlist('scala-compile', 'confs')
    self._depfile_dir = os.path.join(workdir, 'depfiles')
    self._deps = Dependencies(self._classes_dir)
예제 #36
0
  def __init__(self, context, workdir=None):
    NailgunTask.__init__(self, context, workdir=context.config.get('scala-compile', 'nailgun_dir'))

    self._flatten = \
      context.options.scala_compile_flatten if context.options.scala_compile_flatten is not None else \
      context.config.getbool('scala-compile', 'default_to_flatten')

    # We use the scala_compile_color flag if it is explicitly set on the command line.
    self._color = \
      context.options.scala_compile_color or context.config.getbool('scala-compile', 'color', default=True)

    self._compile_profile = context.config.get('scala-compile', 'compile-profile')  # The target scala version.
    self._zinc_profile = context.config.get('scala-compile', 'zinc-profile')

    # All scala targets implicitly depend on the selected scala runtime.
    scaladeps = []
    for spec in context.config.getlist('scala-compile', 'scaladeps'):
      scaladeps.extend(context.resolve(spec))
    for target in context.targets(is_scala):
      target.update_dependencies(scaladeps)

    self._workdir = context.config.get('scala-compile', 'workdir') if workdir is None else workdir
    self._incremental_classes_dir = os.path.join(self._workdir, 'incremental.classes')
    self._flat_classes_dir = os.path.join(self._workdir, 'classes')
    self._analysis_cache_dir = os.path.join(self._workdir, 'analysis_cache')
    self._resources_dir = os.path.join(self._workdir, 'resources')

    self._main = context.config.get('scala-compile', 'main')

    self._args = context.config.getlist('scala-compile', 'args')
    self._jvm_args = context.config.getlist('scala-compile', 'jvm_args')
    if context.options.scala_compile_warnings:
      self._args.extend(context.config.getlist('scala-compile', 'warning_args'))
    else:
      self._args.extend(context.config.getlist('scala-compile', 'no_warning_args'))

    self._confs = context.config.getlist('scala-compile', 'confs')
    self._depfile_dir = os.path.join(self._workdir, 'depfiles')

    artifact_cache_spec = context.config.getlist('scala-compile', 'artifact_caches')
    self.setup_artifact_cache(artifact_cache_spec)
예제 #37
0
    def __init__(self, context, workdir=None):
        NailgunTask.__init__(self,
                             context,
                             workdir=context.config.get(
                                 'scala-compile', 'nailgun_dir'))

        # Set up the zinc utils.
        # Command line switch overrides color setting set in pants.ini
        color = context.options.scala_compile_color if context.options.scala_compile_color is not None else \
                context.config.getbool('scala-compile', 'color', default=True)

        self._zinc_utils = ZincUtils(context=context,
                                     java_runner=self.runjava,
                                     color=color)

        # The rough number of source files to build in each compiler pass.
        self._partition_size_hint = \
          context.options.scala_compile_partition_size_hint \
          if context.options.scala_compile_partition_size_hint != -1 else \
          context.config.getint('scala-compile', 'partition_size_hint')

        # Set up dep checking if needed.
        if context.options.scala_check_missing_deps:
            JvmDependencyCache.init_product_requirements(self)

        # Various output directories.
        self._buildroot = get_buildroot()
        workdir = context.config.get('scala-compile',
                                     'workdir') if workdir is None else workdir
        self._resources_dir = os.path.join(workdir, 'resources')
        self._artifact_factory = ZincArtifactFactory(workdir, self.context,
                                                     self._zinc_utils)

        # The ivy confs for which we're building.
        self._confs = context.config.getlist('scala-compile', 'confs')

        # The artifact cache to read from/write to.
        artifact_cache_spec = context.config.getlist('scala-compile',
                                                     'artifact_caches')
        self.setup_artifact_cache(artifact_cache_spec)
예제 #38
0
  def __init__(self, context):
    NailgunTask.__init__(self, context, workdir=context.config.get('java-compile', 'nailgun_dir'))

    if context.options.java_compile_partition_size_hint != -1:
      self._partition_size_hint = context.options.java_compile_partition_size_hint
    else:
      self._partition_size_hint = context.config.getint('java-compile', 'partition_size_hint',
                                                        default=1000)

    workdir = context.config.get('java-compile', 'workdir')
    self._classes_dir = os.path.join(workdir, 'classes')
    self._resources_dir = os.path.join(workdir, 'resources')
    self._depfile_dir = os.path.join(workdir, 'depfiles')
    self._deps = Dependencies(self._classes_dir)

    self._jmake_profile = context.config.get('java-compile', 'jmake-profile')
    self._compiler_profile = context.config.get('java-compile', 'compiler-profile')

    self._opts = context.config.getlist('java-compile', 'args')
    self._jvm_args = context.config.getlist('java-compile', 'jvm_args')

    self._javac_opts = []
    if context.options.java_compile_args:
      for arg in context.options.java_compile_args:
        self._javac_opts.extend(shlex.split(arg))
    else:
      self._javac_opts.extend(context.config.getlist('java-compile', 'javac_args', default=[]))

    if context.options.java_compile_warnings:
      self._opts.extend(context.config.getlist('java-compile', 'warning_args'))
    else:
      self._opts.extend(context.config.getlist('java-compile', 'no_warning_args'))

    self._confs = context.config.getlist('java-compile', 'confs')
    self.context.products.require_data('exclusives_groups')

    # The artifact cache to read from/write to.
    artifact_cache_spec = context.config.getlist('java-compile', 'artifact_caches', default=[])
    self.setup_artifact_cache(artifact_cache_spec)
예제 #39
0
  def __init__(self, context, workdir):
    NailgunTask.__init__(self, context, workdir=workdir)

    # Set up dep checking if needed.
    def get_lang_specific_option(opt):
      full_opt_name = self.language() + '_' + opt
      return getattr(context.options, full_opt_name, None)

    def munge_flag(flag):
      return None if flag == 'off' else flag
    check_missing_deps = munge_flag(get_lang_specific_option('missing_deps'))
    check_missing_direct_deps = munge_flag(get_lang_specific_option('missing_direct_deps'))
    check_unnecessary_deps = munge_flag(get_lang_specific_option('unnecessary_deps'))

    if check_missing_deps or check_missing_direct_deps or check_unnecessary_deps:
      # Must init it here, so it can set requirements on the context.
      self._dep_analyzer = JvmDependencyAnalyzer(self.context,
                                                 check_missing_deps,
                                                 check_missing_direct_deps,
                                                 check_unnecessary_deps)
    else:
      self._dep_analyzer = None
예제 #40
0
  def __init__(self, context):
    NailgunTask.__init__(self, context, workdir=context.config.get('scala-compile', 'nailgun_dir'))

    # Set up the zinc utils.
    color = not context.options.no_color
    self._zinc_utils = ZincUtils(context=context, nailgun_task=self, color=color)

    # The rough number of source files to build in each compiler pass.
    self._partition_size_hint = (context.options.scala_compile_partition_size_hint
                                 if context.options.scala_compile_partition_size_hint != -1
                                 else context.config.getint('scala-compile', 'partition_size_hint',
                                                            default=1000))

    # Set up dep checking if needed.
    if context.options.scala_check_missing_deps:
      JvmDependencyCache.init_product_requirements(self)

    self._opts = context.config.getlist('scala-compile', 'args')
    if context.options.scala_compile_warnings:
      self._opts.extend(context.config.getlist('scala-compile', 'warning_args'))
    else:
      self._opts.extend(context.config.getlist('scala-compile', 'no_warning_args'))

    # Various output directories.
    workdir = context.config.get('scala-compile', 'workdir')
    self._resources_dir = os.path.join(workdir, 'resources')
    self._artifact_factory = ZincArtifactFactory(workdir, self.context, self._zinc_utils)

    # The ivy confs for which we're building.
    self._confs = context.config.getlist('scala-compile', 'confs')

    # The artifact cache to read from/write to.
    artifact_cache_spec = context.config.getlist('scala-compile', 'artifact_caches', default=[])
    self.setup_artifact_cache(artifact_cache_spec)

    # If we are compiling scala libraries with circular deps on java libraries we need to make sure
    # those cycle deps are present.
    self._inject_java_cycles()
예제 #41
0
    def __init__(self, context, confs=None):
        classpath = context.config.getlist('ivy', 'classpath')
        nailgun_dir = context.config.get('ivy-resolve', 'nailgun_dir')
        NailgunTask.__init__(self,
                             context,
                             classpath=classpath,
                             workdir=nailgun_dir)

        self._cachedir = context.options.ivy_resolve_cache or context.config.get(
            'ivy', 'cache_dir')
        self._confs = confs or context.config.getlist('ivy-resolve', 'confs')
        self._work_dir = context.config.get('ivy-resolve', 'workdir')
        self._classpath_dir = os.path.join(self._work_dir, 'mapped')

        self._outdir = context.options.ivy_resolve_outdir or os.path.join(
            self._work_dir, 'reports')
        self._open = context.options.ivy_resolve_open
        self._report = self._open or context.options.ivy_resolve_report

        self._ivy_bootstrap_key = 'ivy'
        ivy_bootstrap_tools = context.config.getlist('ivy-resolve',
                                                     'bootstrap-tools',
                                                     ':xalan')
        self._bootstrap_utils.register_jvm_build_tools(self._ivy_bootstrap_key,
                                                       ivy_bootstrap_tools)

        self._ivy_utils = IvyUtils(config=context.config,
                                   options=context.options,
                                   log=context.log)
        context.products.require_data('exclusives_groups')

        # Typically this should be a local cache only, since classpaths aren't portable.
        artifact_cache_spec = context.config.getlist('ivy-resolve',
                                                     'artifact_caches',
                                                     default=[])
        self.setup_artifact_cache(artifact_cache_spec)
예제 #42
0
  def __init__(self, context, workdir=None):
    NailgunTask.__init__(self, context, workdir=context.config.get('scala-compile', 'nailgun_dir'))

    self._partition_size_hint = \
      context.options.scala_compile_partition_size_hint \
      if context.options.scala_compile_partition_size_hint != -1 else \
      context.config.getint('scala-compile', 'partition_size_hint')

    self.check_missing_deps = context.options.scala_check_missing_deps
    self.check_intransitive_deps = context.options.scala_check_intransitive_deps
    self.check_unnecessary_deps = context.options.scala_check_unnecessary_deps
    if self.check_missing_deps:
      JvmDependencyCache.init_product_requirements(self)

    # We use the scala_compile_color flag if it is explicitly set on the command line.
    self._color = \
      context.options.scala_compile_color if context.options.scala_compile_color is not None else \
      context.config.getbool('scala-compile', 'color', default=True)

    self._compile_profile = context.config.get('scala-compile', 'compile-profile')  # The target scala version.
    self._zinc_profile = context.config.get('scala-compile', 'zinc-profile')
    plugins_profile = context.config.get('scala-compile', 'scalac-plugins-profile')

    self._zinc_classpath = nailgun_profile_classpath(self, self._zinc_profile)
    compiler_classpath = nailgun_profile_classpath(self, self._compile_profile)
    zinc_jars = ScalaCompile.identify_zinc_jars(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])

    self._plugin_jars = nailgun_profile_classpath(self, plugins_profile) if plugins_profile else []

    # All scala targets implicitly depend on the selected scala runtime.
    scaladeps = []
    for spec in context.config.getlist('scala-compile', 'scaladeps'):
      scaladeps.extend(context.resolve(spec))
    for target in context.targets(is_scala):
      target.update_dependencies(scaladeps)

    self._workdir = context.config.get('scala-compile', 'workdir') if workdir is None else workdir
    self._classes_dir = os.path.join(self._workdir, 'classes')
    self._analysis_cache_dir = os.path.join(self._workdir, 'analysis_cache')
    self._resources_dir = os.path.join(self._workdir, 'resources')

    self._main = context.config.get('scala-compile', 'main')

    self._args = context.config.getlist('scala-compile', 'args')
    self._jvm_args = context.config.getlist('scala-compile', 'jvm_args')
    if context.options.scala_compile_warnings:
      self._args.extend(context.config.getlist('scala-compile', 'warning_args'))
    else:
      self._args.extend(context.config.getlist('scala-compile', 'no_warning_args'))

    # 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 = ScalaCompile.find_plugins(plugin_names, self._plugin_jars)

    for name, jar in active_plugins.items():
      self._args.append('-Xplugin:%s' % jar)
      for arg in plugin_args.get(name, []):
        self._args.append('-P:%s:%s' % (name, arg))

    self._confs = context.config.getlist('scala-compile', 'confs')
    self._depfile_dir = os.path.join(self._workdir, 'depfiles')

    artifact_cache_spec = context.config.getlist('scala-compile', 'artifact_caches')
    self.setup_artifact_cache(artifact_cache_spec)
예제 #43
0
 def __init__(self, context, strict=False, verbose=True):
   NailgunTask.__init__(self, context)
   self.strict = strict
   self.verbose = verbose
예제 #44
0
    def __init__(self, context):
        NailgunTask.__init__(self,
                             context,
                             workdir=context.config.get(
                                 'scala-compile', 'nailgun_dir'))

        # Set up the zinc utils.
        color = not context.options.no_color
        self._zinc_utils = ZincUtils(context=context,
                                     nailgun_task=self,
                                     color=color)

        # The rough number of source files to build in each compiler pass.
        self._partition_size_hint = (
            context.options.scala_compile_partition_size_hint
            if context.options.scala_compile_partition_size_hint != -1 else
            context.config.getint(
                'scala-compile', 'partition_size_hint', default=1000))

        # Set up dep checking if needed.
        if context.options.scala_check_missing_deps:
            JvmDependencyCache.init_product_requirements(self)

        self._opts = context.config.getlist('scala-compile', 'args')
        if context.options.scala_compile_warnings:
            self._opts.extend(
                context.config.getlist('scala-compile', 'warning_args'))
        else:
            self._opts.extend(
                context.config.getlist('scala-compile', 'no_warning_args'))

        # Various output directories.
        workdir = context.config.get('scala-compile', 'workdir')
        self._classes_dir = os.path.join(workdir, 'classes')
        self._analysis_dir = os.path.join(workdir, 'analysis')

        safe_mkdir(self._classes_dir)
        safe_mkdir(self._analysis_dir)

        self._analysis_file = os.path.join(self._analysis_dir,
                                           'global_analysis.valid')
        self._invalid_analysis_file = os.path.join(self._analysis_dir,
                                                   'global_analysis.invalid')
        self._resources_dir = os.path.join(workdir, 'resources')

        # The ivy confs for which we're building.
        self._confs = context.config.getlist('scala-compile', 'confs')

        self.context.products.require_data('exclusives_groups')

        self._local_artifact_cache_spec = \
          context.config.getlist('scala-compile', 'local_artifact_caches2', default=[])
        self._remote_artifact_cache_spec = \
          context.config.getlist('scala-compile', 'remote_artifact_caches2', default=[])

        # A temporary, but well-known, dir to munge analysis files in before caching. It must be
        # well-known so we know where to find the files when we retrieve them from the cache.
        self._analysis_tmpdir = os.path.join(self._analysis_dir,
                                             'artifact_cache_tmpdir')

        # If we are compiling scala libraries with circular deps on java libraries we need to make sure
        # those cycle deps are present.
        self._inject_java_cycles()

        # Sources present in the last analysis that have since been deleted.
        # Generated lazily, so do not access directly. Call self._get_deleted_sources().
        self._deleted_sources = None
예제 #45
0
파일: antlr_gen.py 프로젝트: txidol/commons
  def __init__(self, context):
    CodeGen.__init__(self, context)
    NailgunTask.__init__(self, context)

    for compiler, tools in self._all_possible_antlr_bootstrap_tools():
      self._bootstrap_utils.register_jvm_build_tools(compiler, tools)
예제 #46
0
    def __init__(self, context, workdir=None):
        NailgunTask.__init__(self,
                             context,
                             workdir=context.config.get(
                                 'scala-compile', 'nailgun_dir'))

        self._partition_size_hint = \
          context.options.scala_compile_partition_size_hint \
          if context.options.scala_compile_partition_size_hint != -1 else \
          context.config.getint('scala-compile', 'partition_size_hint')

        # We use the scala_compile_color flag if it is explicitly set on the command line.
        self._color = \
          context.options.scala_compile_color if context.options.scala_compile_color is not None else \
          context.config.getbool('scala-compile', 'color', default=True)

        self._compile_profile = context.config.get(
            'scala-compile', 'compile-profile')  # The target scala version.
        self._zinc_profile = context.config.get('scala-compile',
                                                'zinc-profile')
        plugins_profile = context.config.get('scala-compile',
                                             'scalac-plugins-profile')

        self._zinc_classpath = nailgun_profile_classpath(
            self, self._zinc_profile)
        compiler_classpath = nailgun_profile_classpath(self,
                                                       self._compile_profile)
        zinc_jars = ScalaCompile.identify_zinc_jars(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])

        self._plugin_jars = nailgun_profile_classpath(
            self, plugins_profile) if plugins_profile else []

        # All scala targets implicitly depend on the selected scala runtime.
        scaladeps = []
        for spec in context.config.getlist('scala-compile', 'scaladeps'):
            scaladeps.extend(context.resolve(spec))
        for target in context.targets(is_scala):
            target.update_dependencies(scaladeps)

        self._workdir = context.config.get(
            'scala-compile', 'workdir') if workdir is None else workdir
        self._classes_dir = os.path.join(self._workdir, 'classes')
        self._analysis_cache_dir = os.path.join(self._workdir,
                                                'analysis_cache')
        self._resources_dir = os.path.join(self._workdir, 'resources')

        self._main = context.config.get('scala-compile', 'main')

        self._args = context.config.getlist('scala-compile', 'args')
        self._jvm_args = context.config.getlist('scala-compile', 'jvm_args')
        if context.options.scala_compile_warnings:
            self._args.extend(
                context.config.getlist('scala-compile', 'warning_args'))
        else:
            self._args.extend(
                context.config.getlist('scala-compile', 'no_warning_args'))

        # 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 = ScalaCompile.find_plugins(plugin_names,
                                                   self._plugin_jars)

        for name, jar in active_plugins.items():
            self._args.append('-Xplugin:%s' % jar)
            for arg in plugin_args.get(name, []):
                self._args.append('-P:%s:%s' % (name, arg))

        self._confs = context.config.getlist('scala-compile', 'confs')
        self._depfile_dir = os.path.join(self._workdir, 'depfiles')

        artifact_cache_spec = context.config.getlist('scala-compile',
                                                     'artifact_caches')
        self.setup_artifact_cache(artifact_cache_spec)
예제 #47
0
 def __init__(self, context, strict=False, verbose=True):
     NailgunTask.__init__(self, context)
     self.strict = strict
     self.verbose = verbose
예제 #48
0
  def __init__(self, context):
    CodeGen.__init__(self, context)
    NailgunTask.__init__(self, context)

    for compiler, tools in self._all_possible_antlr_bootstrap_tools():
      self._jvm_tool_bootstrapper.register_jvm_tool(compiler, tools)
예제 #49
0
    def __init__(self, context, confs=None):
        classpath = context.config.getlist('ivy', 'classpath')
        nailgun_dir = context.config.get('ivy-resolve', 'nailgun_dir')
        NailgunTask.__init__(self,
                             context,
                             classpath=classpath,
                             workdir=nailgun_dir)

        self._ivy_settings = context.config.get('ivy', 'ivy_settings')
        self._cachedir = context.options.ivy_resolve_cache or context.config.get(
            'ivy', 'cache_dir')
        self._confs = confs or context.config.getlist('ivy-resolve', 'confs')
        self._transitive = context.config.getbool('ivy-resolve', 'transitive')
        self._opts = context.config.getlist('ivy-resolve', 'args')
        self._ivy_args = context.options.ivy_args

        self._mutable_pattern = (context.options.ivy_mutable_pattern
                                 or context.config.get('ivy-resolve',
                                                       'mutable_pattern',
                                                       default=None))
        if self._mutable_pattern:
            try:
                self._mutable_pattern = re.compile(self._mutable_pattern)
            except re.error as e:
                raise TaskError('Invalid mutable pattern specified: %s %s' %
                                (self._mutable_pattern, e))

        self._profile = context.config.get('ivy-resolve', 'profile')

        self._template_path = os.path.join('templates', 'ivy_resolve',
                                           'ivy.mustache')

        self._work_dir = context.config.get('ivy-resolve', 'workdir')
        self._classpath_dir = os.path.join(self._work_dir, 'mapped')

        self._outdir = context.options.ivy_resolve_outdir or os.path.join(
            self._work_dir, 'reports')
        self._open = context.options.ivy_resolve_open
        self._report = self._open or context.options.ivy_resolve_report
        self._ivy_utils = IvyUtils(context, self._cachedir)
        context.products.require_data('exclusives_groups')

        # Typically this should be a local cache only, since classpaths aren't portable.
        artifact_cache_spec = context.config.getlist('ivy-resolve',
                                                     'artifact_caches2',
                                                     default=[])
        self.setup_artifact_cache(artifact_cache_spec)

        def parse_override(override):
            match = re.match(r'^([^#]+)#([^=]+)=([^\s]+)$', override)
            if not match:
                raise TaskError('Invalid dependency override: %s' % override)

            org, name, rev_or_url = match.groups()

            def fmt_message(message, template):
                return message % dict(
                    overridden='%s#%s;%s' %
                    (template.org, template.module, template.version),
                    rev=rev_or_url,
                    url=rev_or_url)

            def replace_rev(template):
                context.log.info(
                    fmt_message('Overrode %(overridden)s with rev %(rev)s',
                                template))
                return template.extend(version=rev_or_url,
                                       url=None,
                                       force=True)

            def replace_url(template):
                context.log.info(
                    fmt_message(
                        'Overrode %(overridden)s with snapshot at %(url)s',
                        template))
                return template.extend(version='SNAPSHOT',
                                       url=rev_or_url,
                                       force=True)

            replace = replace_url if re.match(r'^\w+://.+',
                                              rev_or_url) else replace_rev
            return (org, name), replace

        self._overrides = {}
        if context.options.ivy_resolve_overrides:
            self._overrides.update(
                parse_override(o)
                for o in context.options.ivy_resolve_overrides)
예제 #50
0
    def __init__(self, context):
        classpath = context.config.getlist('ivy', 'classpath')
        nailgun_dir = context.config.get('ivy-resolve', 'nailgun_dir')
        NailgunTask.__init__(self,
                             context,
                             classpath=classpath,
                             workdir=nailgun_dir)

        self._ivy_settings = context.config.get('ivy', 'ivy_settings')
        self._cachedir = context.config.get('ivy', 'cache_dir')
        self._confs = context.config.getlist('ivy-resolve', 'confs')
        self._transitive = context.config.getbool('ivy-resolve', 'transitive')
        self._args = context.config.getlist('ivy-resolve', 'args')

        self._profile = context.config.get('ivy-resolve', 'profile')

        self._template_path = os.path.join('ivy_resolve', 'ivy.mk')

        self._work_dir = context.config.get('ivy-resolve', 'workdir')
        self._classpath_file = os.path.join(self._work_dir, 'classpath')
        self._classpath_dir = os.path.join(self._work_dir, 'mapped')

        self._outdir = context.options.ivy_resolve_outdir or os.path.join(
            self._work_dir, 'reports')
        self._open = context.options.ivy_resolve_open
        self._report = self._open or context.options.ivy_resolve_report
        self._ivy_utils = IvyUtils(context, self._cachedir)

        def parse_override(override):
            match = re.match(r'^([^#]+)#([^=]+)=([^\s]+)$', override)
            if not match:
                raise TaskError('Invalid dependency override: %s' % override)

            org, name, rev_or_url = match.groups()

            def fmt_message(message, template):
                return message % dict(
                    overridden='%s#%s;%s' %
                    (template.org, template.module, template.version),
                    rev=rev_or_url,
                    url=rev_or_url)

            def replace_rev(template):
                context.log.info(
                    fmt_message('Overrode %(overridden)s with rev %(rev)s',
                                template))
                return template.extend(version=rev_or_url,
                                       url=None,
                                       force=True)

            def replace_url(template):
                context.log.info(
                    fmt_message(
                        'Overrode %(overridden)s with snapshot at %(url)s',
                        template))
                return template.extend(version='SNAPSHOT',
                                       url=rev_or_url,
                                       force=True)

            replace = replace_url if re.match(r'^\w+://.+',
                                              rev_or_url) else replace_rev
            return (org, name), replace

        self._overrides = {}
        if context.options.ivy_resolve_overrides:
            self._overrides.update(
                parse_override(o)
                for o in context.options.ivy_resolve_overrides)
예제 #51
0
 def __init__(self, context):
     CodeGen.__init__(self, context)
     NailgunTask.__init__(self, context)