From e4adad45d0438dd5238886c983b8857e436afc23 Mon Sep 17 00:00:00 2001 From: Mathew Sutcliffe Date: Tue, 6 Oct 2015 18:09:23 +0100 Subject: [PATCH] refs #482 Rationalized the copying of files from source tree to build tree. --- mkspecs/features/common_post.prf | 6 ++++++ mkspecs/features/copyfiles.pri | 26 ++++++++++++++++++++++++++ resources/swift_resources.pro | 16 ++++++++++++---- src/blackgui/blackgui.pro | 14 +------------- src/blackgui/stylesheetutility.cpp | 2 +- src/blackmisc/blackmisc.pro | 17 ----------------- src/blackmisc/project.cpp | 2 +- src/blacksound/blacksound.pro | 14 +------------- src/blacksound/soundgenerator.cpp | 12 ++++++------ 9 files changed, 54 insertions(+), 55 deletions(-) create mode 100644 mkspecs/features/copyfiles.pri diff --git a/mkspecs/features/common_post.prf b/mkspecs/features/common_post.prf index 5695e201f..2abbb89f6 100644 --- a/mkspecs/features/common_post.prf +++ b/mkspecs/features/common_post.prf @@ -1,3 +1,9 @@ +################################ +# Copy data files to build dir +################################ + +include(copyfiles.pri) + ################################ # Externals ################################ diff --git a/mkspecs/features/copyfiles.pri b/mkspecs/features/copyfiles.pri new file mode 100644 index 000000000..44bd77eac --- /dev/null +++ b/mkspecs/features/copyfiles.pri @@ -0,0 +1,26 @@ +copy_files.name = COPY +copy_files.input = COPY_FILES +copy_files.CONFIG = no_link + +copy_files.output_function = fileCopyDestination +defineReplace(fileCopyDestination) { + return($$DestRoot/$$relative_path($$1)) +} + +win32:isEmpty(MINGW_IN_SHELL) { + copy_files.commands = copy /y ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT} +} +else { + copy_files.commands = mkdir -p `dirname ${QMAKE_FILE_OUT}` && \ + cp ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT} +} + +QMAKE_EXTRA_COMPILERS += copy_files + + +# This CONFIG should be all that is needed to add a dependency to "make all" +# but some snafu with absolute vs. relative paths necessitates this workaround +# with PRE_TARGETDEPS instead. + +#copy_files.CONFIG += target_predeps +PRE_TARGETDEPS += compiler_copy_files_make_all diff --git a/resources/swift_resources.pro b/resources/swift_resources.pro index 184c15c6e..c61811333 100644 --- a/resources/swift_resources.pro +++ b/resources/swift_resources.pro @@ -1,7 +1,15 @@ -TEMPLATE = subdirs +load(common_pre) + +TEMPLATE = lib +CONFIG += staticlib +CONFIG -= qt -OTHER_FILES += *.pri OTHER_FILES += data/images/flags/*.png OTHER_FILES += data/images/airlines/*.png -OTHER_FILES += data/swiftdb/*.* -OTHER_FILES += data/vatsim/*.* +OTHER_FILES += swiftDB/*.* + +COPY_FILES += $$PWD/data/images/flags/*.png +COPY_FILES += $$PWD/data/images/airlines/*.png +COPY_FILES += $$PWD/swiftDB/*.* + +load(common_post) diff --git a/src/blackgui/blackgui.pro b/src/blackgui/blackgui.pro index 432ef9380..754e06dbd 100644 --- a/src/blackgui/blackgui.pro +++ b/src/blackgui/blackgui.pro @@ -54,18 +54,6 @@ DESTDIR = $$DestRoot/lib DLLDESTDIR = $$DestRoot/bin OTHER_FILES += ./qss/*.qss ./qss/*.css ./qss/*.ini *.ico *.rc - -win32:isEmpty(MINGW_IN_SHELL): COPY = xcopy /yi -else: COPY = cp -r - -win32 { - QMAKE_POST_LINK += $$COPY $$shell_path($$PWD/qss) \ - $$shell_path($$DestRoot/bin/qss) -} -else { - QMAKE_POST_LINK += mkdir -p $$shell_path($$DestRoot/bin) && \ - $$COPY $$shell_path($$PWD/qss) \ - $$shell_path($$DestRoot/bin) -} +COPY_FILES += $$PWD/qss/* load(common_post) diff --git a/src/blackgui/stylesheetutility.cpp b/src/blackgui/stylesheetutility.cpp index 76fca1cf8..0521d5d48 100644 --- a/src/blackgui/stylesheetutility.cpp +++ b/src/blackgui/stylesheetutility.cpp @@ -321,7 +321,7 @@ namespace BlackGui { QString dirPath = QCoreApplication::applicationDirPath(); if (!dirPath.endsWith('/')) dirPath.append('/'); - dirPath.append("qss"); + dirPath.append("../qss"); return dirPath; } diff --git a/src/blackmisc/blackmisc.pro b/src/blackmisc/blackmisc.pro index c766a5e78..bd2f1ba4b 100644 --- a/src/blackmisc/blackmisc.pro +++ b/src/blackmisc/blackmisc.pro @@ -57,21 +57,4 @@ DLLDESTDIR = $$DestRoot/bin OTHER_FILES += $$TRANSLATIONS readme.txt -win32:isEmpty(MINGW_IN_SHELL): COPY = xcopy /yis -else: COPY = cp -r - -win32 { - QMAKE_PRE_LINK += $$COPY $$shell_path($$SourceRoot/resources/data) \ - $$shell_path($$DestRoot/resources) \ - & $$COPY $$shell_path($$SourceRoot/resources/swiftDB) \ - $$shell_path($$DestRoot/resources/swiftDB) -} -else { - QMAKE_PRE_LINK += mkdir -p $$shell_path($$DestRoot/resources) \ - && $$COPY $$shell_path($$SourceRoot/resources/data) \ - $$shell_path($$DestRoot/resources) \ - && $$COPY $$shell_path($$SourceRoot/resources/swiftDB) \ - $$shell_path($$DestRoot/resources/swiftDB) -} - load(common_post) diff --git a/src/blackmisc/project.cpp b/src/blackmisc/project.cpp index ddffdf9b5..2211be4c1 100644 --- a/src/blackmisc/project.cpp +++ b/src/blackmisc/project.cpp @@ -233,7 +233,7 @@ namespace BlackMisc QString CProject::getSwiftResourceDir() { QDir dir(getApplicationDir()); - if (dir.cd("resources")) { return dir.absolutePath(); } + if (dir.cdUp()) { return dir.absolutePath(); } return ""; } diff --git a/src/blacksound/blacksound.pro b/src/blacksound/blacksound.pro index 2aaea9a7c..6e8b3b444 100644 --- a/src/blacksound/blacksound.pro +++ b/src/blacksound/blacksound.pro @@ -27,19 +27,7 @@ DESTDIR = $$DestRoot/lib DLLDESTDIR = $$DestRoot/bin OTHER_FILES += ./sounds/*.wav sounds/readme.txt +COPY_FILES += $$PWD/sounds/* RESOURCES += -win32:isEmpty(MINGW_IN_SHELL): COPY = xcopy /yi -else: COPY = cp -r - -win32 { - QMAKE_POST_LINK += $$COPY $$shell_path($$PWD/sounds) \ - $$shell_path($$DestRoot/bin/sounds) -} -else { - QMAKE_POST_LINK += mkdir -p $$shell_path($$DestRoot/bin) && \ - $$COPY $$shell_path($$PWD/sounds) \ - $$shell_path($$DestRoot/bin) -} - load(common_post) diff --git a/src/blacksound/soundgenerator.cpp b/src/blacksound/soundgenerator.cpp index 2b36df6d3..74fce3590 100644 --- a/src/blacksound/soundgenerator.cpp +++ b/src/blacksound/soundgenerator.cpp @@ -492,12 +492,12 @@ namespace BlackSound // order here is crucial, needs to be the same as in CSoundGenerator::Notification if (!playlist) playlist = new QMediaPlaylist(mediaPlayer); bool success = true; - success = playlist->addMedia(QUrl::fromLocalFile(QCoreApplication::applicationDirPath().append("/sounds/error.wav"))) && success; - success = playlist->addMedia(QUrl::fromLocalFile(QCoreApplication::applicationDirPath().append("/sounds/login.wav"))) && success; - success = playlist->addMedia(QUrl::fromLocalFile(QCoreApplication::applicationDirPath().append("/sounds/logoff.wav"))) && success; - success = playlist->addMedia(QUrl::fromLocalFile(QCoreApplication::applicationDirPath().append("/sounds/privatemessage.wav"))) && success; - success = playlist->addMedia(QUrl::fromLocalFile(QCoreApplication::applicationDirPath().append("/sounds/voiceroomjoined.wav"))) && success; - success = playlist->addMedia(QUrl::fromLocalFile(QCoreApplication::applicationDirPath().append("/sounds/voiceroomleft.wav"))) && success; + success = playlist->addMedia(QUrl::fromLocalFile(QCoreApplication::applicationDirPath().append("/../sounds/error.wav"))) && success; + success = playlist->addMedia(QUrl::fromLocalFile(QCoreApplication::applicationDirPath().append("/../sounds/login.wav"))) && success; + success = playlist->addMedia(QUrl::fromLocalFile(QCoreApplication::applicationDirPath().append("/../sounds/logoff.wav"))) && success; + success = playlist->addMedia(QUrl::fromLocalFile(QCoreApplication::applicationDirPath().append("/../sounds/privatemessage.wav"))) && success; + success = playlist->addMedia(QUrl::fromLocalFile(QCoreApplication::applicationDirPath().append("/../sounds/voiceroomjoined.wav"))) && success; + success = playlist->addMedia(QUrl::fromLocalFile(QCoreApplication::applicationDirPath().append("/../sounds/voiceroomleft.wav"))) && success; Q_ASSERT(success); playlist->setPlaybackMode(QMediaPlaylist::CurrentItemOnce);