Make GYP build usable for day-to-day work (second attempt)
authorjkummerow@chromium.org <jkummerow@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 5 Aug 2011 09:44:30 +0000 (09:44 +0000)
committerjkummerow@chromium.org <jkummerow@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 5 Aug 2011 09:44:30 +0000 (09:44 +0000)
- Introduce a global Makefile that triggers GYP-based building
- Some fixes to .gyp[i] files to make everything work
- tools/test-wrapper-gypbuild.py as a temporary solution for easy testing

Original review URL: http://codereview.chromium.org/7383006/

Review URL: http://codereview.chromium.org/7550030

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

17 files changed:
.gitignore
Makefile [new file with mode: 0644]
build/all.gyp
build/armu.gypi
build/common.gypi
build/v8-features.gypi
preparser/preparser.gyp [new file with mode: 0644]
samples/samples.gyp
src/d8.gyp
src/deoptimizer.cc
src/heap.cc
test/cctest/cctest.gyp
test/cctest/testcfg.py
test/preparser/testcfg.py
tools/gyp/v8.gyp
tools/test-wrapper-gypbuild.py [new file with mode: 0755]
tools/test.py

index 7219675..d09889b 100644 (file)
@@ -31,5 +31,4 @@ shell_g
 /tools/visual_studio/Release
 /xcodebuild/
 TAGS
-Makefile
 *.Makefile
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..b44b3df
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,113 @@
+# Copyright 2011 the V8 project authors. All rights reserved.
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+#     * Redistributions of source code must retain the above copyright
+#       notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above
+#       copyright notice, this list of conditions and the following
+#       disclaimer in the documentation and/or other materials provided
+#       with the distribution.
+#     * Neither the name of Google Inc. nor the names of its
+#       contributors may be used to endorse or promote products derived
+#       from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+# Variable default definitions. Override them by exporting them in your shell.
+CXX ?= "g++"  # For distcc: export CXX="distcc g++"
+LINK ?= "g++"
+OUTDIR ?= out
+TESTJOBS ?= -j16
+GYPFLAGS ?= -Dv8_can_use_vfp_instructions=true
+
+# Architectures and modes to be compiled.
+ARCHES = ia32 x64 arm
+MODES = release debug
+
+# List of files that trigger Makefile regeneration:
+GYPFILES = build/all.gyp build/common.gypi build/v8-features.gypi \
+           preparser/preparser.gyp samples/samples.gyp src/d8.gyp \
+           test/cctest/cctest.gyp tools/gyp/v8.gyp
+
+# Generates all combinations of ARCHES and MODES, e.g. "ia32.release".
+BUILDS = $(foreach mode,$(MODES),$(addsuffix .$(mode),$(ARCHES)))
+CHECKS = $(addsuffix .check,$(BUILDS))
+# Generates corresponding test targets, e.g. "ia32.release.check".
+
+.PHONY: all release debug ia32 x64 arm $(BUILDS)
+
+# Target definitions. "all" is the default, you can specify any others on the
+# command line, e.g. "make ia32". Targets defined in $(BUILDS), e.g.
+# "ia32.debug", can also be specified.
+all: release debug
+
+release: $(addsuffix .release,$(ARCHES))
+
+debug: $(addsuffix .debug,$(ARCHES))
+
+ia32: $(addprefix ia32.,$(MODES))
+
+x64: $(addprefix x64.,$(MODES))
+
+arm: $(addprefix arm.,$(MODES))
+
+.SECONDEXPANSION:
+$(BUILDS): $(OUTDIR)/Makefile-$$(basename $$@)
+       @$(MAKE) -C "$(OUTDIR)" -f Makefile-$(basename $@) \
+                CXX="$(CXX)" LINK="$(LINK)" \
+                BUILDTYPE=$(shell echo $(subst .,,$(suffix $@)) | \
+                            python -c "print raw_input().capitalize()") \
+                builddir="$(shell pwd)/$(OUTDIR)/$@"
+
+# Test targets.
+check: all
+       @tools/test-wrapper-gypbuild.py $(TESTJOBS)
+
+debug.check: debug
+       @tools/test-wrapper-gypbuild.py $(TESTJOBS) --mode=debug
+
+release.check: release
+       @tools/test-wrapper-gypbuild.py $(TESTJOBS) --mode=release
+
+$(addsuffix .check,$(ARCHES)): $$(basename $$@)
+       @tools/test-wrapper-gypbuild.py $(TESTJOBS) --arch=$(basename $@)
+
+$(CHECKS): $$(basename $$@)
+       @tools/test-wrapper-gypbuild.py $(TESTJOBS) --arch-and-mode=$(basename $@)
+
+# Clean targets. You can clean each architecture individually, or everything.
+$(addsuffix .clean,$(ARCHES)):
+       rm -f $(OUTDIR)/Makefile-$(basename $@)
+       rm -rf $(OUTDIR)/$(basename $@).release
+       rm -rf $(OUTDIR)/$(basename $@).debug
+
+clean: $(addsuffix .clean,$(ARCHES))
+
+# GYP file generation targets.
+$(OUTDIR)/Makefile-ia32: $(GYPFILES)
+       build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
+                     -Ibuild/common.gypi --depth=. -Dtarget_arch=ia32 -S-ia32 \
+                     $(GYPFLAGS)
+
+$(OUTDIR)/Makefile-x64: $(GYPFILES)
+       build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
+                     -Ibuild/common.gypi --depth=. -Dtarget_arch=x64 -S-x64 \
+                     $(GYPFLAGS)
+
+$(OUTDIR)/Makefile-arm: $(GYPFILES) build/armu.gypi
+       build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
+                     -Ibuild/common.gypi --depth=. -Ibuild/armu.gypi -S-arm \
+                     $(GYPFLAGS)
index 38287e3..9c0f05c 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2010 The Chromium Authors. All rights reserved.
+# Copyright (c) 2011 The Chromium Authors. All rights reserved.
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
@@ -8,6 +8,7 @@
       'target_name': 'All',
       'type': 'none',
       'dependencies': [
+        '../preparser/preparser.gyp:*',
         '../samples/samples.gyp:*',
         '../src/d8.gyp:d8',
       ],
index 3f874c0..d15b8ab 100644 (file)
@@ -32,5 +32,5 @@
     'armv7': 1,
     'arm_neon': 0,
     'arm_fpu': 'vfpv3',
-  }
+  },
 }
index 7020495..39a468f 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2010 the V8 project authors. All rights reserved.
+# Copyright 2011 the V8 project authors. All rights reserved.
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions are
 # met:
     'host_arch%': '<(host_arch)',
     'target_arch%': '<(host_arch)',
     'v8_target_arch%': '<(target_arch)',
+    'v8_enable_debugger_support%': 1,
+    'conditions': [
+      ['(target_arch=="arm" and host_arch!="arm") or \
+        (target_arch=="x64" and host_arch!="x64")', {
+        'want_separate_host_toolset': 1,
+      }, {
+        'want_separate_host_toolset': 0,
+      }],
+    ],
   },
   'target_defaults': {
     'default_configuration': 'Debug',
+    'conditions': [
+      ['v8_enable_debugger_support==1', {
+          'defines': ['ENABLE_DEBUGGER_SUPPORT',],
+        },
+      ],
+    ],
     'configurations': {
       'Debug': {
         'cflags': [ '-g', '-O0' ],
-        'defines': [ 'ENABLE_DISASSEMBLER', 'DEBUG' ],
+        'defines': [ 'ENABLE_DISASSEMBLER', 'DEBUG', 'V8_ENABLE_CHECKS',
+                     'OBJECT_PRINT' ],
       },
       'Release': {
-        'cflags': [ '-O3', '-fomit-frame-pointer', '-fdata-sections', '-ffunction-sections' ],
+        'cflags': [ '-O3', '-fomit-frame-pointer', '-fdata-sections',
+                    '-ffunction-sections' ],
       },
     },
   },
   'conditions': [
     [ 'OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"', {
       'target_defaults': {
-        'cflags': [ '-Wall', '-pthread', '-fno-rtti', '-fno-exceptions' ],
+        'cflags': [ '-Wall', '-pthread', '-fno-rtti', '-fno-exceptions',
+                    '-pedantic' ],
         'ldflags': [ '-pthread', ],
         'conditions': [
           [ 'target_arch=="ia32"', {
index 4037452..cb9b61c 100644 (file)
                   'USE_EABI_HARDFLOAT=1',
                   'CAN_USE_VFP_INSTRUCTIONS',
                 ],
+                'cflags': [
+                  '-mfloat-abi=hard',
+                ],
+              }, {
+                'defines': [
+                  'USE_EABI_HARDFLOAT=0',
+                ],
+              }],
+              # The ARM assembler assumes the host is 32 bits,
+              # so force building 32-bit host tools.
+              [ 'host_arch=="x64"', {
+                'cflags': ['-m32'],
+                'ldflags': ['-m32'],
               }],
             ],
           }],
diff --git a/preparser/preparser.gyp b/preparser/preparser.gyp
new file mode 100644 (file)
index 0000000..bcccb48
--- /dev/null
@@ -0,0 +1,41 @@
+# Copyright 2011 the V8 project authors. All rights reserved.
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+#     * Redistributions of source code must retain the above copyright
+#       notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above
+#       copyright notice, this list of conditions and the following
+#       disclaimer in the documentation and/or other materials provided
+#       with the distribution.
+#     * Neither the name of Google Inc. nor the names of its
+#       contributors may be used to endorse or promote products derived
+#       from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+{
+  'targets': [
+    {
+      'target_name': 'preparser',
+      'type': 'executable',
+      'dependencies': [
+        '../tools/gyp/v8.gyp:preparser_lib',
+      ],
+      'sources': [
+        'preparser-process.cc',
+      ],
+    },
+  ],
+}
index f383ee2..7023e0a 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2010 the V8 project authors. All rights reserved.
+# Copyright 2011 the V8 project authors. All rights reserved.
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions are
 # met:
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 {
+  'target_defaults': {
+    'type': 'executable',
+    'dependencies': [
+      '../tools/gyp/v8.gyp:v8',
+    ],
+    'include_dirs': [
+      '../include',
+    ],
+  },
   'targets': [
     {
       'target_name': 'shell',
-      'type': 'executable',
-      'dependencies': [
-        '../tools/gyp/v8.gyp:v8',
-      ],
       'sources': [
         'shell.cc',
       ],
     },
     {
       'target_name': 'process',
-      'type': 'executable',
-      'dependencies': [
-        '../tools/gyp/v8.gyp:v8',
-      ],
       'sources': [
         'process.cc',
       ],
index d2b4254..2d9af78 100644 (file)
       ],
       'conditions': [
         [ 'component!="shared_library"', {
-          'dependencies': [ 'd8_js2c#host', ], 
           'sources': [ 'd8-debug.cc', '<(SHARED_INTERMEDIATE_DIR)/d8-js.cc', ],
           'conditions': [
+            [ 'want_separate_host_toolset==1', {
+              'dependencies': [
+                'd8_js2c#host',
+              ],
+            }, {
+              'dependencies': [
+                'd8_js2c',
+              ],
+            }],
             [ 'console=="readline"', {
               'libraries': [ '-lreadline', ],
               'sources': [ 'd8-readline.cc' ],
     {
       'target_name': 'd8_js2c',
       'type': 'none',
-      'toolsets': ['host'],
       'variables': {
         'js_files': [
           'd8.js',
           'macros.py',
         ],
       },
+      'conditions': [
+        [ 'want_separate_host_toolset==1', {
+          'toolsets': ['host'],
+        }, {
+          'toolsets': ['target'],
+        }]
+      ],
       'actions': [
         {
           'action_name': 'd8_js2c',
             '../tools/js2c.py',
             '<@(_outputs)',
             'D8',
+            'off',  # compress startup data
             '<@(js_files)'
           ],
         },
index 3a7b33a..ed3b1f0 100644 (file)
@@ -1438,6 +1438,7 @@ void SlotRef::ComputeSlotMappingForArguments(JavaScriptFrame* frame,
   UNREACHABLE();
 }
 
+#ifdef ENABLE_DEBUGGER_SUPPORT
 
 DeoptimizedFrameInfo::DeoptimizedFrameInfo(
     Deoptimizer* deoptimizer, int frame_index) {
@@ -1467,5 +1468,6 @@ void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) {
   v->VisitPointers(expression_stack_, expression_stack_ + expression_count_);
 }
 
+#endif  // ENABLE_DEBUGGER_SUPPORT
 
 } }  // namespace v8::internal
index 26fbf44..8c5981b 100644 (file)
@@ -438,7 +438,9 @@ void Heap::GarbageCollectionEpilogue() {
 #if defined(DEBUG)
   ReportStatisticsAfterGC();
 #endif  // DEBUG
+#ifdef ENABLE_DEBUGGER_SUPPORT
   isolate_->debug()->AfterGarbageCollection();
+#endif  // ENABLE_DEBUGGER_SUPPORT
 }
 
 
index 07d12c8..5843440 100644 (file)
@@ -79,6 +79,7 @@
         'test-log.cc',
         'test-mark-compact.cc',
         'test-parsing.cc',
+        'test-platform-tls.cc',
         'test-profile-generator.cc',
         'test-regexp.cc',
         'test-reloc-info.cc',
index a137275..b2eabc4 100644 (file)
@@ -48,7 +48,11 @@ class CcTestCase(test.TestCase):
     return self.path[-1]
 
   def BuildCommand(self, name):
-    serialization_file = join('obj', 'test', self.mode, 'serdes')
+    serialization_file = ''
+    if exists(join(self.context.buildspace, 'obj', 'test', self.mode)):
+      serialization_file = join('obj', 'test', self.mode, 'serdes')
+    else:
+      serialization_file = join('obj', 'serdes')
     serialization_file += '_' + self.GetName()
     serialization_file = join(self.context.buildspace, serialization_file)
     serialization_file += ''.join(self.variant_flags).replace('-', '_')
@@ -78,10 +82,15 @@ class CcTestConfiguration(test.TestConfiguration):
     return ['cctests']
 
   def ListTests(self, current_path, path, mode, variant_flags):
-    executable = join('obj', 'test', mode, 'cctest')
+    executable = 'cctest'
     if utils.IsWindows():
       executable += '.exe'
     executable = join(self.context.buildspace, executable)
+    if not exists(executable):
+      executable = join('obj', 'test', mode, 'cctest')
+      if utils.IsWindows():
+        executable += '.exe'
+      executable = join(self.context.buildspace, executable)
     output = test.Execute([executable, '--list'], self.context)
     if output.exit_code != 0:
       print output.stdout
index 39b62c3..d900e26 100644 (file)
@@ -27,7 +27,7 @@
 
 import test
 import os
-from os.path import join, dirname, exists
+from os.path import join, dirname, exists, isfile
 import platform
 import utils
 import re
@@ -122,10 +122,15 @@ class PreparserTestConfiguration(test.TestConfiguration):
          {"Test": Test, "Template": Template}, {})
 
   def ListTests(self, current_path, path, mode, variant_flags):
-    executable = join('obj', 'preparser', mode, 'preparser')
+    executable = 'preparser'
     if utils.IsWindows():
       executable += '.exe'
     executable = join(self.context.buildspace, executable)
+    if not isfile(executable):
+      executable = join('obj', 'preparser', mode, 'preparser')
+      if utils.IsWindows():
+        executable += '.exe'
+      executable = join(self.context.buildspace, executable)
     expectations = self.GetExpectations()
     result = []
     # Find all .js files in tests/preparser directory.
index 8ea18a6..8606a2e 100644 (file)
     # well when compiling for the ARM target.
     'v8_use_arm_eabi_hardfloat%': 'false',
 
+    'v8_enable_debugger_support%': 1,
+
+    # Chrome needs this definition unconditionally. For standalone V8 builds,
+    # it's handled in common.gypi.
+    'want_separate_host_toolset%': 1,
+
     'v8_use_snapshot%': 'true',
     'host_os%': '<(OS)',
     'v8_use_liveobjectlist%': 'false',
   'conditions': [
     ['use_system_v8==0', {
       'target_defaults': {
-        'defines': [
-          'ENABLE_DEBUGGER_SUPPORT',
-        ],
         'conditions': [
+          ['v8_enable_debugger_support==1', {
+              'defines': ['ENABLE_DEBUGGER_SUPPORT',],
+            },
+          ],
           ['OS!="mac"', {
             # TODO(mark): The OS!="mac" conditional is temporary. It can be
             # removed once the Mac Chromium build stops setting target_arch to
                       'USE_EABI_HARDFLOAT=1',
                       'CAN_USE_VFP_INSTRUCTIONS',
                     ],
+                    'cflags': [
+                      '-mfloat-abi=hard',
+                    ],
+                  }, {
+                    'defines': [
+                      'USE_EABI_HARDFLOAT=0',
+                    ],
+                  }],
+                  # The ARM assembler assumes the host is 32 bits,
+                  # so force building 32-bit host tools.
+                  [ 'host_arch=="x64"', {
+                    'cflags': ['-m32'],
+                    'ldflags': ['-m32'],
                   }],
                 ],
               }],
              ['OS=="freebsd" or OS=="openbsd"', {
                'cflags': [ '-I/usr/local/include' ],
              }],
+             ['OS=="linux" or OS=="freebsd" or OS=="openbsd"', {
+               'cflags': [ '-Wall', '-Werror', '-W', '-Wno-unused-parameter',
+                           '-Wnon-virtual-dtor' ],
+             }],
            ],
           },
           'Release': {
                   '-O2',
                   '-Os',
                 ],
-                'cflags': [
-                  '-fomit-frame-pointer',
-                  '-O3',
-                ],
                 'conditions': [
                   [ 'gcc_version==44', {
                     'cflags': [
       'targets': [
         {
           'target_name': 'v8',
-          'toolsets': ['host', 'target'],
           'conditions': [
+            ['want_separate_host_toolset==1', {
+              'toolsets': ['host', 'target'],
+            }, {
+              'toolsets': ['target'],
+            }],
             ['v8_use_snapshot=="true"', {
               'dependencies': ['v8_snapshot'],
             },
           ],
           'direct_dependent_settings': {
             'include_dirs': [
-               '../../include',
+              '../../include',
             ],
           },
         },
         {
           'target_name': 'v8_snapshot',
           'type': '<(library)',
-          'toolsets': ['host', 'target'],
           'conditions': [
+            ['want_separate_host_toolset==1', {
+              'toolsets': ['host', 'target'],
+              'dependencies': ['mksnapshot#host', 'js2c#host'],
+            }, {
+              'toolsets': ['target'],
+              'dependencies': ['mksnapshot', 'js2c'],
+            }],
             ['component=="shared_library"', {
               'conditions': [
-                # The ARM assembler assumes the host is 32 bits, so force building
-                # 32-bit host tools.
-                ['v8_target_arch=="arm" and host_arch=="x64" and _toolset=="host"', {
-                  'cflags': ['-m32'],
-                  'ldflags': ['-m32'],
-                }],
                 ['OS=="win"', {
                   'defines': [
                     'BUILDING_V8_SHARED',
             }],
           ],
           'dependencies': [
-            'mksnapshot#host',
-            'js2c#host',
             'v8_base',
           ],
           'include_dirs+': [
         {
           'target_name': 'v8_nosnapshot',
           'type': '<(library)',
-          'toolsets': ['host', 'target'],
           'dependencies': [
-            'js2c#host',
             'v8_base',
           ],
           'include_dirs+': [
             '../../src/snapshot-empty.cc',
           ],
           'conditions': [
-            # The ARM assembler assumes the host is 32 bits, so force building
-            # 32-bit host tools.
-            ['v8_target_arch=="arm" and host_arch=="x64" and _toolset=="host"', {
-              'cflags': ['-m32'],
-              'ldflags': ['-m32'],
+            ['want_separate_host_toolset==1', {
+              'toolsets': ['host', 'target'],
+              'dependencies': ['js2c#host'],
+            }, {
+              'toolsets': ['target'],
+              'dependencies': ['js2c'],
             }],
             ['component=="shared_library"', {
               'defines': [
         {
           'target_name': 'v8_base',
           'type': '<(library)',
-          'toolsets': ['host', 'target'],
           'include_dirs+': [
             '../../src',
           ],
             '../../src/extensions/gc-extension.h',
           ],
           'conditions': [
+            ['want_separate_host_toolset==1', {
+              'toolsets': ['host', 'target'],
+            }, {
+              'toolsets': ['target'],
+            }],
             ['v8_target_arch=="arm"', {
-              'include_dirs+': [
-                '../../src/arm',
-              ],
               'sources': [
                 '../../src/arm/assembler-arm-inl.h',
                 '../../src/arm/assembler-arm.cc',
                 '../../src/arm/simulator-arm.cc',
                 '../../src/arm/stub-cache-arm.cc',
               ],
-              'conditions': [
-                # The ARM assembler assumes the host is 32 bits,
-                # so force building 32-bit host tools.
-                ['host_arch=="x64" and _toolset=="host"', {
-                  'cflags': ['-m32'],
-                  'ldflags': ['-m32'],
-                }]
-              ]
             }],
             ['v8_target_arch=="ia32" or v8_target_arch=="mac" or OS=="mac"', {
-              'include_dirs+': [
-                '../../src/ia32',
-              ],
               'sources': [
                 '../../src/ia32/assembler-ia32-inl.h',
                 '../../src/ia32/assembler-ia32.cc',
               ],
             }],
             ['v8_target_arch=="x64" or v8_target_arch=="mac" or OS=="mac"', {
-              'include_dirs+': [
-                '../../src/x64',
-              ],
               'sources': [
                 '../../src/x64/assembler-x64-inl.h',
                 '../../src/x64/assembler-x64.cc',
             }],
             ['OS=="linux"', {
                 'link_settings': {
-                  'libraries': [
-                    # Needed for clock_gettime() used by src/platform-linux.cc.
-                    '-lrt',
-                  ],
                   'conditions': [
                     ['v8_compress_startup_data=="bz2"', {
                       'libraries': [
         {
           'target_name': 'js2c',
           'type': 'none',
-          'toolsets': ['host'],
+          'conditions': [
+            ['want_separate_host_toolset==1', {
+              'toolsets': ['host'],
+            }, {
+              'toolsets': ['target'],
+            }],
+          ],
           'variables': {
             'library_files': [
               '../../src/runtime.js',
               '../../src/macros.py',
             ],
             'experimental_library_files': [
-              '../../src/proxy.js',
               '../../src/macros.py',
+              '../../src/proxy.js',
+              '../../src/weakmap.js',
             ],
           },
           'actions': [
         {
           'target_name': 'mksnapshot',
           'type': 'executable',
-          'toolsets': ['host'],
           'dependencies': [
             'v8_nosnapshot',
           ],
             '../../src/mksnapshot.cc',
           ],
           'conditions': [
-            # The ARM assembler assumes the host is 32 bits, so force building
-            # 32-bit host tools.
-            ['v8_target_arch=="arm" and host_arch=="x64" and _toolset=="host"', {
-              'cflags': ['-m32'],
-              'ldflags': ['-m32'],
+            ['want_separate_host_toolset==1', {
+              'toolsets': ['host'],
+            }, {
+              'toolsets': ['target'],
             }],
             ['v8_compress_startup_data=="bz2"', {
               'libraries': [
         {
           'target_name': 'v8_shell',
           'type': 'executable',
-          'toolsets': ['host'],
           'dependencies': [
             'v8'
           ],
             '../../samples/shell.cc',
           ],
           'conditions': [
+            ['want_separate_host_toolset==1', {
+              'toolsets': ['host'],
+            }, {
+              'toolsets': ['target'],
+            }],
             ['OS=="win"', {
               # This could be gotten by not setting chromium_code, if that's OK.
               'defines': ['_CRT_SECURE_NO_WARNINGS'],
             }],
-            # The ARM assembler assumes the host is 32 bits, so force building
-            # 32-bit host tools.
-            ['v8_target_arch=="arm" and host_arch=="x64" and _toolset=="host"', {
-              'cflags': ['-m32'],
-              'ldflags': ['-m32'],
-            }],
             ['v8_compress_startup_data=="bz2"', {
               'libraries': [
                 '-lbz2',
               ]}],
           ],
         },
+        {
+          'target_name': 'preparser_lib',
+          'type': '<(library)',
+          'include_dirs+': [
+            '../../src',
+          ],
+          'sources': [
+            '../../src/allocation.cc',
+            '../../src/bignum.cc',
+            '../../src/cached-powers.cc',
+            '../../src/conversions.cc',
+            '../../src/hashmap.cc',
+            '../../src/preparse-data.cc',
+            '../../src/preparser.cc',
+            '../../src/preparser-api.cc',
+            '../../src/scanner-base.cc',
+            '../../src/strtod.cc',
+            '../../src/token.cc',
+            '../../src/unicode.cc',
+            '../../src/utils.cc',
+          ],
+        },
       ],
     }, { # use_system_v8 != 0
       'targets': [
         {
           'target_name': 'v8',
           'type': 'settings',
-          'toolsets': ['host', 'target'],
+          'conditions': [
+            ['want_separate_host_toolset==1', {
+              'toolsets': ['host', 'target'],
+            }, {
+              'toolsets': ['target'],
+            }],
+
+          ],
           'link_settings': {
             'libraries': [
               '-lv8',
         {
           'target_name': 'v8_shell',
           'type': 'none',
-          'toolsets': ['host'],
+          'conditions': [
+            ['want_separate_host_toolset==1', {
+              'toolsets': ['host'],
+            }, {
+              'toolsets': ['target'],
+            }],
+          ],
           'dependencies': [
             'v8'
           ],
diff --git a/tools/test-wrapper-gypbuild.py b/tools/test-wrapper-gypbuild.py
new file mode 100755 (executable)
index 0000000..2803573
--- /dev/null
@@ -0,0 +1,223 @@
+#!/usr/bin/env python
+#
+# Copyright 2011 the V8 project authors. All rights reserved.
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+#     * Redistributions of source code must retain the above copyright
+#       notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above
+#       copyright notice, this list of conditions and the following
+#       disclaimer in the documentation and/or other materials provided
+#       with the distribution.
+#     * Neither the name of Google Inc. nor the names of its
+#       contributors may be used to endorse or promote products derived
+#       from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+# This is a convenience script to run the existing tools/test.py script
+# when using the gyp/make based build.
+# It is intended as a stop-gap rather than a long-term solution.
+
+
+import optparse
+import os
+from os.path import join, dirname, abspath
+import subprocess
+import sys
+
+
+PROGRESS_INDICATORS = ['verbose', 'dots', 'color', 'mono']
+
+
+def BuildOptions():
+  result = optparse.OptionParser()
+
+  # Flags specific to this wrapper script:
+  result.add_option("--arch-and-mode",
+                    help='Architecture and mode in the format "arch.mode"',
+                    default=None)
+
+  # Flags this wrapper script handles itself:
+  result.add_option("-m", "--mode",
+                    help="The test modes in which to run (comma-separated)",
+                    default='release,debug')
+  result.add_option("--arch",
+                    help='The architectures to run tests for (comma-separated)',
+                    default='ia32,x64,arm')
+
+  # Flags that are passed on to the wrapped test.py script:
+  result.add_option("-v", "--verbose", help="Verbose output",
+      default=False, action="store_true")
+  result.add_option("-p", "--progress",
+      help="The style of progress indicator (verbose, dots, color, mono)",
+      choices=PROGRESS_INDICATORS, default="mono")
+  result.add_option("--report", help="Print a summary of the tests to be run",
+      default=False, action="store_true")
+  result.add_option("-s", "--suite", help="A test suite",
+      default=[], action="append")
+  result.add_option("-t", "--timeout", help="Timeout in seconds",
+      default=60, type="int")
+  result.add_option("--snapshot", help="Run the tests with snapshot turned on",
+      default=False, action="store_true")
+  result.add_option("--special-command", default=None)
+  result.add_option("--valgrind", help="Run tests through valgrind",
+      default=False, action="store_true")
+  result.add_option("--cat", help="Print the source of the tests",
+      default=False, action="store_true")
+  result.add_option("--warn-unused", help="Report unused rules",
+      default=False, action="store_true")
+  result.add_option("-j", help="The number of parallel tasks to run",
+      default=1, type="int")
+  result.add_option("--time", help="Print timing information after running",
+      default=False, action="store_true")
+  result.add_option("--suppress-dialogs", help="Suppress Windows dialogs for crashing tests",
+        dest="suppress_dialogs", default=True, action="store_true")
+  result.add_option("--no-suppress-dialogs", help="Display Windows dialogs for crashing tests",
+        dest="suppress_dialogs", action="store_false")
+  result.add_option("--isolates", help="Whether to test isolates", default=False, action="store_true")
+  result.add_option("--store-unexpected-output",
+      help="Store the temporary JS files from tests that fails",
+      dest="store_unexpected_output", default=True, action="store_true")
+  result.add_option("--no-store-unexpected-output",
+      help="Deletes the temporary JS files from tests that fails",
+      dest="store_unexpected_output", action="store_false")
+  result.add_option("--stress-only",
+                    help="Only run tests with --always-opt --stress-opt",
+                    default=False, action="store_true")
+  result.add_option("--nostress",
+                    help="Don't run crankshaft --always-opt --stress-op test",
+                    default=False, action="store_true")
+  result.add_option("--crankshaft",
+                    help="Run with the --crankshaft flag",
+                    default=False, action="store_true")
+  result.add_option("--shard-count",
+                    help="Split testsuites into this number of shards",
+                    default=1, type="int")
+  result.add_option("--shard-run",
+                    help="Run this shard from the split up tests.",
+                    default=1, type="int")
+  result.add_option("--noprof", help="Disable profiling support",
+                    default=False)
+
+  # Flags present in the original test.py that are unsupported in this wrapper:
+  # -S [-> scons_flags] (we build with gyp/make, not scons)
+  # --no-build (always true)
+  # --build-only (always false)
+  # --build-system (always 'gyp')
+  # --simulator (always true if arch==arm, always false otherwise)
+  # --shell (automatically chosen depending on arch and mode)
+
+  return result
+
+
+def ProcessOptions(options):
+  if options.arch_and_mode != None and options.arch_and_mode != "":
+    tokens = options.arch_and_mode.split(".")
+    options.arch = tokens[0]
+    options.mode = tokens[1]
+  options.mode = options.mode.split(',')
+  for mode in options.mode:
+    if not mode in ['debug', 'release']:
+      print "Unknown mode %s" % mode
+      return False
+  options.arch = options.arch.split(',')
+  for arch in options.arch:
+    if not arch in ['ia32', 'x64', 'arm']:
+      print "Unknown architecture %s" % arch
+      return False
+
+  return True
+
+
+def PassOnOptions(options):
+  result = []
+  if options.verbose:
+    result += ['--verbose']
+  if options.progress != 'mono':
+    result += ['--progress=' + options.progress]
+  if options.report:
+    result += ['--report']
+  if options.suite != []:
+    for suite in options.suite:
+      result += ['--suite=../../test/' + suite]
+  if options.timeout != 60:
+    result += ['--timeout=%s' % options.timeout]
+  if options.snapshot:
+    result += ['--snapshot']
+  if options.special_command:
+    result += ['--special-command=' + options.special_command]
+  if options.valgrind:
+    result += ['--valgrind']
+  if options.cat:
+    result += ['--cat']
+  if options.warn_unused:
+    result += ['--warn-unused']
+  if options.j != 1:
+    result += ['-j%s' % options.j]
+  if options.time:
+    result += ['--time']
+  if not options.suppress_dialogs:
+    result += ['--no-suppress-dialogs']
+  if options.isolates:
+    result += ['--isolates']
+  if not options.store_unexpected_output:
+    result += ['--no-store-unexpected_output']
+  if options.stress_only:
+    result += ['--stress-only']
+  if options.nostress:
+    result += ['--nostress']
+  if options.crankshaft:
+    result += ['--crankshaft']
+  if options.shard_count != 1:
+    result += ['--shard_count=%s' % options.shard_count]
+  if options.shard_run != 1:
+    result += ['--shard_run=%s' % options.shard_run]
+  if options.noprof:
+    result += ['--noprof']
+  return result
+
+
+def Main():
+  parser = BuildOptions()
+  (options, args) = parser.parse_args()
+  if not ProcessOptions(options):
+    parser.print_help()
+    return 1
+
+  workspace = abspath(join(dirname(sys.argv[0]), '..'))
+  args_for_children = [workspace + '/tools/test.py'] + PassOnOptions(options)
+  args_for_children += ['--no-build', '--build-system=gyp']
+  for arg in args:
+    args_for_children += [arg]
+  returncodes = 0
+
+  for mode in options.mode:
+    for arch in options.arch:
+      print ">>> running tests for %s.%s" % (arch, mode)
+      shell = workspace + '/out/' + arch + '.' + mode + "/shell"
+      child = subprocess.Popen(' '.join(args_for_children +
+                                        ['--mode=' + mode] +
+                                        ['--shell=' + shell]),
+                               shell=True,
+                               cwd=workspace)
+      returncodes += child.wait()
+
+  return returncodes
+
+
+if __name__ == '__main__':
+  sys.exit(Main())
index f625522..d86c596 100755 (executable)
@@ -1181,6 +1181,8 @@ def BuildOptions():
       default=False, action="store_true")
   result.add_option("--build-only", help="Only build requirements, don't run the tests",
       default=False, action="store_true")
+  result.add_option("--build-system", help="Build system in use (scons or gyp)",
+      default='scons')
   result.add_option("--report", help="Print a summary of the tests to be run",
       default=False, action="store_true")
   result.add_option("-s", "--suite", help="A test suite",
@@ -1280,6 +1282,10 @@ def ProcessOptions(options):
   if options.noprof:
     options.scons_flags.append("prof=off")
     options.scons_flags.append("profilingsupport=off")
+  if options.build_system == 'gyp':
+    if options.build_only:
+      print "--build-only not supported for gyp, please build manually."
+      options.build_only = False
   return True
 
 
@@ -1405,6 +1411,9 @@ def Main():
     run_valgrind = join(workspace, "tools", "run-valgrind.py")
     options.special_command = "python -u " + run_valgrind + " @"
 
+  if options.build_system == 'gyp':
+    SUFFIX['debug'] = ''
+
   shell = abspath(options.shell)
   buildspace = dirname(shell)