#!/bin/bashCOUNT_ARGUMENTS=3DEFAULT_APPMODE=appDEFAULT_ACTION=buildDEFAULD_BUILDMODE=releaseif [ $# -gt "$COUNT_ARGUMENTS" ]; then exit -1fiif [ $# -lt "$COUNT_ARGUMENTS" ]; then DEFAULT_ACTION=$1fi#Создает проект, готовый к сборке#Принимает параметрами следующие значения:# $1 - тип собираемого приложения (app - приложение, lib - библиотека)# $2 - режим сборки: debug, releasecreate_project_file() { APPMODE=$1 BUILDMODE=$2 if [ -z "$APPMODE" ]; then APPMODE="$DEFAULT_APPMODE" fi if [ -z "$BUILDMODE" ]; then BUILDMODE="$DEFAULD_BUILDMODE" fi if [ "$BUILDMODE" == release ]; then BUILD_FOLDER=Release fi if [ "$BUILDMODE" == debug ]; then BUILD_FOLDER=Debug else BUILD_FOLDER=Release fi #Ищем все файлы ресурсов qt LST_QRS=`find ./src -name *.qrc -printf "%h/%f"` #Ищем все заголовочные файлы LST_H=`find ./src -name *.h -printf "%h/%f "` #Ищем все файлы реализации (исходного кода) LST_CPP=`find ./src -name "*.cpp" -a -! -name "*moc_*.cpp" -a -! -name "*qmake_*.cpp" -printf "%h/%f "` #Ищем все файлы форм в формате ui LST_UI=`find ./src -name *.ui -printf "%h/%f "` #Ищем все картинки bmp, ppm, xbm, xpm, png, mng, jpg, jpeg, gif LST_IMAGES=`find ./src \( -name "*.png" -o -name "*.bmp" -o -name "*.ppm" -o -name "*.xpm" -o -name "*.mng" -o -name "*.jpg" -o -name "*.jpeg" -o -name "*.gif" \) -printf "%h/%f "` #Имена всех найденных указанных бибилиотек для присоединения LIB_NAMES= #Все найденные указанные пути к библиотекам LIB_PATH= #Имена всех найденных указанных объявлений (DEFINES) DEF_NAMES= #Пути, по которым искать заголовочные файлы INCLUDE_PATH= #Ищем все указанные имена библиотек в файлах реализации for item in $LST_CPP; do TMP=`egrep -h "//#library_name" $item | awk '{l=length($$0)} {n=length("//#library_name ")}{print substr($$0, n, l-n+1)}'` if [ -z "$LIB_NAMES" ] ; then LIB_NAMES="$TMP" else LIB_NAMES="$LIB_NAMES $TMP" fi done #Ищем все указанные имена библиотек в заголовочных файлах for item in $LST_H; do TMP=`egrep -h "//#library_name" $item | awk '{l=length($$0)} {n=length("//#library_name ")}{print substr($$0, n, l-n+1)}'` if [ -z "$LIB_NAMES" ] ; then LIB_NAMES="$TMP" else LIB_NAMES="$LIB_NAMES $TMP" fi done #Ищем все указанные пути к библиотекам в файлах реализации for item in $LST_CPP; do TMP=`egrep -h "//#library_path" $item | awk '{l=length($$0)} {n=length("//#library_path ")}{print substr($$0, n, l-n+1)}'` if [ -z "$LIB_PATH" ] ; then LIB_PATH="$TMP" else LIB_PATH="$LIB_PATH $TMP" fi done #Ищем все указанные пути к библиотекам в заголовочных файлах for item in $LST_H; do TMP=`egrep -h "//#library_path" $item | awk '{l=length($$0)} {n=length("//#library_path ")}{print substr($$0, n, l-n+1)}'` if [ -z "$LIB_PATH" ] ; then LIB_PATH="$TMP" else LIB_PATH="$LIB_PATH $TMP" fi done #Ищем все указанные объявления в файлах реализации for item in $LST_CPP; do TMP=`egrep -h "//#define_name" $item | awk '{l=length($$0)} {n=length("//#define_name ")}{print substr($$0, n, l-n+1)}'` if [ -z "$DEF_NAMES" ] ; then DEF_NAMES="$TMP" else DEF_NAMES="$DEF_NAMES $TMP" fi done #Ищем все указанные объявления в заголовочных файлах for item in $LST_H; do TMP=`egrep -h "//#define_name" $item | awk '{l=length($$0)} {n=length("//#define_name ")}{print substr($$0, n, l-n+1)}'` if [ -z "$DEF_NAMES" ] ; then DEF_NAMES="$TMP" else DEF_NAMES="$DEF_NAMES $TMP" fi done #Ищем все указанные пути INCLUDE в файлах реализации for item in $LST_CPP; do TMP=`egrep -h "//#include_path" $item | awk '{l=length($$0)} {n=length("//#define_name ")}{print substr($$0, n, l-n+1)}'` if [ -z "$INCLUDE_PATH" ] ; then INCLUDE_PATH="$TMP" else INCLUDE_PATH="$INCLUDE_PATH $TMP" fi done #Ищем все указанные пути INCLUDE в заголовочных файлах for item in $LST_H; do TMP=`egrep -h "//#include_path" $item | awk '{l=length($$0)} {n=length("//#define_name ")}{print substr($$0, n, l-n+1)}'` if [ -z "$INCLUDE_PATH" ] ; then INCLUDE_PATH="$TMP" else INCLUDE_PATH="$INCLUDE_PATH $TMP" fi done #Отформатированная строка, содержащая все найденные указанные #в исходном коде имена библиотек для присоединения EXT_LIB_NAMES= #Отформатированная строка, содержащая все найденные указанные #в исходном коде пути к библиотекам для присоединения EXT_LIB_PATH= #Форматируем строку с именами библиотек for item in $LIB_NAMES; do EXT_LIB_NAMES="$EXT_LIB_NAMES -l$item" done #Форматируем строку с путями к библиотекам for item in $LIB_PATH; do EXT_LIB_PATH="$EXT_LIB_PATH -L$item" done #Сформатированная строка с полным указанием библиотек для присоединения EXT_LIBS="$EXT_LIB_PATH $EXT_LIB_NAMES" #Удаляем makefile rm -f Makefile.$BUILDMODE > /dev/null 2>&1 #Удаляем директории rm -r $BUILD_FOLDER > /dev/null 2>&1 #Получаем имя файла цели TARGETFILE=`pwd | xargs basename` PROJECTFILE="$TARGETFILE.$BUILDMODE.pro" #Указываем имя файла цели и перезаписываем файл проекта echo "TARGET = $TARGETFILE" > "$PROJECTFILE" #Указываем шаблом собираемого приложения echo "TEMPLATE = $APPMODE" >> "$PROJECTFILE" #Добавляем пути поиска заголовочных файлов echo "INCLUDEPATH += . src $BUILD_FOLDER/moc $INCLUDE_PATH" >> "$PROJECTFILE" #Указываем язык исходного кода echo "LANGUAGE = C++" >> "$PROJECTFILE" #Указываем дополнительные конфигурацию if [ "$APPMODE" == lib ]; then echo "CONFIG += qt warn_on thread exceptions rtti stl dll $BUILDMODE" >> "$PROJECTFILE" else echo "CONFIG += qt warn_on thread exceptions rtti stl $BUILDMODE" >> "$PROJECTFILE" fi if [ "$BUILDMODE" == debug ] ; then echo "DEFINES += __DEBUG__ $DEF_NAMES" >> "$PROJECTFILE" else if [ ! -z $DEFINES ]; then echo "DEFINES += $DEF_NAMES" >> "$PROJECTFILE" fi fi if [ ! -z "$EXT_LIBS" ]; then echo "LIBS += $EXT_LIBS" >> "$PROJECTFILE" fi echo "" >> "$PROJECTFILE" echo "" >> "$PROJECTFILE" if [ ! -z "$LST_IMAGES" ]; then echo "IMAGES = $LST_IMAGES" >> "$PROJECTFILE" fi if [ ! -z "$LST_UI" ]; then echo "FORMS = $LST_UI" >> "$PROJECTFILE" fi if [ ! -z "$LST_RS" ]; then echo "RESOURCES = $LST_RS" >> "$PROJECTFILE" fi echo "HEADERS = $LST_H" >> "$PROJECTFILE" echo "SOURCES = $LST_CPP" >> "$PROJECTFILE" echo "" >> "$PROJECTFILE" echo "" >> "$PROJECTFILE" echo "DESTDIR = $BUILD_FOLDER" >> "$PROJECTFILE" echo "OBJECTS_DIR = $BUILD_FOLDER" >> "$PROJECTFILE" echo "MOC_DIR = $BUILD_FOLDER/moc" >> "$PROJECTFILE" echo "RCC_DIR = $BUILD_FOLDER/rcc" >> "$PROJECTFILE" echo "UI_DIR = $BUILD_FOLDER/ui" >> "$PROJECTFILE" #Создаем Makefile для указанного проекта qmake -o Makefile.$BUILDMODE $PROJECTFILE #Создаем все необходимые файлы moc for item in $LST_CPP; do TMP=`egrep Q_OBJECT $item` if [ ! -z "$TMP" ]; then MOCFILENAME=`basename $item .cpp` MOCFILENAME="$MOCFILENAME.moc" moc "$item" -o "$BUILD_FOLDER/moc/$MOCFILENAME" > /dev/null 2>&1 fi done}#Собирает проект#Принимает параметрами следующие значения:# $1 - тип собираемого приложения (app - приложение, lib - библиотека)# $2 - режим сборки: debug, releasebuild_project() { BUILD_APPMODE=$1 BUILD_BUILDMODE=$2 if [ -z "$BUILD_APPMODE" ]; then BUILD_APPMODE="$DEFAULT_APPMODE" fi if [ -z "$BUILD_BUILDMODE" ]; then BUILD_BUILDMODE="$DEFAULD_BUILDMODE" fi if [ ! -f Makefile.$BUILD_BUILDMODE ]; then create_project_file $BUILD_APPMODE $BUILD_BUILDMODE fi if [ ! -f Makefile.$BUILD_BUILDMODE ]; then exit -1 fi make -f Makefile.$BUILD_BUILDMODE}#Пересобирает проект#Принимает параметрами следующие значения:# $1 - тип собыраемого приложения (app - приложение, lib - библиотека)# $2 - режим сборки: debug, releaserebuild_project() { REBUILD_APPMODE=$1 REBUILD_BUILDMODE=$2 if [ -z "$REBUILD_APPMODE" ]; then REBUILD_APPMODE="$DEFAULT_APPMODE" fi if [ -z "$REBUILD_BUILDMODE" ]; then REBUILD_BUILDMODE="$DEFAULD_BUILDMODE" fi if [ -f Makefile.$REBUILD_BUILDMODE ]; then make -f Makefile.$REBUILD_BUILDMODE clean rm -f Makefile.$REBUILD_BUILDMODE fi create_project_file $REBUILD_APPMODE $REBUILD_BUILDMODE if [ ! -f Makefile.$REBUILD_BUILDMODE ]; then exit -1 fi make -f Makefile.$REBUILD_BUILDMODE}#Какой шаблон использовать при сборке проектаRUNMODE_APP=$1#Что делать спроектомRUNMODE_ACTION=$2#Режим сборки пересборки проектаRUNMODE_BUILD=$3if [ -z "$RUNMODE_APP" ]; then RUNMODE_APP=appfiif [ -z "$RUNMODE_ACTION" ]; then RUNMODE_ACTION=buildfiif [ -z "$RUNMODE_BUILD" ]; then RUNMODE_BUILD=releaseficase "$RUNMODE_APP" in app) case "$RUNMODE_ACTION" in build) case "$RUNMODE_BUILD" in release) build_project app release ;; debug) build_project app debug ;; all) build_project app debug build_project app release ;; *) echo "Unknown build mode - \"$RUNMODE_BUILD\"" ;; esac ;; rebuild) case "$RUNMODE_BUILD" in release) rebuild_project app release ;; debug) rebuild_project app debug ;; all) rebuild_project app debug rebuild_project app release ;; *) echo "Unknown rebuild mode - \"$RUNMODE_BUILD\"" ;; esac ;; make) case "$RUNMODE_BUILD" in release) create_project_file app release ;; debug) create_project_file app debug ;; all) create_project_file app debug create_project_file app release ;; *) echo "Unknown make mode - \"$RUNMODE_BUILD\"" ;; esac ;; *) echo "Unknown action - \"$RUNMODE_ACTION\"" ;; esac ;; lib) case "$RUNMODE_ACTION" in build) case "$RUNMODE_BUILD" in release) build_project lib release ;; debug) build_project lib debug ;; all) build_project lib debug build_project lib release ;; *) echo "Unknow build lib mode - \"$RUNMODE_BUILD\"" ;; esac ;; rebuild) case "$RUNMODE_BUILD" in release) rebuild_project lib release ;; debug) rebuild_project lib debug ;; all) rebuild_project lib debug rebuild_project lib release ;; *) echo "Unknow rebuild lib mode - \"$RUNMODE_BUILD\"" ;; esac ;; make) case "$RUNMODE_BUILD" in release) create_project_file lib release ;; debug) create_project_file lib debug ;; all) create_project_file lib debug create_project_file lib release ;; *) echo "Unknow make lib mode - \"$RUNMODE_BUILD\"" ;; esac ;; *) echo "Unknow action - \"$RUNMODE_ACTION\"" ;; esac ;; *) echo "Unknow template - \"$RUNMODE_APP\"" ;;esac
<!DOCTYPE Templates SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpt.dtd"><Templates Version="10.0" VendorName="SlickEdit"> <Template Name="Qt 3 Series Application Wizard"> <Config Name="Debug" Type="gnuc" DebugCallbackName="gdb" Version="1" OutputFile="%bd%<e" CompilerConfigName="Latest Version"> <Menu> <Target Name="Compile" MenuCaption="&Compile" CaptureOutputWith="ProcessBuffer" Deletable="0" OutputExts="*.o" SaveOption="SaveCurrent" RunFromDir="%rw"> <Exec CmdLine="make -f Makefile.debug"/> </Target> <Target Name="Link" MenuCaption="&Link" ShowOnMenu="Never" Dialog="_gnuc_options_form Link" CaptureOutputWith="ProcessBuffer" Deletable="0" SaveOption="SaveCurrent" RunFromDir="%rw"> <Exec CmdLine='g++ %xup -g -o "%o" %f %libs'/> </Target> <Target Name="Build" MenuCaption="&Build" CaptureOutputWith="ProcessBuffer" Deletable="0" SaveOption="SaveWorkspaceFiles" RunFromDir="%rw"> <Exec CmdLine="q3make app build debug"/> </Target> <Target Name="Rebuild" MenuCaption="&Rebuild" CaptureOutputWith="ProcessBuffer" Deletable="0" SaveOption="SaveWorkspaceFiles" RunFromDir="%rw"> <Exec CmdLine="q3make app rebuild debug"/> </Target> <Target Name="Debug" MenuCaption="&Debug" Dialog="_gnuc_options_form Run/Debug" BuildFirst="1" CaptureOutputWith="ProcessBuffer" Deletable="0" SaveOption="SaveNone" RunFromDir="%rw"> <Exec CmdLine='vsdebugio -prog "%o"'/> </Target> <Target Name="Execute" MenuCaption="E&xecute" Dialog="_gnuc_options_form Run/Debug" BuildFirst="1" CaptureOutputWith="ProcessBuffer" Deletable="0" SaveOption="SaveWorkspaceFiles" RunFromDir="%rw"> <Exec CmdLine='"%o"'/> </Target> <Target Name="dash" MenuCaption="-" Deletable="0"> <Exec/> </Target> <Target Name="GNU C Options" MenuCaption="GNU C &Options..." ShowOnMenu="HideIfNoCmdLine" Deletable="0" SaveOption="SaveNone"> <Exec CmdLine="gnucoptions" Type="Slick-C"/> </Target> </Menu> <Includes> <Include Dir="/usr/lib/qt3/include"/> </Includes> </Config> <Config Name="Release" Type="gnuc" DebugCallbackName="gdb" Version="1" OutputFile="%bd%<e" CompilerConfigName="Latest Version"> <Menu> <Target Name="Compile" MenuCaption="&Compile" CaptureOutputWith="ProcessBuffer" Deletable="0" OutputExts="*.o" SaveOption="SaveCurrent" RunFromDir="%rw"> <Exec CmdLine="make -f Makefile.release"/> </Target> <Target Name="Link" MenuCaption="&Link" ShowOnMenu="Never" Dialog="_gnuc_options_form Link" CaptureOutputWith="ProcessBuffer" Deletable="0" SaveOption="SaveCurrent" RunFromDir="%rw"> <Exec CmdLine='g++ %xup -o "%o" %f %libs'/> </Target> <Target Name="Build" MenuCaption="&Build" CaptureOutputWith="ProcessBuffer" Deletable="0" SaveOption="SaveWorkspaceFiles" RunFromDir="%rw"> <Exec CmdLine="q3make app build release"/> </Target> <Target Name="Rebuild" MenuCaption="&Rebuild" CaptureOutputWith="ProcessBuffer" Deletable="0" SaveOption="SaveWorkspaceFiles" RunFromDir="%rw"> <Exec CmdLine="q3make app rebuild release"/> </Target> <Target Name="Debug" MenuCaption="&Debug" Dialog="_gnuc_options_form Run/Debug" BuildFirst="1" CaptureOutputWith="ProcessBuffer" Deletable="0" SaveOption="SaveNone" RunFromDir="%rw"> <Exec CmdLine='vsdebugio -prog "%o"'/> </Target> <Target Name="Execute" MenuCaption="E&xecute" Dialog="_gnuc_options_form Run/Debug" BuildFirst="1" CaptureOutputWith="ProcessBuffer" Deletable="0" SaveOption="SaveWorkspaceFiles" RunFromDir="%rw"> <Exec CmdLine='"%o"'/> </Target> <Target Name="dash" MenuCaption="-" Deletable="0"> <Exec/> </Target> <Target Name="GNU C Options" MenuCaption="GNU C &Options..." ShowOnMenu="HideIfNoCmdLine" Deletable="0" SaveOption="SaveNone"> <Exec CmdLine="gnucoptions" Type="Slick-C"/> </Target> </Menu> <Includes> <Include Dir="/usr/lib/qt3/include"/> </Includes> </Config> </Template> <Template Name="Qt 3 Series Library Wizard"> <Config Name="Debug" Type="gnuc" DebugCallbackName="gdb" Version="1" OutputFile="%bd%<e" CompilerConfigName="Latest Version"> <Menu> <Target Name="Compile" MenuCaption="&Compile" CaptureOutputWith="ProcessBuffer" Deletable="0" OutputExts="*.o" SaveOption="SaveCurrent" RunFromDir="%rw"> <Exec CmdLine="make -f Makefile.debug"/> </Target> <Target Name="Link" MenuCaption="&Link" ShowOnMenu="Never" Dialog="_gnuc_options_form Link" CaptureOutputWith="ProcessBuffer" Deletable="0" SaveOption="SaveCurrent" RunFromDir="%rw"> <Exec CmdLine='g++ %xup -g -o "%o" %f %libs'/> </Target> <Target Name="Build" MenuCaption="&Build" CaptureOutputWith="ProcessBuffer" Deletable="0" SaveOption="SaveWorkspaceFiles" RunFromDir="%rw"> <Exec CmdLine="q3make lib build debug"/> </Target> <Target Name="Rebuild" MenuCaption="&Rebuild" CaptureOutputWith="ProcessBuffer" Deletable="0" SaveOption="SaveWorkspaceFiles" RunFromDir="%rw"> <Exec CmdLine="q3make lib rebuild debug"/> </Target> <Target Name="Debug" MenuCaption="&Debug" Dialog="_gnuc_options_form Run/Debug" BuildFirst="1" CaptureOutputWith="ProcessBuffer" Deletable="0" SaveOption="SaveNone" RunFromDir="%rw"> <Exec CmdLine='vsdebugio -prog "%o"'/> </Target> <Target Name="Execute" MenuCaption="E&xecute" Dialog="_gnuc_options_form Run/Debug" BuildFirst="1" CaptureOutputWith="ProcessBuffer" Deletable="0" SaveOption="SaveWorkspaceFiles" RunFromDir="%rw"> <Exec CmdLine='"%o"'/> </Target> <Target Name="dash" MenuCaption="-" Deletable="0"> <Exec/> </Target> <Target Name="GNU C Options" MenuCaption="GNU C &Options..." ShowOnMenu="HideIfNoCmdLine" Deletable="0" SaveOption="SaveNone"> <Exec CmdLine="gnucoptions" Type="Slick-C"/> </Target> </Menu> <Includes> <Include Dir="/usr/lib/qt3/include"/> </Includes> </Config> <Config Name="Release" Type="gnuc" DebugCallbackName="gdb" Version="1" OutputFile="%bd%<e" CompilerConfigName="Latest Version"> <Menu> <Target Name="Compile" MenuCaption="&Compile" CaptureOutputWith="ProcessBuffer" Deletable="0" OutputExts="*.o" SaveOption="SaveCurrent" RunFromDir="%rw"> <Exec CmdLine="make -f Makefile.release"/> </Target> <Target Name="Link" MenuCaption="&Link" ShowOnMenu="Never" Dialog="_gnuc_options_form Link" CaptureOutputWith="ProcessBuffer" Deletable="0" SaveOption="SaveCurrent" RunFromDir="%rw"> <Exec CmdLine='g++ %xup -o "%o" %f %libs'/> </Target> <Target Name="Build" MenuCaption="&Build" CaptureOutputWith="ProcessBuffer" Deletable="0" SaveOption="SaveWorkspaceFiles" RunFromDir="%rw"> <Exec CmdLine="q3make lib build release"/> </Target> <Target Name="Rebuild" MenuCaption="&Rebuild" CaptureOutputWith="ProcessBuffer" Deletable="0" SaveOption="SaveWorkspaceFiles" RunFromDir="%rw"> <Exec CmdLine="q3make lib rebuild release"/> </Target> <Target Name="Debug" MenuCaption="&Debug" Dialog="_gnhttp://ifolder.ru/master/?f54a9b6e6c7dd308e24a4d929365ad79e97694d03a1885f09813823d91252ec726f25382b894989ca2fe17d9c3d44e37e4e5cb566ce5ab54uc_options_form Run/Debug" BuildFirst="1" CaptureOutputWith="ProcessBuffer" Deletable="0" SaveOption="SaveNone" RunFromDir="%rw"> <Exec CmdLine='vsdebugio -prog "%o"'/> </Target> <Target Name="Execute" MenuCaption="E&xecute" Dialog="_gnuc_options_form Run/Debug" BuildFirst="1" CaptureOutputWith="ProcessBuffer" Deletable="0" SaveOption="SaveWorkspaceFiles" RunFromDir="%rw"> <Exec CmdLine='"%o"'/> </Target> <Target Name="dash" MenuCaption="-" Deletable="0"> <Exec/> </Target> <Target Name="GNU C Options" MenuCaption="GNU C &Options..." ShowOnMenu="HideIfNoCmdLine" Deletable="0" SaveOption="SaveNone"> <Exec CmdLine="gnucoptions" Type="Slick-C"/> </Target> </Menu> <Includes> <Include Dir="/usr/lib/qt3/include"/> </Includes> </Config> </Template></Templates>