summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/rust/package.py
blob: b4948703016810e248bd6f34df22f7a58ccf5d76 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Copyright 2013-2019 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

from spack import *


class Rust(Package):
    """The rust programming language toolchain"""

    homepage = "http://www.rust-lang.org"
    git      = "https://github.com/rust-lang/rust.git"

    version('develop', branch='master')
    version('1.34.0', tag='1.34.0')
    version('1.32.0', tag='1.32.0')
    version('1.31.1', tag='1.31.1')
    version('1.31.0', tag='1.31.0')  # "Rust 2018" edition
    version('1.30.1', tag='1.30.1')

    extendable = True

    # Rust
    depends_on("llvm")
    depends_on("curl")
    depends_on("git")
    depends_on("cmake")
    depends_on("binutils")
    depends_on("python@:2.8")

    # Cargo
    depends_on("openssl")

    phases = ['configure', 'install']

    def configure(self, spec, prefix):
        configure_args = [
          '--prefix=%s' % prefix,
          '--llvm-root=' + spec['llvm'].prefix,
          # Workaround for "FileCheck does not exist" error
          '--disable-codegen-tests',
          # Includes Cargo in the build
          # https://github.com/rust-lang/cargo/issues/3772#issuecomment-283109482
          '--enable-extended',
          # Prevent build from writing bash completion into system path
          '--sysconfdir=%s' % join_path(prefix, 'etc/')
          ]

        configure(*configure_args)

        # Build system defaults to searching in the same path as Spack's
        # compiler wrappers which causes the build to fail
        filter_file(
            '#ar = "ar"',
            'ar = "%s"' % join_path(spec['binutils'].prefix.bin, 'ar'),
            'config.toml')

    def install(self, spec, prefix):
        make()
        make("install")