Upgrade to 3.29

Update V8 to 3.29.88.17 and update makefiles to support building on
all the relevant platforms.

Bug: 17370214

Change-Id: Ia3407c157fd8d72a93e23d8318ccaf6ecf77fa4e
diff --git a/build/gyp_v8 b/build/gyp_v8
index 4293e76..14467ec 100755
--- a/build/gyp_v8
+++ b/build/gyp_v8
@@ -1,6 +1,6 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 #
-# Copyright 2010 the V8 project authors. All rights reserved.
+# Copyright 2012 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:
@@ -32,18 +32,21 @@
 
 import glob
 import os
+import platform
 import shlex
+import subprocess
 import sys
 
-script_dir = os.path.dirname(__file__)
-v8_root = os.path.normpath(os.path.join(script_dir, os.pardir))
-
-sys.path.insert(0, os.path.join(v8_root, 'tools'))
-import utils
+script_dir = os.path.dirname(os.path.realpath(__file__))
+v8_root = os.path.abspath(os.path.join(script_dir, os.pardir))
 
 sys.path.insert(0, os.path.join(v8_root, 'build', 'gyp', 'pylib'))
 import gyp
 
+# Add paths so that pymod_do_main(...) can import files.
+sys.path.insert(
+    1, os.path.abspath(os.path.join(v8_root, 'tools', 'generate_shim_headers')))
+
 
 def apply_gyp_environment(file_path=None):
   """
@@ -93,7 +96,7 @@
       result.append(path)
 
   # Always include standalone.gypi
-  AddInclude(os.path.join(script_dir, 'standalone.gypi'))
+  AddInclude(os.path.join(v8_root, 'build', 'standalone.gypi'))
 
   # Optionally add supplemental .gypi files if present.
   supplements = glob.glob(os.path.join(v8_root, '*', 'supplement.gypi'))
@@ -105,6 +108,14 @@
 
 def run_gyp(args):
   rc = gyp.main(args)
+
+  # Check for landmines (reasons to clobber the build). This must be run here,
+  # rather than a separate runhooks step so that any environment modifications
+  # from above are picked up.
+  print 'Running build/landmines.py...'
+  subprocess.check_call(
+      [sys.executable, os.path.join(script_dir, 'landmines.py')])
+
   if rc != 0:
     print 'Error running GYP'
     sys.exit(rc)
@@ -143,7 +154,7 @@
   args.append('--no-circular-check')
 
   # Set the GYP DEPTH variable to the root of the V8 project.
-  args.append('--depth=' + v8_root)
+  args.append('--depth=' + os.path.relpath(v8_root))
 
   # If V8_GYP_SYNTAX_CHECK is set to 1, it will invoke gyp with --check
   # to enfore syntax checking.
@@ -156,23 +167,14 @@
 
   # Generate for the architectures supported on the given platform.
   gyp_args = list(args)
-  gyp_args.append('-Dtarget_arch=ia32')
-  if utils.GuessOS() == 'linux':
-    gyp_args.append('-S-ia32')
+  gyp_generators = os.environ.get('GYP_GENERATORS')
+  if platform.system() == 'Linux' and gyp_generators != 'ninja':
+    # Work around for crbug.com/331475.
+    for f in glob.glob(os.path.join(v8_root, 'out', 'Makefile.*')):
+      os.unlink(f)
+    # --generator-output defines where the Makefile goes.
+    gyp_args.append('--generator-output=out')
+    # -Goutput_dir defines where the build output goes, relative to the
+    # Makefile. Set it to . so that the build output doesn't end up in out/out.
+    gyp_args.append('-Goutput_dir=.')
   run_gyp(gyp_args)
-
-  if utils.GuessOS() == 'linux':
-    gyp_args = list(args)
-    gyp_args.append('-Dtarget_arch=x64')
-    gyp_args.append('-S-x64')
-    run_gyp(gyp_args)
-
-    gyp_args = list(args)
-    gyp_args.append('-I' + v8_root + '/build/armu.gypi')
-    gyp_args.append('-S-armu')
-    run_gyp(gyp_args)
-
-    gyp_args = list(args)
-    gyp_args.append('-I' + v8_root + '/build/mipsu.gypi')
-    gyp_args.append('-S-mipsu')
-    run_gyp(gyp_args)