Skip to content

Commit

Permalink
qmake: use extra compiler to copy qml plugin files. simplify make cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Jan 24, 2014
1 parent 5832ca1 commit 4001989
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 33 deletions.
22 changes: 9 additions & 13 deletions pack.pri
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
#Designed by Wang Bin(Lucas Wang). 2013 <[email protected]>

##TODO: Why use function to add makefile target failed
# add a make command
defineReplace(mcmd) {
return($$escape_expand(\\n\\t)$$1)
}

#defineTest(packageSet) {
# isEmpty(1): warning("packageSet(version [, name]")
# PACKAGE_VERSION = $$1
Expand Down Expand Up @@ -62,17 +57,18 @@ ARCH = `dpkg --print-architecture`
fakeroot.target = fakeroot
fakeroot.depends = FORCE
fakeroot.commands = rm -rf fakeroot && mkdir -p fakeroot/usr/share/doc/$$PACKAGE_NAME && mkdir -p fakeroot/DEBIAN
fakeroot.commands += $$mcmd(chmod -R 755 fakeroot) ##control dir must be 755
fakeroot.commands += $$quote(chmod -R 755 fakeroot) ##control dir must be 755

deb.target = deb
deb.depends += fakeroot
deb.commands += $$mcmd(make install INSTALL_ROOT=\$\$PWD/fakeroot)
deb.commands += $$mcmd(cd fakeroot; md5sum `find usr -type f |grep -v DEBIAN` > DEBIAN/md5sums; cd -)
deb.commands += $$mcmd(cp $$PWD/qtc_packaging/debian_$${PLATFORM}/control fakeroot/DEBIAN)
deb.commands += $$mcmd(sed -i \"s/%arch%/$${ARCH}/\" fakeroot/DEBIAN/control)
deb.commands += $$mcmd(sed -i \"s/%version%/$${PACKAGE_VERSION}/\" fakeroot/DEBIAN/control)
deb.commands += $$mcmd(gzip -9 fakeroot/usr/share/doc/$$PACKAGE_NAME/changelog)
deb.commands += $$mcmd(dpkg -b fakeroot $${PACKAGE_NAME}_$${PACKAGE_VERSION}_$${PLATFORM}_$${ARCH}.deb)
deb.commands += $$quote(make install INSTALL_ROOT=\$\$PWD/fakeroot)
deb.commands += $$quote(cd fakeroot; md5sum `find usr -type f |grep -v DEBIAN` > DEBIAN/md5sums; cd -)
deb.commands += $$quote(cp $$PWD/qtc_packaging/debian_$${PLATFORM}/control fakeroot/DEBIAN)
deb.commands += $$quote(sed -i \"s/%arch%/$${ARCH}/\" fakeroot/DEBIAN/control)
deb.commands += $$quote(sed -i \"s/%version%/$${PACKAGE_VERSION}/\" fakeroot/DEBIAN/control)
deb.commands += $$quote(gzip -9 fakeroot/usr/share/doc/$$PACKAGE_NAME/changelog)
deb.commands += $$quote(dpkg -b fakeroot $${PACKAGE_NAME}_$${PACKAGE_VERSION}_$${PLATFORM}_$${ARCH}.deb)
deb.commands = $$join(deb.commands,$$escape_expand(\\n\\t))

#message("deb.commands: $$deb.commands")
QMAKE_EXTRA_TARGETS += fakeroot deb
Expand Down
5 changes: 3 additions & 2 deletions qml/libQmlAV.pri
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,11 @@ DEPENDPATH *= $$PROJECT_SRCPATH
}

shared {
!CONFIG(plugin) {
!plugin {
!isEqual(DESTDIR, $$BUILD_DIR/bin): DLLDESTDIR = $$BUILD_DIR/bin #copy shared lib there
}
CONFIG(release, debug|release): !isEmpty(QMAKE_STRIP): QMAKE_POST_LINK = -$$QMAKE_STRIP $$PROJECT_LIBDIR/$$qtSharedLib($$NAME)
#QMAKE_POST_LINK+=: just append as a string to previous QMAKE_POST_LINK
CONFIG(release, debug|release): !isEmpty(QMAKE_STRIP): QMAKE_POST_LINK = $$quote(-$$QMAKE_STRIP $$shell_path($$DESTDIR/$$qtSharedLib($$NAME)))
#copy from the pro creator creates.
symbian {
MMP_RULES += EXPORTUNFROZEN
Expand Down
39 changes: 21 additions & 18 deletions qml/libQmlAV.pro
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,41 @@ preparePaths($$OUT_PWD/../out)
#DESTDIR = $$BUILD_DIR/bin/QtAV
RESOURCES +=
message($$BUILD_DIR)
# add a make command
defineReplace(mcmd) {
return($$escape_expand(\\n\\t)$$1)
}

QML_FILES = $$PWD/Video.qml
plugin.files = $$PWD/qmldir $$PWD/Video.qml $$DESTDIR/$$qtSharedLib($$NAME)
# TODO: why add more files e.g. qmldir cause make error?
plugin.files = $$DESTDIR/$$qtSharedLib($$NAME)
plugin.path = $$BUILD_DIR/bin/qml/QtAV/ #TODO: Qt install dir
#plugin.depends = #makefile target
#windows: copy /y file1+file2+... dir. need '+'
for(f, plugin.files) {
plugin.commands += $$mcmd(-\$\(COPY_FILE\) $$shell_path($$f) $$shell_path($$plugin.path))
plugin.commands += $$quote(-\$\(COPY_FILE\) $$shell_path($$f) $$shell_path($$plugin.path))
}
#join values seperated by space. so quote is needed
plugin.commands = $$join(plugin.commands,$$escape_expand(\\n\\t))
OTHER_FILES += $$PWD/qmldir $$PWD/Video.qml
QMAKE_POST_LINK += $$plugin.commands #just append as a string to $$QMAKE_POST_LINK
#just append as a string to $$QMAKE_POST_LINK
isEmpty(QMAKE_POST_LINK): QMAKE_POST_LINK = $$plugin.commands
else: QMAKE_POST_LINK = $${QMAKE_POST_LINK}$$escape_expand(\\n\\t)$$plugin.commands

QMAKE_EXTRA_TARGETS = plugin
#POST_TARGETDEPS = plugin #vs, xcode does not support
mkpath($$plugin.path)

#http://stackoverflow.com/questions/14260542/qmake-extra-compilers-processing-steps
#http://danny-pope.com/?p=86
#custom compiler: auto update if source is newer
#TODO: QMAKE_FIlE_EXT does not work
plugin_maker.output = ${QMAKE_FILE_BASE}${QMAKE_FIlE_EXT}
#plugin_maker.targetdir = $$plugin.path #not exist
plugin_maker.commands = -\$\(COPY_FILE\) ${QMAKE_FILE_NAME} $$shell_path($$plugin.path)${QMAKE_FILE_OUT}
plugin_maker.depends = $$PLUGIN_FILES
plugin_maker.input = PLUGIN_FILES
plugin_maker.CONFIG += no_link
plugin_maker.variable_out = POST_TARGETDEPS
#QMAKE_EXTRA_COMPILERS += plugin_maker

PLUGIN_FILES = $$PWD/qmldir $$PWD/Video.qml $$DESTDIR/$$qtSharedLib($$NAME)
extra_copy.output = $$shell_path($$plugin.path)${QMAKE_FILE_BASE}${QMAKE_FILE_EXT}
# test dir and mkdir here?
extra_copy.commands = -\$\(COPY_FILE\) ${QMAKE_FILE_NAME} $$shell_path($$plugin.path)
#extra_copy.depends = $$EXTRA_COPY_FILES #.input is already the depends
extra_copy.input = EXTRA_COPY_FILES
extra_copy.CONFIG += no_link
extra_copy.variable_out = POST_TARGETDEPS
QMAKE_EXTRA_COMPILERS += extra_copy
# CAN NOT put $$TARGET here otherwise may result in circular dependency.
# update EXTRA_COPY_FILES will result in target relink
EXTRA_COPY_FILES = $$PWD/qmldir $$PWD/Video.qml

win32 {
RC_FILE = #$${PROJECTROOT}/res/QtAV.rc
Expand Down

0 comments on commit 4001989

Please sign in to comment.