From 97c0fcbbef19012f825cba0fc3f16037322ce84c Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 21 Dec 2009 22:24:48 +0000 Subject: We're getting closer and closer, qt4 is more configurable and gets QT flags for you for CXXFLAGS and LDFLAGS, added a bunch more stuff and fixed a strange function input bug. --- default.bld | 4 +-- share/autoinclude/general-rules.bld | 8 ++--- share/include/qt4.bld | 63 +++++++++++++++++++++++++++++++++++-- src/build.y | 12 ++++++- src/context.cpp | 2 ++ src/functionast.cpp | 16 +++++++++- 6 files changed, 94 insertions(+), 11 deletions(-) diff --git a/default.bld b/default.bld index 19b66bf..8fc8fb4 100644 --- a/default.bld +++ b/default.bld @@ -29,7 +29,7 @@ action "clean" action "devinstall" { - if "$(id -u)" != "0\n" then + if "$(id -u)" != "0" then { error "You can only install as the root user, su then run this."; } @@ -38,7 +38,7 @@ action "devinstall" action "viminstall" { - if "$(id -u)" != "0\n" then + if "$(id -u)" != "0" then { error "You can only install as the root user, su then run this."; } diff --git a/share/autoinclude/general-rules.bld b/share/autoinclude/general-rules.bld index 46720c6..30a4376 100644 --- a/share/autoinclude/general-rules.bld +++ b/share/autoinclude/general-rules.bld @@ -78,7 +78,7 @@ rule "lib" rule "cpp" { input "*.cpp"; - output cppToObj(); + output INPUT.cppToObj(); // output replace(".cpp", ".o"); requires getMakeDeps("${CXX} ${CXXFLAGS} -M ${INPUT}"); profile "build" @@ -91,7 +91,7 @@ rule "cpp" rule "c" { input "*.c"; - output cToObj(); + output INPUT.cToObj(); // output replace(".c", ".o"); requires getMakeDeps("${CC} ${CFLAGS} -M ${INPUT}"); profile "build" @@ -115,8 +115,8 @@ rule "bison" rule "flex" { input "*.l"; - output replace(".l", ".yy.c"); - output replace(".l", ".yy.h"); + output INPUT.replace(".l", ".yy.c"); + output INPUT.replace(".l", ".yy.h"); profile "build" { execute("${FLEX} ${FLEXFLAGS} ${INPUT}"); diff --git a/share/include/qt4.bld b/share/include/qt4.bld index 749cc52..a5a7867 100644 --- a/share/include/qt4.bld +++ b/share/include/qt4.bld @@ -1,4 +1,58 @@ +function qt_getCXXFLAGS() +{ + if QTDIR == null then + { + error "QTDIR is not set, cannot find QT tools."; + } + + ret = "-D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LI " + "-DQT_SHARED -I${QTDIR}/mkspecs/linux-g++ " + "$(PKG_CONFIG_PATH=PKG_CONFIG_PATH:${QTDIR}/lib/pkgconfig " + "pkg-config --cflags QtCore QtGui ice glu x11 xext libpng freetype2 " + "gobject-2.0 sm xrender fontconfig gthread-2.0 glib-2.0)"; + if UI_DIR != null then + { + ret += "-I${UI_DIR}"; + } + if RCC_DIR != null then + { + ret += "-I${RCC_DIR}"; + } + if MOC_DIR != null then + { + ret += "-I${MOC_DIR}"; + } + return ret; +} + +function qt_getLDFLAGS() +{ + if QTDIR == null then + { + error "QTDIR is not set, cannot find QT tools."; + } + + return "-Wl,-rpath,${QTDIR}/lib $(PKG_CONFIG_PATH=" + "PKG_CONFIG_PATH:${QTDIR}/lib/pkgconfig " + "pkg-config --libs QtCore QtGui ice glu x11 xext libpng freetype2 " + "gobject-2.0 sm xrender fontconfig gthread-2.0 glib-2.0) -laudio -lz " + "-lm -ldl"; +} + +function qt_getToolPath( TOOL, DEFAULT ) +{ + if QTDIR == null then + { + error "QTDIR is not set, cannot find QT tools."; + } + if TOOL == null then + { + return "${QTDIR}/bin/${DEFAULT}"; + } + return TOOL; +} + function qt_uiToH() { if "${UI_DIR}" == "" then @@ -22,7 +76,8 @@ rule "qt_ui" tag "headers"; profile "build" { - execute("${QTDIR}/bin/uic -o ${OUTPUT} ${INPUT}"); + UIC = qt_getToolPath( UIC, "uic" ); + execute("${UIC} -o ${OUTPUT} ${INPUT}"); } } @@ -48,8 +103,9 @@ rule "qt_rcc" output INPUT.qt_qrcToCpp(); profile "build" { + RCC = qt_getToolPath( RCC, "rcc" ); NAME = INPUT.fileName().replace(".qrc",""); - execute("${QTDIR}/bin/rcc -name ${NAME} -o ${OUTPUT} ${INPUT}"); + execute("${RCC} -name ${NAME} -o ${OUTPUT} ${INPUT}"); } } @@ -90,7 +146,8 @@ rule "qt_moc" output INPUT.qt_hToMocCpp(); profile "build" { - execute("${QTDIR}/bin/moc -o${OUTPUT} ${INPUT}"); + MOC = qt_getToolPath( MOC, "moc" ); + execute("${MOC} -o${OUTPUT} ${INPUT}"); } } diff --git a/src/build.y b/src/build.y index a6618e4..3e9c8fd 100644 --- a/src/build.y +++ b/src/build.y @@ -188,7 +188,7 @@ value_mods: value_core: variable | literal - | function + | function_no_input | list ; @@ -254,6 +254,16 @@ function: UNDEF '(' { } ; +function_no_input: UNDEF '(' { + bld.xAst.addNode( AstNode::typeNull ); + bld.xAst.addNode( AstNode::typeFunction ); + bld.xAst.openBranch(); + bld.xAst.addNode( AstNode::typeString, $1 ); + } func_params ')' { + bld.xAst.closeNode(); + } + ; + requires: TOK_REQUIRES { bld.xAst.addNode( AstNode::typeRequires ); bld.xAst.openBranch(); diff --git a/src/context.cpp b/src/context.cpp index bc48def..e9330e5 100644 --- a/src/context.cpp +++ b/src/context.cpp @@ -232,6 +232,8 @@ Bu::FString Context::expand( const Bu::FString &sInS ) char buf[4096]; sBuf.append( buf, p.read( buf, 4096 ) ); } + sBuf = sBuf.replace("\n", " ").replace("\r", " "); + sBuf.trimBack(' '); sRet.append( sBuf ); } catch(...) { diff --git a/src/functionast.cpp b/src/functionast.cpp index 0d9a938..ceee460 100644 --- a/src/functionast.cpp +++ b/src/functionast.cpp @@ -4,6 +4,9 @@ #include "runner.h" #include "context.h" +#include +using namespace Bu; + FunctionAst::FunctionAst( const AstBranch *pRoot, class Runner *pRunner ) : pRoot( pRoot ), pRunner( pRunner ) @@ -22,9 +25,20 @@ Bu::FString FunctionAst::getName() const return sName; } -Variable FunctionAst::call( Variable &input, VarList /*lParams*/ ) +Variable FunctionAst::call( Variable &input, VarList lParams ) { pContext->pushScope(); + + AstBranch::NodeList::const_iterator vName = + (*(pRoot->getBranchBegin()+1)).begin(); + VarList::iterator vValue = lParams.begin(); + for( ; vName && vValue; vName++, vValue++ ) + { + pContext->addVariable( + dynamic_cast(*vName)->getStrValue(), + *vValue + ); + } pContext->addVariable("INPUT", input ); Variable vRet = pRunner->run( (*(pRoot->getBranchBegin()+2)).begin() ); pContext->popScope(); -- cgit v1.2.3