diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/file_packager.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/tools/file_packager.py b/tools/file_packager.py index 7797e58c..2a39f2b1 100644 --- a/tools/file_packager.py +++ b/tools/file_packager.py @@ -25,7 +25,7 @@ TODO: You can also provide .crn files yourself, pre-crunched. With this o to dds files in the browser, exactly the same as if this tool compressed them. ''' -import os, sys, shutil +import os, sys, shutil, random from shared import Compression, execute, suffix, unsuffixed import shared @@ -97,6 +97,10 @@ for arg in sys.argv[1:]: Compression.js_name = arg in_compress = 0 +print ''' +(function() { +''' + code = ''' function assert(check, msg) { if (!check) throw msg + new Error().stack; @@ -127,6 +131,9 @@ def was_seen(name): return False data_files = filter(lambda file_: not was_seen(file_['name']), data_files) +# Randomize order, to get around silly fake antivirus positivies +random.shuffle(data_files) + # Apply plugins for file_ in data_files: for plugin in plugins: @@ -199,7 +206,7 @@ for file_ in data_files: for i in range(len(parts)): partial = '/'.join(parts[:i+1]) if partial not in partial_dirs: - code += '''Module['FS_createFolder']('/%s', '%s', true, true);\n''' % ('/'.join(parts[:i]), parts[i]) + code += '''Module['FS_createPath']('/%s', '%s', true, true);\n''' % ('/'.join(parts[:i]), parts[i]) partial_dirs.append(partial) if has_preloaded: @@ -296,7 +303,7 @@ if has_preloaded: curr.response = byteArray.subarray(%d,%d); curr.onload(); ''' % (file_['name'], file_['data_start'], file_['data_end']) - use_data += " Module['removeRunDependency']('datafile');\n" + use_data += " Module['removeRunDependency']('datafile_%s');\n" % data_target if Compression.on: use_data = ''' @@ -324,10 +331,10 @@ if has_preloaded: var curr; %s }; - Module['addRunDependency']('datafile'); + Module['addRunDependency']('datafile_%s'); dataFile.send(null); if (Module['setStatus']) Module['setStatus']('Downloading...'); - ''' % (os.path.basename(Compression.compressed_name(data_target) if Compression.on else data_target), use_data) # use basename because from the browser's point of view, we need to find the datafile in the same dir as the html file + ''' % (os.path.basename(Compression.compressed_name(data_target) if Compression.on else data_target), use_data, data_target) # use basename because from the browser's point of view, we need to find the datafile in the same dir as the html file if pre_run: print ''' @@ -349,3 +356,7 @@ if crunch: }); ''' +print ''' +})(); +''' + |