OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 # Copyright 2011 The Android Open Source Project | 3 # Copyright 2011 The Android Open Source Project |
4 # | 4 # |
5 # Use of this source code is governed by a BSD-style license that can be | 5 # Use of this source code is governed by a BSD-style license that can be |
6 # found in the LICENSE file. | 6 # found in the LICENSE file. |
7 | 7 |
8 # This script is a wrapper which invokes gyp with the correct --depth argument, | 8 # This script is a wrapper which invokes gyp with the correct --depth argument, |
9 # and supports the automatic regeneration of build files if all.gyp is | 9 # and supports the automatic regeneration of build files if all.gyp is |
10 # changed (Linux-only). | 10 # changed (Linux-only). |
(...skipping 10 matching lines...) Expand all Loading... |
21 gyp_source_dir = os.path.join(script_dir, 'third_party', 'externals', 'gyp') | 21 gyp_source_dir = os.path.join(script_dir, 'third_party', 'externals', 'gyp') |
22 | 22 |
23 # Directory within which we can find most of Skia's gyp configuration files. | 23 # Directory within which we can find most of Skia's gyp configuration files. |
24 gyp_config_dir = os.path.join(script_dir, 'gyp') | 24 gyp_config_dir = os.path.join(script_dir, 'gyp') |
25 | 25 |
26 # Ensure we import our current gyp source's module, not any version | 26 # Ensure we import our current gyp source's module, not any version |
27 # pre-installed in your PYTHONPATH. | 27 # pre-installed in your PYTHONPATH. |
28 sys.path.insert(0, os.path.join(gyp_source_dir, 'pylib')) | 28 sys.path.insert(0, os.path.join(gyp_source_dir, 'pylib')) |
29 import gyp | 29 import gyp |
30 | 30 |
| 31 ENVVAR_GYP_GENERATORS = 'GYP_GENERATORS' |
| 32 |
| 33 |
31 def additional_include_files(args=[]): | 34 def additional_include_files(args=[]): |
32 # Determine the include files specified on the command line. | 35 # Determine the include files specified on the command line. |
33 # This doesn't cover all the different option formats you can use, | 36 # This doesn't cover all the different option formats you can use, |
34 # but it's mainly intended to avoid duplicating flags on the automatic | 37 # but it's mainly intended to avoid duplicating flags on the automatic |
35 # makefile regeneration which only uses this format. | 38 # makefile regeneration which only uses this format. |
36 specified_includes = set() | 39 specified_includes = set() |
37 for arg in args: | 40 for arg in args: |
38 if arg.startswith('-I') and len(arg) > 2: | 41 if arg.startswith('-I') and len(arg) > 2: |
39 specified_includes.add(os.path.realpath(arg[2:])) | 42 specified_includes.add(os.path.realpath(arg[2:])) |
40 | 43 |
(...skipping 14 matching lines...) Expand all Loading... |
55 # be written. | 58 # be written. |
56 def get_output_dir(): | 59 def get_output_dir(): |
57 | 60 |
58 # SKIA_OUT can be any directory either as a child of the standard out/ | 61 # SKIA_OUT can be any directory either as a child of the standard out/ |
59 # directory or any given location on the file system (e.g. /tmp/skia) | 62 # directory or any given location on the file system (e.g. /tmp/skia) |
60 output_dir = os.getenv('SKIA_OUT') | 63 output_dir = os.getenv('SKIA_OUT') |
61 | 64 |
62 if not output_dir: | 65 if not output_dir: |
63 return os.path.join(os.path.abspath(script_dir), 'out') | 66 return os.path.join(os.path.abspath(script_dir), 'out') |
64 | 67 |
65 if (sys.platform.startswith('darwin') and | 68 if (sys.platform.startswith('darwin') and |
66 (not os.getenv('GYP_GENERATORS') or | 69 (not os.getenv(ENVVAR_GYP_GENERATORS) or |
67 'xcode' in os.getenv('GYP_GENERATORS'))): | 70 'xcode' in os.getenv(ENVVAR_GYP_GENERATORS))): |
68 print 'ERROR: variable SKIA_OUT is not valid on Mac (using xcodebuild)' | 71 print 'ERROR: variable SKIA_OUT is not valid on Mac (using xcodebuild)' |
69 sys.exit(-1); | 72 sys.exit(-1); |
70 | 73 |
71 if os.path.isabs(output_dir): | 74 if os.path.isabs(output_dir): |
72 return output_dir | 75 return output_dir |
73 else: | 76 else: |
74 return os.path.join(os.path.abspath(script_dir), output_dir) | 77 return os.path.join(os.path.abspath(script_dir), output_dir) |
75 | 78 |
76 | 79 |
77 if __name__ == '__main__': | 80 if __name__ == '__main__': |
78 args = sys.argv[1:] | 81 args = sys.argv[1:] |
79 | 82 |
| 83 if not os.getenv(ENVVAR_GYP_GENERATORS): |
| 84 print ('%s environment variable not set, using default' % |
| 85 ENVVAR_GYP_GENERATORS) |
| 86 if sys.platform.startswith('darwin'): |
| 87 default_gyp_generators = 'xcode' |
| 88 elif sys.platform.startswith('win'): |
| 89 default_gyp_generators = 'msvs' |
| 90 elif sys.platform.startswith('cygwin'): |
| 91 default_gyp_generators = 'msvs' |
| 92 else: |
| 93 default_gyp_generators = 'make' |
| 94 os.environ[ENVVAR_GYP_GENERATORS] = default_gyp_generators |
| 95 print '%s is "%s"' % (ENVVAR_GYP_GENERATORS, os.getenv(ENVVAR_GYP_GENERATORS)) |
| 96 |
80 # Set CWD to the directory containing this script. | 97 # Set CWD to the directory containing this script. |
81 # This allows us to launch it from other directories, in spite of gyp's | 98 # This allows us to launch it from other directories, in spite of gyp's |
82 # finickyness about the current working directory. | 99 # finickyness about the current working directory. |
83 # See http://b.corp.google.com/issue?id=5019517 ('Linux make build | 100 # See http://b.corp.google.com/issue?id=5019517 ('Linux make build |
84 # (from out dir) no longer runs skia_gyp correctly') | 101 # (from out dir) no longer runs skia_gyp correctly') |
85 os.chdir(os.path.abspath(script_dir)) | 102 os.chdir(os.path.abspath(script_dir)) |
86 | 103 |
87 # This could give false positives since it doesn't actually do real option | 104 # This could give false positives since it doesn't actually do real option |
88 # parsing. Oh well. | 105 # parsing. Oh well. |
89 gyp_file_specified = False | 106 gyp_file_specified = False |
(...skipping 19 matching lines...) Expand all Loading... |
109 args.extend(['-Goutput_dir=.']) | 126 args.extend(['-Goutput_dir=.']) |
110 | 127 |
111 # By default, we build 'most' instead of 'all' or 'everything'. See skia.gyp. | 128 # By default, we build 'most' instead of 'all' or 'everything'. See skia.gyp. |
112 args.extend(['-Gdefault_target=most']) | 129 args.extend(['-Gdefault_target=most']) |
113 | 130 |
114 print 'Updating projects from gyp files...' | 131 print 'Updating projects from gyp files...' |
115 sys.stdout.flush() | 132 sys.stdout.flush() |
116 | 133 |
117 # Off we go... | 134 # Off we go... |
118 sys.exit(gyp.main(args)) | 135 sys.exit(gyp.main(args)) |
OLD | NEW |