aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorÉloi Rivard <azmeuk@gmail.com>2013-04-14 20:13:26 +0200
committerÉloi Rivard <azmeuk@gmail.com>2013-04-15 13:38:45 +0200
commitfa7a4cc43366577220336e191c068e6300c00f14 (patch)
tree9224c86cf6c6ffb2692548c23d70bd3fad4e2538 /tools
parent06876b9f0ef559553afb708462042fbade0a33c4 (diff)
* Added --no-force argument.
Diffstat (limited to 'tools')
-rw-r--r--tools/file_packager.py30
1 files changed, 20 insertions, 10 deletions
diff --git a/tools/file_packager.py b/tools/file_packager.py
index 8a7cca85..f1f1d5e3 100644
--- a/tools/file_packager.py
+++ b/tools/file_packager.py
@@ -11,7 +11,7 @@ data downloads.
Usage:
- file_packager.py TARGET [--preload A [B..]] [--embed C [D..]] [--compress COMPRESSION_DATA] [--pre-run] [--crunch[=X]] [--js-output=OUTPUT.js]
+ file_packager.py TARGET [--preload A [B..]] [--embed C [D..]] [--compress COMPRESSION_DATA] [--pre-run] [--crunch[=X]] [--js-output=OUTPUT.js] [--no-force]
--pre-run Will generate wrapper code that does preloading in Module.preRun. This is necessary if you add this
code before the main file has been loading, which includes necessary components like addRunDependency.
@@ -24,6 +24,10 @@ Usage:
DDS files will not be crunched if the .crn is more recent than the .dds. This prevents a lot of
unneeded computation.
+ --js-output=FILE Writes output in FILE, if not specified, standard output is used.
+
+ --no-force Don't create output if no valid input file is specified.
+
Notes:
* The file packager generates unix-style file paths. So if you are on windows and a file is accessed at
@@ -40,7 +44,7 @@ from shared import Compression, execute, suffix, unsuffixed
from subprocess import Popen, PIPE, STDOUT
if len(sys.argv) == 1:
- print '''Usage: file_packager.py TARGET [--preload A...] [--embed C...] [--compress COMPRESSION_DATA] [--pre-run] [--crunch[=X]] [--js-output=OUTPUT.js]
+ print '''Usage: file_packager.py TARGET [--preload A...] [--embed B...] [--compress COMPRESSION_DATA] [--pre-run] [--crunch[=X]] [--js-output=OUTPUT.js] [--no-force]
See the source for more details.'''
sys.exit(0)
@@ -65,6 +69,7 @@ pre_run = False
crunch = 0
plugins = []
jsoutput = None
+force = True
for arg in sys.argv[1:]:
if arg == '--preload':
@@ -86,6 +91,8 @@ for arg in sys.argv[1:]:
in_preload = False
in_embed = False
in_compress = 0
+ elif arg == '--no-force':
+ force = False
elif arg.startswith('--js-output'):
jsoutput = arg.split('=')[1] if '=' in arg else None
elif arg.startswith('--crunch'):
@@ -101,10 +108,10 @@ for arg in sys.argv[1:]:
in_embed = False
in_compress = 0
elif in_preload:
- if os.path.isfile(arg):
+ if os.path.isfile(arg) or os.path.isdir(arg):
data_files.append({ 'name': arg, 'mode': 'preload' })
elif in_embed:
- if os.path.isfile(arg):
+ if os.path.isfile(arg) or os.path.isdir(arg):
data_files.append({ 'name': arg, 'mode': 'embed' })
elif in_compress:
if in_compress == 1:
@@ -117,6 +124,9 @@ for arg in sys.argv[1:]:
Compression.js_name = arg
in_compress = 0
+if (not force) and len(data_files) == 0:
+ has_preloaded = False
+
ret = '''
(function() {
'''
@@ -417,9 +427,9 @@ if crunch:
ret += '''
})();
'''
-
-if jsoutput == None:
- print ret
-else:
- f = open(jsoutput, 'w')
- f.write(ret)
+if force or len(data_files) > 0:
+ if jsoutput == None:
+ print ret
+ else:
+ f = open(jsoutput, 'w')
+ f.write(ret)