aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/jsifier.js2
-rw-r--r--system/include/libc/sys/dirent.h16
-rwxr-xr-xtests/runner.py18
-rw-r--r--tools/shared.py2
4 files changed, 35 insertions, 3 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index 156fd65d..faef88d5 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -328,7 +328,7 @@ function JSify(data, functionsOnly, givenFunctions) {
var js = (index !== null ? '' : item.ident + '=') + constant;
if (js) js += ';';
- if (!ASM_JS && (EXPORT_ALL || (item.ident in EXPORTED_GLOBALS))) {
+ if (!ASM_JS && NAMED_GLOBALS && (EXPORT_ALL || (item.ident in EXPORTED_GLOBALS))) {
js += '\nModule["' + item.ident + '"] = ' + item.ident + ';';
}
if (BUILD_AS_SHARED_LIB == 2 && !item.private_) {
diff --git a/system/include/libc/sys/dirent.h b/system/include/libc/sys/dirent.h
index 9dcf34d1..0d8b02b5 100644
--- a/system/include/libc/sys/dirent.h
+++ b/system/include/libc/sys/dirent.h
@@ -34,8 +34,22 @@ int scandir(const char *dirp,
enum {
DT_UNKNOWN = 0,
#define DT_UNKNOWN DT_UNKNOWN
- DT_DIR = 4
+ DT_FIFO = 1,
+#define DT_FIFO DT_FIFO
+ DT_CHR = 2,
+#define DT_CHR DT_CHR
+ DT_DIR = 4,
#define DT_DIR DT_DIR
+ DT_BLK = 6,
+#define DT_BLK DT_BLK
+ DT_REG = 8,
+#define DT_REG DT_REG
+ DT_LNK = 10,
+#define DT_LNK DT_LNK
+ DT_SOCK = 12,
+#define DT_SOCK DT_SOCK
+ DT_WHT = 14
+#define DT_WHT DT_WHT
};
#ifdef __cplusplus
diff --git a/tests/runner.py b/tests/runner.py
index 5e101024..73dbab13 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -10496,6 +10496,24 @@ f.close()
self.assertContained('result: 1', run_js(os.path.join(self.get_dir(), 'a.out.js')))
+ def test_export_all(self):
+ lib = r'''
+ #include <stdio.h>
+ void libf1() { printf("libf1\n"); }
+ void libf2() { printf("libf2\n"); }
+ '''
+ lib_name = os.path.join(self.get_dir(), 'lib.c')
+ open(lib_name, 'w').write(lib)
+
+ open('main.js', 'w').write('''
+ _libf1();
+ _libf2();
+ ''')
+
+ Building.emcc(lib_name, ['-s', 'EXPORT_ALL=1', '--post-js', 'main.js'], output_filename='a.out.js')
+
+ self.assertContained('libf1\nlibf2\n', run_js(os.path.join(self.get_dir(), 'a.out.js')))
+
def test_abspaths(self):
# Includes with absolute paths are generally dangerous, things like -I/usr/.. will get to system local headers, not our portable ones.
diff --git a/tools/shared.py b/tools/shared.py
index 8a172d9c..0d1cfffd 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -1091,7 +1091,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e
@staticmethod
def can_build_standalone():
- return not Settings.BUILD_AS_SHARED_LIB and not Settings.LINKABLE
+ return not Settings.BUILD_AS_SHARED_LIB and not Settings.LINKABLE and not Settings.EXPORT_ALL
@staticmethod
def can_use_unsafe_opts():