From 1336797e0f2a8863a35d4a719c5b21700399e1c2 Mon Sep 17 00:00:00 2001 From: Anthony Leonardo Gracio Date: Tue, 9 May 2023 10:04:10 +0000 Subject: [PATCH] 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 --- share/support/core/gnatcheck.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/share/support/core/gnatcheck.py b/share/support/core/gnatcheck.py index e4c9b9f49f..d71fe1ecbf 100644 --- a/share/support/core/gnatcheck.py +++ b/share/support/core/gnatcheck.py @@ -128,23 +128,28 @@ def updateGnatCmd(self): if target == "": self.gnatCmd = "gnat" self.checkCmd = "gnatcheck" - elif locate_exec_on_path('{}-gnatcheck'.format(target)): - self.gnatCmd = '{}-gnat'.format(target) - self.checkCmd = '{}-gnatcheck'.format(target) else: - runtime = GPS.get_runtime() - self.gnatCmd = "gnat" - self.checkCmd = "gnatcheck" - self.gnatArgs = ["--target=%s" % target] - - if runtime != "": - self.gnatArgs.append("--RTS=%s" % runtime) + # If a target is specified in the GPR project file, check if we have + # a non-prefixed gnatcheck in the PATH, which supports the '--target' + # option. Fallback to the old prefixed gnatcheck if not. + if locate_exec_on_path('gnatcheck') and \ + '--target' in GPS.Process('gnatcheck --help').get_result(): + runtime = GPS.get_runtime() + self.gnatCmd = '{}-gnat'.format(target) + self.checkCmd = "gnatcheck" + self.gnatArgs = ["--target=%s" % target] + + if runtime != "": + self.gnatArgs.append("--RTS=%s" % runtime) + else: + self.gnatCmd = '{}-gnat'.format(target) + self.checkCmd = '{}-gnatcheck'.format(target) if not locate_exec_on_path(self.checkCmd): self.gnatCmd = "" self.checkCmd = "" GPS.Console("Messages").write( - "Error: 'gnatcheck' is not in the path.\n") + "Error: '%s' is not in the path.\n" % self.checkCmd) GPS.Console("Messages").write( "Error: Could not initialize the gnatcheck module.\n") elif not locate_exec_on_path(self.gnatCmd):