~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to setup/build.py

trampoline now takes the jail paths in argv.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# IVLE - Informatics Virtual Learning Environment
 
2
# Copyright (C) 2007-2008 The University of Melbourne
 
3
#
 
4
# This program is free software; you can redistribute it and/or modify
 
5
# it under the terms of the GNU General Public License as published by
 
6
# the Free Software Foundation; either version 2 of the License, or
 
7
# (at your option) any later version.
 
8
#
 
9
# This program is distributed in the hope that it will be useful,
 
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
# GNU General Public License for more details.
 
13
#
 
14
# You should have received a copy of the GNU General Public License
 
15
# along with this program; if not, write to the Free Software
 
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
17
 
 
18
# Module: setup/build
 
19
# Author: Matt Giuca, Refactored by David Coles
 
20
# Date:   02/07/2008
 
21
 
 
22
import optparse
 
23
import os
 
24
import sys
 
25
import compileall
 
26
 
 
27
from setup import util
 
28
 
 
29
def build(args):
 
30
    usage = """usage: %prog build [options]
 
31
(requires root)
 
32
Compiles platform-specific code, and optionally Python too.
 
33
Details:
 
34
Compiles (GCC) bin/trampoline/trampoline.c to bin/trampoline/trampoline.
 
35
Compiles (GCC) bin/timount/timount.c to bin/timount/timount.
 
36
Optionally generates .pyc files for all the IVLE .py files."""
 
37
 
 
38
    # Parse arguments
 
39
    parser = optparse.OptionParser(usage)
 
40
    parser.add_option("-n", "--dry",
 
41
        action="store_true", dest="dry",
 
42
        help="Print out the actions but don't do anything.")
 
43
    parser.add_option("--no-compile",
 
44
        action="store_true", dest="nocompile",
 
45
        help="Don't byte-compile .py files.")
 
46
    (options, args) = parser.parse_args(args)
 
47
 
 
48
    # Call the real function
 
49
    return __build(options.dry, options.nocompile)
 
50
 
 
51
def __build(dry=False, no_compile=None):
 
52
    install_list = util.InstallList()
 
53
 
 
54
    if dry:
 
55
        print "Dry run (no actions will be executed)\n"
 
56
 
 
57
    # Compile the trampoline
 
58
    curdir = os.getcwd()
 
59
    os.chdir('bin/trampoline')
 
60
    util.action_runprog('make', [], dry)
 
61
    os.chdir(curdir)
 
62
 
 
63
    # Compile timount
 
64
    curdir = os.getcwd()
 
65
    os.chdir('bin/timount')
 
66
    util.action_runprog('make', [], dry)
 
67
    os.chdir(curdir)
 
68
 
 
69
    # Compile .py files into .pyc or .pyo files
 
70
    if not no_compile:
 
71
        compileall.compile_dir('www', quiet=True)
 
72
        compileall.compile_dir('ivle', quiet=True)
 
73
        compileall.compile_dir('services', quiet=True)
 
74
 
 
75
    return 0
 
76