Merge pull request #958 from tschaub/requires
Make the `build/check-requires-timestamp` target work with namespace provides in cases where the namespace provide isn't required by a module that provides constructors or other objects within that namespace. This may seem a bit odd, but if I want to provide `foo.bar.Bam` it isn't strictly necessary that my module require `foo.bar`.
To make this build target work, we stick with the following convention (used in the Closure Library):
* If you want to make a function available via `goog.require`, use `goog.provide` to provide the object of which the function is a member (e.g. to make the `foo.bar.baz` function available, use `goog.provide('foo.bar')`).
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from collections import defaultdict
|
||||
from itertools import ifilter
|
||||
from operator import attrgetter
|
||||
from optparse import OptionParser
|
||||
import re
|
||||
@@ -354,7 +352,8 @@ def main(argv):
|
||||
return_type = m.group('return_type')
|
||||
function = Function(name, object_literal, return_type, objects)
|
||||
objects[name] = function
|
||||
requires.add(name)
|
||||
# The require should only be for the namespace, not the function
|
||||
requires.add('.'.join(name.split('.')[0:-1]))
|
||||
continue
|
||||
m = re.match(r'@exportSymbol\s+(?P<name>\S+)(?:\s+(?P<export_as>\S+))?\Z', line)
|
||||
if m:
|
||||
|
||||
25
build.py
25
build.py
@@ -460,17 +460,23 @@ def build_check_requires_timestamp(t):
|
||||
self.children = {}
|
||||
|
||||
def _build_re(self, key):
|
||||
if len(self.children) == 1:
|
||||
if key == '*':
|
||||
assert len(self.children) == 0
|
||||
# We want to match `.doIt` but not `.SomeClass` or `.more.stuff`
|
||||
return '(?=\\.[a-z]\\w*\\b(?!\\.))'
|
||||
elif len(self.children) == 1:
|
||||
child_key, child = next(self.children.iteritems())
|
||||
child_re = '\\.' + child._build_re(child_key)
|
||||
child_re = child._build_re(child_key)
|
||||
if child_key != '*':
|
||||
child_re = '\\.' + child_re
|
||||
if self.present:
|
||||
return key + '(' + child_re + ')?'
|
||||
else:
|
||||
return key + child_re
|
||||
elif self.children:
|
||||
children_re = '(?:\\.(?:' + '|'.join(
|
||||
self.children[k]._build_re(k)
|
||||
for k in sorted(self.children.keys())) + '))'
|
||||
children_re = '(?:' + '|'.join(
|
||||
('\\.' if k != '*' else '') + self.children[k]._build_re(k)
|
||||
for k in sorted(self.children.keys())) + ')'
|
||||
if self.present:
|
||||
return key + children_re + '?'
|
||||
else:
|
||||
@@ -488,7 +494,14 @@ def build_check_requires_timestamp(t):
|
||||
if component not in node.children:
|
||||
node.children[component] = Node()
|
||||
node = node.children[component]
|
||||
node.present = True
|
||||
if component[0].islower():
|
||||
# We've arrived at a namespace provide like `ol.foo`.
|
||||
# In this case, we want to match uses like `ol.foo.doIt()` but
|
||||
# not match things like `new ol.foo.SomeClass()`.
|
||||
# For this purpose, we use the special wildcard key for the child.
|
||||
node.children['*'] = Node()
|
||||
else:
|
||||
node.present = True
|
||||
provide_res = [child.build_re(key)
|
||||
for key, child in root.children.iteritems()]
|
||||
missing_count = 0
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.RendererHints');
|
||||
goog.require('ol.View2D');
|
||||
goog.require('ol.animation.bounce');
|
||||
goog.require('ol.animation.pan');
|
||||
goog.require('ol.animation.rotate');
|
||||
goog.require('ol.animation');
|
||||
goog.require('ol.easing');
|
||||
goog.require('ol.layer.TileLayer');
|
||||
goog.require('ol.proj');
|
||||
|
||||
@@ -2,8 +2,8 @@ goog.require('ol');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.RendererHints');
|
||||
goog.require('ol.View2D');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.control.Control');
|
||||
goog.require('ol.control.defaults');
|
||||
goog.require('ol.layer.TileLayer');
|
||||
goog.require('ol.source.OSM');
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.RendererHints');
|
||||
goog.require('ol.View2D');
|
||||
goog.require('ol.interaction');
|
||||
goog.require('ol.interaction.DragRotateAndZoom');
|
||||
goog.require('ol.interaction.defaults');
|
||||
goog.require('ol.layer.TileLayer');
|
||||
goog.require('ol.source.MapQuestOpenAerial');
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.RendererHint');
|
||||
goog.require('ol.View2D');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.control.ScaleLine');
|
||||
goog.require('ol.control.ScaleLineUnits');
|
||||
goog.require('ol.control.defaults');
|
||||
goog.require('ol.layer.TileLayer');
|
||||
goog.require('ol.source.TiledWMS');
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.RendererHint');
|
||||
goog.require('ol.View2D');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.control.FullScreen');
|
||||
goog.require('ol.control.defaults');
|
||||
goog.require('ol.interaction');
|
||||
goog.require('ol.interaction.DragRotateAndZoom');
|
||||
goog.require('ol.interaction.defaults');
|
||||
goog.require('ol.layer.TileLayer');
|
||||
goog.require('ol.source.BingMaps');
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.RendererHints');
|
||||
goog.require('ol.View2D');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.control.FullScreen');
|
||||
goog.require('ol.control.defaults');
|
||||
goog.require('ol.layer.TileLayer');
|
||||
goog.require('ol.source.BingMaps');
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.RendererHints');
|
||||
goog.require('ol.View2D');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.control.MousePosition');
|
||||
goog.require('ol.control.defaults');
|
||||
goog.require('ol.coordinate');
|
||||
goog.require('ol.dom.Input');
|
||||
goog.require('ol.layer.TileLayer');
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.RendererHints');
|
||||
goog.require('ol.View2D');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.control.ZoomToExtent');
|
||||
goog.require('ol.control.defaults');
|
||||
goog.require('ol.layer.TileLayer');
|
||||
goog.require('ol.source.OSM');
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.RendererHints');
|
||||
goog.require('ol.View2D');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.control.ScaleLine');
|
||||
goog.require('ol.control.defaults');
|
||||
goog.require('ol.dom.Input');
|
||||
goog.require('ol.layer.TileLayer');
|
||||
goog.require('ol.source.OSM');
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.RendererHint');
|
||||
goog.require('ol.View2D');
|
||||
goog.require('ol.interaction');
|
||||
goog.require('ol.interaction.Select');
|
||||
goog.require('ol.interaction.defaults');
|
||||
goog.require('ol.layer.TileLayer');
|
||||
goog.require('ol.layer.Vector');
|
||||
goog.require('ol.parser.ogc.GML_v3');
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.RendererHint');
|
||||
goog.require('ol.View2D');
|
||||
goog.require('ol.control.defaults');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.expr');
|
||||
goog.require('ol.layer.Vector');
|
||||
goog.require('ol.parser.GeoJSON');
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.RendererHint');
|
||||
goog.require('ol.View2D');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.control.MousePosition');
|
||||
goog.require('ol.control.defaults');
|
||||
goog.require('ol.geom2.LineStringCollection');
|
||||
goog.require('ol.geom2.PointCollection');
|
||||
goog.require('ol.layer.TileLayer');
|
||||
|
||||
@@ -2,9 +2,9 @@ goog.require('ol.Attribution');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.RendererHints');
|
||||
goog.require('ol.View2D');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.control.ScaleLine');
|
||||
goog.require('ol.control.ScaleLineUnits');
|
||||
goog.require('ol.control.defaults');
|
||||
goog.require('ol.layer.TileLayer');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.source.TiledWMS');
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
goog.require('ol.parser.ogc.WMTSCapabilities');
|
||||
goog.require('ol.proj.addCommonProjections');
|
||||
goog.require('ol.proj.common');
|
||||
|
||||
ol.proj.addCommonProjections();
|
||||
ol.proj.common.add();
|
||||
Proj4js.defs['EPSG:31256'] = '+proj=tmerc +lat_0=0 ' +
|
||||
'+lon_0=16.33333333333333 +k=1 +x_0=0 +y_0=-5000000 +ellps=bessel ' +
|
||||
'+towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 ' +
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// FIXME works for View2D only
|
||||
|
||||
goog.provide('ol.animation.bounce');
|
||||
goog.provide('ol.animation.pan');
|
||||
goog.provide('ol.animation.rotate');
|
||||
goog.provide('ol.animation.zoom');
|
||||
goog.provide('ol.animation');
|
||||
|
||||
goog.require('ol.PreRenderFunction');
|
||||
goog.require('ol.ViewHint');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
goog.provide('ol.control.defaults');
|
||||
goog.provide('ol.control');
|
||||
|
||||
goog.require('ol.Collection');
|
||||
goog.require('ol.control.Attribution');
|
||||
|
||||
@@ -6,7 +6,7 @@ goog.require('goog.dom');
|
||||
goog.require('goog.dom.TagName');
|
||||
goog.require('goog.events');
|
||||
goog.require('goog.events.EventType');
|
||||
goog.require('ol.animation.zoom');
|
||||
goog.require('ol.animation');
|
||||
goog.require('ol.control.Control');
|
||||
goog.require('ol.css');
|
||||
goog.require('ol.easing');
|
||||
|
||||
@@ -15,7 +15,7 @@ goog.require('goog.fx.Dragger.EventType');
|
||||
goog.require('goog.math');
|
||||
goog.require('goog.math.Rect');
|
||||
goog.require('goog.style');
|
||||
goog.require('ol.animation.zoom');
|
||||
goog.require('ol.animation');
|
||||
goog.require('ol.control.Control');
|
||||
goog.require('ol.css');
|
||||
goog.require('ol.easing');
|
||||
|
||||
@@ -3,7 +3,6 @@ goog.provide('ol.geom.SharedVertices');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.Coordinate');
|
||||
goog.require('ol.CoordinateArray');
|
||||
goog.require('ol.geom'); // TODO: remove this when #958 is addressed
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
goog.provide('ol.interaction.Interaction');
|
||||
|
||||
goog.require('ol.MapBrowserEvent');
|
||||
goog.require('ol.animation.pan');
|
||||
goog.require('ol.animation.rotate');
|
||||
goog.require('ol.animation.zoom');
|
||||
goog.require('ol.animation');
|
||||
goog.require('ol.easing');
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
goog.provide('ol.interaction.defaults');
|
||||
goog.provide('ol.interaction');
|
||||
|
||||
goog.require('ol.Collection');
|
||||
goog.require('ol.Kinetic');
|
||||
|
||||
@@ -3,7 +3,7 @@ goog.provide('ol.Kinetic');
|
||||
|
||||
goog.require('ol.Coordinate');
|
||||
goog.require('ol.PreRenderFunction');
|
||||
goog.require('ol.animation.pan');
|
||||
goog.require('ol.animation');
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -50,13 +50,13 @@ goog.require('ol.TileQueue');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.View2D');
|
||||
goog.require('ol.ViewHint');
|
||||
goog.require('ol.control.defaults');
|
||||
goog.require('ol.control');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.interaction.defaults');
|
||||
goog.require('ol.interaction');
|
||||
goog.require('ol.layer.LayerBase');
|
||||
goog.require('ol.layer.LayerGroup');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.proj.addCommonProjections');
|
||||
goog.require('ol.proj.common');
|
||||
goog.require('ol.renderer.Map');
|
||||
goog.require('ol.renderer.canvas.Map');
|
||||
goog.require('ol.renderer.canvas.SUPPORTED');
|
||||
@@ -1217,7 +1217,7 @@ ol.RendererHints.createFromQueryData = function(opt_queryData) {
|
||||
};
|
||||
|
||||
|
||||
ol.proj.addCommonProjections();
|
||||
ol.proj.common.add();
|
||||
|
||||
|
||||
if (goog.DEBUG) {
|
||||
|
||||
@@ -13,10 +13,11 @@
|
||||
@exportProperty ol.ProjectionUnits.METERS
|
||||
|
||||
@exportSymbol ol.proj.addProjection
|
||||
@exportSymbol ol.proj.addCommonProjections
|
||||
@exportSymbol ol.proj.get
|
||||
@exportSymbol ol.proj.getTransform
|
||||
@exportSymbol ol.proj.getTransformFromProjections
|
||||
@exportSymbol ol.proj.transform
|
||||
@exportSymbol ol.proj.transformWithProjections
|
||||
@exportSymbol ol.proj.configureProj4jsProjection
|
||||
|
||||
@exportSymbol ol.proj.common.add
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
goog.provide('ol.proj.addCommonProjections');
|
||||
goog.provide('ol.proj.common');
|
||||
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.proj.EPSG3857');
|
||||
@@ -8,7 +8,7 @@ goog.require('ol.proj.EPSG4326');
|
||||
/**
|
||||
* FIXME empty description for jsdoc
|
||||
*/
|
||||
ol.proj.addCommonProjections = function() {
|
||||
ol.proj.common.add = function() {
|
||||
// Add transformations that don't alter coordinates to convert within set of
|
||||
// projections with equal meaning.
|
||||
ol.proj.addEquivalentProjections(ol.proj.EPSG3857.PROJECTIONS);
|
||||
|
||||
@@ -127,6 +127,6 @@ goog.require('goog.dom');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.RendererHint');
|
||||
goog.require('ol.RendererHints');
|
||||
goog.require('ol.interaction');
|
||||
goog.require('ol.interaction.DoubleClickZoom');
|
||||
goog.require('ol.interaction.MouseWheelZoom');
|
||||
goog.require('ol.interaction.defaults');
|
||||
|
||||
Reference in New Issue
Block a user