Example #1
0
File: build.py Project: igrcic/ol3
def host_examples(t):
    examples_dir = 'build/hosted/%(BRANCH)s/examples'
    build_dir = 'build/hosted/%(BRANCH)s/build'
    css_dir = 'build/hosted/%(BRANCH)s/css'
    closure_lib_path = output('node', '-e',
        'process.stdout.write(require("closure-util").getLibraryPath())')
    t.rm_rf(examples_dir)
    t.makedirs(examples_dir)
    t.rm_rf(build_dir)
    t.makedirs(build_dir)
    t.rm_rf(css_dir)
    t.makedirs(css_dir)
    t.cp(EXAMPLES, examples_dir)
    for example in [path.replace('.html', '.js') for path in EXAMPLES]:
        split_example_file(example, examples_dir % vars(variables))
    t.cp_r('examples/data', examples_dir + '/data')
    t.cp('bin/loader_hosted_examples.js', examples_dir + '/loader.js')
    t.cp('build/ol.js', 'build/ol-debug.js', build_dir)
    t.cp('build/ol.css', css_dir)
    t.cp('examples/index.html', 'examples/example-list.js',
         'examples/example-list.xml', 'examples/Jugl.js', examples_dir)
    t.rm_rf('build/hosted/%(BRANCH)s/closure-library')
    t.cp_r(closure_lib_path, 'build/hosted/%(BRANCH)s/closure-library')
    t.rm_rf('build/hosted/%(BRANCH)s/ol')
    t.makedirs('build/hosted/%(BRANCH)s/ol')
    t.cp_r('src/ol', 'build/hosted/%(BRANCH)s/ol/ol')
    t.rm_rf('build/hosted/%(BRANCH)s/ol.ext')
    t.cp_r('build/ol.ext', 'build/hosted/%(BRANCH)s/ol.ext')
    t.run('%(PYTHON)s', closure_lib_path + '/closure/bin/build/depswriter.py',
          '--root_with_prefix', 'src ../../../ol',
          '--root_with_prefix', 'build/ol.ext ../../../ol.ext',
          '--root', 'build/hosted/%(BRANCH)s/closure-library/closure/goog',
          '--root_with_prefix', 'build/hosted/%(BRANCH)s/closure-library/'
          'third_party ../../third_party',
          '--output_file', 'build/hosted/%(BRANCH)s/build/ol-deps.js')
Example #2
0
def host_examples(t):
    examples_dir = 'build/hosted/%(BRANCH)s/examples'
    build_dir = 'build/hosted/%(BRANCH)s/build'
    css_dir = 'build/hosted/%(BRANCH)s/css'
    closure_lib_path = output('node', '-e',
        'process.stdout.write(require("closure-util").getLibraryPath())')
    t.rm_rf(examples_dir)
    t.cp_r('build/examples', examples_dir)
    for example in EXAMPLES_SRC_JS:
        split_example_file(example, examples_dir % vars(variables))
    t.cp('bin/loader_hosted_examples.js', examples_dir + '/loader.js')
    t.rm_rf(build_dir)
    t.makedirs(build_dir)
    t.rm_rf(css_dir)
    t.makedirs(css_dir)
    t.cp('build/ol.js', 'build/ol-debug.js', build_dir)
    t.cp('build/ol.css', css_dir)
    t.rm_rf('build/hosted/%(BRANCH)s/closure-library')
    t.cp_r(closure_lib_path, 'build/hosted/%(BRANCH)s/closure-library')
    t.rm_rf('build/hosted/%(BRANCH)s/ol')
    t.makedirs('build/hosted/%(BRANCH)s/ol')
    t.cp_r('src/ol', 'build/hosted/%(BRANCH)s/ol/ol')
    t.rm_rf('build/hosted/%(BRANCH)s/ol.ext')
    t.cp_r('build/ol.ext', 'build/hosted/%(BRANCH)s/ol.ext')
    t.run('%(PYTHON)s', closure_lib_path + '/closure/bin/build/depswriter.py',
          '--root_with_prefix', 'src ../../../ol',
          '--root_with_prefix', 'build/ol.ext ../../../ol.ext',
          '--root', 'build/hosted/%(BRANCH)s/closure-library/closure/goog',
          '--root_with_prefix', 'build/hosted/%(BRANCH)s/closure-library/'
          'third_party ../../third_party',
          '--output_file', 'build/hosted/%(BRANCH)s/build/ol-deps.js')
Example #3
0
def host_examples(t):
    examples_dir = 'build/hosted/%(BRANCH)s/examples'
    build_dir = 'build/hosted/%(BRANCH)s/build'
    css_dir = 'build/hosted/%(BRANCH)s/css'
    closure_lib_path = output(
        'node', '-e',
        'process.stdout.write(require("closure-util").getLibraryPath())')
    t.rm_rf(examples_dir)
    t.makedirs(examples_dir)
    t.rm_rf(build_dir)
    t.makedirs(build_dir)
    t.rm_rf(css_dir)
    t.makedirs(css_dir)
    t.cp(EXAMPLES, examples_dir)
    for example in [path.replace('.html', '.js') for path in EXAMPLES]:
        split_example_file(example, examples_dir % vars(variables))
    t.cp_r('examples/data', examples_dir + '/data')
    t.cp('bin/loader_hosted_examples.js', examples_dir + '/loader.js')
    t.cp('build/ol.js', 'build/ol-simple.js', 'build/ol-whitespace.js',
         build_dir)
    t.cp('build/ol.css', css_dir)
    t.cp('examples/index.html', 'examples/example-list.js',
         'examples/example-list.xml', 'examples/Jugl.js',
         'examples/jquery.min.js', examples_dir)
    t.rm_rf('build/hosted/%(BRANCH)s/closure-library')
    t.cp_r(closure_lib_path, 'build/hosted/%(BRANCH)s/closure-library')
    t.rm_rf('build/hosted/%(BRANCH)s/ol')
    t.makedirs('build/hosted/%(BRANCH)s/ol')
    t.cp_r('src/ol', 'build/hosted/%(BRANCH)s/ol/ol')
    t.run(
        '%(PYTHON)s', closure_lib_path + '/closure/bin/build/depswriter.py',
        '--root_with_prefix', 'src ../../../ol', '--root',
        'build/hosted/%(BRANCH)s/closure-library/closure/goog',
        '--root_with_prefix', 'build/hosted/%(BRANCH)s/closure-library/'
        'third_party ../../third_party', '--output_file',
        'build/hosted/%(BRANCH)s/build/ol-deps.js')
Example #4
0
else:
    variables.GIT = 'git'
    variables.GJSLINT = 'gjslint'
    if sys.platform == 'darwin':
        variables.JAVA = '/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java'
    else:
        variables.JAVA = 'java'
    variables.JAR = 'jar'
    variables.JSDOC = 'jsdoc'
    variables.NODE = 'node'
    variables.PYTHON = 'python'
    variables.PHANTOMJS = 'phantomjs'

TEMPLATE_GLSL_COMPILER_JS = 'build/glsl-unit/bin/template_glsl_compiler.js'

variables.BRANCH = output('%(GIT)s', 'rev-parse', '--abbrev-ref',
                          'HEAD').strip()

EXECUTABLES = [
    variables.GIT, variables.GJSLINT, variables.JAVA, variables.JAR,
    variables.JSDOC, variables.PYTHON, variables.PHANTOMJS
]

EXPORTS = [path for path in ifind('src') if path.endswith('.exports')]

EXTERNAL_SRC = [
    'build/src/external/externs/types.js', 'build/src/external/src/exports.js',
    'build/src/external/src/types.js'
]

EXAMPLES = [
    path for path in ifind('examples') if path.endswith('.html')
Example #5
0
        variables.PHANTOMJS = 'phantomjs.exe'
    else:
        variables.PHANTOMJS = os.path.join(windows_defaults['phantomjs'],
                                           'phantomjs.exe')

else:
    variables.GIT = 'git'
    variables.GJSLINT = 'gjslint'
    variables.JAVA = 'java'
    variables.JAR = 'jar'
    variables.JSDOC = 'jsdoc'
    variables.NODE = 'node'
    variables.PYTHON = 'python'
    variables.PHANTOMJS = 'phantomjs'

variables.BRANCH = output(
    '%(GIT)s', 'rev-parse', '--abbrev-ref', 'HEAD').strip()

EXECUTABLES = [variables.GIT, variables.GJSLINT, variables.JAVA, variables.JAR,
               variables.JSDOC, variables.PYTHON, variables.PHANTOMJS]

EXPORTS = [path
           for path in ifind('src')
           if path.endswith('.exports')]

EXTERNAL_SRC = [
    'build/src/external/externs/types.js',
    'build/src/external/src/exports.js',
    'build/src/external/src/types.js']

EXAMPLES = [path
            for path in ifind('examples')
Example #6
0
File: build.py Project: igrcic/ol3
def build_check_requires_timestamp(t):
    unused_count = 0
    all_provides = set()
    closure_lib_path = output('node', '-e',
        'process.stdout.write(require("closure-util").getLibraryPath())')
    for filename in ifind(closure_lib_path):
        if filename.endswith('.js'):
            if not re.match(r'.*/closure/goog/', filename):
                continue
            # Skip goog.i18n because it contains so many modules that it causes
            # the generated regular expression to exceed Python's limits
            if re.match(r'.*/closure/goog/i18n/', filename):
                continue
            for line in open(filename, 'rU'):
                m = re.match(r'goog.provide\(\'(.*)\'\);', line)
                if m:
                    all_provides.add(m.group(1))
    for filename in sorted(t.dependencies):
        require_linenos = {}
        uses = set()
        lines = open(filename, 'rU').readlines()
        for lineno, line in _strip_comments(lines):
            m = re.match(r'goog.provide\(\'(.*)\'\);', line)
            if m:
                all_provides.add(m.group(1))
                continue
            m = re.match(r'goog.require\(\'(.*)\'\);', line)
            if m:
                require_linenos[m.group(1)] = lineno
                continue
        ignore_linenos = require_linenos.values()
        for lineno, line in enumerate(lines):
            if lineno in ignore_linenos:
                continue
            for require in require_linenos.iterkeys():
                if require in line:
                    uses.add(require)
        for require in sorted(set(require_linenos.keys()) - uses):
            t.info('%s:%d: unused goog.require: %r' % (
                filename, require_linenos[require], require))
            unused_count += 1
    all_provides.discard('ol')
    all_provides.discard('ol.MapProperty')

    class Node(object):

        def __init__(self):
            self.present = False
            self.children = {}

        def _build_re(self, key):
            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)
                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(
                    ('\\.' if k != '*' else '') + self.children[k]._build_re(k)
                    for k in sorted(self.children.keys())) + ')'
                if self.present:
                    return key + children_re + '?'
                else:
                    return key + children_re
            else:
                assert self.present
                return key

        def build_re(self, key):
            return re.compile('\\b' + self._build_re(key) + '\\b')
    root = Node()
    for provide in all_provides:
        node = root
        for component in provide.split('.'):
            if component not in node.children:
                node.children[component] = Node()
            node = node.children[component]
        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
    for filename in sorted(t.dependencies):
        provides = set()
        requires = set()
        uses = set()
        uses_linenos = {}
        for lineno, line in _strip_comments(open(filename, 'rU')):
            m = re.match(r'goog.provide\(\'(.*)\'\);', line)
            if m:
                provides.add(m.group(1))
                continue
            m = re.match(r'goog.require\(\'(.*)\'\);', line)
            if m:
                requires.add(m.group(1))
                continue
            while True:
                for provide_re in provide_res:
                    m = provide_re.search(line)
                    if m:
                        uses.add(m.group())
                        uses_linenos[m.group()] = lineno
                        line = line[:m.start()] + line[m.end():]
                        break
                else:
                    break
        if filename == 'src/ol/renderer/layerrenderer.js':
            uses.discard('ol.renderer.Map')
        m = re.match(
            r'src/ol/renderer/(\w+)/\1(\w*)layerrenderer\.js\Z', filename)
        if m:
            uses.discard('ol.renderer.Map')
            uses.discard('ol.renderer.%s.Map' % (m.group(1),))
        missing_requires = uses - requires - provides
        if missing_requires:
            for missing_require in sorted(missing_requires):
                t.info("%s:%d missing goog.require('%s')" %
                       (filename, uses_linenos[missing_require], missing_require))
                missing_count += 1
    if unused_count or missing_count:
        t.error('%d unused goog.requires, %d missing goog.requires' %
                (unused_count, missing_count))
    t.touch()
Example #7
0
def build_check_requires_timestamp(t):
    unused_count = 0
    all_provides = set()
    closure_lib_path = output('node', '-e',
        'process.stdout.write(require("closure-util").getLibraryPath())')
    for filename in ifind(closure_lib_path):
        if filename.endswith('.js'):
            if not re.match(r'.*/closure/goog/', filename):
                continue
            # Skip goog.i18n because it contains so many modules that it causes
            # the generated regular expression to exceed Python's limits
            if re.match(r'.*/closure/goog/i18n/', filename):
                continue
            for line in open(filename, 'rU'):
                m = re.match(r'goog.provide\(\'(.*)\'\);', line)
                if m:
                    all_provides.add(m.group(1))
    for filename in sorted(t.dependencies):
        require_linenos = {}
        uses = set()
        lines = open(filename, 'rU').readlines()
        for lineno, line in _strip_comments(lines):
            m = re.match(r'goog.provide\(\'(.*)\'\);', line)
            if m:
                all_provides.add(m.group(1))
                continue
            m = re.match(r'goog.require\(\'(.*)\'\);', line)
            if m:
                require_linenos[m.group(1)] = lineno
                continue
        ignore_linenos = require_linenos.values()
        for lineno, line in enumerate(lines):
            if lineno in ignore_linenos:
                continue
            for require in require_linenos.iterkeys():
                if require in line:
                    uses.add(require)
        for require in sorted(set(require_linenos.keys()) - uses):
            t.info('%s:%d: unused goog.require: %r' % (
                filename, require_linenos[require], require))
            unused_count += 1
    all_provides.discard('ol')
    all_provides.discard('ol.MapProperty')

    class Node(object):

        def __init__(self):
            self.present = False
            self.children = {}

        def _build_re(self, key):
            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)
                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(
                    ('\\.' if k != '*' else '') + self.children[k]._build_re(k)
                    for k in sorted(self.children.keys())) + ')'
                if self.present:
                    return key + children_re + '?'
                else:
                    return key + children_re
            else:
                assert self.present
                return key

        def build_re(self, key):
            return re.compile('\\b' + self._build_re(key) + '\\b')
    root = Node()
    for provide in all_provides:
        node = root
        for component in provide.split('.'):
            if component not in node.children:
                node.children[component] = Node()
            node = node.children[component]
        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
    for filename in sorted(t.dependencies):
        provides = set()
        requires = set()
        uses = set()
        uses_linenos = {}
        for lineno, line in _strip_comments(open(filename, 'rU')):
            m = re.match(r'goog.provide\(\'(.*)\'\);', line)
            if m:
                provides.add(m.group(1))
                continue
            m = re.match(r'goog.require\(\'(.*)\'\);', line)
            if m:
                requires.add(m.group(1))
                continue
            while True:
                for provide_re in provide_res:
                    m = provide_re.search(line)
                    if m:
                        uses.add(m.group())
                        uses_linenos[m.group()] = lineno
                        line = line[:m.start()] + line[m.end():]
                        break
                else:
                    break
        if filename == 'src/ol/renderer/layerrenderer.js':
            uses.discard('ol.renderer.Map')
        m = re.match(
            r'src/ol/renderer/(\w+)/\1(\w*)layerrenderer\.js\Z', filename)
        if m:
            uses.discard('ol.renderer.Map')
            uses.discard('ol.renderer.%s.Map' % (m.group(1),))
        missing_requires = uses - requires - provides
        if missing_requires:
            for missing_require in sorted(missing_requires):
                t.info("%s:%d missing goog.require('%s')" %
                       (filename, uses_linenos[missing_require], missing_require))
                missing_count += 1
    if unused_count or missing_count:
        t.error('%d unused goog.requires, %d missing goog.requires' %
                (unused_count, missing_count))
    t.touch()
Example #8
0
File: build.py Project: geops/ol3
if sys.platform == "win32":
    pake.variables.GIT = "C:/Program Files/Git/bin/git.exe"
    pake.variables.GJSLINT = "gjslint"  # FIXME
    pake.variables.JAVA = "C:/Program Files/Java/jre7/bin/java.exe"
    pake.variables.JSDOC = "jsdoc"  # FIXME
    pake.variables.PHANTOMJS = "phantomjs"  # FIXME
    pake.variables.PYTHON = "C:/Python27/python.exe"
else:
    pake.variables.GIT = "git"
    pake.variables.GJSLINT = "gjslint"
    pake.variables.JAVA = "java"
    pake.variables.JSDOC = "jsdoc"
    pake.variables.PHANTOMJS = "phantomjs"
    pake.variables.PYTHON = "python"

pake.variables.BRANCH = pake.output("%(GIT)s", "rev-parse", "--abbrev-ref", "HEAD").strip()

EXPORTS = [path for path in pake.ifind("src") if path.endswith(".exports") if path != "src/objectliterals.exports"]

EXTERNAL_SRC = [
    "build/src/external/externs/types.js",
    "build/src/external/src/exports.js",
    "build/src/external/src/types.js",
]

EXAMPLES = [path for path in glob.glob("examples/*.html") if path != "examples/example-list.html"]

EXAMPLES_SRC = [
    path
    for path in pake.ifind("examples")
    if path.endswith(".js")