Results 1 to 2 of 2

Thread: Creating lint build targets

  1. #1
    Join Date
    Jun 2007
    Posts
    56
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Creating lint build targets

    Hello,

    I am trying to include in my project file for qmake, support for extra build targets that will run lint on my source and create lint output that is tied to the source file name.

    Snippet from my project file...

    SOURCES += fileone.cpp \
    filetwo.cpp \
    filethree.cpp

    INCLUDEPATH += /usr/include/somepath \
    /home/user/somepath

    MYSOURCES = SOURCES
    for( name, $$MYSOURCES ) {
    exists( $$name ) {
    tmp_source = name
    name ~= s/\.cpp//
    lint_targets += $${name}.lint
    sub.target = $${name}.lint
    sub.commands = flint -os $${name}.lint -i $$INCLUDEPATH $${tmp_source}
    QMAKE_EXTRA_TARGETS += sub
    unset( sub )
    }
    }

    linttarget.target = lint
    linttarget.depends = $$lint_targets

    QMAKE_EXTRA_TARGETS += linttarget
    When I run qmake on it, it generates the following Makefile snippet...
    filethree.lint:
    flint -os filethree.lint -i /usr/include/somepath /home/usr/somepath name

    filethree.lint:
    flint -os filethree.lint -i /usr/include/somepath /home/usr/somepath name

    filethree.lint:
    flint -os filethree.lint -i /usr/include/somepath /home/usr/somepath name

    lint: fileone.lint filetwo.lint filethree.lint
    I think I just figured out the reason "name" is on the end of each of the commands for the lint targets.

    I can't figure out why the QMAKE_EXTRA_TARGETS doesn't generate the expected targets with the proper command line.

    Any help would be appreciated.

    Oh, BTW, I using Qt 4.3.1 on Linux

    -Mic

  2. #2
    Join Date
    Jun 2007
    Posts
    56
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Creating lint build targets

    Reply to my own thread!

    I solved my problem by using QMAKE_EXTRA_COMPILER instead and treating the lint program as a separate compiler
    Qt Code:
    1. mylint.output = ${QMAKE_FILE_BASE}.lint
    2. mylint.input = SOURCES
    3. mylint.CONFIG = no_link
    4. mylint.commands = llint -os ${QMAKE_FILE_OUT} $${mylint_include_path} ${QMAKE_FILE_NAME}
    5. QMAKE_EXTRA_COMPILERS += mylint
    6.  
    7. linttarget.target = lint
    8. linttarget.depends = $$lint_targets # computed above (see original post)
    9. QMAKE_EXTRA_TARGETS += linttarget
    To copy to clipboard, switch view to plain text mode 

    It ain't pretty, but it works. I now have an extra make target called lint that depends on fileone.lint filetwo.lint filethree.lint

    Those in turn are generated by the extra compiler that invokes lint on each source.

    I still would like to have a finer control on things like the include paths but without 3 or 4 weeks to dive into the guts of qmake, this works for me. Hopefully it helps someone else.

    -Mic

Similar Threads

  1. Build error on mac Platform::WaitMouseMoved
    By patrik08 in forum Qt Programming
    Replies: 1
    Last Post: 12th July 2007, 13:18

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.