OLD | NEW |
| (Empty) |
1 #!/usr/bin/env python | |
2 # | |
3 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
4 # for details. All rights reserved. Use of this source code is governed by a | |
5 # BSD-style license that can be found in the LICENSE file. | |
6 | |
7 import os | |
8 import sys | |
9 import platform | |
10 | |
11 def NormJoin(path1, path2): | |
12 return os.path.normpath(os.path.join(path1, path2)) | |
13 | |
14 | |
15 def GetProjectGypFile(project_name): | |
16 project_file = os.path.join(project_name, 'dart-%s.gyp' % project_name) | |
17 if not os.path.exists(project_file): | |
18 sys.stderr.write('%s does not exist\n' % project_file) | |
19 project_file = os.path.join(project_name, 'dart.gyp') | |
20 return project_file | |
21 | |
22 dart_src = NormJoin(os.path.dirname(sys.argv[0]), os.pardir) | |
23 project_src = sys.argv[1] | |
24 gyp_pylib = os.path.join(dart_src, 'third_party', 'gyp', 'pylib') | |
25 | |
26 if __name__ == '__main__': | |
27 # If this script is invoked with the -fmake option, we assume that | |
28 # it is being run automatically via a project Makefile. That can be | |
29 # problematic (because GYP is really bad at setting up the paths | |
30 # correctly), so we try to run "gclient runhooks" instead. | |
31 if '-fmake' in sys.argv: | |
32 try: | |
33 sys.exit(os.execvp("gclient", ["gclient", "runhooks"])) | |
34 except OSError: | |
35 # Sometimes gclient is not on the PATH. Let the user know that | |
36 # he must run "gclient runhooks" manually. | |
37 sys.stderr.write('Error: GYP files are out of date.\n') | |
38 sys.stderr.write('\n\n*** Please run "gclient runhooks" ***\n\n\n') | |
39 sys.exit(1) | |
40 | |
41 | |
42 # Add gyp to the imports and if needed get it from the third_party location | |
43 # inside the standalone dart gclient checkout. | |
44 try: | |
45 import gyp | |
46 except ImportError, e: | |
47 sys.path.append(os.path.abspath(gyp_pylib)) | |
48 import gyp | |
49 | |
50 | |
51 if __name__ == '__main__': | |
52 # Make our own location absolute as it is stored in Makefiles. | |
53 sys.argv[0] = os.path.abspath(sys.argv[0]) | |
54 | |
55 # Add any extra arguments. Needed by compiler/dart.gyp to build v8. | |
56 args = sys.argv[2:] | |
57 | |
58 args += ['--depth', project_src] | |
59 args += ['-I', './tools/gyp/common.gypi'] | |
60 | |
61 if platform.system() == 'Linux': | |
62 # We need to fiddle with toplevel-dir to work around a GYP bug | |
63 # that breaks building v8 from compiler/dart.gyp. | |
64 args += ['--toplevel-dir', os.curdir] | |
65 args += ['--generator-output', project_src] | |
66 else: | |
67 # On at least the Mac, the toplevel-dir should be where the | |
68 # sources are. Otherwise, Xcode won't show sources correctly. | |
69 args += ['--toplevel-dir', project_src] | |
70 | |
71 if sys.platform == 'win32': | |
72 # Generate Visual Studio 2008 compatible files by default. | |
73 if not os.environ.get('GYP_MSVS_VERSION'): | |
74 args.extend(['-G', 'msvs_version=2008']) | |
75 | |
76 # Change into the dart directory as we want the project to be rooted here. | |
77 # Also, GYP is very sensitive to exacly from where it is being run. | |
78 os.chdir(dart_src) | |
79 | |
80 args += [GetProjectGypFile(project_src)] | |
81 | |
82 # Generate the projects. | |
83 sys.exit(gyp.main(args)) | |
OLD | NEW |