Added support for building V8 on Windows with either the shared or static version...
authorsgjesse@chromium.org <sgjesse@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 21 Nov 2008 11:19:01 +0000 (11:19 +0000)
committersgjesse@chromium.org <sgjesse@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 21 Nov 2008 11:19:01 +0000 (11:19 +0000)
Review URL: http://codereview.chromium.org/11564

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@817 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

SConstruct
src/dtoa-config.c

index a6f77382896d547d91670282a408802f30c38be8..0f73dacd22e0e2de5f30c7fad955fa3dce05c68e 100644 (file)
@@ -74,15 +74,27 @@ LIBRARY_FLAGS = {
       'CCPDBFLAGS':   ['/Zi']
     },
     'mode:debug': {
-      'CCFLAGS':      ['/Od', '/Gm', '/MTd'],
+      'CCFLAGS':      ['/Od', '/Gm'],
       'CPPDEFINES':   ['_DEBUG', 'ENABLE_DISASSEMBLER', 'DEBUG'],
-      'LINKFLAGS':    ['/DEBUG']
+      'LINKFLAGS':    ['/DEBUG'],
+      'msvcrt:static': {
+        'CCFLAGS': ['/MTd']
+      },
+      'msvcrt:shared': {
+        'CCFLAGS': ['/MDd']
+      }
     },
     'mode:release': {
-      'CCFLAGS':      ['/O2', '/MT', '/GL'],
+      'CCFLAGS':      ['/O2', '/GL'],
       'LINKFLAGS':    ['/OPT:REF', '/OPT:ICF', '/LTCG'],
-      'ARFLAGS':      ['/LTCG']
-    }
+      'ARFLAGS':      ['/LTCG'],
+      'msvcrt:static': {
+        'CCFLAGS': ['/MT']
+      },
+      'msvcrt:shared': {
+        'CCFLAGS': ['/MD']
+      }
+    },
   }
 }
 
@@ -215,12 +227,24 @@ SAMPLE_FLAGS = {
       'LINKFLAGS': ['/MAP']
     },
     'mode:release': {
-      'CCFLAGS':   ['/O2', '/MT'],
-      'LINKFLAGS': ['/OPT:REF', '/OPT:ICF', '/LTCG']
+      'CCFLAGS':   ['/O2'],
+      'LINKFLAGS': ['/OPT:REF', '/OPT:ICF', '/LTCG'],
+      'msvcrt:static': {
+        'CCFLAGS': ['/MT']
+      },
+      'msvcrt:shared': {
+        'CCFLAGS': ['/MD']
+      }
     },
     'mode:debug': {
-      'CCFLAGS':   ['/Od', '/MTd'],
-      'LINKFLAGS': ['/DEBUG']
+      'CCFLAGS':   ['/Od'],
+      'LINKFLAGS': ['/DEBUG'],
+      'msvcrt:static': {
+        'CCFLAGS': ['/MTd']
+      },
+      'msvcrt:shared': {
+        'CCFLAGS': ['/MDd']
+      }
     }
   }
 }
@@ -232,7 +256,6 @@ D8_FLAGS = {
       'LIBS': ['readline']
     }
   },
-  'msvc': { }
 }
 
 
@@ -294,6 +317,11 @@ SIMPLE_OPTIONS = {
     'default': 'static',
     'help': 'the type of library to produce'
   },
+  'msvcrt': {
+    'values': ['static', 'shared'],
+    'default': 'static',
+    'help': 'the type of MSVCRT library to use'
+  },
   'wordsize': {
     'values': ['64', '32'],
     'default': WORDSIZE_GUESS,
@@ -381,11 +409,18 @@ class BuildContext(object):
     result = initial.copy()
     self.AppendFlags(result, flags.get('all'))
     toolchain = self.options['toolchain']
-    self.AppendFlags(result, flags[toolchain].get('all'))
+    if toolchain in flags:
+      self.AppendFlags(result, flags[toolchain].get('all'))
+      for option in sorted(self.options.keys()):
+        value = self.options[option]
+        self.AppendFlags(result, flags[toolchain].get(option + ':' + value))
+    return result
+
+  def AddRelevantSubFlags(self, options, flags):
+    self.AppendFlags(options, flags.get('all'))
     for option in sorted(self.options.keys()):
       value = self.options[option]
-      self.AppendFlags(result, flags[toolchain].get(option + ':' + value))
-    return result
+      self.AppendFlags(options, flags.get(option + ':' + value))
 
   def GetRelevantSources(self, source):
     result = []
@@ -398,12 +433,15 @@ class BuildContext(object):
     if not added:
       return
     for (key, value) in added.iteritems():
-      if not key in options:
-        options[key] = value
+      if key.find(':') != -1:
+        self.AddRelevantSubFlags(options, { key: value })
       else:
-        prefix = options[key]
-        if isinstance(prefix, StringTypes): prefix = prefix.split()
-        options[key] = prefix + value
+        if not key in options:
+          options[key] = value
+        else:
+          prefix = options[key]
+          if isinstance(prefix, StringTypes): prefix = prefix.split()
+          options[key] = prefix + value
 
   def ConfigureObject(self, env, input, **kw):
     if self.options['library'] == 'static':
index bb610a90ee65033280f47ddbdb15c31c227ade36..eb2c9555fd9163016089fc733d503ced702bac26 100644 (file)
  * gay_strtod, it will mangle the name of gay_strtod, which is
  * unwanted. */
 #include <stdlib.h>
+
+#endif
+/* stdlib.h on Windows adds __declspec(dllimport) to all functions when using
+ * the DLL version of the CRT (compiling with /MD or /MDd). If stdlib.h is
+ * included after strtod is redefined as gay_strtod, it will add
+ * __declspec(dllimport) to gay_strtod, which causes the compilation of
+ * gay_strtod in dtoa.c to fail.
+*/
+#if defined(WIN32) && defined(_DLL)
+#include "stdlib.h"
 #endif
+
 /* Make sure we use the David M. Gay version of strtod(). On Linux, we
  * cannot use the same name (maybe the function does not have weak
  * linkage?). */