QMAKE_POST_LINK doesn't work for Android!



  • Hello,

    I've two issues not single one as mention in post subject.

    First issue:
    QMAKE_POST_LINK doesn't work for Android as mentioned below while system() works!

    Does this issue related to Android with qmake? Or there is something wrong with my code?

    .pro

    contains(ANDROID_TARGET_ARCH,armeabi-v7a) {
        CONFIG(release, debug|release) {
            APKPATH = $$shadowed($$PWD)/android-build/build/outputs/apk/android-build-debug.apk
            DISTRO_NAME = $$TARGET-android-$${PREFIX}.apk
            COMMAND = '$$PWD/distro-android/create.sh "$$APKPATH" "$$PWD" "$${DISTRO_NAME}" '
    #        Doesn't work!!!
            QMAKE_POST_LINK += $${COMMAND}
    #        Works!
    #       system($${COMMAND})
        }
    
        ANDROID_EXTRA_LIBS = \
            /home/tansu/mysql_driver_qt/libmariadb/libmariadb.so \
            /home/tansu/Qt/5.9.1/android_armv7/plugins/sqldrivers/libqsqlmysql.so
    }
    

    create.sh

    #!/bin/bash
    
    APKPATH=$1
    PROJECT=$2
    DISTRO_NAME=$3
    
    cp -f $APKPATH $PROJECT/../distro/$DISTRO_NAME
    

    Second issue
    In case I used system() instead of QMAKE_POST_LINK I noticed that qmake call the function only in case .pro is not saved!

    Does this issue is a bug in QMake? Or I miss something in my code?


  • Lifetime Qt Champion

    Hi,

    I can't really comment on that however one thing I would check is what you are getting in your script. You might not be in the folder you think you are when the post link stuff is called.



  • @SGaist Well, for chekcing my code I added message() in .pro and echo in .sh files

    .pro

    contains(ANDROID_TARGET_ARCH,armeabi-v7a) {
        CONFIG(release, debug|release) {
            APKPATH = $$shadowed($$PWD)/android-build/build/outputs/apk/android-build-debug.apk
            DISTRO_NAME = $$TARGET-android-$${PREFIX}.apk
            COMMAND = '$$PWD/distro-android/create.sh "$$APKPATH" "$$PWD" "$${DISTRO_NAME}" '
            message($${COMMAND})
    #        Doesn't work!!!
            QMAKE_POST_LINK += $${COMMAND}
    #        Works!
    #        system($${COMMAND})
        }
    
        ANDROID_EXTRA_LIBS = \
            /home/tansu/mysql_driver_qt/libmariadb/libmariadb.so \
            /home/tansu/Qt/5.9.1/android_armv7/plugins/sqldrivers/libqsqlmysql.so
    }
    

    create.sh

    #!/bin/bash
    
    APKPATH=$1
    PROJECT=$2
    DISTRO_NAME=$3
    
    echo "${PROJECT}/../distro/${DISTRO_NAME}" > ${PROJECT}/../distro/log.txt
    cp -f $APKPATH $PROJECT/../distro/$DISTRO_NAME
    

    The output of message() is correct as shown below:

    Project MESSAGE: /home/tansu/Projects/Tetris/src-qml/distro-android/create.sh "/home/tansu/Projects/Tetris/build-Tetris-Android_for_armeabi_v7a_GCC_4_9_Qt_5_9_1_for_Android_armv72-Release/android-build/build/outputs/apk/android-build-debug.apk" "/home/tansu/Projects/Tetris/src-qml" "Tetris-android-2017-08-03_04-43-05.apk" 
    

    But I couldn't get log.txt so I get pretty sure QMake doesn't call QMAKE_POST_LINK!

    In case I use:
    .pro

    contains(ANDROID_TARGET_ARCH,armeabi-v7a) {
        CONFIG(release, debug|release) {
            APKPATH = $$shadowed($$PWD)/android-build/build/outputs/apk/android-build-debug.apk
            DISTRO_NAME = $$TARGET-android-$${PREFIX}.apk
            COMMAND = '$$PWD/distro-android/create.sh "$$APKPATH" "$$PWD" "$${DISTRO_NAME}" '
            message($${COMMAND})
    #        Doesn't work!!!
    #        QMAKE_POST_LINK += $${COMMAND}
    #        Works!
            system($${COMMAND})
        }
    
        ANDROID_EXTRA_LIBS = \
            /home/tansu/mysql_driver_qt/libmariadb/libmariadb.so \
            /home/tansu/Qt/5.9.1/android_armv7/plugins/sqldrivers/libqsqlmysql.so
    }
    

    Everything goes fine except QMake doesn't call mesage() and system() functions unless .pro modified (not saved) which force me to modify .pro manually whenever I want to create a distro

    @SGaist Do you believe I've to attach a full project or a full demo project for clarifying this issue well?


  • Lifetime Qt Champion

    Yes, that would be nice.



  • @SGaist said in QMAKE_POST_LINK doesn't work for Android!:

    Yes, that would be nice.

    Whenever I try to upload the project I get this error although the zip file doesn't contain on binaries and its size is about 60KB

    0_1501802001170_Screenshot_2017-08-04_02-13-10.png



  • @tansgumus said in QMAKE_POST_LINK doesn't work for Android!:

    @SGaist said in QMAKE_POST_LINK doesn't work for Android!:

    Yes, that would be nice.

    Whenever I try to upload the project I get this error although the zip file doesn't contain on binaries and its size is about 60KB

    0_1501802001170_Screenshot_2017-08-04_02-13-10.png

    I uploaded the project on shared host because this forum doesn't work fine with attachments :(
    https://send.firefox.com/download/9f8c48f645/#s-5nIhjmzt1mvgGEyGcNvw
    [Mirror] https://www.justbeamit.com/8gbxp
    [Mirror] https://ufile.io/fue6k

    Please download QMLDistroTest.tar.bz2 (60 KB)



  • @SGaist Did you receive the project. I couldn't figure out how to fix this issue till now :(



Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.