【问题标题】:How to make qmake to do a clean rebuild if DEFINES are changed如果 DEFINES 更改,如何使 qmake 进行干净的重建
【发布时间】:2013-06-07 13:48:53
【问题描述】:

...它应该做但没有。

这对我来说是 qmake 的主要挫折之一。 qbs 是我们 Qt 的未来,但现在我们仍然坚持使用 qmake。那么,有什么办法呢?

【问题讨论】:

    标签: qmake


    【解决方案1】:

    我滥用 QMAKE_EXTRA_COMPILERS 来完成这个。我需要使用它,因为我必须在处理完所有功能后获取 DEFINES 值。

    # in this function all the work is done
    defineReplace(checkDefinesForChanges) {
      old_def = $$cat($$OUT_PWD/defines.txt)
      curr_def = $$DEFINES
      curr_def -= $$old_def
      old_def -= $$DEFINES
      diff = $$old_def $$curr_def
      # delete all files in OUT_PWD if macros were changed
      !isEmpty(diff) {
        A = $$system(del /F /Q /S $$system_path($${OUT_PWD}/*.*))
        message(DEFINES WERE CHANGED)
      }
      write_file($$OUT_PWD/defines.txt, DEFINES);
      return(???)
    }
    
    # use QMAKE_EXTRA_COMPILERS to launch function
    # checkDefinesForChanges after all features processing
    _defines_check_ = ???
    defines_check.name = check on defines being changed
    defines_check.input = _defines_check_
    defines_check.CONFIG += no_link ignore_no_exist
    defines_check.depends = ???
    defines_check.commands = ???
    defines_check.output_function = checkDefinesForChanges
    defines_check.clean = 333
    QMAKE_EXTRA_COMPILERS += defines_check
    
    # make sure qmake is run if deines.txt is deleted
    recompile_on_defines_txt_not_existsing.target = $(MAKEFILE)
    recompile_on_defines_txt_not_existsing.depends = $$OUT_PWD/defines.txt
    recompile_on_defines_txt_not_existsing2.target = $$OUT_PWD/defines.txt
    recompile_on_defines_txt_not_existsing2.depends = qmake
    QMAKE_EXTRA_TARGETS += recompile_on_defines_txt_not_existsing recompile_on_defines_txt_not_existsing2    
    

    Source in Russian

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-15
      • 1970-01-01
      • 2019-03-12
      • 1970-01-01
      • 2013-09-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多