Commits

ariovistus committed 1be1f48

multiple modules can now be loaded without it dying horribly
(I think it's still buggy though)

Comments (0)

Files changed (6)

examples/hello/hello.d

-// A minimal "hello world" Pyd module.
-module hello;
-
-import pyd.pyd;
-import std.stdio;
-
-void hello() {
-    writefln("Hello, world!");
-}
-
-extern(C) void PydMain() {
-    def!(hello);
-    module_init();
-}
+// A minimal "hello world" Pyd module.
+module hello;
+
+import pyd.pyd;
+import std.stdio;
+
+void hello() {
+    writefln("Hello, world!");
+}
+
+extern(C) void PydMain() {
+    def!(hello);
+    module_init();
+}

examples/hello/hello2.d

+// A minimal "hello world" Pyd module.
+module hello2;
+
+import pyd.pyd;
+import std.stdio;
+
+void hello() {
+    writefln("Hello, burrito!");
+}
+
+extern(C) void PydMain() {
+    def!(hello);
+    module_init();
+}

examples/hello/makefile

 	echo 'import sys; sys.path.append("../../build/lib/");' > tsetup.py
 	cat setup.py >> tsetup.py
 	python tsetup.py build
+	echo 'import sys; sys.path.append("../../build/lib/");' > tsetup.py
+	cat setup2.py >> tsetup.py
+	python tsetup.py build
 
 clean:
 	rm -rf build

examples/hello/setup2.py

+from celerid.support import setup, Extension
+
+projName = 'hello2'
+
+setup(
+    name=projName,
+    version='0.1',
+    ext_modules=[
+        Extension(projName, ['hello2.d'])
+    ],
+)

examples/hello/test.py

 sys.path.append(os.path.abspath(libDir))
 print sys.path
 import hello
+import hello2
 
 
 try:
     hello.hello()
+    hello2.hello()
 except Exception, e:
     print e
     print e.__dict__

infrastructure/d/python_so_linux_boilerplate.d

 // Also note that this is inferior to the Windows version: it does not call the
 // static constructors or unit tests. As far as I can tell, this can't be done
 // until Phobos is updated to explicitly allow it.
+extern(C) shared bool _D2rt6dmain212_d_isHaltingOb;
+alias _D2rt6dmain212_d_isHaltingOb _d_isHalting;
 extern(C) {
 
-void rt_init();
-void rt_term();
+    void rt_init();
+    void rt_term();
 
-void _init() {
-    rt_init();
-}
+    void _init() {
+        rt_init();
+    }
 
-void _fini() {
-    rt_term();
-}
+    void _fini() {
+        if(!_d_isHalting){
+            rt_term();
+        }
+    }
 
 } /* extern(C) */