OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # | 2 # |
3 # Copyright 2012 the V8 project authors. All rights reserved. | 3 # Copyright 2012 the V8 project authors. All rights reserved. |
4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
6 # met: | 6 # met: |
7 # | 7 # |
8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
(...skipping 20 matching lines...) Expand all Loading... |
31 # is invoked by V8 beyond what can be done in the gclient hooks. | 31 # is invoked by V8 beyond what can be done in the gclient hooks. |
32 | 32 |
33 import glob | 33 import glob |
34 import os | 34 import os |
35 import shlex | 35 import shlex |
36 import sys | 36 import sys |
37 | 37 |
38 script_dir = os.path.dirname(__file__) | 38 script_dir = os.path.dirname(__file__) |
39 v8_root = os.path.normpath(os.path.join(script_dir, os.pardir)) | 39 v8_root = os.path.normpath(os.path.join(script_dir, os.pardir)) |
40 | 40 |
| 41 if __name__ == '__main__': |
| 42 os.chdir(v8_root) |
| 43 script_dir = os.path.dirname(__file__) |
| 44 v8_root = '.' |
| 45 |
41 sys.path.insert(0, os.path.join(v8_root, 'tools')) | 46 sys.path.insert(0, os.path.join(v8_root, 'tools')) |
42 import utils | 47 import utils |
43 | 48 |
44 sys.path.insert(0, os.path.join(v8_root, 'build', 'gyp', 'pylib')) | 49 sys.path.insert(0, os.path.join(v8_root, 'build', 'gyp', 'pylib')) |
45 import gyp | 50 import gyp |
46 | 51 |
47 | 52 |
48 def apply_gyp_environment(file_path=None): | 53 def apply_gyp_environment(file_path=None): |
49 """ | 54 """ |
50 Reads in a *.gyp_env file and applies the valid keys to os.environ. | 55 Reads in a *.gyp_env file and applies the valid keys to os.environ. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 for arg in args: | 91 for arg in args: |
87 if arg.startswith('-I') and len(arg) > 2: | 92 if arg.startswith('-I') and len(arg) > 2: |
88 specified_includes.add(os.path.realpath(arg[2:])) | 93 specified_includes.add(os.path.realpath(arg[2:])) |
89 | 94 |
90 result = [] | 95 result = [] |
91 def AddInclude(path): | 96 def AddInclude(path): |
92 if os.path.realpath(path) not in specified_includes: | 97 if os.path.realpath(path) not in specified_includes: |
93 result.append(path) | 98 result.append(path) |
94 | 99 |
95 # Always include standalone.gypi | 100 # Always include standalone.gypi |
96 AddInclude(os.path.join(script_dir, 'standalone.gypi')) | 101 AddInclude(os.path.join(v8_root, 'build', 'standalone.gypi')) |
97 | 102 |
98 # Optionally add supplemental .gypi files if present. | 103 # Optionally add supplemental .gypi files if present. |
99 supplements = glob.glob(os.path.join(v8_root, '*', 'supplement.gypi')) | 104 supplements = glob.glob(os.path.join(v8_root, '*', 'supplement.gypi')) |
100 for supplement in supplements: | 105 for supplement in supplements: |
101 AddInclude(supplement) | 106 AddInclude(supplement) |
102 | 107 |
103 return result | 108 return result |
104 | 109 |
105 | 110 |
106 def run_gyp(args): | 111 def run_gyp(args): |
(...skipping 21 matching lines...) Expand all Loading... |
128 | 133 |
129 # If we didn't get a file, check an env var, and then fall back to | 134 # If we didn't get a file, check an env var, and then fall back to |
130 # assuming 'all.gyp' from the same directory as the script. | 135 # assuming 'all.gyp' from the same directory as the script. |
131 if not gyp_file_specified: | 136 if not gyp_file_specified: |
132 gyp_file = os.environ.get('V8_GYP_FILE') | 137 gyp_file = os.environ.get('V8_GYP_FILE') |
133 if gyp_file: | 138 if gyp_file: |
134 # Note that V8_GYP_FILE values can't have backslashes as | 139 # Note that V8_GYP_FILE values can't have backslashes as |
135 # path separators even on Windows due to the use of shlex.split(). | 140 # path separators even on Windows due to the use of shlex.split(). |
136 args.extend(shlex.split(gyp_file)) | 141 args.extend(shlex.split(gyp_file)) |
137 else: | 142 else: |
138 args.append(os.path.join(script_dir, 'all.gyp')) | 143 # Note that this must not start with "./" or things break. |
| 144 # So we rely on having done os.chdir(v8_root) above and use the |
| 145 # relative path. |
| 146 args.append(os.path.join('build', 'all.gyp')) |
139 | 147 |
140 args.extend(['-I' + i for i in additional_include_files(args)]) | 148 args.extend(['-I' + i for i in additional_include_files(args)]) |
141 | 149 |
142 # There shouldn't be a circular dependency relationship between .gyp files | 150 # There shouldn't be a circular dependency relationship between .gyp files |
143 args.append('--no-circular-check') | 151 args.append('--no-circular-check') |
144 | 152 |
145 # Set the GYP DEPTH variable to the root of the V8 project. | 153 # Set the GYP DEPTH variable to the root of the V8 project. |
146 args.append('--depth=' + v8_root) | 154 args.append('--depth=' + v8_root) |
147 | 155 |
148 # If V8_GYP_SYNTAX_CHECK is set to 1, it will invoke gyp with --check | 156 # If V8_GYP_SYNTAX_CHECK is set to 1, it will invoke gyp with --check |
149 # to enfore syntax checking. | 157 # to enfore syntax checking. |
150 syntax_check = os.environ.get('V8_GYP_SYNTAX_CHECK') | 158 syntax_check = os.environ.get('V8_GYP_SYNTAX_CHECK') |
151 if syntax_check and int(syntax_check): | 159 if syntax_check and int(syntax_check): |
152 args.append('--check') | 160 args.append('--check') |
153 | 161 |
154 print 'Updating projects from gyp files...' | 162 print 'Updating projects from gyp files...' |
155 sys.stdout.flush() | 163 sys.stdout.flush() |
156 | 164 |
157 # Generate for the architectures supported on the given platform. | 165 # Generate for the architectures supported on the given platform. |
158 gyp_args = list(args) | 166 gyp_args = list(args) |
159 target_arch = None | |
160 for p in gyp_args: | |
161 if p.find('-Dtarget_arch=') == 0: | |
162 target_arch = p | |
163 if target_arch is None: | |
164 gyp_args.append('-Dtarget_arch=ia32') | |
165 if utils.GuessOS() == 'linux': | 167 if utils.GuessOS() == 'linux': |
166 gyp_args.append('-S.ia32') | 168 gyp_args.append('--generator-output=out') |
167 run_gyp(gyp_args) | 169 run_gyp(gyp_args) |
168 | |
169 if utils.GuessOS() == 'linux': | |
170 gyp_args = list(args) | |
171 gyp_args.append('-Dtarget_arch=x64') | |
172 gyp_args.append('-S.x64') | |
173 run_gyp(gyp_args) | |
174 | |
175 gyp_args = list(args) | |
176 gyp_args.append('-Dv8_target_arch=arm') | |
177 gyp_args.append('-S.arm') | |
178 run_gyp(gyp_args) | |
179 | |
180 gyp_args = list(args) | |
181 gyp_args.append('-Dv8_target_arch=mips') | |
182 gyp_args.append('-S.mips') | |
183 run_gyp(gyp_args) | |
OLD | NEW |