diff options
author | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2014-02-27 17:42:48 +0100 |
---|---|---|
committer | Andras Becsi <andras.becsi@digia.com> | 2014-06-04 18:19:55 +0200 |
commit | 43923809b83f3b6919f346cdaffd37c608971252 (patch) | |
tree | 58d63fc00e271672f5fa0c8941f69a6429661099 /chromium/tools/gyp | |
parent | 6ebae8b61ce66fb247e7c497b2086db68adeb2a0 (diff) | |
download | qtwebengine-chromium-43923809b83f3b6919f346cdaffd37c608971252.tar.gz |
<tools/gyp> Allow letting qmake do the link step
This adds a let_qmake_do_the_linking target variable to tell ninja
not to link but rather dump the linking information from gyp in a
file that we'll parse with qmake.
Reviewed-by: Zoltan Arvai <zarvai@inf.u-szeged.hu>
Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Change-Id: I753888776679e449d7a64b6bf5b47e7a60dfa827
Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
Diffstat (limited to 'chromium/tools/gyp')
-rw-r--r-- | chromium/tools/gyp/pylib/gyp/generator/ninja.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/chromium/tools/gyp/pylib/gyp/generator/ninja.py b/chromium/tools/gyp/pylib/gyp/generator/ninja.py index a1692348873..909c8d820b7 100644 --- a/chromium/tools/gyp/pylib/gyp/generator/ninja.py +++ b/chromium/tools/gyp/pylib/gyp/generator/ninja.py @@ -1101,6 +1101,49 @@ class NinjaWriter: else: command = command + '_notoc' + if config.get('let_qmake_do_the_linking', 0): + def toAbsPaths(paths): + return [os.path.relpath(path, self.toplevel_build) if os.path.isabs(path) else path + for path in paths] + def qmakeLiteral(s): + return s.replace('"', '\\"') + + # Generate this file for all solink targets, this assumes that + # a .pro file will pick up this pri file and do the rest of the work. + pri_file = open(os.path.join(self.toplevel_build, self.name + "_linking.pri"), 'w') + + if self.flavor == 'win': + # qmake will take care of the manifest + ldflags = filter(lambda x: not x.lower().startswith('/manifest'), ldflags) + + # Replace "$!PRODUCT_DIR" with "$$PWD" in link flags (which might contain some -L directives). + prefixed_lflags = [self.ExpandSpecial(f, '$$PWD') for f in ldflags] + prefixed_library_dirs = ['-L' + self.ExpandSpecial(f, '$$PWD') for f in config.get('library_dirs', [])] + prefixed_libraries = gyp.common.uniquer([self.ExpandSpecial(f, '$$PWD') for f in spec.get('libraries', [])]) + if self.flavor == 'mac': + prefixed_libraries = self.xcode_settings.AdjustLibraries(prefixed_libraries) + elif self.flavor == 'win': + prefixed_libraries = self.msvs_settings.AdjustLibraries(prefixed_libraries) + + # Make sure that we have relative paths to our out/(Release|Debug), where we generate our .pri file, and then prepend $$PWD to them. + prefixed_object_and_archives = ['$$PWD/' + o for o in toAbsPaths(link_deps)] + + pri_file.write("QMAKE_LFLAGS += %s\n" % qmakeLiteral(' '.join(prefixed_lflags))) + # Follow the logic of the solink rule. + if self.flavor != 'mac' and self.flavor != 'win': + pri_file.write("LIBS_PRIVATE += -Wl,--whole-archive %s -Wl,--no-whole-archive\n" % qmakeLiteral(' '.join(prefixed_object_and_archives))) + else: + pri_file.write("LIBS_PRIVATE += %s\n" % qmakeLiteral(' '.join(prefixed_object_and_archives))) + # External libs have to come after objects/archives, the linker resolve them in order. + pri_file.write("LIBS_PRIVATE += %s\n" % qmakeLiteral(' '.join(prefixed_library_dirs + prefixed_libraries))) + # Make sure that if ninja modifies one of the inputs, qmake/make will link again. + pri_file.write("POST_TARGETDEPS += %s\n" % qmakeLiteral(' '.join(prefixed_object_and_archives))) + pri_file.close() + + # In this mode we prevent letting ninja link at all. + command = 'phony' + command_suffix = '' + if len(solibs): extra_bindings.append(('solibs', gyp.common.EncodePOSIXShellList(solibs))) |