Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(257)

Side by Side Diff: gyp_skia

Issue 1813233002: Make Win runtime DLLs writeable before overwriting (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env 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).
11 11
12 import glob 12 import glob
13 import os 13 import os
14 import platform 14 import platform
15 import shlex 15 import shlex
16 import stat
16 import sys 17 import sys
17 18
18 script_dir = os.path.abspath(os.path.dirname(__file__)) 19 script_dir = os.path.abspath(os.path.dirname(__file__))
19 20
20 # Directory within which we can find the gyp source. 21 # Directory within which we can find the gyp source.
21 gyp_source_dir = os.path.join(script_dir, 'third_party', 'externals', 'gyp') 22 gyp_source_dir = os.path.join(script_dir, 'third_party', 'externals', 'gyp')
22 23
23 # Directory within which we can find most of Skia's gyp configuration files. 24 # Directory within which we can find most of Skia's gyp configuration files.
24 gyp_config_dir = os.path.join(script_dir, 'gyp') 25 gyp_config_dir = os.path.join(script_dir, 'gyp')
25 26
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 elif sys.platform.startswith('win'): 84 elif sys.platform.startswith('win'):
84 default_gyp_generators = 'ninja,msvs-ninja' 85 default_gyp_generators = 'ninja,msvs-ninja'
85 elif sys.platform.startswith('cygwin'): 86 elif sys.platform.startswith('cygwin'):
86 default_gyp_generators = 'ninja,msvs-ninja' 87 default_gyp_generators = 'ninja,msvs-ninja'
87 else: 88 else:
88 default_gyp_generators = 'ninja' 89 default_gyp_generators = 'ninja'
89 os.environ[ENVVAR_GYP_GENERATORS] = default_gyp_generators 90 os.environ[ENVVAR_GYP_GENERATORS] = default_gyp_generators
90 print ('%s environment variable not set, using default, %s' % 91 print ('%s environment variable not set, using default, %s' %
91 (ENVVAR_GYP_GENERATORS, default_gyp_generators)) 92 (ENVVAR_GYP_GENERATORS, default_gyp_generators))
92 93
93 vs2013_runtime_dll_dirs = None 94 vs_runtime_dll_dirs = None
94 if os.getenv('CHROME_HEADLESS', '0') == '1': 95 if os.getenv('CHROME_HEADLESS', '0') == '1':
95 if sys.platform.startswith('win') or sys.platform.startswith('cygwin'): 96 if sys.platform.startswith('win') or sys.platform.startswith('cygwin'):
96 chrome_path = os.getenv('CHROME_PATH') 97 chrome_path = os.getenv('CHROME_PATH')
97 os.chdir(chrome_path) 98 os.chdir(chrome_path)
98 sys.path.append(os.path.join(chrome_path, 'build')) 99 sys.path.append(os.path.join(chrome_path, 'build'))
99 sys.path.append(os.path.join(chrome_path, 'tools')) 100 sys.path.append(os.path.join(chrome_path, 'tools'))
100 import vs_toolchain 101 import vs_toolchain
101 vs2013_runtime_dll_dirs = \ 102 vs_runtime_dll_dirs = \
102 vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs() 103 vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs()
103 104
104 # Set CWD to the directory containing this script. 105 # Set CWD to the directory containing this script.
105 # This allows us to launch it from other directories, in spite of gyp's 106 # This allows us to launch it from other directories, in spite of gyp's
106 # finickyness about the current working directory. 107 # finickyness about the current working directory.
107 # See http://b.corp.google.com/issue?id=5019517 ('Linux make build 108 # See http://b.corp.google.com/issue?id=5019517 ('Linux make build
108 # (from out dir) no longer runs skia_gyp correctly') 109 # (from out dir) no longer runs skia_gyp correctly')
109 os.chdir(os.path.abspath(script_dir)) 110 os.chdir(os.path.abspath(script_dir))
110 111
111 # This could give false positives since it doesn't actually do real option 112 # This could give false positives since it doesn't actually do real option
112 # parsing. Oh well. 113 # parsing. Oh well.
113 gyp_file_specified = False 114 gyp_file_specified = False
114 for arg in args: 115 for arg in args:
115 if arg.endswith('.gyp'): 116 if arg.endswith('.gyp'):
116 gyp_file_specified = True 117 gyp_file_specified = True
117 break 118 break
118 119
119 # If we didn't get a file, then fall back to assuming 'skia.gyp' from the 120 # If we didn't get a file, then fall back to assuming 'skia.gyp' from the
120 # same directory as the script. 121 # same directory as the script.
121 # The gypfile must be passed as a relative path, not an absolute path, 122 # The gypfile must be passed as a relative path, not an absolute path,
122 # or else the gyp code doesn't write into the proper output dir. 123 # or else the gyp code doesn't write into the proper output dir.
123 if not gyp_file_specified: 124 if not gyp_file_specified:
124 args.append('skia.gyp') 125 args.append('skia.gyp')
125 126
126 args.extend(['-I' + i for i in additional_include_files(args)]) 127 args.extend(['-I' + i for i in additional_include_files(args)])
127 args.extend(['--depth', '.']) 128 args.extend(['--depth', '.'])
128 129
129 # Tell gyp to write the build files into output_dir. 130 # Tell gyp to write the build files into output_dir.
130 args.extend(['--generator-output', os.path.abspath(get_output_dir())]) 131 out_dir = os.path.abspath(get_output_dir())
132 args.extend(['--generator-output', out_dir])
131 133
132 # Tell ninja to write its output into the same directory. 134 # Tell ninja to write its output into the same directory.
133 args.extend(['-Goutput_dir=%s' % gyp_output_dir]) 135 args.extend(['-Goutput_dir=%s' % gyp_output_dir])
134 136
135 # By default, we build 'most' instead of 'all' or 'everything'. See skia.gyp. 137 # By default, we build 'most' instead of 'all' or 'everything'. See skia.gyp.
136 args.extend(['-Gdefault_target=most']) 138 args.extend(['-Gdefault_target=most'])
137 139
138 # Fail if any files specified in the project are missing 140 # Fail if any files specified in the project are missing
139 if sys.platform.startswith('win'): 141 if sys.platform.startswith('win'):
140 gyp_generator_flags = os.getenv(ENVVAR_GYP_GENERATOR_FLAGS, '') 142 gyp_generator_flags = os.getenv(ENVVAR_GYP_GENERATOR_FLAGS, '')
(...skipping 10 matching lines...) Expand all
151 args.remove('--dry-run') 153 args.remove('--dry-run')
152 print gyp_source_dir, ' '.join(args) 154 print gyp_source_dir, ' '.join(args)
153 else: 155 else:
154 # Off we go... 156 # Off we go...
155 res = gyp.main(args) 157 res = gyp.main(args)
156 if res: 158 if res:
157 sys.exit(res) 159 sys.exit(res)
158 160
159 # This code is copied from Chrome's build/gyp_chromium. It's not clear why 161 # This code is copied from Chrome's build/gyp_chromium. It's not clear why
160 # the *_runtime variables are reversed. 162 # the *_runtime variables are reversed.
161 if vs2013_runtime_dll_dirs: 163 if vs_runtime_dll_dirs:
162 x64_runtime, x86_runtime = vs2013_runtime_dll_dirs 164 # The DLLs might be read-only, which will cause an error when attempting to
165 # overwrite them. Make them writeable first.
166 for path, dirs, files in os.walk(out_dir):
167 for f in files:
168 if f.endswith('.dll'):
169 os.chmod(os.path.join(path, f), stat.S_IWRITE)
170
171 x64_runtime, x86_runtime = vs_runtime_dll_dirs
163 vs_toolchain.CopyVsRuntimeDlls( 172 vs_toolchain.CopyVsRuntimeDlls(
164 os.path.join(os.getenv('CHROME_PATH'), get_output_dir()), 173 os.path.join(os.getenv('CHROME_PATH'), out_dir),
165 (x86_runtime, x64_runtime)) 174 (x86_runtime, x64_runtime))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698