Merge lp:~salgado/lazr-js/build-fixes into lp:lazr-js

Proposed by Guilherme Salgado
Status: Merged
Merged at revision: not available
Proposed branch: lp:~salgado/lazr-js/build-fixes
Merge into: lp:lazr-js
Diff against target: 153 lines (+33/-7)
3 files modified
Makefile (+0/-1)
src-py/lazr/js/build.py (+20/-4)
src-py/lazr/js/meta.py (+13/-2)
To merge this branch: bzr merge lp:~salgado/lazr-js/build-fixes
Reviewer Review Type Date Requested Status
Māris Fogels (community) Approve
Review via email: mp+15827@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Guilherme Salgado (salgado) wrote :

This branch moves the copying of src-js/lazrjs/yui/ to the build dir
from the Makefile to the build script, so that we don't have to
duplicate that 'cp -r' hack in Launchpad's Makefile. This is not related
to the combo loader but is needed to make Launchpad to work against a
lazr-js version that has the combo loader.

It also adds a --no-skin argument to the meta.py script, so that we can
use the combo loader for javascript but not for CSS.

 reviewer mars

Revision history for this message
Māris Fogels (mars) wrote :

Hi Salgado,

As discussed on IRC, your changes look good, r=mars. We'll leave the --copy-yui-to switch, in favour of --no-yui, and change the Python parameter from 'no_skin=False' to 'include_skin=True'.

Maris

review: Approve
lp:~salgado/lazr-js/build-fixes updated
166. By Guilherme Salgado

Couple minor changes as suggested by Maris

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2009-11-30 19:07:28 +0000
3+++ Makefile 2009-12-08 20:19:10 +0000
4@@ -21,7 +21,6 @@
5
6 # Update the build directory
7 build: $(PY)
8- cp -r src-js/lazrjs/yui/* build
9 $(PYTHON) -S bin/jsbuild -b build/lazr -s src-js/lazrjs -n lazr -x lazr/yui
10 $(PYTHON) -S bin/yuimeta -n LAZR_MODULES \
11 -s build/lazr \
12
13=== modified file 'src-py/lazr/js/build.py'
14--- src-py/lazr/js/build.py 2009-11-13 21:25:57 +0000
15+++ src-py/lazr/js/build.py 2009-12-08 20:19:10 +0000
16@@ -9,7 +9,6 @@
17 import re
18 import shutil
19 import sys
20-import xml.dom
21
22 from glob import glob
23
24@@ -24,7 +23,6 @@
25 ESCAPE_STAR_PROPERTY_RE = re.compile(r'\*([a-zA-Z0-9_-]+):')
26 UNESCAPE_STAR_PROPERTY_RE = re.compile(r'([a-zA-Z0-9_-]+)_ie_star_hack:')
27
28-import lazrjs
29 from jsmin import JavascriptMinify
30
31
32@@ -185,7 +183,8 @@
33 class Builder:
34
35 def __init__(self, name='lazr', build_dir=BUILD_DIR, src_dir=SRC_DIR,
36- extra_files=None, exclude_regex='', file_type='raw'):
37+ extra_files=None, exclude_regex='', file_type='raw',
38+ copy_yui_to=BUILD_DIR):
39 """Create a new Builder.
40
41 :param name: The name of the package we are building. This will
42@@ -201,6 +200,8 @@
43 file. Possible values are 'raw', 'min', and 'debug'. File types
44 are identified by their basename suffix: foo.js, foo-min.js,
45 foo-debug.js, etc.
46+ :param copy_yui_to: The absolute path (as a string) to the place where
47+ the YUI modules should be copied to. Defaults to BUILD_DIR.
48 """
49 self.name = name
50 self.build_dir = build_dir
51@@ -214,6 +215,7 @@
52
53 self.exclusion_regex = exclude_regex
54 self.file_type = file_type
55+ self.copy_yui_to = copy_yui_to
56
57 self.log("Using filter: " + self.file_type)
58
59@@ -403,7 +405,17 @@
60 continue
61 yield name, path
62
63+ def copy_yui_package(self):
64+ """Copy the contents of our 'yui' dir to self.copy_yui_to."""
65+ yui_dirs = glob(os.path.join(SRC_DIR, 'yui') + '/*')
66+ for dir in yui_dirs:
67+ dir_name = os.path.split(dir)[-1]
68+ dst_dir = os.path.join(self.copy_yui_to, dir_name)
69+ if not os.path.isdir(dst_dir):
70+ shutil.copytree(dir, dst_dir)
71+
72 def do_build(self):
73+ self.copy_yui_package()
74 for name, cpath in self.find_components():
75 files_to_link = glob(os.path.join(cpath, '*.js'))
76 if len(files_to_link) == 0:
77@@ -445,6 +457,9 @@
78 help=('Only bundle files in the source directory that match the '
79 'specified file-type filter. Possible values are '
80 '[min, raw, debug]. [default: %default]'))
81+ parser.add_option(
82+ '-c', '--copy-yui-to', dest='copy_yui_to', default=BUILD_DIR,
83+ help=('Copy the YUI tree to the given directory before building'))
84 return parser.parse_args()
85
86
87@@ -456,5 +471,6 @@
88 src_dir=options.src_dir,
89 extra_files=extra,
90 exclude_regex=options.exclude,
91- file_type=options.file_type
92+ file_type=options.file_type,
93+ copy_yui_to=options.copy_yui_to,
94 ).do_build()
95
96=== modified file 'src-py/lazr/js/meta.py'
97--- src-py/lazr/js/meta.py 2009-11-23 18:55:48 +0000
98+++ src-py/lazr/js/meta.py 2009-12-08 20:19:10 +0000
99@@ -30,7 +30,7 @@
100 class Builder:
101
102 def __init__(self, name, src_dir=SRC_DIR, output=None,
103- prefix="", exclude_regex=None, ext=True):
104+ prefix="", exclude_regex=None, ext=True, include_skin=True):
105 """Create a new Builder.
106
107 :param name: The name of the global variable name that will
108@@ -43,12 +43,16 @@
109 will still be built.
110 :param ext: Default value for the 'ext' setting. Set to
111 'False' to use modules with a local combo loader.
112+ :param include_skin: If False, the generated metadata won't include
113+ skin modules and all javascript modules will have skinnable=False.
114+ Defaults to True.
115 """
116 self.name = name
117 self.output = output
118 self.prefix = prefix
119 self.src_dir = src_dir
120 self.exclude_regex = exclude_regex
121+ self.include_skin = include_skin
122 self.ext = ext
123
124 def log(self, msg):
125@@ -85,8 +89,10 @@
126
127 entry["type"] = "js"
128 entry["ext"] = self.ext
129- if entry.get("skinnable"):
130+ if self.include_skin and entry.get("skinnable"):
131 self.generate_skin_modules(entry, metadata, root)
132+ else:
133+ entry['skinnable'] = False
134 metadata.extend(meta)
135
136 modules = {}
137@@ -224,6 +230,10 @@
138 '-x', '--exclude', dest='exclude_regex',
139 default=None, metavar='REGEX',
140 help=('Exclude any files that match the given regular expressions.'))
141+ parser.add_option(
142+ '-k', '--no-skin', dest='no_skin', default=False, action="store_true",
143+ help=('Do not include skin files in the list of modules and set '
144+ 'skinnable=False for all modules.'))
145 return parser.parse_args()
146
147
148@@ -236,4 +246,5 @@
149 prefix=options.prefix,
150 exclude_regex=options.exclude_regex,
151 ext=options.ext,
152+ include_skin=not options.no_skin,
153 ).do_build()

Subscribers

People subscribed via source and target branches