aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2019-06-19 21:56:00 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2019-08-05 19:31:32 +0300
commitf41bdae36861baa8be541af8273adc5b4b94ec48 (patch)
tree9334ac78c12e5505592dcff7f6f5c32c999ee4fb /mesonbuild/compilers
parentddbf60f86da4ece3d407fe3b3e38ff45e34f561e (diff)
downloadmeson-f41bdae36861baa8be541af8273adc5b4b94ec48.zip
meson-f41bdae36861baa8be541af8273adc5b4b94ec48.tar.gz
meson-f41bdae36861baa8be541af8273adc5b4b94ec48.tar.bz2
Add basic Webassembly support via Emscripten.
Diffstat (limited to 'mesonbuild/compilers')
-rw-r--r--mesonbuild/compilers/__init__.py2
-rw-r--r--mesonbuild/compilers/c.py25
-rw-r--r--mesonbuild/compilers/compilers.py1
-rw-r--r--mesonbuild/compilers/cpp.py35
4 files changed, 62 insertions, 1 deletions
diff --git a/mesonbuild/compilers/__init__.py b/mesonbuild/compilers/__init__.py
index 6d9e814..5cd56b8 100644
--- a/mesonbuild/compilers/__init__.py
+++ b/mesonbuild/compilers/__init__.py
@@ -126,6 +126,7 @@ from .c import (
ClangClCCompiler,
GnuCCompiler,
ElbrusCCompiler,
+ EmscriptenCCompiler,
IntelCCompiler,
IntelClCCompiler,
PGICCompiler,
@@ -140,6 +141,7 @@ from .cpp import (
ClangClCPPCompiler,
GnuCPPCompiler,
ElbrusCPPCompiler,
+ EmscriptenCPPCompiler,
IntelCPPCompiler,
IntelClCPPCompiler,
PGICPPCompiler,
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py
index eff7161..f50b77c 100644
--- a/mesonbuild/compilers/c.py
+++ b/mesonbuild/compilers/c.py
@@ -119,6 +119,31 @@ class ClangCCompiler(ClangCompiler, CCompiler):
return basic
+class EmscriptenCCompiler(ClangCCompiler):
+ def __init__(self, exelist, version, compiler_type, for_machine: MachineChoice, is_cross, exe_wrapper=None, **kwargs):
+ if not is_cross:
+ raise MesonException('Emscripten compiler can only be used for cross compilation.')
+ ClangCCompiler.__init__(self, exelist, version, compiler_type, for_machine, is_cross, exe_wrapper, **kwargs)
+ self.id = 'emscripten'
+
+ def get_option_link_args(self, options):
+ return []
+
+ def get_linker_always_args(self):
+ return []
+
+ def get_asneeded_args(self):
+ return []
+
+ def get_lundef_args(self):
+ return []
+
+ def build_rpath_args(self, *args, **kwargs):
+ return []
+
+ def get_soname_args(self, *args, **kwargs):
+ raise MesonException('Emscripten does not support shared libraries.')
+
class ArmclangCCompiler(ArmclangCompiler, CCompiler):
def __init__(self, exelist, version, compiler_type, for_machine: MachineChoice, is_cross, exe_wrapper=None, **kwargs):
CCompiler.__init__(self, exelist, version, for_machine, is_cross, exe_wrapper, **kwargs)
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index 179756a..5249068 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -1204,6 +1204,7 @@ class CompilerType(enum.Enum):
CLANG_STANDARD = 10
CLANG_OSX = 11
CLANG_MINGW = 12
+ CLANG_EMSCRIPTEN = 13
# Possibly clang-cl?
ICC_STANDARD = 20
diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py
index 6ae2673..5808b2e 100644
--- a/mesonbuild/compilers/cpp.py
+++ b/mesonbuild/compilers/cpp.py
@@ -131,7 +131,7 @@ class CPPCompiler(CLikeCompiler, Compiler):
}
# Currently, remapping is only supported for Clang, Elbrus and GCC
- assert(self.id in frozenset(['clang', 'lcc', 'gcc']))
+ assert(self.id in frozenset(['clang', 'lcc', 'gcc', 'emscripten']))
if cpp_std not in CPP_FALLBACKS:
# 'c++03' and 'c++98' don't have fallback types
@@ -183,6 +183,39 @@ class ClangCPPCompiler(ClangCompiler, CPPCompiler):
return ['-lstdc++']
+class EmscriptenCPPCompiler(ClangCPPCompiler):
+ def __init__(self, exelist, version, compiler_type, for_machine: MachineChoice, is_cross, exe_wrapper=None, **kwargs):
+ if not is_cross:
+ raise MesonException('Emscripten compiler can only be used for cross compilation.')
+ ClangCPPCompiler.__init__(self, exelist, version, compiler_type, for_machine, is_cross, exe_wrapper, **kwargs)
+ self.id = 'emscripten'
+
+ def get_option_compile_args(self, options):
+ args = []
+ std = options['cpp_std']
+ if std.value != 'none':
+ args.append(self._find_best_cpp_std(std.value))
+ return args
+
+ def get_option_link_args(self, options):
+ return []
+
+ def get_linker_always_args(self):
+ return []
+
+ def get_asneeded_args(self):
+ return []
+
+ def get_lundef_args(self):
+ return []
+
+ def build_rpath_args(self, *args, **kwargs):
+ return []
+
+ def get_soname_args(self, *args, **kwargs):
+ raise MesonException('Emscripten does not support shared libraries.')
+
+
class ArmclangCPPCompiler(ArmclangCompiler, CPPCompiler):
def __init__(self, exelist, version, compiler_type, for_machine: MachineChoice, is_cross, exe_wrapper=None, **kwargs):
CPPCompiler.__init__(self, exelist, version, for_machine, is_cross, exe_wrapper, **kwargs)