コード例 #1
0
    def __ensure_switches(self):
        prev_cmd = self.gnatCmd
        self.gnatCmd = gps_utils.get_gnat_driver_cmd()

        if self.gnatCmd == "":
            self.gnatCmd = "gnat"

        if GPS.is_server_local("Build_Server"):
            if not os.path.isfile(self.gnatCmd):
                cmd = os_utils.locate_exec_on_path(self.gnatCmd)
                if cmd == "":
                    GPS.Console("Messages").write(
                        "Error: '%s' is not in the path.\n" % self.gnatCmd)
                    GPS.Console("Messages").write(
                        "Error: Could not initialize the ada_support module.\n"
                    )
                    return

                self.gnatCmd = cmd

        # gnat check command changed: we reinitialize the rules list
        if prev_cmd != self.gnatCmd:
            self.__get_switches_from_help()
            return True
        else:
            return False
コード例 #2
0
ファイル: codepeer.py プロジェクト: zackboll/gps
def on_project_changed(hook):
    # Change default build mode to "codepeer"
    # when GNAT is absent and build mode not set for the project
    gnatCmd = gps_utils.get_gnat_driver_cmd()
    if not os_utils.locate_exec_on_path(gnatCmd):
        root_project = GPS.Project.root()
        try:
            mode = root_project.get_property("Build-Mode")
        except GPS.Exception:
            GPS.set_build_mode("codepeer")
コード例 #3
0
ファイル: gnatcheck.py プロジェクト: ocsobservatory/gps
    def updateGnatCmd(self):
        self.gnatCmd = gps_utils.get_gnat_driver_cmd()

        if self.gnatCmd == "":
            self.gnatCmd = "gnat"

        if self.gnatCmd == "":
            GPS.Console("Messages").write(
                "Error: 'gnat' is not in the path.\n")
            GPS.Console("Messages").write(
                "Error: Could not initialize the gnatcheck module.\n")
コード例 #4
0
def generate_body(as_separate):
    """
    Run gnatstub on the current Ada spec to generate a matching
    body file.
    """
    global can_update_body

    """ Doesn't work for now
    #  Check gnatstub for --update-body support
    command = [gps_utils.get_gnat_driver_cmd(), 'stub', '--help']
    if os_utils.locate_exec_on_path (command[0]):
        process = GPS.Process(command)
        output = process.get_result()
        can_update_body = output.find('--update-body') >= 0
    """

    GPS.MDI.save_all()
    context = GPS.current_context()

    file = context.file()
    sv = GPS.Project.scenario_variables()
    x_args = ['-X%s=%s' % (k, v) for k, v in sv.items()] if sv else []
    command = [gps_utils.get_gnat_driver_cmd(), 'stub']

    entity = context.entity() if context.entity_name() else None
    if entity and entity.requires_body() and not entity.has_body():
        command.append('--update-body=' + str(entity.declaration().line()))
    else:
        entity = None

    if as_separate:
        command.append('--subunits')

    proj = context.project()
    if proj:
        command.append('-P%s' % proj.file().path)
    command += x_args + [file.path, file.directory()]

    proc = GPS.Process(
        command,
        task_manager=True,
        show_command=True,
        on_exit=OnExit(file, entity).on_exit)
    proc.wait()
コード例 #5
0
ファイル: gnatstub.py プロジェクト: dailler/gps
def generate_body():
    """
    Run gnatstub on the current Ada spec to generate a matching
    body file.
    """
    GPS.MDI.save_all()
    file = GPS.current_context().file()
    sv = GPS.Project.scenario_variables()
    x_args = ['-X%s=%s' % (k, v) for k, v in sv.items()] if sv else []
    command = [gps_utils.get_gnat_driver_cmd(), 'stub']
    proj = GPS.current_context().project()
    if proj:
        command.append('-P%s' % proj.file().path)
    command += x_args + [file.path, file.directory()]

    proc = GPS.Process(command,
                       task_manager=True,
                       show_command=True,
                       on_exit=OnExit(file).on_exit)
    proc.wait()
コード例 #6
0
def gnatpp(file):
    """
    Run gnatpp on a specific file.
    Nothing is done if the file is not an Ada file.
    """
    if file.language().lower() != 'ada':
        GPS.Logger("GNATPP").log("Not an Ada file: %s" % file.path)
        return

    p = ProcessWrapper([
        gps_utils.get_gnat_driver_cmd(), 'pretty', '-rf',
        '-P%s' % GPS.Project.root().file().path,
        GPS.Project.scenario_variables_cmd_line('-X'), file.path
    ],
                       spawn_console='')
    status, output = yield p.wait_until_terminate()

    if status != 0:
        GPS.Locations.parse(output, category='gnat pretty')
    else:
        GPS.EditorBuffer.get(file, force=True, open=True)
コード例 #7
0
def generate_body():
    """
    Run gnatstub on the current Ada spec to generate a matching
    body file.
    """
    GPS.MDI.save_all()
    proj = GPS.current_context().project()
    file = GPS.current_context().file()
    command = '"%s" stub "%s" %s "%s" "%s"' % (
        gps_utils.get_gnat_driver_cmd(),
        "-P%s" % proj.file().path if proj else "",
        GPS.Project.scenario_variables_cmd_line("-X"),
        file.path,
        file.directory())

    proc = GPS.Process(
        command,
        task_manager=True,
        show_command=True,
        on_exit=OnExit(file).on_exit)
    proc.wait()
コード例 #8
0
ファイル: gnatpp.py プロジェクト: MichelKramer31/gps
def gnatpp(file):
    """
    Run gnatpp on a specific file.
    Nothing is done if the file is not an Ada file.
    """
    if file.language().lower() != 'ada':
        GPS.Logger("GNATPP").log("Not an Ada file: %s" % file.path)
        return

    p = ProcessWrapper(
        [gps_utils.get_gnat_driver_cmd(),
         'pretty',
         '-rf',
         '-P%s' % GPS.Project.root().file().path,
         GPS.Project.scenario_variables_cmd_line('-X'),
         file.path],
        spawn_console='')
    status, output = yield p.wait_until_terminate()

    if status != 0:
        GPS.Locations.parse(output, category='gnat pretty')
    else:
        GPS.EditorBuffer.get(file, force=True, open=True)
コード例 #9
0
def gnatpp(file):
    """
    Run gnatpp on a specific file.
    Nothing is done if the file is not an Ada file.
    """
    if file.language().lower() != 'ada':
        GPS.Logger("GNATPP").log("Not an Ada file: %s" % file.path)
        return

    sv = GPS.Project.scenario_variables()
    x_args = ['-X%s=%s' % (k, v) for k, v in sv.items()] if sv else []

    cmd = [
        gps_utils.get_gnat_driver_cmd(), 'pretty', '-rnb',
        '-P%s' % GPS.Project.root().file().path
    ] + x_args + [file.path]

    p = ProcessWrapper(cmd, spawn_console='')
    status, output = yield p.wait_until_terminate()

    if status != 0:
        GPS.Locations.parse(output, category='gnat pretty')
    else:
        GPS.EditorBuffer.get(file, force=True, open=True)