Esempio n. 1
0
def get_ninja_info():
  # Make sure the Ninja executable exists and find its version.
  ninja_bin = session.options.get('global.ninja') or \
      session.options.get('craftr.ninja') or os.getenv('NINJA', 'ninja')
  ninja_bin = shell.find_program(ninja_bin)
  ninja_version = get_ninja_version(ninja_bin)
  logger.debug('Ninja executable:', ninja_bin)
  logger.debug('Ninja version:', ninja_version)
  return ninja_bin, ninja_version
Esempio n. 2
0
def get_ninja_info():
    # Make sure the Ninja executable exists and find its version.
    ninja_bin = session.options.get('global.ninja') or \
        session.options.get('craftr.ninja') or os.getenv('NINJA', 'ninja')
    ninja_bin = shell.find_program(ninja_bin)
    ninja_version = get_ninja_version(ninja_bin)
    logger.debug('Ninja executable:', ninja_bin)
    logger.debug('Ninja version:', ninja_version)
    return ninja_bin, ninja_version
Esempio n. 3
0
def get_ninja_info():
    # Make sure the Ninja executable exists and find its version.
    ninja_bin = (
        session.options.get("global.ninja") or session.options.get("craftr.ninja") or os.getenv("NINJA", "ninja")
    )
    ninja_bin = shell.find_program(ninja_bin)
    ninja_version = get_ninja_version(ninja_bin)
    logger.debug("Ninja executable:", ninja_bin)
    logger.debug("Ninja version:", ninja_version)
    return ninja_bin, ninja_version
Esempio n. 4
0
 def prepare_commands(self, commands):
   # ISSUE craftr-build/craftr#67
   # On Windows, commands that are not executables need to be invoked via CMD.
   new_commands = []
   for args in commands:
     try:
       prog = shell.find_program(args[0])
       is_executable = prog.endswith('.exe')
     except FileNotFoundError:
       is_executable = args[0].endswith('.exe')
     if not is_executable:
       args = ['cmd', '/c'] + args
     new_commands.append(args)
   return new_commands
Esempio n. 5
0
 def prepare_commands(self, commands):
     # ISSUE craftr-build/craftr#67
     # On Windows, commands that are not executables need to be invoked via CMD.
     new_commands = []
     for args in commands:
         try:
             prog = shell.find_program(args[0])
             is_executable = prog.endswith('.exe')
         except FileNotFoundError:
             is_executable = args[0].endswith('.exe')
         if not is_executable:
             args = ['cmd', '/c'] + args
         new_commands.append(args)
     return new_commands
Esempio n. 6
0
    def write_command_file(self,
                           filename,
                           commands,
                           inputs=None,
                           outputs=None,
                           cwd=None,
                           environ=None,
                           foreach=False,
                           suffix='.sh',
                           dry=False,
                           accept_additional_args=False):

        if suffix is not None:
            filename = path.addsuffix(filename, suffix)
        result = [filename]
        if foreach:
            result += ['$in', '$out']
            inputs, outputs = ['%1'], ['%2']

        commands = self.replace_commands_inout_vars(commands, inputs, outputs)
        if dry:
            return result, filename

        path.makedirs(path.dirname(filename))
        with open(filename, 'w') as fp:
            # TODO: Make sure this also works for shells other than bash.
            fp.write('#!' + shell.find_program(environ.get('SHELL', 'bash')) +
                     '\n')
            fp.write('set -e\n')
            if cwd:
                fp.write('cd ' + shell.quote(cwd) + '\n')
            fp.write('\n')
            for key, value in environ.items():
                fp.write('export {}={}\n'.format(key, shell.quote(value)))
            fp.write('\n')
            for index, command in enumerate(commands):
                if accept_additional_args and index == len(commands) - 1:
                    command.append(shell.safe('$*'))
                fp.write(shell.join(command))
                fp.write('\n')

        os.chmod(filename, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR
                 | stat.S_IRGRP | stat.S_IWGRP | stat.S_IROTH)  # rwxrw-r--

        return result, filename
Esempio n. 7
0
  def write_command_file(self, filename, commands, inputs=None, outputs=None,
      cwd=None, environ=None, foreach=False, suffix='.sh', dry=False,
      accept_additional_args=False):

    if suffix is not None:
      filename = path.addsuffix(filename, suffix)
    result = [filename]
    if foreach:
      result += ['$in', '$out']
      inputs, outputs = ['%1'], ['%2']

    commands = self.replace_commands_inout_vars(commands, inputs, outputs)
    if dry:
      return result, filename

    path.makedirs(path.dirname(filename))
    with open(filename, 'w') as fp:
      # TODO: Make sure this also works for shells other than bash.
      fp.write('#!' + shell.find_program(environ.get('SHELL', 'bash')) + '\n')
      fp.write('set -e\n')
      if cwd:
        fp.write('cd ' + shell.quote(cwd) + '\n')
      fp.write('\n')
      for key, value in environ.items():
        fp.write('export {}={}\n'.format(key, shell.quote(value)))
      fp.write('\n')
      for index, command in enumerate(commands):
        if accept_additional_args and index == len(commands)-1:
          command.append(shell.safe('$*'))
        fp.write(shell.join(command))
        fp.write('\n')

    os.chmod(filename, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR |
      stat.S_IRGRP | stat.S_IWGRP | stat.S_IROTH)  # rwxrw-r--

    return result, filename