Ejemplo n.º 1
0
    def install_rust(self):
        """Download and run the rustup installer."""
        import errno
        import stat
        import tempfile

        platform = rust.platform()
        url = rust.rustup_url(platform)
        checksum = rust.rustup_hash(platform)
        if not url or not checksum:
            print("ERROR: Could not download installer.")
            sys.exit(1)
        print("Downloading rustup-init... ", end="")
        fd, rustup_init = tempfile.mkstemp(prefix=os.path.basename(url))
        os.close(fd)
        try:
            self.http_download_and_save(url, rustup_init, checksum)
            mode = os.stat(rustup_init).st_mode
            os.chmod(rustup_init, mode | stat.S_IRWXU)
            print("Ok")
            print("Running rustup-init...")
            subprocess.check_call([rustup_init, "-y", "--default-toolchain", "stable", "--default-host", platform])
            cargo_home, cargo_bin = self.cargo_home()
            print("Rust installation complete.")
            print("You should now have rustc and cargo in %s" % cargo_bin)
            print(RUST_PATH_ADVICE % {"cargo_home": cargo_home})
        finally:
            try:
                os.remove(rustup_init)
            except OSError as e:
                if e.errno != errno.ENOENT:
                    raise
Ejemplo n.º 2
0
 def install_rust(self):
     """Download and run the rustup installer."""
     import errno
     import stat
     import tempfile
     platform = rust.platform()
     url = rust.rustup_url(platform)
     checksum = rust.rustup_hash(platform)
     if not url or not checksum:
         print('ERROR: Could not download installer.')
         sys.exit(1)
     print('Downloading rustup-init... ', end='')
     fd, rustup_init = tempfile.mkstemp(prefix=os.path.basename(url))
     os.close(fd)
     try:
         self.http_download_and_save(url, rustup_init, checksum)
         mode = os.stat(rustup_init).st_mode
         os.chmod(rustup_init, mode | stat.S_IRWXU)
         print('Ok')
         print('Running rustup-init...')
         subprocess.check_call([rustup_init, '-y',
             '--default-toolchain', 'stable',
             '--default-host', platform,
         ])
         cargo_home, cargo_bin = self.cargo_home()
         self.print_rust_path_advice(RUST_INSTALL_COMPLETE,
                 cargo_home, cargo_bin)
     finally:
         try:
             os.remove(rustup_init)
         except OSError as e:
             if e.errno != errno.ENOENT:
                 raise
Ejemplo n.º 3
0
    def ensure_rust_targets(self, rustup):
        """Make sure appropriate cross target libraries are installed."""
        target_list = subprocess.check_output([rustup, 'target', 'list'])
        targets = [line.split()[0] for line in target_list.splitlines()
                   if 'installed' in line or 'default' in line]
        print('Rust supports %s targets.' % ', '.join(targets))

        # Support 32-bit Windows on 64-bit Windows.
        win32 = 'i686-pc-windows-msvc'
        win64 = 'x86_64-pc-windows-msvc'
        if rust.platform() == win64 and win32 not in targets:
            subprocess.check_call([rustup, 'target', 'add', win32])
Ejemplo n.º 4
0
    def ensure_rust_targets(self, rustup):
        """Make sure appropriate cross target libraries are installed."""
        target_list = subprocess.check_output([rustup, 'target', 'list'])
        targets = [
            line.split()[0] for line in target_list.splitlines()
            if 'installed' in line or 'default' in line
        ]
        print('Rust supports %s targets.' % ', '.join(targets))

        # Support 32-bit Windows on 64-bit Windows.
        win32 = 'i686-pc-windows-msvc'
        win64 = 'x86_64-pc-windows-msvc'
        if rust.platform() == win64 and not win32 in targets:
            subprocess.check_call([rustup, 'target', 'add', win32])
Ejemplo n.º 5
0
    def install_rust(self):
        """Download and run the rustup installer."""
        import errno
        import stat
        import tempfile

        platform = rust.platform()
        url = rust.rustup_url(platform)
        checksum = rust.rustup_hash(platform)
        if not url or not checksum:
            print("ERROR: Could not download installer.")
            sys.exit(1)
        print("Downloading rustup-init... ", end="")
        fd, rustup_init = tempfile.mkstemp(prefix=os.path.basename(url))
        os.close(fd)
        try:
            self.http_download_and_save(url, rustup_init, checksum)
            mode = os.stat(rustup_init).st_mode
            os.chmod(rustup_init, mode | stat.S_IRWXU)
            print("Ok")
            print("Running rustup-init...")
            subprocess.check_call(
                [
                    rustup_init,
                    "-y",
                    "--default-toolchain",
                    "stable",
                    "--default-host",
                    platform,
                    "--component",
                    "rustfmt",
                ]
            )
            cargo_home, cargo_bin = self.cargo_home()
            self.print_rust_path_advice(RUST_INSTALL_COMPLETE, cargo_home, cargo_bin)
        finally:
            try:
                os.remove(rustup_init)
            except OSError as e:
                if e.errno != errno.ENOENT:
                    raise
Ejemplo n.º 6
0
    def ensure_rust_targets(self, rustup):
        """Make sure appropriate cross target libraries are installed."""
        target_list = subprocess.check_output([rustup, 'target', 'list'])
        targets = [line.split()[0] for line in target_list.splitlines()
                   if 'installed' in line or 'default' in line]
        print('Rust supports %s targets.' % ', '.join(targets))

        # Support 32-bit Windows on 64-bit Windows.
        win32 = 'i686-pc-windows-msvc'
        win64 = 'x86_64-pc-windows-msvc'
        if rust.platform() == win64 and win32 not in targets:
            subprocess.check_call([rustup, 'target', 'add', win32])

        if 'mobile_android' in self.application:
            # Let's add the most common targets.
            android_targets = ('armv7-linux-androideabi',
                               'aarch64-linux-android',
                               'i686-linux-android',
                               'x86_64-linux-android', )
            for target in android_targets:
                if target not in targets:
                    subprocess.check_call([rustup, 'target', 'add', target])
Ejemplo n.º 7
0
 def install_rust(self):
     """Download and run the rustup installer."""
     import errno
     import stat
     import tempfile
     platform = rust.platform()
     url = rust.rustup_url(platform)
     checksum = rust.rustup_hash(platform)
     if not url or not checksum:
         print('ERROR: Could not download installer.')
         sys.exit(1)
     print('Downloading rustup-init... ', end='')
     fd, rustup_init = tempfile.mkstemp(prefix=os.path.basename(url))
     os.close(fd)
     try:
         self.http_download_and_save(url, rustup_init, checksum)
         mode = os.stat(rustup_init).st_mode
         os.chmod(rustup_init, mode | stat.S_IRWXU)
         print('Ok')
         print('Running rustup-init...')
         subprocess.check_call([
             rustup_init,
             '-y',
             '--default-toolchain',
             'stable',
             '--default-host',
             platform,
         ])
         cargo_home, cargo_bin = self.cargo_home()
         print('Rust installation complete.')
         print('You should now have rustc and cargo in %s' % cargo_bin)
         print(RUST_PATH_ADVICE % {'cargo_home': cargo_home})
     finally:
         try:
             os.remove(rustup_init)
         except OSError as e:
             if e.errno != errno.ENOENT:
                 raise