Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 5a4992553b
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 86 lines (63 sloc) 2.351 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85

import sys
import os
import subprocess
import jslibs

def _concat_path(fname, *rnames):
    return os.path.join(os.path.dirname(fname), *rnames)

def module_path(mod, *rnames):
    return _concat_path(mod.__file__, *rnames)


def update_submodule(dir):
    # update submodules in this tree.
    current_dir = os.getcwd()
    os.chdir(dir)
    try:
        subprocess.call(('git', 'submodule', 'init'))
        subprocess.call(('git', 'submodule', 'update'))
    finally:
        os.chdir(current_dir)


def prep_jquery(dir):
    # from jQuery Makefile:
    #@@sed '/EXPOSE/r src/sizzle-jquery.js' ${SIZZLE_DIR}/sizzle.js | grep -v window.Sizzle > ${SRC_DIR}/selector.js
    outf = file(os.path.join(dir, 'src', 'selector.js'), 'w')
    for line in file(os.path.join(dir, 'src', 'sizzle', 'sizzle.js')):
        if 'EXPOSE' in line:
            outf.write(file(os.path.join(dir, 'src', 'sizzle-jquery.js')).read())
        elif 'window.Sizzle' not in line:
            outf.write(line)
    outf.close()


def prep_tinymce(dir):
    # run 'ant' in the source directory
    current_dir = os.getcwd()
    os.chdir(dir)
    try:
        subprocess.call(('ant', ))
    finally:
        os.chdir(current_dir)


def prepare_sources():
    # Need to update the submodules.
    # It also prepares the sources for jQuery.
    # (Other sources do not need this.)
    jslibs_gitroot = module_path(jslibs, '..')
    externals_dir = module_path(jslibs, 'externals')

    update_submodule(jslibs_gitroot)

    # jQuery 1.6.2
    # it has its own submodules that requires an update
    update_submodule(os.path.join(externals_dir, 'jquery', '1.6.2'))
    # it also requires some special preparation
    prep_jquery(os.path.join(externals_dir, 'jquery', '1.6.2'))

    # TinyMCE 3.4.7
    # needs its main js precompiled
    prep_tinymce(os.path.join(externals_dir, 'tinymce', '3.4.7'))

    # TinyMCE 3.4.8
    # needs its main js precompiled
    prep_tinymce(os.path.join(externals_dir, 'tinymce', '3.4.8'))

    # TinyMCE 3.5b3
    # needs its main js precompiled
    prep_tinymce(os.path.join(externals_dir, 'tinymce', '3.5b3'))



def main(argv=sys.argv):
    if len(argv) > 1:
        raise RuntimeError, 'jslibs_prepare_sources accepts no parameters.'

    prepare_sources()

    print "\n\n##### All sources prepared OK"

if __name__ == '__main__':
    main()
Something went wrong with that request. Please try again.