From 4ce1fd950d8c20d21c851340350fb2b1dc920ce4 Mon Sep 17 00:00:00 2001 From: Milian Wolff Date: Mon, 4 Aug 2014 16:16:22 +0200 Subject: Make standalone example mostly self-contained. Install qwebchannel.js file and also copy it to the build dir. This makes the examples subdirectory self-contained and useable when compiling it from the install directory. Making individual examples self-contained would cause too much code duplication, so it was not done. Change-Id: Ifeb5eac7d05b92779d24cb4da413f3fb173f992d Reviewed-by: Sumedha Widyadharma Reviewed-by: Oswald Buddenhagen --- examples/qwebchannel/exampleassets.pri | 31 ++++++++++++++++++++++++++ examples/qwebchannel/standalone/index.html | 2 +- examples/qwebchannel/standalone/main.cpp | 2 +- examples/qwebchannel/standalone/standalone.pro | 7 ++++-- 4 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 examples/qwebchannel/exampleassets.pri (limited to 'examples') diff --git a/examples/qwebchannel/exampleassets.pri b/examples/qwebchannel/exampleassets.pri new file mode 100644 index 0000000..035ca12 --- /dev/null +++ b/examples/qwebchannel/exampleassets.pri @@ -0,0 +1,31 @@ +# This adds the qwebchannel js library to an example, creating a self-contained bundle +QTDIR_build { + # Build from within Qt. Copy and install the reference lib. + jslib = $$dirname(_QMAKE_CONF_)/src/webchannel/qwebchannel.js + copyfiles = $$jslib +} else { + # This is what an actual 3rd party project would do. + jslib = qwebchannel.js +} + +# This installs all assets including qwebchannel.js, regardless of the source. +exampleassets.files += $$jslib +INSTALLS += exampleassets + +# This code ensures that all assets are present in the build directory. + +!equals(_PRO_FILE_PWD_, $$OUT_PWD) { + # Shadow build, copy all example assets. + copyfiles = $$exampleassets.files +} + +defineReplace(stripSrcDir) { + return($$basename(1)) +} + +assetcopy.input = copyfiles +assetcopy.output = $$OUT_PWD/${QMAKE_FUNC_FILE_IN_stripSrcDir} +assetcopy.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT} +assetcopy.name = COPY ${QMAKE_FILE_IN} +assetcopy.CONFIG = no_link target_predeps +QMAKE_EXTRA_COMPILERS += assetcopy diff --git a/examples/qwebchannel/standalone/index.html b/examples/qwebchannel/standalone/index.html index 8c85143..778a502 100644 --- a/examples/qwebchannel/standalone/index.html +++ b/examples/qwebchannel/standalone/index.html @@ -2,7 +2,7 @@ - +