~launchpad-pqm/launchpad/devel

10386.5.4 by Paul Hummer
Added code to bring in the dependencies
1
#!/usr/bin/python
2
#
3
# Copyright 2010 Canonical Ltd.  This software is licensed under the
4
# GNU Affero General Public License version 3 (see the file LICENSE).
5
6
"""Print the Launchpad javascript files we are using.
7
8
The output of this script is meant to be given to the jsbuild script so that
9
they are included in the launchpad.js file.
10
"""
11
12
__metaclass__ = type
13
14
import os
10785.1.2 by Brad Crittenden
Move registry JS to lp.registry namespace
15
10985.2.1 by Deryck Hodge
Get js minified from app-specific javascript directories.
16
from lazr.js.build import Builder
10386.5.4 by Paul Hummer
Added code to bring in the dependencies
17
18
TOP = os.path.abspath(
19
    os.path.join(os.path.dirname(__file__), '..'))
10386.5.5 by Paul Hummer
Symlinks FTMFW!
20
# JS_DIRSET is a tuple of the dir where the code exists, and the name of the
21
# symlink it should be linked as in the icing build directory.
22
JS_DIRSET = [
11090.5.2 by Tim Penhey
Add an app link, and remove the duplicate bug link.
23
    (os.path.join('lib', 'lp', 'app', 'javascript'), 'app'),
11009.1.2 by Edwin Grubbs
Made formoverlay appear correctly with textareas that are wider than normal.
24
    (os.path.join('lib', 'lp', 'bugs', 'javascript'), 'bugs'),
10785.1.1 by Brad Crittenden
Move registry javascript
25
    (os.path.join('lib', 'lp', 'code', 'javascript'), 'code'),
26
    (os.path.join('lib', 'lp', 'registry', 'javascript'), 'registry'),
10876.6.1 by Adi Roiban
Move translation jsfiles into lib/lp.
27
    (os.path.join('lib', 'lp', 'translations', 'javascript'), 'translations'),
10785.1.1 by Brad Crittenden
Move registry javascript
28
    ]
10386.5.5 by Paul Hummer
Symlinks FTMFW!
29
ICING_ROOT = os.path.join(TOP, 'lib', 'canonical', 'launchpad', 'icing')
30
ICING_BUILD = os.path.join(ICING_ROOT, 'build')
10386.5.4 by Paul Hummer
Added code to bring in the dependencies
31
10985.2.3 by Deryck Hodge
Add a comment describing why the monkey patch
32
# Builder has lots of logging, which might not
33
# play well with printing filenames.  Monkey patch
34
# to disable it.
10985.2.1 by Deryck Hodge
Get js minified from app-specific javascript directories.
35
def log_none(msg):
36
    return
37
10386.5.5 by Paul Hummer
Symlinks FTMFW!
38
for DIRSET in JS_DIRSET:
39
    full_dir = os.path.join(TOP, DIRSET[0])
10985.2.1 by Deryck Hodge
Get js minified from app-specific javascript directories.
40
    module_name = DIRSET[1]
41
    BUILD_DIR = os.path.join(ICING_BUILD, module_name)
42
    if not os.path.exists(BUILD_DIR):
43
        os.mkdir(BUILD_DIR)
44
    builder = Builder(
45
        name=module_name, src_dir=full_dir, build_dir=ICING_BUILD)
46
    builder.log = log_none
10386.5.5 by Paul Hummer
Symlinks FTMFW!
47
    # We don't want the tests to be included.  If we want to nest the files in
48
    # more folders though, this is where we change it.
10386.5.4 by Paul Hummer
Added code to bring in the dependencies
49
    for filename in os.listdir(full_dir):
50
        if filename.endswith('.js'):
10985.2.1 by Deryck Hodge
Get js minified from app-specific javascript directories.
51
            basename, nothing = filename.split('.js')
52
            min_filename = basename + '-min.js'
10386.5.4 by Paul Hummer
Added code to bring in the dependencies
53
            absolute_filename = os.path.join(full_dir, filename)
10985.2.1 by Deryck Hodge
Get js minified from app-specific javascript directories.
54
            builder.link_and_minify(builder.name, absolute_filename)
55
            print os.path.join(BUILD_DIR, min_filename)