Thursday, January 9, 2014

QtCreator and Ninja warning/error parsing

We have a custom build binary that launches ninja and we couldn't get QtCreator to parse the warnings from that output. Errors/warnings show up, they just weren't being parsed. I finally got QtCreator building with symbols and tracked it down to this in makestep.cpp:

 267     if (m_useNinja)
 268         AbstractProcessStep::stdError(line);
 269     else
 270         AbstractProcessStep::stdOutput(line);

Ninja is processing stderr and regular makefiles are processing stdout. So I added this to our custom shell script and it's working now:

Command: .../bin/mkvogl.sh
Arguments: --amd64 --debug 3>&1 1>&2 2>&3

I guess if you ever find QtCreator isn't parsing your output, try swapping stderr and stdout. :)

If anyone wants to get QtCreator building release with symbols on something vaguely resembling 64-bit Linux Mint 16, this is what I wound up doing:

apt-get install: libgl1-mesa-dev libxml2-dev libglib2.0-dev libxslt1-dev libglib2.0-dev libgstreamer-plugins-base0.10-dev libgstreamer0.10-dev
diff --git a/qtcreator.pri b/qtcreator.pri
index 1750705..9be9c03 100644
--- a/qtcreator.pri
+++ b/qtcreator.pri
@@ -180,6 +180,9 @@ unix {

     RCC_DIR = $${OUT_PWD}/.rcc
     UI_DIR = $${OUT_PWD}/.uic
+
+    QMAKE_CXXFLAGS_RELEASE += -g
+    QMAKE_CFLAGS_RELEASE += -g
 }

 win32-msvc* {
cd ~/dev/qt-creator/src
qmake -r
make

If there is a better way of achieving this, please let me know - I don't know much about qmake and couldn't find anything...

Wednesday, January 8, 2014

QtCreator projects

I've switched to using QtCreator 3.0 as my main editor. I'm really liking it (and FakeVim!), but one big issue we've run into is projects. What files are loaded, what defines are set, files not listed in our makefiles (.sh), listing include files in our makefiles just so they're in the project, etc. It also likes to blast .user files where you open your makefile and now we're dealing with getting mercurial or git to ignore those, etc.

I wrote the below which just finds everything under our vogl project directory with specified extensions. It also takes some patterns to remove files after the fact (possibly someone can tell me a more optimal way of doing this?).

Next I'm going to figure out how to get QtCreator to parse ninja build output. (Grumble, grumble. :)

In any case, throwing it up here in case someone might find it useful...

#
# VoglProj QtCreator cmake file.
#
# Do the following in the directory above your vogl enlistment:
#
#  ln -s vogl/bin/qtcreator/CMakeLists.txt
#
# Then open it up with QtCreator and you should be off and running.
#
project(VoglProj)
cmake_minimum_required(VERSION 2.8)

# List of file extensions that we search for.
set(EXTLIST *.i *.sh *.inl *.inc *.txt *.vs *.vp *.frag *.vert *.py *.m *.c* *.h* *.S)

# Vogl directory.
set(VOGL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/vogl")
if(NOT EXISTS "${VOGL_DIR}/")
    message("\nERROR: ${VOGL_DIR} does not exist. Please put this script one level up from your vogl enlistement.\n")
    message(FATAL_ERROR "Exiting...")
endif()

# Create list of vogl directorie plus extensions.
set(GLOBSPEC)
foreach(ext ${EXTLIST})
    list(APPEND GLOBSPEC ${VOGL_DIR}/${ext})
endforeach()

# Search for all the files.
file(GLOB_RECURSE vogl_srcs
    RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
    ${GLOBSPEC}
    )

# Macro to remove files based on regex pattern.
macro(RemoveSrcFiles pat)
    set(result)
    foreach(file ${vogl_srcs})
        if(file MATCHES ${pat})
        else()
            list(APPEND result ${file})
        endif()
    endforeach()
    set(vogl_srcs ${result})
endmacro()

# Remove all files under .git and .hg directories.
RemoveSrcFiles("/[.]git/")
RemoveSrcFiles("/[.]hg/")

# Spew out all files we've found.
set(count 0)
foreach(file ${vogl_srcs})
    message("${file}")
    math(EXPR count "${count} + 1")
endforeach()

message("${count} files added.\n")

add_executable(VoglProj ${vogl_srcs})
set_target_properties(VoglProj PROPERTIES LINKER_LANGUAGE C)