File: gnathub.py

package info (click to toggle)
gnat-gps 18-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 45,716 kB
  • sloc: ada: 362,679; python: 31,031; xml: 9,597; makefile: 1,030; ansic: 917; sh: 264; java: 17
file content (84 lines) | stat: -rw-r--r-- 2,623 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
"""
This file provides support for gnathub.
"""

import GPS
import gps_utils
import os_utils
import six

gnathub_menu = "/Analyze/GNAThub/"
tools = ['codepeer', 'gcov', 'gnatcoverage', 'gnatcheck', 'gnatmetric',
         'spark2014']


XML = r"""<?xml version="1.0" ?>
<GPS>
  <target-model name="gnathub">
    <iconname>gps-build-all-symbolic</iconname>
    <description>Run gnathub executable</description>
    <command-line>
      <arg>gnathub</arg>
      <arg>-P%PP</arg>
      <arg>%X</arg>
      <arg>%subdirsarg</arg>
    </command-line>
    <switches command="%(tool_name)s" columns="2">
    <title line="1" column="1">Available plugins</title>
    {}
    <title line="1" column="2">Other options</title>
    <field line="1" column="2" label="Execute" switch="--exec="
      tip="Python script to execute (implies --incremental)"/>
    <spin line="1" column="2" label="Parallel" switch="-j"
      tip="Number of jobs to run in parallel"
      max="99" min="0" default="0"/>
    <check line="1" column="2" label="Incremental" switch="-i"
      tip="Do not remove database if exists"/>
    <check line="1" column="2" label="Quiet" switch="-q"
      tip="Toggle quiet mode on"/>
    <check line="1" column="2" label="Verbose" switch="-v"
      tip="Toggle verbose mode on"/>
    </switches>
  </target-model>

  <target name="gnathub" category="_Project_" model="gnathub">
    <read-only>TRUE</read-only>
    <launch-mode>MANUALLY_WITH_DIALOG</launch-mode>
    <in-menu>FALSE</in-menu>
    <command-line>
      <arg>gnathub</arg>
      <arg>-P%PP</arg>
      <arg>%X</arg>
      <arg>%subdirsarg</arg>
    </command-line>
  </target>

</GPS>
"""

# Template to insert into target-model for each gnathub plugin
template = r"""<check line="1" column="1"
 label="{}" switch="--plugins={}" tip="Run {} plugin"/>
"""


# Check for gnathub executable and GNAThub module active status:

logger = GPS.Logger("GPS.INTERNAL.MODULE_GNAThub")

if os_utils.locate_exec_on_path("gnathub") and logger.active:
    checkboxes = six.reduce(lambda x, y: x+template.format(y, y, y), tools, "")

    GPS.parse_xml(XML.format(checkboxes))

    @gps_utils.interactive(category="Gnathub",
                           menu=gnathub_menu+"Run...",
                           name="Run gnathub...")
    def show_dialog_and_run_gnathub():
        target = GPS.BuildTarget("gnathub")
        target.execute(synchronous=False)

    @gps_utils.hook("compilation_finished")
    def __hook(category, target_name="", mode_name="", status=""):
        if not status and target_name == "gnathub":
            GPS.execute_action("gnathub display analysis")