Преглед на файлове

build.py: strip comments from glsl files.

Mr.doob преди 9 години
родител
ревизия
c9ebd1cc8c
променени са 1 файла, в които са добавени 3 реда и са изтрити 2 реда
  1. 3 2
      utils/build/build.py

+ 3 - 2
utils/build/build.py

@@ -10,6 +10,7 @@ if sys.version_info < (2, 7):
 import argparse
 import json
 import os
+import re
 import shutil
 import tempfile
 
@@ -45,7 +46,7 @@ def main(argv=None):
 	fd, path = tempfile.mkstemp()
 	tmp = open(path, 'w', encoding='utf-8')
 	sources = []
-		
+
 	if args.amd:
 		tmp.write(u'( function ( root, factory ) {\n\n\tif ( typeof define === \'function\' && define.amd ) {\n\n\t\tdefine( [ \'exports\' ], factory );\n\n\t} else if ( typeof exports === \'object\' ) {\n\n\t\tfactory( exports );\n\n\t} else {\n\n\t\tfactory( root );\n\n\t}\n\n}( this, function ( exports ) {\n\n')
 
@@ -60,7 +61,7 @@ def main(argv=None):
 			with open(filename, 'r', encoding='utf-8') as f:
 				if filename.endswith(".glsl"):
 					tmp.write(u'THREE.ShaderChunk[ \'' + os.path.splitext(os.path.basename(filename))[0] + u'\'] = "')
-					tmp.write(f.read().replace('\n','\\n'))
+					tmp.write(re.sub(r"\t*//.*\n", "", f.read()).replace('\n','\\n'))
 					tmp.write(u'";\n\n')
 				else:
 					tmp.write(f.read())