tools/sublime/compile_current_file.py
def run(self, edit, target_build):
    """The method called by Sublime Text to execute our command.

    Note that this command is a toggle, so if the thread is are already running,
    calling run will interrupt it.

    Args:
      edit: Sumblime Text specific edit brace.
      target_build: Release/Debug/Other... Used for the subfolder of out.
    """
    # There can only be one... If we are running, interrupt and return.
    if self.thread and self.thread.is_alive():
      self.interrupted = True
      self.thread.join(5.0)
      self.update_panel_text("\n\nInterrupted current command:\n%s\n" % command)
      self.thread = None
      return

    # It's nice to display how long it took to build.
    self.start_time = datetime.datetime.now()
    # Output our results in the same panel as a regular build.
    self.output_panel = self.view.window().get_output_panel("exec")
    self.output_panel.set_read_only(True)
    self.view.window().run_command("show_panel", {"panel": "output.exec"})
    # TODO(mad): Not sure if the project folder is always the first one... ???
    project_folder = self.view.window().folders()[0]
    self.update_panel_text("Compiling current file %s\n" %
                           self.view.file_name())
    # The file must be somewhere under the project folder...
    if (project_folder.lower() !=
        self.view.file_name()[:len(project_folder)].lower()):
      self.update_panel_text(
          "ERROR: File %s is not in current project folder %s\n" %
              (self.view.file_name(), project_folder))
    else:
      output_dir = os.path.join(project_folder, 'out', target_build)
      source_relative_path = os.path.relpath(self.view.file_name(),
                                             output_dir)
      # On Windows the caret character needs to be escaped as it's an escape
      # character.
      carets = '^'
      if sys.platform.startswith('win'):
        carets = '^^'
      command = [
          os.path.join(project_folder, rel_path_to_ninja), "-C",
          os.path.join(project_folder, 'out', target_build),
          source_relative_path + carets]
      self.update_panel_text(' '.join(command) + '\n')
      self.interrupted = False
      self.thread = threading.Thread(target=self.execute_command,
                                     kwargs={"command":command,
                                             "cwd": output_dir})
      self.thread.start()

    time_length = datetime.datetime.now() - self.start_time
    logging.debug("Took %s seconds on UI thread to startup",
                  time_length.seconds)
    self.view.window().focus_view(self.view)
The method called by Sublime Text to execute our command.

    Note that this command is a toggle, so if the thread is are already running,
    calling run will interrupt it.

    Args:
      edit: Sumblime Text specific edit brace.
      target_build: Release/Debug/Other... Used for the subfolder of out.
    
The method called by Sublime Text to execute our command.
Note that this command is a toggle, so if the thread is are already running,
calling run will interrupt it.
The method called by Sublime Text to execute our command . Note that this command is a toggle so if the thread is are already running calling run will interrupt it .
def run(self, edit, target_build):
    if self.thread and self.thread.is_alive():
      self.interrupted = True
      self.thread.join(5.0)
      self.update_panel_text("\n\nInterrupted current command:\n%s\n" % command)
      self.thread = None
      return
    self.start_time = datetime.datetime.now()
    self.output_panel = self.view.window().get_output_panel("exec")
    self.output_panel.set_read_only(True)
    self.view.window().run_command("show_panel", {"panel": "output.exec"})
    project_folder = self.view.window().folders()[0]
    self.update_panel_text("Compiling current file %s\n" %
                           self.view.file_name())
    if (project_folder.lower() !=
        self.view.file_name()[:len(project_folder)].lower()):
      self.update_panel_text(
          "ERROR: File %s is not in current project folder %s\n" %
              (self.view.file_name(), project_folder))
    else:
      output_dir = os.path.join(project_folder, 'out', target_build)
      source_relative_path = os.path.relpath(self.view.file_name(),
                                             output_dir)
      carets = '^'
      if sys.platform.startswith('win'):
        carets = '^^'
      command = [
          os.path.join(project_folder, rel_path_to_ninja), "-C",
          os.path.join(project_folder, 'out', target_build),
          source_relative_path + carets]
      self.update_panel_text(' '.join(command) + '\n')
      self.interrupted = False
      self.thread = threading.Thread(target=self.execute_command,
                                     kwargs={"command":command,
                                             "cwd": output_dir})
      self.thread.start()
    time_length = datetime.datetime.now() - self.start_time
    logging.debug("Took %s seconds on UI thread to startup",
                  time_length.seconds)
    self.view.window().focus_view(self.view)
def run ( self , edit , target_build ) : if self . thread and self . thread . is_alive ( ) : self . interrupted = True self . thread . join ( 5.0 ) self . update_panel_text ( "\n\nInterrupted current command:\n%s\n" % command ) self . thread = None return self . start_time = datetime . datetime . now ( ) self . output_panel = self . view . window ( ) . get_output_panel ( "exec" ) self . output_panel . set_read_only ( True ) self . view . window ( ) . run_command ( "show_panel" , { "panel" : "output.exec" } ) project_folder = self . view . window ( ) . folders ( ) [ 0 ] self . update_panel_text ( "Compiling current file %s\n" % self . view . file_name ( ) ) if ( project_folder . lower ( ) != self . view . file_name ( ) [ : len ( project_folder ) ] . lower ( ) ) : self . update_panel_text ( "ERROR: File %s is not in current project folder %s\n" % ( self . view . file_name ( ) , project_folder ) ) else : output_dir = os . path . join ( project_folder , 'out' , target_build ) source_relative_path = os . path . relpath ( self . view . file_name ( ) , output_dir ) carets = '^' if sys . platform . startswith ( 'win' ) : carets = '^^' command = [ os . path . join ( project_folder , rel_path_to_ninja ) , "-C" , os . path . join ( project_folder , 'out' , target_build ) , source_relative_path + carets ] self . update_panel_text ( ' ' . join ( command ) + '\n' ) self . interrupted = False self . thread = threading . Thread ( target = self . execute_command , kwargs = { "command" : command , "cwd" : output_dir } ) self . thread . start ( ) time_length = datetime . datetime . now ( ) - self . start_time logging . debug ( "Took %s seconds on UI thread to startup" , time_length . seconds ) self . view . window ( ) . focus_view ( self . view )
The method called by Sublime Text to execute our command.
The method called by Sublime Text to execute our command .
"""The method called by Sublime Text to execute our command.

    Note that this command is a toggle, so if the thread is are already running,
    calling run will interrupt it.

    Args:
      edit: Sumblime Text specific edit brace.
      target_build: Release/Debug/Other... Used for the subfolder of out.
    """ # There can only be one... If we are running, interrupt and return. # It's nice to display how long it took to build. # Output our results in the same panel as a regular build. # TODO(mad): Not sure if the project folder is always the first one... ??? # The file must be somewhere under the project folder... # On Windows the caret character needs to be escaped as it's an escape # character.
self
edit
Sumblime Text specific edit brace.
Sumblime Text specific edit brace .
target_build
Release/Debug/Other... Used for the subfolder of out.
Release / Debug / Other ... Used for the subfolder of out .