Resource Compiler Plugin for GNAT Studio

This Python plugin enhances GNAT Studio's build menu with a command to compile Windows resources from a *.rc file in your project's root directory.

Save the following script as <project_name>.ide.py in the same folder as <project_name>.gpr.

import GPS

def add_res_compiler_cmd(hook_name):
    """
    Register a build menu command to run the resource compiler
    """
    GPS.parse_xml('''
      <filter_and name="Ada Project Open" >
        <filter language="ada"/>
        <filter_or>
          <filter id="Explorer_Project_Node"/>
          <filter id="Source editor"/>
        </filter_or>
      </filter_and>
      <action name="Compile Resources" category="Build">
        <shell lang="python" show-command="false">GPS.get_system_dir() + 'bin\\\\windres.exe'</shell>
        <shell lang="python" show-command="false">GPS.Project.root().name() + '.rc'</shell>
        <shell lang="python" show-command="false">GPS.Project.root().get_attribute_as_string('object_dir') + '\\\\resources.o'</shell>
        <external output="Resource Compiler">%3 -i %2 --output-format=coff -o %1</external>
      </action>
      <menu action="Compile Resources" after="Compile All Sources">
        <title>/Build/Project/Compile Resources</title>
      </menu>
    ''')

GPS.Hook("gps_started").add(add_res_compiler_cmd)

License

Copyright 2022 Robert Di Pardo

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.