3
# Copyright 2010 Canonical Ltd. This software is licensed under the
4
# GNU Affero General Public License version 3 (see the file LICENSE).
6
"""Print the Launchpad javascript files we are using.
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.
16
from lazr.js.build import Builder
18
TOP = os.path.abspath(
19
os.path.join(os.path.dirname(__file__), '..'))
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.
23
(os.path.join('lib', 'lp', 'app', 'javascript'), 'app'),
24
(os.path.join('lib', 'lp', 'bugs', 'javascript'), 'bugs'),
25
(os.path.join('lib', 'lp', 'code', 'javascript'), 'code'),
26
(os.path.join('lib', 'lp', 'registry', 'javascript'), 'registry'),
27
(os.path.join('lib', 'lp', 'translations', 'javascript'), 'translations'),
28
(os.path.join('lib', 'lp', 'soyuz', 'javascript'), 'soyuz'),
29
(os.path.join('lib', 'lp', 'contrib', 'javascript', 'yui3-gallery', 'gallery-accordion'), 'contrib'),
31
ICING_ROOT = os.path.join(TOP, 'lib', 'canonical', 'launchpad', 'icing')
32
ICING_BUILD = os.path.join(ICING_ROOT, 'build')
34
# Builder has lots of logging, which might not
35
# play well with printing filenames. Monkey patch
40
for DIRSET in JS_DIRSET:
41
full_dir = os.path.join(TOP, DIRSET[0])
42
module_name = DIRSET[1]
43
BUILD_DIR = os.path.join(ICING_BUILD, module_name)
44
if not os.path.exists(BUILD_DIR):
47
name=module_name, src_dir=full_dir, build_dir=ICING_BUILD)
48
builder.log = log_none
49
# We don't want the tests to be included. If we want to nest the files in
50
# more folders though, this is where we change it.
51
for filename in os.listdir(full_dir):
52
# Some third-party JavaScript libraries may include pre-built -min and
53
# -debug files. Skip those.
54
if filename.endswith('-min.js') or filename.endswith('-debug.js'):
56
if filename.endswith('.js'):
57
basename, nothing = filename.split('.js')
58
min_filename = basename + '-min.js'
59
absolute_filename = os.path.join(full_dir, filename)
60
builder.link_and_minify(builder.name, absolute_filename)
61
print os.path.join(BUILD_DIR, min_filename)