예제 #1
0
 def _fetch_tool_jar_from_scalac_classpath(self, products, jar_name):
   scala_version = ScalaPlatform.global_instance().version
   classpath = self.tool_classpath_from_products(products,
                                                 ScalaPlatform.versioned_tool_name('scalac', scala_version),
                                                 scope=self.options_scope)
   candidates = [jar for jar in classpath if jar_name in jar]
   assert(len(candidates) == 1)
   return candidates[0]
예제 #2
0
파일: zinc.py 프로젝트: hrfuller/pants
 def _fetch_tool_jar_from_scalac_classpath(self, products, jar_name):
     scala_version = ScalaPlatform.global_instance().version
     classpath = self.tool_classpath_from_products(
         products,
         ScalaPlatform.versioned_tool_name('scalac', scala_version),
         scope=self.options_scope)
     candidates = [jar for jar in classpath if jar_name in jar]
     assert (len(candidates) == 1)
     return candidates[0]
예제 #3
0
    def register_options(cls, register):
      super(Zinc.Factory, cls).register_options(register)

      zinc_rev = '1.0.3'

      shader_rules = [
          # The compiler-interface and compiler-bridge tool jars carry xsbt and
          # xsbti interfaces that are used across the shaded tool jar boundary so
          # we preserve these root packages wholesale along with the core scala
          # APIs.
          Shader.exclude_package('scala', recursive=True),
          Shader.exclude_package('xsbt', recursive=True),
          Shader.exclude_package('xsbti', recursive=True),
          # Unfortunately, is loaded reflectively by the compiler.
          Shader.exclude_package('org.apache.logging.log4j', recursive=True),
        ]

      cls.register_jvm_tool(register,
                            Zinc.ZINC_BOOTSTRAPPER_TOOL_NAME,
                            classpath=[
                              JarDependency('org.pantsbuild', 'zinc-bootstrapper_2.11', '0.0.4'),
                            ],
                            main=Zinc.ZINC_BOOTSTRAPER_MAIN,
                            custom_rules=shader_rules,
                          )

      cls.register_jvm_tool(register,
                            Zinc.ZINC_COMPILER_TOOL_NAME,
                            classpath=[
                              JarDependency('org.pantsbuild', 'zinc-compiler_2.11', '0.0.9'),
                            ],
                            main=Zinc.ZINC_COMPILE_MAIN,
                            custom_rules=shader_rules)

      cls.register_jvm_tool(register,
                            'compiler-bridge',
                            classpath=[
                              ScalaJarDependency(org='org.scala-sbt',
                                                name='compiler-bridge',
                                                rev=zinc_rev,
                                                classifier='sources',
                                                intransitive=True),
                            ])

      cls.register_jvm_tool(register,
                            'compiler-interface',
                            classpath=[
                              JarDependency(org='org.scala-sbt',
                                            name='compiler-interface',
                                            rev=zinc_rev),
                            ],
                            # NB: We force a noop-jarjar'ing of the interface, since it is now
                            # broken up into multiple jars, but zinc does not yet support a sequence
                            # of jars for the interface.
                            main='no.such.main.Main',
                            custom_rules=shader_rules)

      cls.register_jvm_tool(register,
                            Zinc.ZINC_EXTRACTOR_TOOL_NAME,
                            classpath=[
                              JarDependency('org.pantsbuild', 'zinc-extractor_2.11', '0.0.6')
                            ])

      # Register scalac for fixed versions of Scala, 2.10, 2.11 and 2.12.
      # Relies on ScalaPlatform to get the revision version from the major.minor version.
      # The tool with the correct scala version will be retrieved later,
      # taking the user-passed option into account.
      supported_scala_versions=['2.10', '2.11', '2.12']
      wanted_jars = ['scala-compiler', 'scala-library', 'scala-reflect']
      for scala_version in supported_scala_versions:
        cls.register_jvm_tool(register,
                              ScalaPlatform.versioned_tool_name('scalac', scala_version),
                              classpath=[
                                ScalaPlatform.create_jardep(jar, scala_version) for jar in wanted_jars
                              ])

      # Register custom scalac tool.
      cls.register_jvm_tool(register,
                            ScalaPlatform.versioned_tool_name('scalac', 'custom'),
                            classpath=[JarDependency('missing spec', ' //:scalac')])
예제 #4
0
파일: zinc.py 프로젝트: hrfuller/pants
        def register_options(cls, register):
            super(Zinc.Factory, cls).register_options(register)
            register(
                '--native-image',
                fingerprint=True,
                type=bool,
                help=
                'Use a pre-compiled native-image for zinc. Requires running in hermetic mode'
            )

            zinc_rev = '1.0.3'

            shader_rules = [
                # The compiler-interface and compiler-bridge tool jars carry xsbt and
                # xsbti interfaces that are used across the shaded tool jar boundary so
                # we preserve these root packages wholesale along with the core scala
                # APIs.
                Shader.exclude_package('scala', recursive=True),
                Shader.exclude_package('xsbt', recursive=True),
                Shader.exclude_package('xsbti', recursive=True),
                # Unfortunately, is loaded reflectively by the compiler.
                Shader.exclude_package('org.apache.logging.log4j',
                                       recursive=True),
            ]

            cls.register_jvm_tool(
                register,
                Zinc.ZINC_BOOTSTRAPPER_TOOL_NAME,
                classpath=[
                    JarDependency('org.pantsbuild', 'zinc-bootstrapper_2.12',
                                  '0.0.11'),
                ],
                main=Zinc.ZINC_BOOTSTRAPER_MAIN,
                custom_rules=shader_rules,
            )

            cls.register_jvm_tool(register,
                                  Zinc.ZINC_COMPILER_TOOL_NAME,
                                  classpath=[
                                      JarDependency('org.pantsbuild',
                                                    'zinc-compiler_2.12',
                                                    _ZINC_COMPILER_VERSION),
                                  ],
                                  main=Zinc.ZINC_COMPILE_MAIN,
                                  custom_rules=shader_rules)

            cls.register_jvm_tool(register,
                                  'compiler-bridge',
                                  classpath=[
                                      ScalaJarDependency(
                                          org='org.scala-sbt',
                                          name='compiler-bridge',
                                          rev=zinc_rev,
                                          classifier='sources',
                                          intransitive=True),
                                  ])

            cls.register_jvm_tool(
                register,
                'compiler-interface',
                classpath=[
                    JarDependency(org='org.scala-sbt',
                                  name='compiler-interface',
                                  rev=zinc_rev),
                ],
                # NB: We force a noop-jarjar'ing of the interface, since it is now
                # broken up into multiple jars, but zinc does not yet support a sequence
                # of jars for the interface.
                main='no.such.main.Main',
                custom_rules=shader_rules)

            cls.register_jvm_tool(register,
                                  Zinc.ZINC_EXTRACTOR_TOOL_NAME,
                                  classpath=[
                                      JarDependency('org.pantsbuild',
                                                    'zinc-extractor_2.12',
                                                    '0.0.12')
                                  ])

            # Register scalac for fixed versions of Scala, 2.10, 2.11 and 2.12.
            # Relies on ScalaPlatform to get the revision version from the major.minor version.
            # The tool with the correct scala version will be retrieved later,
            # taking the user-passed option into account.
            supported_scala_versions = ['2.10', '2.11', '2.12']
            wanted_jars = ['scala-compiler', 'scala-library', 'scala-reflect']
            for scala_version in supported_scala_versions:
                cls.register_jvm_tool(
                    register,
                    ScalaPlatform.versioned_tool_name('scalac', scala_version),
                    classpath=[
                        ScalaPlatform.create_jardep(jar, scala_version)
                        for jar in wanted_jars
                    ])

            # Register custom scalac tool.
            cls.register_jvm_tool(
                register,
                ScalaPlatform.versioned_tool_name('scalac', 'custom'),
                classpath=[JarDependency('missing spec', ' //:scalac')])
예제 #5
0
파일: zinc.py 프로젝트: pyranja/pants
        def register_options(cls, register):
            super(Zinc.Factory, cls).register_options(register)
            register(
                "--native-image",
                fingerprint=True,
                type=bool,
                help=
                "Use a pre-compiled native-image for zinc. Requires running in hermetic mode",
            )

            zinc_rev = "1.0.3"

            shader_rules = [
                # The compiler-interface and compiler-bridge tool jars carry xsbt and
                # xsbti interfaces that are used across the shaded tool jar boundary so
                # we preserve these root packages wholesale along with the core scala
                # APIs.
                Shader.exclude_package("scala", recursive=True),
                Shader.exclude_package("xsbt", recursive=True),
                Shader.exclude_package("xsbti", recursive=True),
                # Unfortunately, is loaded reflectively by the compiler.
                Shader.exclude_package("org.apache.logging.log4j",
                                       recursive=True),
                # We can't shade the Nailgun package, otherwise Nailgun won't recognize the
                # signatures of the nailMain methods in our custom nails:
                # http://www.martiansoftware.com/nailgun/quickstart.html#nails
                Shader.exclude_package("com.martiansoftware.nailgun",
                                       recursive=True),
            ]

            cls.register_jvm_tool(
                register,
                Zinc.ZINC_BOOTSTRAPPER_TOOL_NAME,
                classpath=[
                    JarDependency("org.pantsbuild", "zinc-bootstrapper_2.12",
                                  "0.0.12")
                ],
                main=Zinc.ZINC_BOOTSTRAPER_MAIN,
                custom_rules=shader_rules,
            )

            cls.register_jvm_tool(
                register,
                Zinc.ZINC_COMPILER_TOOL_NAME,
                classpath=[
                    JarDependency("org.pantsbuild", "zinc-compiler_2.12",
                                  _ZINC_COMPILER_VERSION),
                ],
                main=Zinc.ZINC_COMPILE_MAIN,
                custom_rules=shader_rules,
            )

            cls.register_jvm_tool(
                register,
                "compiler-bridge",
                classpath=[
                    ScalaJarDependency(
                        org="org.scala-sbt",
                        name="compiler-bridge",
                        rev=zinc_rev,
                        classifier="sources",
                        intransitive=True,
                    ),
                ],
            )

            cls.register_jvm_tool(
                register,
                "compiler-interface",
                classpath=[
                    JarDependency(org="org.scala-sbt",
                                  name="compiler-interface",
                                  rev=zinc_rev),
                ],
                # NB: We force a noop-jarjar'ing of the interface, since it is now
                # broken up into multiple jars, but zinc does not yet support a sequence
                # of jars for the interface.
                main="no.such.main.Main",
                custom_rules=shader_rules,
            )

            # Register scalac for fixed versions of Scala, 2.10, 2.11 and 2.12.
            # Relies on ScalaPlatform to get the revision version from the major.minor version.
            # The tool with the correct scala version will be retrieved later,
            # taking the user-passed option into account.
            supported_scala_versions = ["2.10", "2.11", "2.12"]
            wanted_jars = ["scala-compiler", "scala-library", "scala-reflect"]
            for scala_version in supported_scala_versions:
                cls.register_jvm_tool(
                    register,
                    ScalaPlatform.versioned_tool_name("scalac", scala_version),
                    classpath=[
                        ScalaPlatform.create_jardep(jar, scala_version)
                        for jar in wanted_jars
                    ],
                )

            # Register custom scalac tool.
            cls.register_jvm_tool(
                register,
                ScalaPlatform.versioned_tool_name("scalac", "custom"),
                classpath=[JarDependency("missing spec", " //:scalac")],
            )