
import os
import subprocess
import sys

def execute(args):
  process = subprocess.Popen(args)
  process.wait()
  return process.returncode

def main():
  component = 'all'
  if len(sys.argv) == 2:
    component = sys.argv[1]

  component_gyp_files = {
    'all' : 'dart/dart.gyp',
    'runtime' : 'dart/runtime/dart-runtime.gyp',
  }
  args = ['python', '-S', 'dart/third_party/gyp/gyp_main.py',
          '--depth=dart', '-Idart/tools/gyp/all.gypi',
          component_gyp_files[component]]

  if sys.platform == 'win32':
    # Generate Visual Studio 2010 compatible files by default.
    if not os.environ.get('GYP_MSVS_VERSION'):
      args.extend(['-G', 'msvs_version=2010'])

  sys.exit(execute(args))

if __name__ == '__main__':
  main()


import os
import subprocess
import sys

SCRIPT_DIR = os.path.dirname(sys.argv[0])
DART_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..'))

def execute(args):
  process = subprocess.Popen(args, cwd=DART_ROOT)
  process.wait()
  return process.returncode

def main():
  component = 'all'
  if len(sys.argv) == 2:
    component = sys.argv[1]

  component_gyp_files = {
    'all' : 'dart.gyp',
    'runtime' : 'runtime/dart-runtime.gyp',
  }
  args = ['python', '-S', 'third_party/gyp/gyp_main.py',
          '--depth=.', '-Itools/gyp/all.gypi',
          component_gyp_files[component]]

  if sys.platform == 'win32':
    # Generate Visual Studio 2010 compatible files by default.
    if not os.environ.get('GYP_MSVS_VERSION'):
      args.extend(['-G', 'msvs_version=2010'])

  sys.exit(execute(args))

if __name__ == '__main__':
  main()

Make tools/gypdart independent of the directory from which it is called.
Make tools/gypdart independent of the directory from which it is called.

This enables more independence in the way you can structure your checkout using gclient.

BUG=
R=ahe@google.com

Review URL: https://codereview.chromium.org//1023893003

git-svn-id: c93d8a2297af3b929165606efe145742a534bc71@44640 260f80e4-7a28-3924-810f-c04153c831b5

  
  import os
  import subprocess
  import sys
  
+ SCRIPT_DIR = os.path.dirname(sys.argv[0])
+ DART_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..'))
+ 
  def execute(args):
-   process = subprocess.Popen(args)
+   process = subprocess.Popen(args, cwd=DART_ROOT)
    process.wait()
    return process.returncode
  
  def main():
    component = 'all'
    if len(sys.argv) == 2:
      component = sys.argv[1]
  
    component_gyp_files = {
-     'all' : 'dart/dart.gyp',
+     'all' : 'dart.gyp',
-     'runtime' : 'dart/runtime/dart-runtime.gyp',
+     'runtime' : 'runtime/dart-runtime.gyp',
    }
-   args = ['python', '-S', 'dart/third_party/gyp/gyp_main.py',
+   args = ['python', '-S', 'third_party/gyp/gyp_main.py',
-           '--depth=dart', '-Idart/tools/gyp/all.gypi',
+           '--depth=.', '-Itools/gyp/all.gypi',
            component_gyp_files[component]]
  
    if sys.platform == 'win32':
      # Generate Visual Studio 2010 compatible files by default.
      if not os.environ.get('GYP_MSVS_VERSION'):
        args.extend(['-G', 'msvs_version=2010'])
  
    sys.exit(execute(args))
  
  if __name__ == '__main__':
    main()
  
Make tools/gypdart independent of the directory from which it is called.
## Code Before:

import os
import subprocess
import sys

def execute(args):
  process = subprocess.Popen(args)
  process.wait()
  return process.returncode

def main():
  component = 'all'
  if len(sys.argv) == 2:
    component = sys.argv[1]

  component_gyp_files = {
    'all' : 'dart/dart.gyp',
    'runtime' : 'dart/runtime/dart-runtime.gyp',
  }
  args = ['python', '-S', 'dart/third_party/gyp/gyp_main.py',
          '--depth=dart', '-Idart/tools/gyp/all.gypi',
          component_gyp_files[component]]

  if sys.platform == 'win32':
    # Generate Visual Studio 2010 compatible files by default.
    if not os.environ.get('GYP_MSVS_VERSION'):
      args.extend(['-G', 'msvs_version=2010'])

  sys.exit(execute(args))

if __name__ == '__main__':
  main()

## Instruction:
Make tools/gypdart independent of the directory from which it is called.
## Code After:

import os
import subprocess
import sys

SCRIPT_DIR = os.path.dirname(sys.argv[0])
DART_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..'))

def execute(args):
  process = subprocess.Popen(args, cwd=DART_ROOT)
  process.wait()
  return process.returncode

def main():
  component = 'all'
  if len(sys.argv) == 2:
    component = sys.argv[1]

  component_gyp_files = {
    'all' : 'dart.gyp',
    'runtime' : 'runtime/dart-runtime.gyp',
  }
  args = ['python', '-S', 'third_party/gyp/gyp_main.py',
          '--depth=.', '-Itools/gyp/all.gypi',
          component_gyp_files[component]]

  if sys.platform == 'win32':
    # Generate Visual Studio 2010 compatible files by default.
    if not os.environ.get('GYP_MSVS_VERSION'):
      args.extend(['-G', 'msvs_version=2010'])

  sys.exit(execute(args))

if __name__ == '__main__':
  main()
