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

Side by Side Diff: pylib/gyp/generator/ninja.py

Issue 1813053003: ninja: Add target_rpath generator flag (Closed) Base URL: https://chromium.googlesource.com/external/gyp.git@master
Patch Set: Add gyptest-target-rpath.py unit test 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 | « AUTHORS ('k') | test/linux/gyptest-target-rpath.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2013 Google Inc. All rights reserved. 1 # Copyright (c) 2013 Google Inc. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import collections 5 import collections
6 import copy 6 import copy
7 import hashlib 7 import hashlib
8 import json 8 import json
9 import multiprocessing 9 import multiprocessing
10 import os.path 10 import os.path
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 self.name = spec['target_name'] 372 self.name = spec['target_name']
373 self.toolset = spec['toolset'] 373 self.toolset = spec['toolset']
374 config = spec['configurations'][config_name] 374 config = spec['configurations'][config_name]
375 self.target = Target(spec['type']) 375 self.target = Target(spec['type'])
376 self.is_standalone_static_library = bool( 376 self.is_standalone_static_library = bool(
377 spec.get('standalone_static_library', 0)) 377 spec.get('standalone_static_library', 0))
378 # Track if this target contains any C++ files, to decide if gcc or g++ 378 # Track if this target contains any C++ files, to decide if gcc or g++
379 # should be used for linking. 379 # should be used for linking.
380 self.uses_cpp = False 380 self.uses_cpp = False
381 381
382 self.target_rpath = generator_flags.get('target_rpath', r'\$$ORIGIN/lib/')
383
382 self.is_mac_bundle = gyp.xcode_emulation.IsMacBundle(self.flavor, spec) 384 self.is_mac_bundle = gyp.xcode_emulation.IsMacBundle(self.flavor, spec)
383 self.xcode_settings = self.msvs_settings = None 385 self.xcode_settings = self.msvs_settings = None
384 if self.flavor == 'mac': 386 if self.flavor == 'mac':
385 self.xcode_settings = gyp.xcode_emulation.XcodeSettings(spec) 387 self.xcode_settings = gyp.xcode_emulation.XcodeSettings(spec)
386 if self.flavor == 'win': 388 if self.flavor == 'win':
387 self.msvs_settings = gyp.msvs_emulation.MsvsSettings(spec, 389 self.msvs_settings = gyp.msvs_emulation.MsvsSettings(spec,
388 generator_flags) 390 generator_flags)
389 arch = self.msvs_settings.GetArch(config_name) 391 arch = self.msvs_settings.GetArch(config_name)
390 self.ninja.variable('arch', self.win_env[arch]) 392 self.ninja.variable('arch', self.win_env[arch])
391 self.ninja.variable('cc', '$cl_' + arch) 393 self.ninja.variable('cc', '$cl_' + arch)
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 if def_file: 1188 if def_file:
1187 implicit_deps.add(def_file) 1189 implicit_deps.add(def_file)
1188 else: 1190 else:
1189 # Respect environment variables related to build, but target-specific 1191 # Respect environment variables related to build, but target-specific
1190 # flags can still override them. 1192 # flags can still override them.
1191 ldflags = env_ldflags + config.get('ldflags', []) 1193 ldflags = env_ldflags + config.get('ldflags', [])
1192 if is_executable and len(solibs): 1194 if is_executable and len(solibs):
1193 rpath = 'lib/' 1195 rpath = 'lib/'
1194 if self.toolset != 'target': 1196 if self.toolset != 'target':
1195 rpath += self.toolset 1197 rpath += self.toolset
1196 ldflags.append(r'-Wl,-rpath=\$$ORIGIN/%s' % rpath) 1198 ldflags.append(r'-Wl,-rpath=\$$ORIGIN/%s' % rpath)
1199 else:
1200 ldflags.append('-Wl,-rpath=%s' % self.target_rpath)
1197 ldflags.append('-Wl,-rpath-link=%s' % rpath) 1201 ldflags.append('-Wl,-rpath-link=%s' % rpath)
1198 self.WriteVariableList(ninja_file, 'ldflags', 1202 self.WriteVariableList(ninja_file, 'ldflags',
1199 map(self.ExpandSpecial, ldflags)) 1203 map(self.ExpandSpecial, ldflags))
1200 1204
1201 library_dirs = config.get('library_dirs', []) 1205 library_dirs = config.get('library_dirs', [])
1202 if self.flavor == 'win': 1206 if self.flavor == 'win':
1203 library_dirs = [self.msvs_settings.ConvertVSMacros(l, config_name) 1207 library_dirs = [self.msvs_settings.ConvertVSMacros(l, config_name)
1204 for l in library_dirs] 1208 for l in library_dirs]
1205 library_dirs = ['/LIBPATH:' + QuoteShellArgument(self.GypPathToNinja(l), 1209 library_dirs = ['/LIBPATH:' + QuoteShellArgument(self.GypPathToNinja(l),
1206 self.flavor) 1210 self.flavor)
(...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after
2418 arglists.append( 2422 arglists.append(
2419 (target_list, target_dicts, data, params, config_name)) 2423 (target_list, target_dicts, data, params, config_name))
2420 pool.map(CallGenerateOutputForConfig, arglists) 2424 pool.map(CallGenerateOutputForConfig, arglists)
2421 except KeyboardInterrupt, e: 2425 except KeyboardInterrupt, e:
2422 pool.terminate() 2426 pool.terminate()
2423 raise e 2427 raise e
2424 else: 2428 else:
2425 for config_name in config_names: 2429 for config_name in config_names:
2426 GenerateOutputForConfig(target_list, target_dicts, data, params, 2430 GenerateOutputForConfig(target_list, target_dicts, data, params,
2427 config_name) 2431 config_name)
OLDNEW
« no previous file with comments | « AUTHORS ('k') | test/linux/gyptest-target-rpath.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698