diff --git a/tools/build/build.py b/tools/build/build.py index a2387102..9b5eae99 100755 --- a/tools/build/build.py +++ b/tools/build/build.py @@ -9,7 +9,7 @@ import re import shutil import subprocess import sys - +import time def build_oxjs(geo): @@ -17,14 +17,18 @@ def build_oxjs(geo): if base_path: os.chdir(base_path) - source_path = '../../source/' - build_path = '../../build/' - dev_path = '../../dev/' + root_path = '../../' + source_path = root_path + 'source/' + build_path = root_path + 'build/' + dev_path = root_path + 'dev/' + version = '0.1.%s' % subprocess.Popen( ['bzr', 'revno'], stdout=subprocess.PIPE ).communicate()[0].strip() - comment = 'OxJS %s (c) 2012 0x2620, dual-licensed GPL/MIT, see http://oxjs.org for details' % version + year = time.strftime('%Y', time.gmtime()) + comment = 'OxJS %s (c) %s 0x2620, dual-licensed GPL/MIT, see https://oxjs.org for details' % (version, year) + # SVGs path = source_path + 'Ox.UI/themes/classic/svg/' for filename in os.listdir(path): @@ -89,11 +93,11 @@ def build_oxjs(geo): ] js = '' js_dir = 'Ox/js/' - data = [[], [], []] + ox_files = [[], [], []] for filename in filenames[0]: - data[0].append(js_dir + filename) + ox_files[0].append(js_dir + filename) for filename in filenames[1]: - data[1].append(js_dir + filename) + ox_files[1].append(js_dir + filename) filenames = filenames[0] + filenames[1] for filename in os.listdir(source_path + js_dir): if not filename in filenames \ @@ -102,11 +106,11 @@ def build_oxjs(geo): filenames.append(filename) for filename in filenames: js += read_file(source_path + js_dir + filename) + '\n' - if not js_dir + filename in data[0] + data[1]: - data[2].append(js_dir + filename) - js = js.replace("Ox.VERSION = '0.1.2';", "Ox.VERSION = '%s';" % version) + if not js_dir + filename in ox_files[0] + ox_files[1]: + ox_files[2].append(js_dir + filename) + js = re.sub("Ox.VERSION = '([\d\.]+)'", "Ox.VERSION = '%s'" % version, js) write_file(build_path + 'Ox.js', ox.js.minify(js, comment)) - write_file(dev_path + '/Ox/json/' + 'Ox.json', json.dumps(data, indent=4)) + write_file(dev_path + '/Ox/json/' + 'Ox.json', json.dumps(ox_files, indent=4)) # Ox.UI js = '' @@ -136,6 +140,30 @@ def build_oxjs(geo): files = json.dumps(sorted(ui_files['dev']), indent=4) write_file(dev_path + 'Ox.UI/json/Ox.UI.files.json', files) + # index + data = { + # sum(list, []) is flatten + 'documentation': sorted(sum(ox_files, [])) + sorted(filter( + lambda x: re.match('.+\.js$', x), + ui_files['dev'] + ) + map( + lambda x: 'Ox.%s/Ox.%s.js' % (x, x), + ['Geo', 'Image', 'Unicode'] + )), + 'examples': filter( + lambda x: not re.match('^\.', x), + os.listdir(root_path + 'examples/') + ), + 'readme': map( + lambda x: x.split('.')[0], + filter( + lambda x: not re.match('^[\._]', x), + os.listdir(root_path + 'readme/html') + ) + ) + } + write_file(root_path + 'index.json', json.dumps(data, indent=4, sort_keys=True)) + def copy_file(source, target): print 'copying', source, 'to', target