xmake-io / xmake

🔥 A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
9.87k stars 776 forks source link

User's `qt.deploy.flags` should have priority over defaults #5351

Closed yh-sb closed 2 months ago

yh-sb commented 2 months ago

5350

jingkaimori commented 2 months ago

@waruqi @yh-sb value of qt.deploy.flags may be array, but there is no table:find method.

> xmake l
xmake> ({"-print"}):find("-p", 1, true) 
stdin:1: method 'find' is not callable (a nil value)
stack traceback:
        stdin:1: in main chunk
        [C]: in function 'sandbox/sandbox.interactive'
        ...dir\core\sandbox\modules\import\core\sandbox\sandbox.lua:102: in field 'interactive'
        @programdir\plugins\lua\main.lua:183: in function <@programdir\plugins\lua\main.lua:161>
        (...tail calls...)
        [C]: in function 'xpcall'
        @programdir\core\base\utils.lua:275: in function 'base/utils.trycall'
        (...tail calls...)
        @programdir\core\base\task.lua:491: in function 'base/task.run'
        @programdir\core\main.lua:327: in upvalue 'cotask'
        @programdir\core\base\scheduler.lua:406: in function <@programdir\core\base\scheduler.lua:399>

thus the follow code will throw error when running xmake install:

add_rules("mode.debug", "mode.release")

add_requires("qt5widgets")

target("testqt2")
    add_rules("qt.widgetapp")
    set_values("qt.deploy.flags", {"-printsupport", "--no-opengl-sw", "--no-translations"})
    add_headerfiles("src/*.h")
    add_files("src/*.cpp")
    add_files("src/mainwindow.ui")
    -- add files with Q_OBJECT meta (only for qt.moc)
    add_files("src/mainwindow.h")
    add_packages("qt5widgets")
waruqi commented 2 months ago

@waruqi @yh-sb value of qt.deploy.flags may be array, but there is no table:find method.

> xmake l
xmake> ({"-print"}):find("-p", 1, true) 
stdin:1: method 'find' is not callable (a nil value)
stack traceback:
        stdin:1: in main chunk
        [C]: in function 'sandbox/sandbox.interactive'
        ...dir\core\sandbox\modules\import\core\sandbox\sandbox.lua:102: in field 'interactive'
        @programdir\plugins\lua\main.lua:183: in function <@programdir\plugins\lua\main.lua:161>
        (...tail calls...)
        [C]: in function 'xpcall'
        @programdir\core\base\utils.lua:275: in function 'base/utils.trycall'
        (...tail calls...)
        @programdir\core\base\task.lua:491: in function 'base/task.run'
        @programdir\core\main.lua:327: in upvalue 'cotask'
        @programdir\core\base\scheduler.lua:406: in function <@programdir\core\base\scheduler.lua:399>

thus the follow code will throw error when running xmake install:

add_rules("mode.debug", "mode.release")

add_requires("qt5widgets")

target("testqt2")
    add_rules("qt.widgetapp")
    set_values("qt.deploy.flags", {"-printsupport", "--no-opengl-sw", "--no-translations"})
    add_headerfiles("src/*.h")
    add_files("src/*.cpp")
    add_files("src/mainwindow.ui")
    -- add files with Q_OBJECT meta (only for qt.moc)
    add_files("src/mainwindow.h")
    add_packages("qt5widgets")

you can open a pr to improve it.