Exemple #1
0
    def install(self, env):
        if self.installed:
            return

        sh = env.shell

        installed_path, installed_version = Toolchain.find_compiler(
            env.spec.compiler, env.spec.compiler_version)
        if installed_path:
            print('Compiler {} {} already exists at {}'.format(
                env.spec.compiler, installed_version, installed_path))
            self.installed = True
            return

        sudo = env.config.get('sudo', current_os() == 'linux')
        sudo = ['sudo'] if sudo else []

        version = env.toolchain.compiler_version.replace('\..+', '')

        script = tempfile.NamedTemporaryFile(delete=False)
        script_path = script.name
        script.write(LLVM_SH.encode())
        script.close()

        # Make script executable
        os.chmod(
            script_path, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH
            | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
        sh.exec(*sudo, [script_path, version], check=True)

        self.installed = True
Exemple #2
0
    def install(self, env):
        if self.installed:
            return

        sh = env.shell
        config = env.config

        installed_path, installed_version = Toolchain.find_compiler(
            env.spec.compiler, env.spec.compiler_version)
        if installed_path:
            print('Compiler {} {} already exists at {}'.format(
                env.spec.compiler, installed_version, installed_path))
            self.installed = True
            return

        packages = UniqueList(config.get('compiler_packages', []))
        compiler = env.spec.compiler
        version = env.spec.compiler_version

        Script([InstallPackages(packages)], name='install gcc').run(env)

        self.installed = True