File: build.py

package info (click to toggle)
gnat-gps 4.3-5
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 49,096 kB
  • ctags: 20,461
  • sloc: ada: 274,120; ansic: 154,849; python: 9,890; tcl: 9,812; sh: 8,192; xml: 7,970; cpp: 4,737; yacc: 3,520; makefile: 2,136; lex: 2,043; java: 1,638; perl: 302; awk: 265; sed: 161; asm: 14; fortran: 2; lisp: 1
file content (44 lines) | stat: -rw-r--r-- 1,342 bytes parent folder | download | duplicates (6)
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
## This script adds support for building all the main units found in a
## project tree.
##
## Put this file in $HOME/.gps/plug-ings/build.py
## Launch gps: a new menu is available in Build/Make/All Main Units
##
## Or in batch mode (to generate a batch file to execute in command line mode):
##    gps -Pproject --hide --eval="python:build.compile_and_exit('foo.sh')"

import GPS

GPS.parse_xml ("""
   <action name='Compile all main units' category="Builder">
       <shell lang='python'>build.compile_recursive()</shell>
   </action>
   <menu action='Compile all main units'>
       <title>/Build/Make/All Main Units</title>
   </menu>
""")


def compile_recursive (to_file=''):
   """Prepares all the commands needed to compile all the executables found
      in the project tree. If TO_FILE is provided, the commands are written
      in that file, otherwise they are run within GPS directly"""

   if to_file != '':
       out = file (to_file, 'w')

   for p in GPS.Project.root().dependencies (recursive=True):
      for main in p.get_attribute_as_list ("main"):
        if to_file != '':
           out.write ("gnatmake -P" + p.file().name() + " " + main + "\n");
        else:
           GPS.File (main).make()

   if to_file != '':
      out.close()

def compile_and_exit (to_file=''):
   compile_recursive (to_file)
   GPS.exit()