aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/jsifier.js1
-rw-r--r--src/settings.js3
-rwxr-xr-xtests/runner.py18
3 files changed, 21 insertions, 1 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index 045328f8..5fcf6b18 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -487,6 +487,7 @@ function JSify(data, functionsOnly, givenFunctions) {
} else {
// If this is not linkable, anything not in the library is definitely missing
if (!LINKABLE && !LibraryManager.library.hasOwnProperty(shortident) && !LibraryManager.library.hasOwnProperty(shortident + '__inline')) {
+ if (ERROR_ON_UNDEFINED_SYMBOLS) error('unresolved symbol: ' + shortident);
if (VERBOSE || WARN_ON_UNDEFINED_SYMBOLS) printErr('warning: unresolved symbol: ' + shortident);
LibraryManager.library[shortident] = new Function("Module['printErr']('missing function: " + shortident + "'); abort(-1);");
}
diff --git a/src/settings.js b/src/settings.js
index c878be92..48b0347e 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -317,6 +317,9 @@ var WARN_ON_UNDEFINED_SYMBOLS = 0; // If set to 1, we will warn on any undefined
// the existing buildsystem), and (2) functions might be
// implemented later on, say in --pre-js
+var ERROR_ON_UNDEFINED_SYMBOLS = 0; // If set to 1, we will give a compile-time error on any
+ // undefined symbols (see WARN_ON_UNDEFINED_SYMBOLS).
+
var SMALL_XHR_CHUNKS = 0; // Use small chunk size for binary synchronous XHR's in Web Workers.
// Used for testing.
// See test_chunked_synchronous_xhr in runner.py and library.js.
diff --git a/tests/runner.py b/tests/runner.py
index 418133a0..008a73f0 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -10230,13 +10230,29 @@ f.close()
}
''')
+ def clear(): try_delete('a.out.js')
+
for args in [[], ['-O2']]:
- print args
+ clear()
+ print 'warn', args
output = Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'main.cpp'), '-s', 'WARN_ON_UNDEFINED_SYMBOLS=1'] + args, stderr=PIPE).communicate()
self.assertContained('unresolved symbol: something', output[1])
+ clear()
+ output = Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'main.cpp')] + args, stderr=PIPE).communicate()
+ self.assertNotContained('unresolved symbol: something\n', output[1])
+
+ for args in [[], ['-O2']]:
+ clear()
+ print 'error', args
+ output = Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'main.cpp'), '-s', 'ERROR_ON_UNDEFINED_SYMBOLS=1'] + args, stderr=PIPE).communicate()
+ self.assertContained('unresolved symbol: something', output[1])
+ assert not os.path.exists('a.out.js')
+
+ clear()
output = Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'main.cpp')] + args, stderr=PIPE).communicate()
self.assertNotContained('unresolved symbol: something\n', output[1])
+ assert os.path.exists('a.out.js')
def test_toobig(self):
open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write(r'''