Explorar o código

[cpp] Add the cpp static link code to the haxe ditro. Use static linking and no threads for emscripten

hughsando %!s(int64=10) %!d(string=hai) anos
pai
achega
2743ba1c3d

+ 17 - 0
std/cpp/link/StaticMysql.hx

@@ -0,0 +1,17 @@
+package cpp.link;
+
+@:cppFileCode( 'extern "C" int mysql_register_prims();')
+@:buildXml("
+<target id='haxe'>
+  <lib name='${HXCPP}/lib/${BINDIR}/libmysql5${LIBEXTRA}${LIBEXT}'/>
+  <lib name='ws2_32.lib' if='windows'/>
+</target>
+")
+@:keep class StaticMysql
+{
+   static function __init__()
+   {
+     untyped __cpp__("mysql_register_prims();");
+   }
+}
+

+ 16 - 0
std/cpp/link/StaticRegexp.hx

@@ -0,0 +1,16 @@
+package cpp.link;
+
+@:cppFileCode( 'extern "C" int regexp_register_prims();')
+@:buildXml("
+<target id='haxe'>
+  <lib name='${HXCPP}/lib/${BINDIR}/libregexp${LIBEXTRA}${LIBEXT}'/>
+</target>
+")
+@:keep class StaticRegexp
+{
+   static function __init__()
+   {
+     untyped __cpp__("regexp_register_prims();");
+   }
+}
+

+ 17 - 0
std/cpp/link/StaticSqlite.hx

@@ -0,0 +1,17 @@
+package cpp.link;
+
+@:cppFileCode( 'extern "C" int sqlite_register_prims();')
+@:buildXml("
+<target id='haxe'>
+  <lib name='${HXCPP}/lib/${BINDIR}/libsqlite${LIBEXTRA}${LIBEXT}'/>
+  <lib name='-lpthread' if='linux'/>
+</target>
+")
+@:keep class StaticSqlite
+{
+   static function __init__()
+   {
+     untyped __cpp__("sqlite_register_prims();");
+   }
+}
+

+ 17 - 0
std/cpp/link/StaticStd.hx

@@ -0,0 +1,17 @@
+package cpp.link;
+
+@:cppFileCode( 'extern "C" int std_register_prims();')
+@:buildXml("
+<target id='haxe'>
+  <lib name='${HXCPP}/lib/${BINDIR}/libstd${LIBEXTRA}${LIBEXT}'/>
+   <lib name='ws2_32.lib' if='windows'/>
+</target>
+")
+@:keep class StaticStd
+{
+   static function __init__()
+   {
+     untyped __cpp__("std_register_prims();");
+   }
+}
+

+ 16 - 0
std/cpp/link/StaticZlib.hx

@@ -0,0 +1,16 @@
+package cpp.link;
+
+@:cppFileCode( 'extern "C" int zlib_register_prims();')
+@:buildXml("
+<target id='haxe'>
+  <lib name='${HXCPP}/lib/${BINDIR}/libzlib${LIBEXTRA}${LIBEXT}'/>
+</target>
+")
+@:keep class StaticZlib
+{
+   static function __init__()
+   {
+     untyped __cpp__("zlib_register_prims();");
+   }
+}
+

+ 7 - 0
tests/unit/src/unit/Test.hx

@@ -1,5 +1,12 @@
 package unit;
 
+#if (!macro && emscripten)
+import cpp.link.StaticStd;
+import cpp.link.StaticRegexp;
+import cpp.link.StaticSqlite;
+import cpp.link.StaticZlib;
+#end
+
 @:expose("unit.Test")
 @:keepSub
 #if as3

+ 1 - 1
tests/unit/src/unit/issues/Issue3767.hx

@@ -10,7 +10,7 @@ import cpp.vm.*;
 
 class Issue3767 extends Test
 {
-#if (java || (neko && !interp && !macro) || cpp)
+#if (java || (neko && !interp && !macro) || (cpp && !emscripten))
 	function testBasicLock()
 	{
 		var lock = new Lock();