Skip to content

Commit 1336797

Browse files
Prioritize new gnatcheck over old prefixed ones
If we have a new LAL-based gnatcheck that supports the '--target' option in the PATH, we should prioritize it over older prefixed versions of gnatcheck (e.g: powerpc-elf-gnatcheck). We should still use the prefixed GNAT executable though to enable checks for GNAT warnings. For eng/ide/gnatstudio#37
1 parent 593f296 commit 1336797

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

share/support/core/gnatcheck.py

+16-11
Original file line numberDiff line numberDiff line change
@@ -128,23 +128,28 @@ def updateGnatCmd(self):
128128
if target == "":
129129
self.gnatCmd = "gnat"
130130
self.checkCmd = "gnatcheck"
131-
elif locate_exec_on_path('{}-gnatcheck'.format(target)):
132-
self.gnatCmd = '{}-gnat'.format(target)
133-
self.checkCmd = '{}-gnatcheck'.format(target)
134131
else:
135-
runtime = GPS.get_runtime()
136-
self.gnatCmd = "gnat"
137-
self.checkCmd = "gnatcheck"
138-
self.gnatArgs = ["--target=%s" % target]
139-
140-
if runtime != "":
141-
self.gnatArgs.append("--RTS=%s" % runtime)
132+
# If a target is specified in the GPR project file, check if we have
133+
# a non-prefixed gnatcheck in the PATH, which supports the '--target'
134+
# option. Fallback to the old prefixed gnatcheck if not.
135+
if locate_exec_on_path('gnatcheck') and \
136+
'--target' in GPS.Process('gnatcheck --help').get_result():
137+
runtime = GPS.get_runtime()
138+
self.gnatCmd = '{}-gnat'.format(target)
139+
self.checkCmd = "gnatcheck"
140+
self.gnatArgs = ["--target=%s" % target]
141+
142+
if runtime != "":
143+
self.gnatArgs.append("--RTS=%s" % runtime)
144+
else:
145+
self.gnatCmd = '{}-gnat'.format(target)
146+
self.checkCmd = '{}-gnatcheck'.format(target)
142147

143148
if not locate_exec_on_path(self.checkCmd):
144149
self.gnatCmd = ""
145150
self.checkCmd = ""
146151
GPS.Console("Messages").write(
147-
"Error: 'gnatcheck' is not in the path.\n")
152+
"Error: '%s' is not in the path.\n" % self.checkCmd)
148153
GPS.Console("Messages").write(
149154
"Error: Could not initialize the gnatcheck module.\n")
150155
elif not locate_exec_on_path(self.gnatCmd):

0 commit comments

Comments
 (0)