aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-06-12 10:44:11 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-06-12 10:44:11 -0700
commit4bb5c641d3eedfc1d2e922cdd7eacee7cc03d317 (patch)
tree15977ab7a2ef072e804e330d00683d1b94225472
parentfeef3ca3c5bc76d2bad1a739966a2143876847cf (diff)
handle duplicate files in file packager
-rwxr-xr-xtests/runner.py4
-rw-r--r--tools/file_packager.py8
2 files changed, 12 insertions, 0 deletions
diff --git a/tests/runner.py b/tests/runner.py
index c8e3de37..e847f727 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -6837,6 +6837,10 @@ f.close()
Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp'), '--embed-file', 'somefile.txt']).communicate()
self.assertContained('|hello from a file wi|', run_js(os.path.join(self.get_dir(), 'a.out.js')))
+ # preload twice, should not err
+ Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp'), '--embed-file', 'somefile.txt', '--embed-file', 'somefile.txt']).communicate()
+ self.assertContained('|hello from a file wi|', run_js(os.path.join(self.get_dir(), 'a.out.js')))
+
def test_multidynamic_link(self):
# Linking the same dynamic library in will error, normally, since we statically link it, causing dupe symbols
# A workaround is to use --ignore-dynamic-linking, see emcc --help for details
diff --git a/tools/file_packager.py b/tools/file_packager.py
index 9e98320a..4f24af28 100644
--- a/tools/file_packager.py
+++ b/tools/file_packager.py
@@ -101,6 +101,14 @@ for file_ in data_files:
file_['name'] = file_['name'].replace(os.path.sep, '/')
file_['net_name'] = file_['name']
+# remove duplicates (can occur naively, for example preload dir/, preload dir/subdir/)
+seen = {}
+def was_seen(name):
+ if seen.get(name): return True
+ seen[name] = 1
+ return False
+data_files = filter(lambda file_: not was_seen(file_['name']), data_files)
+
data_target = sys.argv[1]
# Set up folders