From af0696048223c0113245983dec4d7623fba2791a Mon Sep 17 00:00:00 2001 From: James Duley Date: Wed, 25 Mar 2015 14:46:52 +1300 Subject: [PATCH] OP-1792 Makefile tidy: set dependencies for copydata by using new functions addCopyFileTarget and addCopyDirTarget --- ground/openpilotgcs/copydata.pro | 128 +++++++----------- ground/openpilotgcs/openpilotgcs.pri | 51 +++++++ ground/openpilotgcs/share/copydata.pro | 15 +- .../src/libs/sdlgamepad/copydata.pro | 8 +- .../src/plugins/hitl/aerosimrc/src/plugin.pro | 12 +- 5 files changed, 102 insertions(+), 112 deletions(-) diff --git a/ground/openpilotgcs/copydata.pro b/ground/openpilotgcs/copydata.pro index bf9d7b4d7..94482e4c2 100644 --- a/ground/openpilotgcs/copydata.pro +++ b/ground/openpilotgcs/copydata.pro @@ -4,34 +4,7 @@ TEMPLATE = aux # Copy Qt runtime libraries into the build directory (to run or package) equals(copyqt, 1) { - - # Copy QtQuick2 complete directories - # Some of these directories have a lot of files - # Easier to copy everything - QT_QUICK2_DIRS = QtQuick/Controls \ - QtQuick/Dialogs \ - QtQuick/Layouts \ - QtQuick/LocalStorage \ - QtQuick/Particles.2 \ - QtQuick/PrivateWidgets \ - QtQuick/Window.2 \ - QtQuick/XmlListModel \ - QtQuick.2 - - # create QtQuick directory - data_copy.commands += -@$(MKDIR) $$targetPath(\"$$GCS_QT_QML_PATH/QtQuick\") $$addNewline() - - for(dir, QT_QUICK2_DIRS) { - data_copy.commands += @rm -rf $$targetPath(\"$$GCS_QT_QML_PATH/$$dir\") $$addNewline() - data_copy.commands += $(COPY_DIR) $$targetPath(\"$$[QT_INSTALL_QML]/$$dir\") $$targetPath(\"$$GCS_QT_QML_PATH/$$dir\") $$addNewline() - } - - data_copy.depends = FORCE - QMAKE_EXTRA_TARGETS += data_copy - PRE_TARGETDEPS += data_copy - linux { - QT_LIBS = libQt5Core.so.5 \ libQt5Gui.so.5 \ libQt5Widgets.so.5 \ @@ -57,35 +30,21 @@ equals(copyqt, 1) { libicui18n.so.53 \ libicuuc.so.53 \ libicudata.so.53 - - data_copy.commands += -@$(MKDIR) $$targetPath(\"$$GCS_QT_LIBRARY_PATH\") $$addNewline() for(lib, QT_LIBS) { - data_copy.commands += $(COPY_FILE) $$targetPath(\"$$[QT_INSTALL_LIBS]/$$lib\") $$targetPath(\"$$GCS_QT_LIBRARY_PATH/$$lib\") $$addNewline() + addCopyFileTarget($${lib},$$[QT_INSTALL_LIBS],$${GCS_QT_LIBRARY_PATH}) } - # create Qt plugin directories - QT_PLUGIN_DIRS = iconengines \ - imageformats \ - platforms \ - mediaservice \ - sqldrivers - for(dir, QT_PLUGIN_DIRS) { - data_copy.commands += -@$(MKDIR) $$targetPath(\"$$GCS_QT_PLUGINS_PATH/$$dir\") $$addNewline() - } - QT_PLUGIN_LIBS = iconengines/libqsvgicon.so \ - imageformats/libqgif.so \ - imageformats/libqico.so \ - imageformats/libqjpeg.so \ - imageformats/libqmng.so \ - imageformats/libqsvg.so \ - imageformats/libqtiff.so \ - mediaservice/libgstaudiodecoder.so \ - mediaservice/libgstmediaplayer.so \ - platforms/libqxcb.so \ - sqldrivers/libqsqlite.so - for(lib, QT_PLUGIN_LIBS) { - data_copy.commands += $(COPY_FILE) $$targetPath(\"$$[QT_INSTALL_PLUGINS]/$$lib\") $$targetPath(\"$$GCS_QT_PLUGINS_PATH/$$lib\") $$addNewline() - } + QT_PLUGINS = iconengines/libqsvgicon.so \ + imageformats/libqgif.so \ + imageformats/libqico.so \ + imageformats/libqjpeg.so \ + imageformats/libqmng.so \ + imageformats/libqsvg.so \ + imageformats/libqtiff.so \ + mediaservice/libgstaudiodecoder.so \ + mediaservice/libgstmediaplayer.so \ + platforms/libqxcb.so \ + sqldrivers/libqsqlite.so } win32 { @@ -121,33 +80,7 @@ equals(copyqt, 1) { libstdc++-6.dll \ libwinpthread-1.dll for(dll, QT_DLLS) { - data_copy.commands += $(COPY_FILE) $$targetPath(\"$$[QT_INSTALL_BINS]/$$dll\") $$targetPath(\"$$GCS_APP_PATH/$$dll\") $$addNewline() - } - - # create Qt plugin directories - QT_PLUGIN_DIRS = iconengines \ - imageformats \ - platforms \ - mediaservice \ - sqldrivers \ - opengl32_32 - for(dir, QT_PLUGIN_DIRS) { - data_copy.commands += -@$(MKDIR) $$targetPath(\"$$GCS_APP_PATH/$$dir\") $$addNewline() - } - - # copy Qt plugin DLLs - QT_PLUGIN_DLLS = iconengines/qsvgicon$${DS}.dll \ - imageformats/qgif$${DS}.dll \ - imageformats/qico$${DS}.dll \ - imageformats/qjpeg$${DS}.dll \ - imageformats/qmng$${DS}.dll \ - imageformats/qsvg$${DS}.dll \ - imageformats/qtiff$${DS}.dll \ - platforms/qwindows$${DS}.dll \ - mediaservice/dsengine$${DS}.dll \ - sqldrivers/qsqlite$${DS}.dll - for(dll, QT_PLUGIN_DLLS) { - data_copy.commands += $(COPY_FILE) $$targetPath(\"$$[QT_INSTALL_PLUGINS]/$$dll\") $$targetPath(\"$$GCS_APP_PATH/$$dll\") $$addNewline() + addCopyFileTarget($${dll},$$[QT_INSTALL_BINS],$${GCS_APP_PATH}) } # copy OpenSSL DLLs @@ -155,14 +88,45 @@ equals(copyqt, 1) { ssleay32.dll \ libeay32.dll for(dll, OPENSSL_DLLS) { - data_copy.commands += $(COPY_FILE) $$targetPath(\"$${OPENSSL_DIR}/$$dll\") $$targetPath(\"$$GCS_APP_PATH/$$dll\") $$addNewline() + addCopyFileTarget($${dll},$${OPENSSL_DIR},$${GCS_APP_PATH}) } # copy OpenGL DLL OPENGL_DLLS = \ opengl32_32/opengl32.dll for(dll, OPENGL_DLLS) { - data_copy.commands += $(COPY_FILE) $$targetPath(\"$${MESAWIN_DIR}/$$dll\") $$targetPath(\"$$GCS_APP_PATH/$$dll\") $$addNewline() + addCopyFileTarget($${dll},$${MESAWIN_DIR},$${GCS_APP_PATH}) } + + QT_PLUGINS = iconengines/qsvgicon$${DS}.dll \ + imageformats/qgif$${DS}.dll \ + imageformats/qico$${DS}.dll \ + imageformats/qjpeg$${DS}.dll \ + imageformats/qmng$${DS}.dll \ + imageformats/qsvg$${DS}.dll \ + imageformats/qtiff$${DS}.dll \ + platforms/qwindows$${DS}.dll \ + mediaservice/dsengine$${DS}.dll \ + sqldrivers/qsqlite$${DS}.dll + } + + for(plugin, QT_PLUGINS) { + addCopyFileTarget($${plugin},$$[QT_INSTALL_PLUGINS],$${GCS_QT_PLUGINS_PATH}) + } + + # Copy QtQuick2 complete directories + # Some of these directories have a lot of files + # Easier to copy everything + QT_QUICK2_DIRS = QtQuick/Controls \ + QtQuick/Dialogs \ + QtQuick/Layouts \ + QtQuick/LocalStorage \ + QtQuick/Particles.2 \ + QtQuick/PrivateWidgets \ + QtQuick/Window.2 \ + QtQuick/XmlListModel \ + QtQuick.2 + for(dir, QT_QUICK2_DIRS) { + addCopyDirTarget($${dir},$$[QT_INSTALL_QML],$${GCS_QT_QML_PATH}) } } diff --git a/ground/openpilotgcs/openpilotgcs.pri b/ground/openpilotgcs/openpilotgcs.pri index cbf44dd75..b09693eaf 100644 --- a/ground/openpilotgcs/openpilotgcs.pri +++ b/ground/openpilotgcs/openpilotgcs.pri @@ -32,6 +32,55 @@ defineReplace(qtLibraryName) { return($$RET) } +defineTest(addCopyFileTarget) { + file = $$1 + src = $$2/$$1 + dest = $$3/$$1 + + $${file}.target = $$dest + $${file}.depends = $$src + + # create directory. Better would be an order only dependency + $${file}.commands = -@$(MKDIR) \"$$targetPath($$dirname(dest))\" $$addNewline() + $${file}.commands += $(COPY_FILE) \"$$targetPath($$src)\" \"$$targetPath($$dest)\" + + QMAKE_EXTRA_TARGETS += $$file + POST_TARGETDEPS += $$eval($${file}.target) + + export($${file}.target) + export($${file}.depends) + export($${file}.commands) + export(QMAKE_EXTRA_TARGETS) + export(POST_TARGETDEPS) + + return(true) +} + +defineTest(addCopyDirTarget) { + dir = $$1 + src = $$2/$$1 + dest = $$3/$$1 + + $${dir}.target = $$dest + $${dir}.depends = $$src + + $${dir}.commands = @rm -rf \"$$targetPath($$dest)\" $$addNewline() + # create directory. Better would be an order only dependency + $${dir}.commands += -@$(MKDIR) \"$$targetPath($$dirname(dest))\" $$addNewline() + $${dir}.commands += $(COPY_DIR) \"$$targetPath($$src)\" \"$$targetPath($$dest)\" + + QMAKE_EXTRA_TARGETS += $$dir + POST_TARGETDEPS += $$eval($${dir}.target) + + export($${dir}.target) + export($${dir}.depends) + export($${dir}.commands) + export(QMAKE_EXTRA_TARGETS) + export(POST_TARGETDEPS) + + return(true) +} + # For use in custom compilers which just copy files win32:i_flag = i defineReplace(stripSrcDir) { @@ -119,6 +168,8 @@ macx { contains(TEMPLATE, vc.*)|contains(TEMPLATE_PREFIX, vc):vcproj = 1 GCS_APP_TARGET = openpilotgcs + + GCS_QT_PLUGINS_PATH = $$GCS_APP_PATH GCS_QT_QML_PATH = $$GCS_APP_PATH copyqt = $$copydata diff --git a/ground/openpilotgcs/share/copydata.pro b/ground/openpilotgcs/share/copydata.pro index 2b3a89b6e..b9c2a1875 100644 --- a/ground/openpilotgcs/share/copydata.pro +++ b/ground/openpilotgcs/share/copydata.pro @@ -7,20 +7,7 @@ DATACOLLECTIONS = cloudconfig default_configurations dials models pfd sounds dia equals(copydata, 1) { for(dir, DATACOLLECTIONS) { exists($$GCS_SOURCE_TREE/share/openpilotgcs/$$dir) { - # Qt make macros (CHK_DIR_EXISTS, COPY_DIR, etc) have different syntax. They cannot be used - # reliably to copy subdirectories in two different Windows environments (bash and cmd/QtCreator). - # So undocumented QMAKE_SH variable is used to find out the real environment. - !isEmpty(QMAKE_SH) { - # sh environment (including Windows bash) - data_copy.commands += $(MKDIR) $$targetPath(\"$$GCS_DATA_PATH/$$dir\") $$addNewline() - data_copy.commands += $(COPY_DIR) $$targetPath(\"$$GCS_SOURCE_TREE/share/openpilotgcs/$$dir\") $$targetPath(\"$$GCS_DATA_PATH/\") $$addNewline() - } else { - # native Windows cmd environment - data_copy.commands += $(COPY_DIR) $$targetPath(\"$$GCS_SOURCE_TREE/share/openpilotgcs/$$dir\") $$targetPath(\"$$GCS_DATA_PATH/$$dir\") $$addNewline() - } + addCopyDirTarget($$dir, $$GCS_SOURCE_TREE/share/openpilotgcs, $$GCS_DATA_PATH) } } - data_copy.depends = FORCE - QMAKE_EXTRA_TARGETS += data_copy - PRE_TARGETDEPS += data_copy } diff --git a/ground/openpilotgcs/src/libs/sdlgamepad/copydata.pro b/ground/openpilotgcs/src/libs/sdlgamepad/copydata.pro index 91cc5292c..af9cecbff 100644 --- a/ground/openpilotgcs/src/libs/sdlgamepad/copydata.pro +++ b/ground/openpilotgcs/src/libs/sdlgamepad/copydata.pro @@ -1,16 +1,10 @@ equals(copydata, 1) { - win32 { # copy SDL DLL SDL_DLLS = \ SDL.dll for(dll, SDL_DLLS) { - data_copy.commands += $(COPY_FILE) $$targetPath(\"$${SDL_DIR}/bin/$$dll\") $$targetPath(\"$$GCS_APP_PATH/$$dll\") $$addNewline() + addCopyFileTarget($${dll},$${SDL_DIR}/bin,$${GCS_APP_PATH}) } - - data_copy.depends = FORCE - QMAKE_EXTRA_TARGETS += data_copy - PRE_TARGETDEPS += data_copy } - } diff --git a/ground/openpilotgcs/src/plugins/hitl/aerosimrc/src/plugin.pro b/ground/openpilotgcs/src/plugins/hitl/aerosimrc/src/plugin.pro index dc809e67d..5f4c57579 100644 --- a/ground/openpilotgcs/src/plugins/hitl/aerosimrc/src/plugin.pro +++ b/ground/openpilotgcs/src/plugins/hitl/aerosimrc/src/plugin.pro @@ -35,8 +35,6 @@ equals(copydata, 1) { # Windows release only win32:CONFIG(release, debug|release) { - data_copy.commands += -@$(MKDIR) $$targetPath(\"$$PLUGIN_DIR\") $$addNewline() - # resources and sample configuration PLUGIN_RESOURCES = \ cc_off.tga \ @@ -46,7 +44,7 @@ equals(copydata, 1) { cc_plugin.ini \ plugin.txt for(res, PLUGIN_RESOURCES) { - data_copy.commands += $(COPY_FILE) $$targetPath(\"$$RES_DIR/$$res\") $$targetPath(\"$$PLUGIN_DIR/$$res\") $$addNewline() + addCopyFileTarget($${res},$${RES_DIR},$${PLUGIN_DIR}) } # Qt DLLs @@ -54,7 +52,7 @@ equals(copydata, 1) { Qt5Core.dll \ Qt5Network.dll for(dll, QT_DLLS) { - data_copy.commands += $(COPY_FILE) $$targetPath(\"$$[QT_INSTALL_BINS]/$$dll\") $$targetPath(\"$$SIM_DIR/$$dll\") $$addNewline() + addCopyFileTarget($${dll},$$[QT_INSTALL_BINS],$${SIM_DIR}) } # MinGW DLLs @@ -62,11 +60,7 @@ equals(copydata, 1) { # libgcc_s_dw2-1.dll \ # mingwm10.dll #for(dll, MINGW_DLLS) { - # data_copy.commands += $(COPY_FILE) $$targetPath(\"$$(QTMINGW)/$$dll\") $$targetPath(\"$$SIM_DIR/$$dll\") $$addNewline() + # addCopyFileTarget($${dll},$$(QTMINGW),$${SIM_DIR}) #} - - data_copy.depends = FORCE - QMAKE_EXTRA_TARGETS += data_copy - PRE_TARGETDEPS += data_copy } }