import fnmatch
import sys
import os
def locate(pattern, root=os.curdir):
'''Locate all files matching supplied filename pattern in and below
supplied root directory.'''
for path, dirs, files in os.walk(os.path.abspath(root)):
for filename in fnmatch.filter(files, pattern):
yield os.path.join(path, filename)
# MERGER
rev = 4;
excluded_files = ('Matrix3.js', )
files = list()
for js_file in locate('*.js', '../src'):
file_is_suitable = True
for excluded_file in excluded_files:
file_name = os.path.split(js_file)[1]
if file_name == excluded_file:
file_is_suitable = False
break
if file_is_suitable:
files.append(js_file)
string = '';
for item in files:
src_file = open(item, 'r');
string += src_file.read() + "\n";
dep_file = open('temp.js', 'w');
dep_file.write(string);
dep_file.close();
# YUICOMPRESSOR
os.system("java -jar yuicompressor-2.4.2.jar temp.js -o ../build/three.js --charset utf-8 -v");
# HEADER
output = '../build/three.js';
string = "// three.js r" + str(rev) + " - http://github.com/mrdoob/three.js\n";
src_file = open(output,'r');
string += src_file.read();
dep_file = open(output,'w');
dep_file.write(string);
dep_file.close();