Пример #1
0
def create_build_area(build_system, args):
    os.mkdir('build')
    os.chdir('build')
    cmd_args = ['../srcs', '-G', '{0}'.format(build_system.cmake_generator)]
    output = ''
    try:
        output = cmake(*cmd_args, output=str, error=str)
    except spack.util.executable.ProcessError as e:
        tty.msg(output)
        tty.error('''The SpackDev area has been initialized, but the initial
CMake command returned with status {status} and message:
"{msg}". Please check output above for
details and run:
  . {env}
  cd {build_dir}
  {cmd}
when you have addressed any problems.'''.format(
            msg=' '.join([e.message, e.long_message]),
            status=cmake.returncode,
            env=cmd_quote(
                os.path.join(spackdev_base, dev.spackdev_aux_subdir,
                             'env.sh')),
            build_dir=cmd_quote(os.path.join(spackdev_base, 'build')),
            cmd=' '.join([cmd_quote(x) for x in [cmake.name] + cmd_args])))
        sys.exit(cmake.returncode)
    if args.verbose:
        tty.msg(output)
Пример #2
0
    def shell_modifications(self, shell='sh', explicit=False, env=None):
        """Return shell code to apply the modifications and clears the list."""
        modifications = self.group_by_name()

        if env is None:
            env = os.environ

        new_env = env.copy()

        for name, actions in sorted(modifications.items()):
            for x in actions:
                x.execute(new_env)

        if 'MANPATH' in new_env and not new_env.get('MANPATH').endswith(':'):
            new_env['MANPATH'] += ':'

        cmds = ''

        for name in sorted(set(modifications)):
            new = new_env.get(name, None)
            old = env.get(name, None)
            if explicit or new != old:
                if new is None:
                    cmds += _shell_unset_strings[shell].format(name)
                else:
                    cmds += _shell_set_strings[shell].format(
                        name, cmd_quote(new_env[name]))
        return cmds
Пример #3
0
def env_var_to_source_line(var, val):
    if var.startswith('BASH_FUNC'):
        source_line = 'function {fname}{decl}; export -f {fname}'.\
                      format(fname=bash_function_finder.sub(r'\1', var),
                             decl=val)
    else:
        source_line = '{var}={val}; export {var}'.format(var=var,
                                                         val=cmd_quote(val))
    return source_line
Пример #4
0
    def shell_modifications(self, shell='sh'):
        """Return shell code to apply the modifications and clears the list."""
        modifications = self.group_by_name()
        new_env = os.environ.copy()

        for name, actions in sorted(modifications.items()):
            for x in actions:
                x.execute(new_env)

        cmds = ''
        for name in set(new_env) & set(os.environ):
            new = new_env.get(name, None)
            old = os.environ.get(name, None)
            if new != old:
                if new is None:
                    cmds += _shell_unset_strings[shell].format(name)
                else:
                    cmds += _shell_set_strings[shell].format(
                        name, cmd_quote(new_env[name]))
        return cmds
Пример #5
0
def sanitized_environment(environment, drop_unchanged=False):
    return dict((var, val) for (var, val) in environment.iteritems()
                if _var_whitelist.match(var) or not
                (_var_blacklist.match(var) or
                 (drop_unchanged and var in os.environ and
                  val == cmd_quote(os.environ[var]))))