From a060d25ef2d71567d4057016d22f318ffda9dcf7 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 22 Apr 2016 20:05:53 +0200 Subject: [PATCH] add support for copying arbitrary files this adds file_copies.prf, which understands the variable COPIES, which works analogously to INSTALLS. i've been holding this off for a long time, as it is not without caveats. however, similar hacks are proliferating all over the code base, so it's time we formalized it. in fact, it's the easiest way to fix some nasty shadow build problems, which is why i'm adding this on the stable branch. Task-number: QTBUG-52256 Change-Id: Icbe3b9fbb79c952546aad2d467a438d3a69d749f Reviewed-by: Liang Qi Reviewed-by: Joerg Bornemann --- mkspecs/features/file_copies.prf | 41 ++++++++++++++++++++++++++++++++ mkspecs/features/spec_pre.prf | 2 +- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 mkspecs/features/file_copies.prf diff --git a/mkspecs/features/file_copies.prf b/mkspecs/features/file_copies.prf new file mode 100644 index 00000000000..f679129e030 --- /dev/null +++ b/mkspecs/features/file_copies.prf @@ -0,0 +1,41 @@ +isEmpty(COPIES): return() +contains(TEMPLATE, .*subdirs): error("COPIES does not work with TEMPLATE=subdirs") + +build_pass:build_all: \ + debug_and_release:debug { + # Avoid that multiple build passes race with each other. + # This will fail to copy anything if the user explicitly invokes + # only the non-primary build. This is unfixable, as at qmake time + # we cannot possibly know how make will be invoked, yet we must + # predict it here. + return() +} + +defineReplace(qtStripProPwd) { + return($$relative_path($$1, $$_PRO_FILE_PWD_)) +} + +for (cp, COPIES) { + isEmpty($${cp}.files): next() + pfx = copy_$${cp} + for (f, $${cp}.files): \ + $${pfx}.files += $$absolute_path($$f, $$_PRO_FILE_PWD_) + path = $$eval($${cp}.path) + isEmpty(path): error("COPY $cp defines no .path") + base = $$eval($${cp}.base) + isEmpty(base) { + $${pfx}.output = $$path/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT} + } else: isEqual(base, $$_PRO_FILE_PWD_) { + $${pfx}.output = $$path/${QMAKE_FUNC_FILE_IN_qtStripProPwd} + } else { + eval(defineReplace(qtStripSrcDir_$$cp) { \ + return(\$\$relative_path(\$\$1, $$val_escape(base))) \ + }) + $${pfx}.output = $$path/${QMAKE_FUNC_FILE_IN_qtStripSrcDir_$$cp} + } + $${pfx}.input = $${pfx}.files + $${pfx}.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT} + $${pfx}.name = COPY ${QMAKE_FILE_IN} + $${pfx}.CONFIG = no_link no_clean target_predeps + QMAKE_EXTRA_COMPILERS += $${pfx} +} diff --git a/mkspecs/features/spec_pre.prf b/mkspecs/features/spec_pre.prf index ff310d9793f..090f348ebff 100644 --- a/mkspecs/features/spec_pre.prf +++ b/mkspecs/features/spec_pre.prf @@ -51,5 +51,5 @@ equals(QMAKE_HOST.os, Windows) { QMAKE_SH = sh } -CONFIG = qt warn_on release link_prl +CONFIG = file_copies qt warn_on release link_prl QT = core gui