made a mistake in dmd.diff

"Lars Ivar Igesund" <[email protected]>
Newsgroups gmane.comp.tools.aap.devel
Message-ID <045401c3949e$422e9ac0$0200000a@mesmer>
just a minor mistake, should be fixed
replace the other with this one

Lars Ivar Igesund
dmd.diff (application/octet-stream, 4.9 KB)
Index: dmd.py
===================================================================
RCS file: /cvsroot/a-a-p/Exec/tools/dmd.py,v
retrieving revision 1.4
diff -u -r1.4 dmd.py
--- dmd.py	8 Oct 2003 07:26:55 -0000	1.4
+++ dmd.py	17 Oct 2003 09:57:26 -0000
@@ -27,6 +27,7 @@
     Define the actions that DMD can accomplish.
     """
     rd = Global.globals
+    # Compile one sourcefile at the time
     rpstack = [ RecPos("compile_dmd d action") ]
     action_add(rpstack, rd, str2dictlist(rpstack, "compile_dmd object,dllobject,libobject d"),
             "opt =\n"
@@ -37,10 +38,56 @@
             "@if _no.DEBUG == 'yes':\n"
             "  dbg = -g\n"
             ":sys $DMD $?DFLAGS $?DVERSION $opt $dbg $?DDEBUG $?DIMPORT -of$target -c $source")
+    # Build a program/static lib from object files
     rpstack = [ RecPos("build_dmd action") ]
     action_add(rpstack, rd, str2dictlist(rpstack, "build_dmd object,dllobject,libobject"),
             ":sys $DMD $?DLINKFLAGS -of$target $source")
-    
+    # Build a dll from object files  
+    rpstack = [ RecPos("builddll_dmd action") ]
+    action_add(rpstack, rd, str2dictlist(rpstack, "builddll_dmd dllobject"),
+            "@exec \"import tools.dmd\"\n"
+            "@if not tools.dmd.find_dll_main_object(source):\n"
+            "   @f = file(\"aap_dllmain.d\", 'w')\n"
+            "   @f.write(tools.dmd.dll_main_source())\n"
+            "   @f.close()\n"
+            "   :do compile {target = aap_dllmain.obj} aap_dllmain.d\n"
+            "   source += aap_dllmain.obj\n"
+            ":sys $DMD $?DLINKFLAGS -of$target $source\n"
+            ":del {f} {q} aap_dllmain.*")
+    # Build a program/static lib directly from source
+    rpstack = [ RecPos("buildonestep_dmd d action") ]
+    action_add(rpstack, rd, str2dictlist(rpstack, "buildonestep_dmd d"),
+            "opt =\n"
+            "@if _no.OPTIMIZE and int(_no.OPTIMIZE) > 0:\n"
+            "  opt = -O\n"
+            "dbg =\n"
+            "DEBUG ?=\n"
+            "@if _no.DEBUG == 'yes':\n"
+            "  dbg = -g\n"
+            ":sys $DMD $?DFLAGS $?DVERSION $opt $dbg $?DDEBUG $?DIMPORT"
+            "       $?DLINKFLAGS -of$target $source\n"
+            ":del {f} {q} *.obj")
+    # Build a dll directly from source
+    rpstack = [ RecPos("builddllonestep_dmd d action") ]
+    action_add(rpstack, rd, str2dictlist(rpstack, "builddllonestep_dmd d"),
+            "opt =\n"
+            "@if _no.OPTIMIZE and int(_no.OPTIMIZE) > 0:\n"
+            "  opt = -O\n"
+            "dbg =\n"
+            "DEBUG ?=\n"
+            "@if _no.DEBUG == 'yes':\n"
+            "  dbg = -g\n"
+            "@exec \"import tools.dmd\"\n"
+            "@if not tools.dmd.find_dll_main_source(source):\n"
+            "   @f = file(\"aap_dllmain.d\", 'w')\n"
+            "   @f.write(tools.dmd.dll_main_source())\n"
+            "   @f.close()\n"
+            "   source += aap_dllmain.d\n"
+            ":sys $DMD $?DFLAGS $?DVERSION $opt $dbg $?DDEBUG $?DIMPORT"
+            "       $?DLINKFLAGS -of$target $source\n"
+            ":del {f} {q} aap_dllmain.d\n"
+            ":del {q} *.obj")
+        
     if not rd["_top"].get("DMD"):
         rd["_top"]["DMD"] = "dmd"
 
@@ -51,5 +98,70 @@
     """
     scope["D_COMPILE_ACTION"] = "compile_dmd"
     scope["D_BUILD_ACTION"] = "build_dmd"
+    scope["D_BUILDLIB_ACTION"] = "build_dmd"
+    scope["D_BUILDDLL_ACTION"] = "builddll_dmd"
+    scope["D_BUILDONESTEP_ACTION"] = "buildonestep_dmd"
+    scope["D_BUILDDLLONESTEP_ACTION"] = "builddllonestep_dmd"
+    scope["D_BUILDLIBONESTEP_ACTION"] = "buildonestep_dmd"
+
+def find_dll_main_source(sourcestr):
+    import re
+    m = re.compile(r"BOOL\s+DllMain\s*\(\s*HINSTANCE")
+    for si in var2list(sourcestr):
+        f = file2string(si)
+        if m.search(f):
+            return 1
+
+    return None 
+
+def find_dll_main_object(sourcestr):
+    for si in var2list(sourcestr):
+        f = file2string(si)
+        from string import find
+        if find(f, "_DllMain@12") > -1:
+            return 1
+
+    return None 
+
+def dll_main_source():
+    source = """
+        import windows;
+
+        HINSTANCE g_hInst;
+
+        extern (C)
+        {
+            void gc_init();
+            void gc_term();
+            void _minit();
+            void _moduleCtor();
+        }
+
+        extern (Windows)
+        BOOL DllMain(HINSTANCE hInstance,
+                     ULONG ulReason,
+                     LPVOID pvReserved)
+        {   
+            switch (ulReason)
+            {
+                case DLL_PROCESS_ATTACH:
+                gc_init();
+                _minit();
+                _moduleCtor();
+                break;
+
+                case DLL_PROCESS_DETACH:
+                gc_term();
+                break;
+
+                case DLL_THREAD_ATTACH:
+                case DLL_THREAD_DETACH:
+                return false;
+            }
+            g_hInst = hInstance;
+            return true;
+        }
+        """
+    return source
 
 # vim: set sw=4 et sts=4 tw=79 fo+=l:
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.