Exemplo n.º 1
0
    def setup_parser(cls, option_group, args, mkflag):
        JvmCompile.setup_parser(ScalaCompile, option_group, args, mkflag)

        option_group.add_option(
            mkflag("warnings"),
            mkflag("warnings", negate=True),
            dest="scala_compile_warnings",
            default=True,
            action="callback",
            callback=mkflag.set_bool,
            help="[%default] Compile scala code with all configured warnings " "enabled.",
        )

        option_group.add_option(
            mkflag("plugins"),
            dest="plugins",
            default=None,
            action="append",
            help="Use these scalac plugins. Default is set in pants.ini.",
        )

        option_group.add_option(
            mkflag("partition-size-hint"),
            dest="scala_compile_partition_size_hint",
            action="store",
            type="int",
            default=-1,
            help="Roughly how many source files to attempt to compile together. Set to a large number "
            "to compile all sources together. Set this to 0 to compile target-by-target. "
            "Default is set in pants.ini.",
        )
Exemplo n.º 2
0
    def __init__(self, context):
        JvmCompile.__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, bootstrap_utils=self._bootstrap_utils
        )

        # 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)
        )

        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.setup_artifact_cache_from_config(config_section="scala-compile")

        # 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
Exemplo n.º 3
0
  def __init__(self, context):
    JvmCompile.__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_bootstrap_key = 'jmake'
    external_tools = context.config.getlist('java-compile', 'jmake-bootstrap-tools', default=[':jmake'])
    self._bootstrap_utils.register_jvm_build_tools(self._jmake_bootstrap_key, external_tools)

    self._compiler_bootstrap_key = 'java-compiler'
    compiler_bootstrap_tools = context.config.getlist('java-compile', 'compiler-bootstrap-tools',
                                                      default=[':java-compiler'])
    self._bootstrap_utils.register_jvm_build_tools(self._compiler_bootstrap_key, compiler_bootstrap_tools)

    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_caches', 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')
Exemplo n.º 4
0
    def __init__(self, context):
        JvmCompile.__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_bootstrap_key = "jmake"
        external_tools = context.config.getlist("java-compile", "jmake-bootstrap-tools", default=[":jmake"])
        self._bootstrap_utils.register_jvm_build_tools(self._jmake_bootstrap_key, external_tools)

        self._compiler_bootstrap_key = "java-compiler"
        compiler_bootstrap_tools = context.config.getlist(
            "java-compile", "compiler-bootstrap-tools", default=[":java-compiler"]
        )
        self._bootstrap_utils.register_jvm_build_tools(self._compiler_bootstrap_key, compiler_bootstrap_tools)

        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")

        self.setup_artifact_cache_from_config(config_section="java-compile")

        # 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")
Exemplo n.º 5
0
  def setup_parser(cls, option_group, args, mkflag):
    JvmCompile.setup_parser(JavaCompile, option_group, args, mkflag)

    option_group.add_option(mkflag("warnings"), mkflag("warnings", negate=True),
                            dest="java_compile_warnings", default=True,
                            action="callback", callback=mkflag.set_bool,
                            help="[%default] Compile java code with all configured warnings "
                                 "enabled.")

    option_group.add_option(mkflag("args"), dest="java_compile_args", action="append",
                            help="Pass these extra args to javac.")

    option_group.add_option(mkflag("partition-size-hint"), dest="java_compile_partition_size_hint",
                            action="store", type="int", default=-1,
                            help="Roughly how many source files to attempt to compile together. Set"
                                 " to a large number to compile all sources together. Set this to 0"
                                 " to compile target-by-target. Default is set in pants.ini.")
Exemplo n.º 6
0
  def __init__(self, context):
    JvmCompile.__init__(self, context, workdir=context.config.get('java-compile', 'nailgun_dir'))

    self._depfile = os.path.join(self._analysis_dir, 'global_depfile')

    self._jmake_bootstrap_key = 'jmake'
    external_tools = context.config.getlist('java-compile', 'jmake-bootstrap-tools', default=[':jmake'])
    self._jvm_tool_bootstrapper.register_jvm_tool(self._jmake_bootstrap_key, external_tools)

    self._compiler_bootstrap_key = 'java-compiler'
    compiler_bootstrap_tools = context.config.getlist('java-compile', 'compiler-bootstrap-tools',
                                                      default=[':java-compiler'])
    self._jvm_tool_bootstrapper.register_jvm_tool(self._compiler_bootstrap_key, compiler_bootstrap_tools)

    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=[]))
Exemplo n.º 7
0
  def __init__(self, context):
    JvmCompile.__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,
                                 jvm_args = self._jvm_args,
                                 color=color,
                                 bootstrap_utils=self._bootstrap_utils)

    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')

    # 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
Exemplo n.º 8
0
    def __init__(self, context):
        JvmCompile.__init__(self, context, workdir=context.config.get("java-compile", "nailgun_dir"))

        self._depfile = os.path.join(self._analysis_dir, "global_depfile")

        self._jmake_bootstrap_key = "jmake"
        external_tools = context.config.getlist("java-compile", "jmake-bootstrap-tools", default=[":jmake"])
        self._bootstrap_utils.register_jvm_build_tools(self._jmake_bootstrap_key, external_tools)

        self._compiler_bootstrap_key = "java-compiler"
        compiler_bootstrap_tools = context.config.getlist(
            "java-compile", "compiler-bootstrap-tools", default=[":java-compiler"]
        )
        self._bootstrap_utils.register_jvm_build_tools(self._compiler_bootstrap_key, compiler_bootstrap_tools)

        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=[]))
Exemplo n.º 9
0
  def setup_parser(cls, option_group, args, mkflag):
    JvmCompile.setup_parser(ScalaCompile, option_group, args, mkflag)

    option_group.add_option(mkflag('plugins'), dest='plugins', default=None,
      action='append', help='Use these scalac plugins. Default is set in pants.ini.')
Exemplo n.º 10
0
    def setup_parser(cls, option_group, args, mkflag):
        JvmCompile.setup_parser(JavaCompile, option_group, args, mkflag)

        option_group.add_option(
            mkflag("args"), dest="java_compile_args", action="append", help="Pass these extra args to javac."
        )