Commits

Russel Winder committed 659e621

Merge in changes from the old repository that used a named branch.

Comments (0)

Files changed (2)

 
                             Change Log
 
+  From Russel Winder:
+    - Changes made to the dmd tool to allow for various breaking changes
+      made in D 1.068 and 2.053 to do with the introduction of 64-bit
+      builds of DMD.   NB  D v.1 is now deprecated.
+
 RELEASE 2.X.X - 
 
   From dubcanada on Bitbucket:

src/engine/SCons/Tool/dmd.py

 15 November 2003
 
 Amended by Russel Winder (russel@russel.org.uk)
-2010-02-07
+2010-02-07, 2010-11-17, 2011-02, 2011-05-14
 
 There are a number of problems with this script at this point in time.
 The one that irritates me the most is the Windows linker setup.  The D
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
 import os
+import subprocess
 
 import SCons.Action
 import SCons.Builder
     env['DFLAGSUFFIX'] = ''
     env['DFILESUFFIX'] = '.d'
 
+    if dc == 'dmd' :
+        #
+        #  We have to know exactly which version of DMD is in use so as to ensure correct behaviour.  DMD has
+        #  no option to return the version number.  The only place it is found is int he first line of the
+        #  help output.  So grab that first line and then scan it.
+        #
+        process = subprocess.Popen ('dmd', stdout=subprocess.PIPE)
+        versionLine = process.stdout.readline()
+        process.kill()
+        #
+        #  Up to and including DMD 1.067 and 2.052 the first line of the help starte "Digital Mars D Compiler
+        #  v" followed by the version number.  As of version 1.068 and 2.053, this string has changed to
+        #  "DMD## D Compiler v" where ## is either 32 or 64 depending on the build of the executable.  So
+        #  instead of a simple replacement, extra work is needed.
+        #
+        #env['DMDVERSIONNUMBER'] = tuple([int(i) for i in versionLine.replace('Digital Mars D Compiler v', '').strip().split('.')])
+        if 'DMD32' in versionLine : stringToReplace = 'DMD32 D Compiler v'
+        elif 'DMD64' in versionLine : stringToReplace = 'DMD64 D Compiler v'
+        else : stringToReplace = 'Digital Mars D Compiler v'
+        env['DMDVERSIONNUMBER'] = tuple([int(i) for i in versionLine.replace(stringToReplace, '').strip().split('.')])
+
     # Need to use the Digital Mars linker/lib on windows.
     # *nix can just use GNU link.
     if env['PLATFORM'] == 'win32':
                     except KeyError:
                         libs = []
                     if dc == 'dmd':
-                        # TODO: This assumes that the dmd executable is in the
-                        # bin directory and that the libraries are in a peer
-                        # directory lib.  This true of the Digital Mars
-                        # distribution but . . .
+                        #
+                        #  TODO: This assumes that the dmd executable is in the bin (or as of 1.068 and 2.053
+                        #  possible bin32 or bin64 -- at least on Linux) directory and that the libraries
+                        #  are in a peer directory lib (for versions prior to 1.067 and 2.052) or lib32 and
+                        #  lib64 (for version 1.067 and 2.052 and later on Linux, Mac OS X remains with
+                        #  lib as there is no 64-bit backend or build for DMD on this platform).  This is
+                        #  true of the Digital Mars distribution but what about Debian, Ubuntu, Fedora,
+                        #  FreeBSD, etc. packagings?
+                        #
+                        platformName , _ , _ , _ , architectureName = os.uname ( )
+                        mode64bit = False
+                        if architectureName == 'x86_64' and '-m32' not in env['DFLAGS']:
+                            mode64bit = True
+                        if mode64bit and '-m64' not in env['DFLAGS']:
+                            env.Append(DFLAGS = ['-m64'])
+                        dHome = env.WhereIs(dc).replace('/dmd' , '/..')
+                        if (env['DMDVERSIONNUMBER'][0] == 1 and env['DMDVERSIONNUMBER'][1] < 67 ) or \
+                               (env['DMDVERSIONNUMBER'][0] == 2 and env['DMDVERSIONNUMBER'][1] < 52 ):
+                            libComponent = 'lib'
+                        else:
+                            if platformName == 'Linux' :
+                                libComponent = 'lib64' if mode64bit else 'lib32'
+                            else :
+                                libComponent = 'lib'
                         import glob
-                        dHome = env.WhereIs(dc).replace('/dmd' , '/..')
-                        if glob.glob(dHome + '/lib/*phobos2*'):
+                        if glob.glob(dHome + '/' + libComponent + '/*phobos2*'):
                             if 'phobos2' not in libs:
-                                env.Append(LIBPATH = [dHome + '/lib'])
+                                env.Append(LIBPATH = [dHome + '/' + libComponent])
                                 env.Append(LIBS = ['phobos2'])
-                                # TODO: Find out when there will be a
-                                # 64-bit version of D.
-                                env.Append(LINKFLAGS = ['-m32'])
+                                if (env['DMDVERSIONNUMBER'][0] == 1 and env['DMDVERSIONNUMBER'][1] < 67 ) or \
+                                       (env['DMDVERSIONNUMBER'][0] == 2 and env['DMDVERSIONNUMBER'][1] < 52 ) :
+                                    env.Append(LINKFLAGS = ['-m32'])
+                                else:
+                                    pass
                         else:
                             if 'phobos' not in libs:
                                 env.Append(LIBS = ['phobos'])
                         env.Append(LIBS = ['pthread'])
                     if 'm' not in libs:
                         env.Append(LIBS = ['m'])
+                    if (env['DMDVERSIONNUMBER'][0] == 1 and env['DMDVERSIONNUMBER'][1] >= 67 ) or \
+                           (env['DMDVERSIONNUMBER'][0] == 2 and env['DMDVERSIONNUMBER'][1] >= 52 ):
+                        if platformName == 'Linux' and 'rt' not in libs :
+                            env.Append(LIBS = ['rt'])
                 return defaultLinker
             env['SMART_LINKCOM'] = smart_link[linkcom] = _smartLink
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.